]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@24 d1b88da0-ebda-0310-925b-ed51d8...
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 7 Jun 2004 15:54:14 +0000 (15:54 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 7 Jun 2004 15:54:14 +0000 (15:54 +0000)
OGoContentStore/OCSFolderType.h
OGoContentStore/OCSFolderType.m

index bf6106e006190fc720e25a4cb4d847e2e34ca918..015745b707dad869de321b175e0a841a81a643f9 100644 (file)
 #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 <Foundation/NSObject.h>
 
+@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__ */
index 61056edd64b04dd80d7e0775bffe7e386a739f62..5e206c06ffe794a8f14a3aaf890deb18b708e750 100644 (file)
 // $Id$
 
 #include "OCSFolderType.h"
+#include "OCSFolder.h"
 #include "common.h"
+#include <EOControl/EOKeyValueCoding.h>
 
 @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 */