From ccb6716426ed0329b481e22f5a4d774bb68c0a06 Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 26 Aug 2004 22:34:12 +0000 Subject: [PATCH] started contact folder support git-svn-id: http://svn.opengroupware.org/SOGo/trunk@276 d1b88da0-ebda-0310-925b-ed51d893ca5b --- OGoContentStore/ChangeLog | 8 ++ OGoContentStore/GNUmakefile | 1 + OGoContentStore/OCSContactFieldExtractor.m | 77 +++++++++++++ OGoContentStore/OCSFolderType.h | 2 + OGoContentStore/OCSFolderType.m | 38 ++++-- OGoContentStore/OCSiCalFieldExtractor.m | 1 - OGoContentStore/Version | 2 +- OGoContentStore/appointment.ocs | 5 +- OGoContentStore/contact.ocs | 40 +++++-- OGoContentStore/misc/iNetOrgPerson.txt | 108 ++++++++++++++++++ .../sql/foldertablecreate-test-contacts.psql | 27 +++++ .../sql/register-agenor-test-contacts.psql | 13 +++ .../sql/testapt-agenor-helge-privcal.psql | 1 - .../sql/testcontact-agenor-test-contact.psql | 33 ++++++ 14 files changed, 331 insertions(+), 25 deletions(-) create mode 100644 OGoContentStore/OCSContactFieldExtractor.m create mode 100644 OGoContentStore/misc/iNetOrgPerson.txt create mode 100644 OGoContentStore/sql/foldertablecreate-test-contacts.psql create mode 100644 OGoContentStore/sql/register-agenor-test-contacts.psql create mode 100644 OGoContentStore/sql/testcontact-agenor-test-contact.psql diff --git a/OGoContentStore/ChangeLog b/OGoContentStore/ChangeLog index 328b1edb..6dde311b 100644 --- a/OGoContentStore/ChangeLog +++ b/OGoContentStore/ChangeLog @@ -1,5 +1,13 @@ 2004-08-26 Helge Hess + * 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 diff --git a/OGoContentStore/GNUmakefile b/OGoContentStore/GNUmakefile index e5e6ade8..00ad8195 100644 --- a/OGoContentStore/GNUmakefile +++ b/OGoContentStore/GNUmakefile @@ -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 index 00000000..0dc72f49 --- /dev/null +++ b/OGoContentStore/OCSContactFieldExtractor.m @@ -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 + +@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 */ diff --git a/OGoContentStore/OCSFolderType.h b/OGoContentStore/OCSFolderType.h index c4583f45..c07474b5 100644 --- a/OGoContentStore/OCSFolderType.h +++ b/OGoContentStore/OCSFolderType.h @@ -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; diff --git a/OGoContentStore/OCSFolderType.m b/OGoContentStore/OCSFolderType.m index 20940048..8b2fa5e3 100644 --- a/OGoContentStore/OCSFolderType.m +++ b/OGoContentStore/OCSFolderType.m @@ -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: @@ -78,11 +80,13 @@ } - (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]; } @@ -136,8 +140,25 @@ /* 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 */ @@ -151,6 +172,7 @@ [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]; diff --git a/OGoContentStore/OCSiCalFieldExtractor.m b/OGoContentStore/OCSiCalFieldExtractor.m index 7f99df23..fefcebfe 100644 --- a/OGoContentStore/OCSiCalFieldExtractor.m +++ b/OGoContentStore/OCSiCalFieldExtractor.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "OCSiCalFieldExtractor.h" #include "common.h" diff --git a/OGoContentStore/Version b/OGoContentStore/Version index a73270b5..8e956c34 100644 --- a/OGoContentStore/Version +++ b/OGoContentStore/Version @@ -2,4 +2,4 @@ MAJOR_VERSION=0 MINOR_VERSION=9 -SUBMINOR_VERSION:=5 +SUBMINOR_VERSION:=6 diff --git a/OGoContentStore/appointment.ocs b/OGoContentStore/appointment.ocs index 35fdb2ab..3ad0386f 100644 --- a/OGoContentStore/appointment.ocs +++ b/OGoContentStore/appointment.ocs @@ -1,6 +1,7 @@ { - blobTablePattern = "SOGo_$folderId$_blob"; - quickTablePattern = "SOGo_$folderId$_quick"; + blobTablePattern = "SOGo_$folderId$_blob"; + quickTablePattern = "SOGo_$folderId$_quick"; + extractorClassName = "OCSiCalFieldExtractor"; fields = ( { diff --git a/OGoContentStore/contact.ocs b/OGoContentStore/contact.ocs index fa794eda..a08d2234 100644 --- a/OGoContentStore/contact.ocs +++ b/OGoContentStore/contact.ocs @@ -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 index 00000000..eff00af8 --- /dev/null +++ b/OGoContentStore/misc/iNetOrgPerson.txt @@ -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 index 00000000..415d78a6 --- /dev/null +++ b/OGoContentStore/sql/foldertablecreate-test-contacts.psql @@ -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 index 00000000..1d49923e --- /dev/null +++ b/OGoContentStore/sql/register-agenor-test-contacts.psql @@ -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' ); diff --git a/OGoContentStore/sql/testapt-agenor-helge-privcal.psql b/OGoContentStore/sql/testapt-agenor-helge-privcal.psql index d0ee2f49..7a912c3e 100644 --- a/OGoContentStore/sql/testapt-agenor-helge-privcal.psql +++ b/OGoContentStore/sql/testapt-agenor-helge-privcal.psql @@ -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 index 00000000..6b873db7 --- /dev/null +++ b/OGoContentStore/sql/testcontact-agenor-test-contact.psql @@ -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' +); -- 2.39.5