TOOL_NAME = \
ldapPersonExporter \
findLongestEMailAddress \
- personalFolderInfoInserts
+ personalFolderInfoInserts \
+ adaptorChannelInserts
ldapPersonExporter_OBJC_FILES = lpe.m
ldapPersonExporter_TOOL_LIBS += -lNGLdap
personalFolderInfoInserts_OBJC_FILES = pfinserts.m
+adaptorChannelInserts_OBJC_FILES = inserts.m
+adaptorChannelInserts_TOOL_LIBS += -lGDLAccess
+
+
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/tool.make
-include GNUmakefile.postamble
--- /dev/null
+{
+/*
+ CREATE TABLE SOGo_test (
+ c_id INT PRIMARY KEY,
+ c_dir VARCHAR(255) NOT NULL,
+ c_cn VARCHAR(40) NOT NULL,
+ c_mailto VARCHAR(120) NOT NULL,
+ );
+*/
+
+ EOModelVersion = 1;
+ adaptorClassName = PostgreSQLAdaptor;
+ adaptorName = PostgreSQL;
+
+ entities = (
+ {
+ name = Test;
+ externalName = SOGo_test;
+ className = EOGenericRecord;
+ primaryKeyAttributes = ( pkey );
+ attributesUsedForLocking = ( pkey,
+ dir,
+ cn,
+ mailto
+ );
+ classProperties = ( pkey,
+ dir,
+ cn,
+ mailto
+ );
+ attributes = (
+ {
+ columnName = "c_id";
+ name = "pkey";
+ valueClassName = "NSNumber";
+ valueType = i;
+ externalType = INT;
+ },
+ {
+ columnName = "c_dir";
+ name = "dir";
+ valueClassName = "NSString";
+ externalType = "VARCHAR(255)";
+ allowsNull = N;
+ width = 255;
+ },
+ {
+ columnName = "c_cn";
+ name = "cn";
+ valueClassName = "NSString";
+ externalType = "VARCHAR(40)";
+ allowsNull = N;
+ width = 40;
+ },
+ {
+ columnName = "c_mailto";
+ name = "mailto";
+ valueClassName = "NSString";
+ externalType = "VARCHAR(120)";
+ allowsNull = N;
+ width = 120;
+ }
+ );
+ }
+ );
+}
--- /dev/null
+/*
+ @DISCLAIMER@
+*/
+// $Id$
+
+#import <Foundation/Foundation.h>
+#import <EOAccess/EOAccess.h>
+#import <NGExtensions/NGExtensions.h>
+
+
+#define DEBUG 0
+
+
+#define ALL_RECORDS @"/home/znek/all-BALI.plist"
+
+
+int main(int argc, char **argv, char **env) {
+ NSAutoreleasePool *pool;
+ EOModel *m = nil;
+ EOAdaptor *a;
+ EOAdaptorContext *ctx;
+ EOAdaptorChannel *ch;
+ NSDictionary *conDict;
+
+ pool = [[NSAutoreleasePool alloc] init];
+#if LIB_FOUNDATION_LIBRARY
+ [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
+#endif
+
+ conDict = [NSDictionary dictionaryWithContentsOfFile:@"connection.plist"];
+ NSLog(@"condict is %@", conDict);
+
+ if ((a = [EOAdaptor adaptorWithName:@"PostgreSQL72"]) == nil) {
+ NSLog(@"found no PostgreSQL adaptor ..");
+ exit(1);
+ }
+
+ NSLog(@"got adaptor %@", a);
+ [a setConnectionDictionary:conDict];
+ NSLog(@"got adaptor with condict %@", a);
+
+ ctx = [a createAdaptorContext];
+ ch = [ctx createAdaptorChannel];
+
+ m = [[EOModel alloc] initWithContentsOfFile:@"inserts.eomodel"];
+ if (m) {
+ [a setModel:m];
+ [a setConnectionDictionary:conDict];
+ }
+
+
+ NSLog(@"opening channel ..");
+
+ [ch setDebugEnabled:YES];
+
+ if ([ch openChannel]) {
+ NSLog(@"channel is open");
+
+#if 0
+ if ([ctx beginTransaction]) {
+ NSLog(@"began tx ..");
+#endif
+ /* do something */
+ {
+ NSAutoreleasePool *lpool = [[NSAutoreleasePool alloc] init];
+ EOEntity *e;
+ EOSQLQualifier *q;
+ NSArray *attrs;
+ NSString *expr;
+
+#if 0
+ NS_DURING
+
+ if([ctx beginTransaction]) {
+ expr = @"DROP TABLE SOGo_test";
+
+ if([ch evaluateExpression:expr]) {
+ attrs = [ch describeResults];
+ NSLog(@"results: %@", attrs);
+
+
+ if([ctx commitTransaction]) {
+ NSLog(@"DROP'ed table - committed.");
+ } else {
+ NSLog(@"couldn't commit DROP TABLE!");
+ }
+ }
+ }
+ NS_HANDLER
+
+ NSLog(@"DROP table aborted - %@", [localException reason]);
+ NSLog(@"a");
+
+ NS_ENDHANDLER
+#endif
+
+ NS_DURING
+
+ if([ctx beginTransaction]) {
+ expr = @"CREATE TABLE SOGo_test (c_id INT PRIMARY KEY, c_dir VARCHAR(255) NOT NULL, c_cn VARCHAR(40) NOT NULL, c_mailto VARCHAR(120) NOT NULL);";
+ if([ch evaluateExpression:expr]) {
+ if([ctx commitTransaction]) {
+ NSLog(@"CREATE TABLE - committed");
+ } else {
+ NSLog(@"couldn't commit CREATE TABLE!");
+ }
+ }
+ }
+
+ NS_HANDLER
+
+ fprintf(stderr, "exception: %s\n", [[localException description] cString]);
+ abort();
+
+ NS_ENDHANDLER;
+
+ [lpool release];
+ }
+
+#if 0
+ NSLog(@"committing tx ..");
+ if ([ctx commitTransaction])
+ NSLog(@" could commit.");
+ else
+ NSLog(@" commit failed.");
+ }
+#endif
+
+ NSLog(@"closing channel ..");
+ [ch closeChannel];
+ }
+
+
+ [m release];
+ [pool release];
+
+ exit(0);
+ return 0;
+}