]> err.no Git - scalable-opengroupware.org/commitdiff
started contact folder support
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 26 Aug 2004 22:34:12 +0000 (22:34 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Thu, 26 Aug 2004 22:34:12 +0000 (22:34 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@276 d1b88da0-ebda-0310-925b-ed51d893ca5b

14 files changed:
OGoContentStore/ChangeLog
OGoContentStore/GNUmakefile
OGoContentStore/OCSContactFieldExtractor.m [new file with mode: 0644]
OGoContentStore/OCSFolderType.h
OGoContentStore/OCSFolderType.m
OGoContentStore/OCSiCalFieldExtractor.m
OGoContentStore/Version
OGoContentStore/appointment.ocs
OGoContentStore/contact.ocs
OGoContentStore/misc/iNetOrgPerson.txt [new file with mode: 0644]
OGoContentStore/sql/foldertablecreate-test-contacts.psql [new file with mode: 0644]
OGoContentStore/sql/register-agenor-test-contacts.psql [new file with mode: 0644]
OGoContentStore/sql/testapt-agenor-helge-privcal.psql
OGoContentStore/sql/testcontact-agenor-test-contact.psql [new file with mode: 0644]

index 328b1edb0dd17366b5054bd43ef24b75e101781a..6dde311b3260ccb9e2a75cb5c6d21c702d9ba0b4 100644 (file)
@@ -1,5 +1,13 @@
 2004-08-26  Helge Hess  <helge.hess@skyrix.com>
 
+       * v0.9.6
+
+       * added OCSContactFieldExtractor
+       
+       * sql: added sample contact folder create scripts
+       
+       * OCSFolderType.m: read extractor class name from type model
+
        * OCSFolderManager.m: added contact type model per default (v0.9.5)
 
 2004-08-25  Helge Hess  <helge.hess@skyrix.com>
index e5e6ade88d796104e790d533b8b682b37292c583..00ad819575e37a97a6cc01459ee36995bb12d1d7 100644 (file)
@@ -37,6 +37,7 @@ libOGoContentStore_OBJC_FILES += \
        OCSChannelManager.m     \
        OCSFieldExtractor.m     \
        OCSiCalFieldExtractor.m \
+       OCSContactFieldExtractor.m
 
 libOGoContentStore_TYPEMODELS += \
        appointment.ocs \
diff --git a/OGoContentStore/OCSContactFieldExtractor.m b/OGoContentStore/OCSContactFieldExtractor.m
new file mode 100644 (file)
index 0000000..0dc72f4
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+  Copyright (C) 2004 SKYRIX Software AG
+
+  This file is part of OpenGroupware.org.
+
+  OGo is free software; you can redistribute it and/or modify it under
+  the terms of the GNU Lesser General Public License as published by the
+  Free Software Foundation; either version 2, or (at your option) any
+  later version.
+
+  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+  License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with OGo; see the file COPYING.  If not, write to the
+  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+  02111-1307, USA.
+*/
+
+#include <OGoContentStore/OCSFieldExtractor.h>
+
+@interface OCSContactFieldExtractor : OCSFieldExtractor
+@end
+
+#include "common.h"
+
+@implementation OCSContactFieldExtractor
+
+- (NSMutableDictionary *)extractQuickFieldsFromContent:(NSString *)_content {
+  static NSString *fieldNames[] = {
+    @"givenName",
+    @"cn",
+    @"sn",
+    @"l",
+    @"mail",
+    @"o",
+    @"ou",
+    @"telephoneNumber",
+    nil
+  };
+  NSMutableDictionary *fields;
+  NSDictionary *plist;
+  unsigned i;
+  
+  if ([_content length] == 0)
+    return nil;
+  
+  // TODO: we want to support vcard storage in the future?!
+  
+  if ((plist = [_content propertyList]) == nil) {
+    [self logWithFormat:@"ERROR: could not parse property list content!"];
+    return nil;
+  }
+  
+  fields = [NSMutableDictionary dictionaryWithCapacity:16];
+  
+  /* copy field values to quick record */
+  for (i = 0; fieldNames[i] != nil; i++) {
+    NSString *fieldName, *sqlName;
+    id value;
+
+    fieldName = fieldNames[i];
+    sqlName   = [fieldName lowercaseString]; /* actually pgsql doesn't care */
+    
+    value = [plist objectForKey:fieldName];
+    if ([value isNotNull])
+      [fields setObject:value forKey:sqlName];
+    else
+      [fields setObject:[NSNull null] forKey:sqlName];
+  }
+  
+  return fields;
+}
+
+@end /* OCSContactFieldExtractor */
index c4583f45b95b3185ce4ce5ae46bc460ad5fe3e54..c07474b5063801abfebc4aaf685c10a01673e976 100644 (file)
@@ -50,6 +50,8 @@
   NSArray      *fields;            // OCSFieldInfo objects
   NSDictionary *fieldDict;         // maps a name to OCSFieldInfo
   EOQualifier  *folderQualifier;   // to further limit the table set
+  NSString     *extractorClassName;
+  OCSFieldExtractor *extractor;
 }
 
 - (id)initWithPropertyList:(id)_plist;
index 2094004872d3561f8834639a88b3e7874c4d0d02..8b2fa5e3d2882ec68283d79b2cb993dc26890a10 100644 (file)
@@ -18,7 +18,6 @@
   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
 */
-// $Id$
 
 #include "OCSFolderType.h"
 #include "OCSFolder.h"
@@ -33,6 +32,9 @@
   if ((self = [super init])) {
     self->blobTablePattern  = [[_plist objectForKey:@"blobTablePattern"] copy];
     self->quickTablePattern = [[_plist objectForKey:@"quickTablePattern"]copy];
+    
+    self->extractorClassName =
+      [[_plist objectForKey:@"extractorClassName"] copy];
     // TODO: qualifier;
     
     self->fields = [[OCSFieldInfo fieldsForPropertyList:
 }
 
 - (void)dealloc {
-  [self->blobTablePattern  release];
-  [self->quickTablePattern release];
-  [self->fields            release];
-  [self->fieldDict         release];
-  [self->folderQualifier   release];
+  [self->extractor          release];
+  [self->extractorClassName release];
+  [self->blobTablePattern   release];
+  [self->quickTablePattern  release];
+  [self->fields             release];
+  [self->fieldDict          release];
+  [self->folderQualifier    release];
   [super dealloc];
 }
 
 /* quick support */
 
 - (OCSFieldExtractor *)quickExtractor {
-  // TODO: hack
-  return [OCSiCalFieldExtractor sharedICalFieldExtractor];
+  Class clazz;
+  
+  if (self->extractor)
+    return [self->extractor isNotNull] ? self->extractor : nil;
+
+  clazz = self->extractorClassName
+    ? NSClassFromString(self->extractorClassName)
+    : [OCSFieldExtractor class];
+  if (clazz == Nil) {
+    [self logWithFormat:@"ERROR: did not find field extractor class!"];
+    return nil;
+  }
+  
+  if ((self->extractor = [[clazz alloc] init]) == nil) {
+    [self logWithFormat:@"ERROR: could not create field extractor of class %@",
+           clazz];
+    return nil;
+  }
+  return self->extractor;
 }
 
 /* description */
   [ms appendFormat:@" blobtable='%@'",  self->blobTablePattern];
   [ms appendFormat:@" quicktable='%@'", self->quickTablePattern];
   [ms appendFormat:@" fields=%@",       self->fields];
+  [ms appendFormat:@" extractor=%@",    self->extractorClassName];
   
   if (self->folderQualifier)
     [ms appendFormat:@" qualifier=%@", self->folderQualifier];
index 7f99df2378a20e81d53a32a8c59dfc0382c5444f..fefcebfe99b8e59b023d8989697f414aacf5d3e7 100644 (file)
@@ -18,7 +18,6 @@
   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
 */
-// $Id$
 
 #include "OCSiCalFieldExtractor.h"
 #include "common.h"
index a73270b540e9c1a42a13cdd38d47451568de19a8..8e956c3402cf01e84bb074bfd0f89e19db0a9fad 100644 (file)
@@ -2,4 +2,4 @@
 
 MAJOR_VERSION=0
 MINOR_VERSION=9
-SUBMINOR_VERSION:=5
+SUBMINOR_VERSION:=6
index 35fdb2ab3937c76988aea899cccb8a6c0b9a5c4a..3ad0386f3920c27fe20c8d00e6bbe601e9603b93 100644 (file)
@@ -1,6 +1,7 @@
 {
-  blobTablePattern  = "SOGo_$folderId$_blob";
-  quickTablePattern = "SOGo_$folderId$_quick";
+  blobTablePattern   = "SOGo_$folderId$_blob";
+  quickTablePattern  = "SOGo_$folderId$_quick";
+  extractorClassName = "OCSiCalFieldExtractor";
 
   fields = (
     {
index fa794edae6db11f0dc88e5f723aa665400a632a2..a08d2234ffa66acc28c0c471aa5dc0f0d2285f87 100644 (file)
@@ -1,30 +1,46 @@
 {
   blobTablePattern  = "SOGo_$folderId$_blob";
   quickTablePattern = "SOGo_$folderId$_quick";
+  extractorClassName= "OCSContactFieldExtractor";
 
   fields = (
     {
-      columnName = uid;
+      columnName = givenname;
       sqlType    = "VARCHAR(256)";
-      allowsNull = NO;
+      allowsNull = YES;
+    },
+    {
+      columnName = cn;
+      sqlType    = "VARCHAR(256)";
+      allowsNull = YES;
     },
     {
-      columnName = name;
-      sqlType    = "VARCHAR(1000)";
-      allowsNull = NO;
+      columnName = sn;
+      sqlType    = "VARCHAR(256)";
+      allowsNull = YES;
     },
     {
-      columnName = lastname;
-      sqlType    = "VARCHAR(1000)";
-      allowsNull = NO;
+      columnName = l;
+      sqlType    = "VARCHAR(256)";
+      allowsNull = YES;
     },
     {
-      columnName = email;
-      sqlType    = "VARCHAR(1000)";
-      allowsNull = NO;
+      columnName = mail;
+      sqlType    = "VARCHAR(256)";
+      allowsNull = YES;
+    },
+    {
+      columnName = o;
+      sqlType    = "VARCHAR(256)";
+      allowsNull = YES;
+    },
+    {
+      columnName = ou;
+      sqlType    = "VARCHAR(256)";
+      allowsNull = YES;
     },
     {
-      columnName = location;
+      columnName = telephoneNumber;
       sqlType    = "VARCHAR(256)";
       allowsNull = YES;
     },
diff --git a/OGoContentStore/misc/iNetOrgPerson.txt b/OGoContentStore/misc/iNetOrgPerson.txt
new file mode 100644 (file)
index 0000000..eff00af
--- /dev/null
@@ -0,0 +1,108 @@
+http://www.faqs.org/rfcs/rfc2798.html
+
+Class
+    NAME 'inetOrgPerson'
+    SUP organizationalPerson
+    STRUCTURAL
+    MAY (
+        audio $ businessCategory $ carLicense $ departmentNumber $
+        displayName $ employeeNumber $ employeeType $ givenName $
+        homePhone $ homePostalAddress $ initials $ jpegPhoto $
+        labeledURI $ mail $ manager $ mobile $ o $ pager $
+        photo $ roomNumber $ secretary $ uid $ userCertificate $
+        x500uniqueIdentifier $ preferredLanguage $
+        userSMIMECertificate $ userPKCS12
+    )
+    MUST (
+        cn $ objectClass $ sn
+    )
+    MAY (
+        description $ destinationIndicator $ facsimileTelephoneNumber $
+        internationaliSDNNumber $ l $ ou $ physicalDeliveryOfficeName $
+        postalAddress $ postalCode $ postOfficeBox $
+        preferredDeliveryMethod $ registeredAddress $ seeAlso $
+        st $ street $ telephoneNumber $ teletexTerminalIdentifier $
+        telexNumber $ title $ userPassword $ x121Address
+    )
+
+Properties (inetOrgPerson + organizationalPerson)
+       businessCategory 
+       carLicense 
+       departmentNumber
+       destinationIndicator 
+       employeeNumber 
+       employeeType 
+       facsimileTelephoneNumber
+       givenName
+       homePostalAddress 
+       initials 
+       jpegPhoto
+       l 
+       mail 
+       manager 
+       mobile 
+       o 
+       objectClass 
+       ou 
+       pager
+       physicalDeliveryOfficeName
+       postOfficeBox
+       postalCode 
+       preferredLanguage
+       registeredAddress 
+       roomNumber 
+       secretary 
+       seeAlso
+       sn
+       street 
+       telephoneNumber 
+       teletexTerminalIdentifier
+       title 
+       uid 
+       userCertificate
+       userPKCS12
+       userPassword 
+       x121Address
+        audio 
+        cn 
+        description 
+        displayName 
+        homePhone 
+        internationaliSDNNumber 
+        labeledURI 
+        photo 
+        postalAddress 
+        preferredDeliveryMethod 
+        st 
+        telexNumber 
+        userSMIMECertificate 
+        x500uniqueIdentifier 
+
+Sample:
+   version:           1
+   dn:                cn=Barbara Jensen,ou=Product Development,dc=siroe,dc=com
+   objectClass:       top
+   objectClass:       person
+   objectClass:       organizationalPerson
+   objectClass:       inetOrgPerson
+   cn:                Barbara Jensen
+   cn:                Babs Jensen
+   displayName:       Babs Jensen
+   sn:                Jensen
+   givenName:         Barbara
+   initials:          BJJ
+   title:             manager, product development
+   uid:               bjensen
+   mail:              bjensen@siroe.com
+   telephoneNumber:   +1 408 555 1862
+   facsimileTelephoneNumber: +1 408 555 1992
+   mobile:            +1 408 555 1941
+   roomNumber:        0209
+   carLicense:        6ABC246
+   o:                 Siroe
+   ou:                Product Development
+   departmentNumber:  2604
+   employeeNumber:    42
+   employeeType:      full time
+   preferredLanguage: fr, en-gb;q=0.8, en;q=0.7
+   labeledURI:        http://www.siroe.com/users/bjensen My Home Page
diff --git a/OGoContentStore/sql/foldertablecreate-test-contacts.psql b/OGoContentStore/sql/foldertablecreate-test-contacts.psql
new file mode 100644 (file)
index 0000000..415d78a
--- /dev/null
@@ -0,0 +1,27 @@
+-- $Id$
+--
+-- (C) 2004 SKYRIX Software AG
+--
+
+DROP TABLE SOGo_test_contacts_quick;
+DROP TABLE SOGo_test_contacts_blob;
+
+CREATE TABLE SOGo_test_contacts_quick (
+  c_name          VARCHAR(256)    NOT NULL PRIMARY KEY, -- the filename
+  givenname       VARCHAR(256),
+  cn              VARCHAR(256),
+  sn              VARCHAR(256),
+  l               VARCHAR(256),
+  mail            VARCHAR(256),
+  o               VARCHAR(256),
+  ou              VARCHAR(256),
+  telephonenumber VARCHAR(256)
+);
+
+CREATE TABLE SOGo_test_contacts_blob (
+  c_name         VARCHAR(256)    NOT NULL PRIMARY KEY, -- the filename
+  c_content      VARCHAR(100000) NOT NULL, -- the BLOB
+  c_creationdate INT             NOT NULL, -- creation date
+  c_lastmodified INT             NOT NULL, -- last modification (UPDATE)
+  c_version      INT             NOT NULL  -- version counter
+);
diff --git a/OGoContentStore/sql/register-agenor-test-contacts.psql b/OGoContentStore/sql/register-agenor-test-contacts.psql
new file mode 100644 (file)
index 0000000..1d49923
--- /dev/null
@@ -0,0 +1,13 @@
+INSERT INTO SOGo_folder_info  
+  ( c_path, c_path1, c_path2, c_path3, c_path4, c_foldername,  
+    c_location, c_quick_location, c_folder_type )  
+VALUES  
+  ( '/Users/test.et.di.cete-lyon/Contacts',  
+    'Users', 
+    'test.et.di.cete-lyon', 
+    'Contacts', 
+     NULL, 
+    'Contacts',  
+    'http://postgres:@agenor-db:5432/test/SOGo_test_contacts_blob',  
+    'http://postgres:@agenor-db:5432/test/SOGo_test_contacts_quick',  
+    'Contact' ); 
index d0ee2f49b206828a118052bf4fe7a4b68b626616..7a912c3e9de60d1933281eecb2d81f28ce5ccd07 100644 (file)
@@ -1,4 +1,3 @@
--- $Id$
 --
 -- (C) 2004 SKYRIX Software AG
 --
diff --git a/OGoContentStore/sql/testcontact-agenor-test-contact.psql b/OGoContentStore/sql/testcontact-agenor-test-contact.psql
new file mode 100644 (file)
index 0000000..6b873db
--- /dev/null
@@ -0,0 +1,33 @@
+--
+-- (C) 2004 SKYRIX Software AG
+--
+
+DELETE FROM SOGo_test_contacts_blob
+  WHERE c_name = 'contact_donald';
+DELETE FROM SOGo_test_contacts_quick
+  WHERE c_name = 'contact_donald';
+
+INSERT INTO SOGo_test_contacts_blob
+  ( c_name, c_creationdate, c_lastmodified, c_version, c_content )
+VALUES (
+  'contact_donald',
+  928383,
+  928383,
+  1,
+  '{ 
+     givenname="Donald"; cn="Donald Duck"; sn="Duck"; 
+     l="Entenhausen";
+     mail="dd@entenhausen.com";
+     o="Geldspeicher AG";
+     ou="Support";
+     telephoneNumber="0190-1234567";
+   }'
+);
+
+INSERT INTO SOGo_test_contacts_quick
+  ( c_name, givenname, cn, sn, l, mail, o, ou, telephoneNumber )
+VALUES (
+  'contact_donald', 'Donald', 'Donald Duck', 'Duck', 'Entenhausen',
+  'dd@entenhausen.com', 'Geldspeicher AG', 'Support',
+  '0190-1234567'
+);