From 3e449ec09cc7e190ac5cd8879294439111d1e2ef Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 7 Jun 2004 15:54:14 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/trunk@24 d1b88da0-ebda-0310-925b-ed51d893ca5b --- OGoContentStore/OCSFolderType.h | 23 ++++++++++++++++ OGoContentStore/OCSFolderType.m | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/OGoContentStore/OCSFolderType.h b/OGoContentStore/OCSFolderType.h index bf6106e0..015745b7 100644 --- a/OGoContentStore/OCSFolderType.h +++ b/OGoContentStore/OCSFolderType.h @@ -23,12 +23,35 @@ #ifndef __OGoContentStore_OCSFolderType_H__ #define __OGoContentStore_OCSFolderType_H__ +/* + OCSFolderType + + This is the "model" of a folder, it specifies what quick attributes are + available, in which tables it is stored and how it is retrieved. + + For now, we only support one 'quick' table (we might want to have multiple + ones in the future). +*/ + #import +@class NSString, NSDictionary; +@class EOQualifier; +@class OCSFolder; + @interface OCSFolderType : NSObject { + NSString *blobTablePattern; // eg 'SOGo_$folderId$_blob + NSString *quickTablePattern; // eg 'SOGo_$folderId$_quick + NSDictionary *fields; + EOQualifier *folderQualifier; // to further limit the table set } +/* operations */ + +- (NSString *)blobTableNameForFolder:(OCSFolder *)_folder; +- (NSString *)quickTableNameForFolder:(OCSFolder *)_folder; + @end #endif /* __OGoContentStore_OCSFolderType_H__ */ diff --git a/OGoContentStore/OCSFolderType.m b/OGoContentStore/OCSFolderType.m index 61056edd..5e206c06 100644 --- a/OGoContentStore/OCSFolderType.m +++ b/OGoContentStore/OCSFolderType.m @@ -21,12 +21,61 @@ // $Id$ #include "OCSFolderType.h" +#include "OCSFolder.h" #include "common.h" +#include @implementation OCSFolderType - (void)dealloc { + [self->blobTablePattern release]; + [self->quickTablePattern release]; + [self->fields release]; + [self->folderQualifier release]; [super dealloc]; } +/* operations */ + +- (NSString *)blobTableNameForFolder:(OCSFolder *)_folder { + return [self->blobTablePattern + stringByReplacingVariablesWithBindings:_folder]; +} +- (NSString *)quickTableNameForFolder:(OCSFolder *)_folder { + return [self->quickTablePattern + stringByReplacingVariablesWithBindings:_folder]; +} + +- (EOQualifier *)qualifierForFolder:(OCSFolder *)_folder { + NSArray *keys; + NSDictionary *bindings; + + keys = [[self->folderQualifier allQualifierKeys] allObjects]; + if ([keys count] == 0) + return self->folderQualifier; + + bindings = [_folder valuesForKeys:keys]; + return [self->folderQualifier qualifierWithBindings:bindings + requiresAllVariables:NO]; +} + +/* description */ + +- (NSString *)description { + NSMutableString *ms; + + ms = [NSMutableString stringWithCapacity:256]; + [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])]; + + [ms appendFormat:@" blobtable='%@'", self->blobTablePattern]; + [ms appendFormat:@" quicktable='%@'", self->quickTablePattern]; + [ms appendFormat:@" fields=%@", self->fields]; + + if (self->folderQualifier) + [ms appendFormat:@" qualifier=%@", self->folderQualifier]; + + [ms appendString:@">"]; + return ms; +} + @end /* OCSFolderType */ -- 2.39.5