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>
OCSChannelManager.m \
OCSFieldExtractor.m \
OCSiCalFieldExtractor.m \
+ OCSContactFieldExtractor.m
libOGoContentStore_TYPEMODELS += \
appointment.ocs \
--- /dev/null
+/*
+ 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 */
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;
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "OCSFolderType.h"
#include "OCSFolder.h"
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];
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "OCSiCalFieldExtractor.h"
#include "common.h"
MAJOR_VERSION=0
MINOR_VERSION=9
-SUBMINOR_VERSION:=5
+SUBMINOR_VERSION:=6
{
- blobTablePattern = "SOGo_$folderId$_blob";
- quickTablePattern = "SOGo_$folderId$_quick";
+ blobTablePattern = "SOGo_$folderId$_blob";
+ quickTablePattern = "SOGo_$folderId$_quick";
+ extractorClassName = "OCSiCalFieldExtractor";
fields = (
{
{
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;
},
--- /dev/null
+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
--- /dev/null
+-- $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
+);
--- /dev/null
+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' );
--- $Id$
--
-- (C) 2004 SKYRIX Software AG
--
--- /dev/null
+--
+-- (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'
+);