From: helge Date: Wed, 30 Jun 2004 15:08:32 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/trunk@125 d1b88da0-ebda-0310-925b-ed51d... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92c97653ece581d1697afe9cc26140398d5d81c6;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/trunk@125 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/OGoContentStore/ChangeLog b/OGoContentStore/ChangeLog index e1fd12d8..d23be329 100644 --- a/OGoContentStore/ChangeLog +++ b/OGoContentStore/ChangeLog @@ -1,5 +1,7 @@ 2004-06-30 Helge Hess + * OCSFolder.m: added quick fetches + * GNUmakefile.preamble: fix link path * GNUmakefile (libOGoContentStore_HEADER_FILES_INSTALL_DIR): install diff --git a/OGoContentStore/GNUmakefile.preamble b/OGoContentStore/GNUmakefile.preamble index e99d298a..27075f2c 100644 --- a/OGoContentStore/GNUmakefile.preamble +++ b/OGoContentStore/GNUmakefile.preamble @@ -2,7 +2,8 @@ libOGoContentStore_LIBRARIES_DEPEND_UPON += \ -lGDLAccess \ - -lEOControl + -lEOControl \ + -lSaxObjC OCS_TOOL_LIBS += \ -lOGoContentStore \ diff --git a/OGoContentStore/OCSFolder.h b/OGoContentStore/OCSFolder.h index f47000dc..c19bec9a 100644 --- a/OGoContentStore/OCSFolder.h +++ b/OGoContentStore/OCSFolder.h @@ -26,6 +26,7 @@ #import @class NSString, NSURL, NSNumber, NSArray, NSException; +@class EOQualifier; @class EOAdaptorChannel; @class OCSFolderManager, OCSFolderType, OCSChannelManager; @@ -79,6 +80,8 @@ - (NSString *)fetchContentWithName:(NSString *)_name; - (NSException *)writeContent:(NSString *)_content toName:(NSString *)_name; +- (NSArray *)fetchFields:(NSArray *)_flds matchingQualifier:(EOQualifier *)_q; + @end #endif /* __OGoContentStore_OCSFolder_H__ */ diff --git a/OGoContentStore/OCSFolder.m b/OGoContentStore/OCSFolder.m index d906925b..d8f5939c 100644 --- a/OGoContentStore/OCSFolder.m +++ b/OGoContentStore/OCSFolder.m @@ -224,6 +224,71 @@ static BOOL debugOn = YES; userInfo:nil]; } +- (NSString *)columnNameForFieldName:(NSString *)_fieldName { + return _fieldName; +} + +- (NSArray *)fetchFields:(NSArray *)_flds matchingQualifier:(EOQualifier *)_q { + EOAdaptorChannel *channel; + NSException *error; + NSMutableString *sql; + NSArray *attrs; + NSMutableArray *results; + NSDictionary *row; + +#if 0 + [self logWithFormat:@"FETCH: %@", _flds]; + [self logWithFormat:@" MATCH: %@", _q]; +#endif + + /* generate SQL */ + + sql = [NSMutableString stringWithCapacity:256]; + [sql appendString:@"SELECT "]; + if (_flds == nil) + [sql appendString:@"*"]; + else { + unsigned i, count; + + count = [_flds count]; + for (i = 0; i < count; i++) { + if (i > 0) [sql appendString:@", "]; + [sql appendString:[self columnNameForFieldName:[_flds objectAtIndex:i]]]; + } + } + [sql appendString:@" FROM "]; + [sql appendString:[self quickTableName]]; + + /* open channel */ + + if ((channel = [self acquireStoreChannel]) == nil) { + [self logWithFormat:@"ERROR(%s): could not open storage channel!"]; + return nil; + } + + /* run SQL */ + + if ((error = [channel evaluateExpressionX:sql]) != nil) { + [self logWithFormat:@"ERROR(%s): cannot execute quick-fetch SQL '%@': %@", + __PRETTY_FUNCTION__, sql, error]; + [self releaseChannel:channel]; + return nil; + } + + /* fetch results */ + + results = [NSMutableArray arrayWithCapacity:64]; + attrs = [channel describeResults]; + while ((row = [channel fetchAttributes:attrs withZone:NULL]) != nil) + [results addObject:row]; + + /* release channels */ + + [self releaseChannel:channel]; + + return results; +} + /* description */ - (NSString *)description {