gnustep-dl2-0.12.0/ 0000775 0001750 0001750 00000000000 14754660701 013034 5 ustar yavor yavor gnustep-dl2-0.12.0/Version 0000664 0001750 0001750 00000001044 14632325605 014377 0 ustar yavor yavor # This file is included in various Makefile's to get version information.
# Compatible with Bourne shell syntax, so it can included there too.
# The gcc version required to compile the library.
GNUSTEP_GCC=2.95.2
# The version number of this release.
MAJOR_VERSION=0
MINOR_VERSION=12
SUBMINOR_VERSION=0
GDL2_VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${SUBMINOR_VERSION}
VERSION=${GDL2_VERSION}
GDL2_FTP_MACHINE=ftp.gnustep.org
GDL2_FTP_DIRECTORY=pub/gnustep/gdl2
GDL2_SNAP_FTP_MACHINE=ftp.gnustep.org
GDL2_SNAP_FTP_DIRECTORY=pub/daily-snapshots
gnustep-dl2-0.12.0/Tools/ 0000775 0001750 0001750 00000000000 14754345005 014131 5 ustar yavor yavor gnustep-dl2-0.12.0/Tools/gdl2gsdoc.gsdoc 0000664 0001750 0001750 00000001264 14632325605 017024 0 ustar yavor yavor
GDL2 GSDoc
GDL2 GSDoc
...
gnustep-dl2-0.12.0/Tools/EOJoin+GSDoc.h 0000664 0001750 0001750 00000002453 14632325605 016363 0 ustar yavor yavor /* -*-objc-*-
EOJoin+GSDoc.h
EOJoin+GSDoc
Copyright (C) 2000-2002,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
// $Id$
#ifndef __EOJoin_GSDoc_h__
#define __EOJoin_GSDoc_h__
#include
@interface EOJoin (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr;
@end
#endif /* __EOJoin_GSDoc_h__ */
gnustep-dl2-0.12.0/Tools/Makefile.preamble 0000664 0001750 0001750 00000004737 14636004727 017374 0 ustar yavor yavor #
# Makefile.preamble
#
# Copyright (C) 1997,2002,2004,2005 Free Software Foundation, Inc.
#
# Written by: Scott Christley
#
# This file is part of the GNUstep Database Library.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# Makefile.preamble
#
# Project specific makefile variables, and additional
#
# Do not put any Makefile rules in this file, instead they should
# be put into Makefile.postamble.
#
#
# Flags dealing with compiling and linking
#
# Additional flags to pass to the preprocessor
#ADDITIONAL_CPPFLAGS = $(FND_DEFINE) $(RUNTIME_DEFINE) -g
# Additional flags to pass to the Objective-C compiler
ADDITIONAL_OBJCFLAGS += -Wall
# Additional flags to pass to the C compiler
ADDITIONAL_CFLAGS =
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS = -I../EOControl/$(GNUSTEP_TARGET_DIR) -I..
# Additional LDFLAGS to pass to the linker
ifneq ($(FOUNDATION_LIB),gnu)
ADDITIONAL_TOOL_LIBS += -lgnustep-baseadd
else
ADDITIONAL_LDFLAGS +=-Wl,--allow-shlib-undefined
endif
ADDITIONAL_NATIVE_LIBS+=EOControl EOAccess
ADDITIONAL_NATIVE_LIB_DIRS+=../EOControl ../EOAccess
# Additional library directories the linker should search
ADDITIONAL_LIB_DIRS +=
#
# Flags dealing with installing and uninstalling
#
# Additional directories to be created during installation
ADDITIONAL_INSTALL_DIRS =
# What are the libraries this library depends upon. This is needed for some
# systems where building a shared library requires to pass to the linker
# all the libraries the target library depends upon.
ifneq ($(FOUNDATION_LIBRARY_NAME),)
LIBRARIES_DEPEND_UPON = -l$(FOUNDATION_LIBRARY_NAME)
endif
ifeq ($(FOUNDATION_HAS_KVC), yes)
ADDITIONAL_OBJCFLAGS := $(ADDITIONAL_OBJCFLAGS) -DFOUNDATION_HAS_KVC=1
endif
gnustep-dl2-0.12.0/Tools/NSDictionary+GSDoc.m 0000664 0001750 0001750 00000005423 14636026724 017617 0 ustar yavor yavor /**
NSDictionary+GSDoc.m
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#ifdef GNUSTEP
#include
#include
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#endif
#include "NSDictionary+GSDoc.h"
@implementation NSDictionary (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr
{
return [self gsdocContentWithTagName: @"dictionary"
idPtr: xmlIdPtr];
}
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
idPtr: (int *)xmlIdPtr
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *content = [NSString string];
NSEnumerator *enumerator = [self keyEnumerator];
id key = nil;
NSLog(@"Start: %@", [self class]);
if (tagName)
content = [content stringByAppendingFormat: @"<%@%@>\n",
tagName,
(!xmlIdPtr
|| [tagName isEqualToString: @"dictionary"] ? @""
: [NSString stringWithFormat: @" debugId=\"%d\"",
(*xmlIdPtr)++])];
while ((key = [enumerator nextObject]))
{
id elem = [self objectForKey: key];
NSLog(@"key: %@ elem: %@", key, elem);
if ([elem respondsToSelector: @selector(gsdocContentWithIdPtr:)])
content = [content stringByAppendingFormat:
@"\n%@ \n",
key,
[elem gsdocContentWithIdPtr: xmlIdPtr]];
else
content = [content stringByAppendingFormat:
@"\n",
key,
elem];
}
if (tagName)
content = [content stringByAppendingFormat: @"%@>\n",
tagName];
NSLog(@"Stop: %@", [self class]);
RETAIN(content);
DESTROY(arp);
return AUTORELEASE(content);
}
@end
gnustep-dl2-0.12.0/Tools/eomodeltemplate.gsdoc 0000664 0001750 0001750 00000001576 14632325605 020342 0 ustar yavor yavor
[[projectName]]
[[infoDictionary.authorDesc]]
[[infoDictionary.version]]
[[infoDictionary.date]] [[timestampString]]
[Source : [[fileName]] ] DTD ]
[[infoDictionary.copyright]]
[[content]]
gnustep-dl2-0.12.0/Tools/GNUmakefile 0000664 0001750 0001750 00000004652 14632325605 016211 0 ustar yavor yavor #
# Tools makefile for GNUstep Database Library.
#
# Copyright (C) 1997,2002,2003,2004,2005 Free Software Foundation, Inc.
#
# Written by: Scott Christley
#
# This file is part of the GNUstep Database Library.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
include ../common.make
include $(GNUSTEP_MAKEFILES)/common.make
include ../Version
# The library to be compiled
TOOL_NAME=gdlgsdoc eoutil
gdlgsdoc_NEEDS_GUI = no
# The C source files to be compiled
gdlgsdoc_C_FILES =
# The Objective-C source files to be compiled
gdlgsdoc_OBJC_FILES = \
EOAttribute+GSDoc.m \
EOEntity+GSDoc.m \
EOJoin+GSDoc.m \
EOModel+GSDoc.m \
EORelationship+GSDoc.m \
gsdoc-model.m \
NSArray+GSDoc.m \
NSDictionary+GSDoc.m \
gdlgsdoc_HEADER_FILES_DIR = .
#gdlgsdoc_HEADER_FILES_INSTALL_DIR =
gdlgsdoc_HEADER_FILES = \
EOAttribute+GSDoc.h \
EOEntity+GSDoc.h \
EOJoin+GSDoc.h \
EOModel+GSDoc.h \
EORelationship+GSDoc.h \
NSArray+GSDoc.h \
NSDictionary+GSDoc.h \
gdl2gsdoc_AUTOGSDOC_HEADERS = $(gdlgsdoc_HEADER_FILES)
gdl2gsdoc_AUTOGSDOC_SOURCE = $(gdlgsdoc_OBJC_FILES)
DOCUMENT_NAME = gdl2gsdoc
gdl2gsdoc_HEADER_FILES_DIR = $(HEADER_DIR)
gdl2gsdoc_AGSDOC_FILES = gdl2gsdoc.gsdoc $(gdl2gsdoc_AUTOGSDOC_HEADERS)
#$(gdl2gsdoc_AUTOGSDOC_SOURCE)
gdl2gsdoc_AGSDOC_FLAGS = \
-Declared gdlgsdoc \
-Project gdl2gsdoc \
-Up gdl2gsdoc \
$(GDL2_AGSDOC_FLAGS)
eoutil_NEEDS_GUI = no
eoutil_OBJC_FILES = eoutil.m
eoutil_HEADER_FILES =
-include Makefile.preamble
-include GNUmakefile.local
include $(GNUSTEP_MAKEFILES)/tool.make
include $(GNUSTEP_MAKEFILES)/ctool.make
# Only build the doc if doc=yes was passed on the command line
ifeq ($(doc),yes)
include $(GNUSTEP_MAKEFILES)/documentation.make
endif
-include Makefile.postamble
gnustep-dl2-0.12.0/Tools/gsdoc-model.m 0000664 0001750 0001750 00000040635 14636026724 016517 0 ustar yavor yavor /* This tool produce .gsdoc files from eomodel files
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Written by: Manuel Guesdon
Created: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#ifdef GNUSTEP
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#endif
#include
#include "EOModel+GSDoc.h"
NSString *PathExtension_GSDoc = @"gsdoc";
NSString *PathExtension_EOModel = @"eomodeld";
NSString *PathExtension_Model = @"model";
int verbose = 0;
//--------------------------------------------------------------------
// In text, replace keys from variables with their values
// variables is like something like this
// {
// "[[key1]]" = "value1";
// "[[key2]]" = "value2";
// };
NSString *TextByReplacingVariablesInText(NSString *text,
NSDictionary *variables)
{
NSEnumerator *variablesEnum = [variables keyEnumerator];
id key;
while ((key = [variablesEnum nextObject]))
{
id value = [variables objectForKey: key];
text = [text stringByReplacingString: key
withString: [value description]];
}
return text;
}
//--------------------------------------------------------------------
// Return list of files found in dir (deep search) which have extension extension
NSArray *FilesInPathWithExtension(NSString *dir, NSString *extension)
{
NSMutableArray *files = [NSMutableArray array];
NSString *file = nil;
NSFileManager *fm = [NSFileManager defaultManager];
NSDirectoryEnumerator *enumerator = [fm enumeratorAtPath: dir];
while ((file = [enumerator nextObject]))
{
BOOL isDirectory = NO;
file = [dir stringByAppendingPathComponent: file];
if ([[file pathExtension] isEqual: extension])
{
if ([fm fileExistsAtPath: file isDirectory: &isDirectory])
{
if (!isDirectory)
{
[files addObject: file];
}
}
}
}
return files;
}
//--------------------------------------------------------------------
int
main(int argc, char **argv, char **env)
{
NSProcessInfo *proc;
NSArray *args;
NSUInteger i;
NSUserDefaults *defs;
NSMutableArray *files = nil; // Files to parse
NSString *templateFileName = nil; // makeIndex template file name
NSMutableDictionary *infoDictionary = nil; // user info
NSDictionary *variablesDictionary = nil; // variables dictionary
BOOL goOn = YES;
BOOL splitByEntities = NO;
NSFileManager *fileManager = nil;
NSString *documentationDirectory = nil;
NSString *declared = nil;
NSString *project = nil;
BOOL generateHtml = YES;
BOOL ignoreDependencies = NO;
BOOL showDependencies = NO;
id obj = nil;
CREATE_AUTORELEASE_POOL(pool);
#ifdef GS_PASS_ARGUMENTS
[NSProcessInfo initializeWithArguments: argv count: argc environment: env];
#endif
defs = [NSUserDefaults standardUserDefaults];
[defs registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys:
@"Untitled", @"Project",
nil]];
verbose = [defs boolForKey: @"Verbose"];
ignoreDependencies = [defs boolForKey: @"IgnoreDependencies"];
showDependencies = [defs boolForKey: @"ShowDependencies"];
if (ignoreDependencies == YES)
{
if (showDependencies == YES)
{
showDependencies = NO;
NSLog(@"ShowDependencies(YES) used with IgnoreDependencies(YES)");
}
}
obj = [defs objectForKey: @"GenerateHtml"];
if (obj != nil)
{
generateHtml = [defs boolForKey: @"GenerateHtml"];
}
declared = [defs stringForKey: @"Declared"];
project = [defs stringForKey: @"Project"];
documentationDirectory = [defs stringForKey: @"DocumentationDirectory"];
if (documentationDirectory == nil)
{
documentationDirectory = @"";
}
proc = [NSProcessInfo processInfo];
if (proc == nil)
{
NSLog(@"unable to get process information!");
goOn = NO;
}
fileManager = [NSFileManager defaultManager];
if (goOn)
{
args = [proc arguments];
// First, process arguments
for (i = 1; goOn && i < [args count]; i++)
{
NSString *arg = [args objectAtIndex: i];
// is this an option ?
if ([arg hasPrefix: @"--"])
{
NSString *argWithoutPrefix = [arg stringByDeletingPrefix: @"--"];
NSString *key = nil;
NSString *value = nil;
NSArray *parts = [argWithoutPrefix componentsSeparatedByString:
@"="];
key = [parts objectAtIndex: 0];
if ([parts count] > 1)
value = [[parts subarrayWithRange:
NSMakeRange(1, [parts count] - 1)]
componentsJoinedByString: @"="];
// projectName option
if ([key isEqualToString: @"projectName"]
|| [key isEqualToString: @"project"])
{
project = value;
NSCAssert([project length], @"No project name");
}
// template option
else if ([key isEqualToString: @"template"])
{
templateFileName = value;
NSCAssert([templateFileName length], @"No template filename");
}
else if ([key isEqualToString: @"splitByEntities"])
{
splitByEntities = [value boolValue];
}
// Verbose
else if ([key hasPrefix: @"verbose"])
{
NSCAssert1(value, @"No value for %@", key);
verbose = [value intValue];
if (verbose > 0)
{
NSMutableSet *debugSet = [proc debugSet];
[debugSet addObject: @"dflt"];
}
}
// define option
else if ([key hasPrefix: @"define-"])
{
if (!infoDictionary)
infoDictionary = (id)[NSMutableDictionary dictionary];
NSCAssert1(value, @"No value for %@", key);
[infoDictionary setObject: value
forKey:
[key stringByDeletingPrefix: @"define-"]];
}
// DocumentationDirectory
else if ([key hasPrefix: @"documentationDirectory"])
{
if (!value)
value = @"";
documentationDirectory = value;
}
/* // unknown option
else
{
NSLog(@"Unknown option %@", arg);
goOn = NO;
};*/
}
// file to parse
else
{
if (!files)
files = [NSMutableArray array];
[files addObject: arg];
}
}
}
//Default Values
if (goOn)
{
if (!project)
project = @"unknown";
}
// Verify option compatibilities
if (goOn)
{
}
//Variables
if (goOn)
{
NSMutableDictionary *variablesMutableDictionary =
[NSMutableDictionary dictionary];
NSEnumerator *enumer = [infoDictionary keyEnumerator];
id key;
while ((key = [enumer nextObject]))
{
id value = [infoDictionary objectForKey: key];
[variablesMutableDictionary
setObject: value
forKey: [NSString stringWithFormat: @"[[infoDictionary.%@]]", key]];
}
[variablesMutableDictionary setObject: [NSCalendarDate calendarDate]
forKey: @"[[timestampString]]"];
if (project)
[variablesMutableDictionary setObject: project
forKey: @"[[projectName]]"];
variablesDictionary = [[variablesMutableDictionary copy] autorelease];
if (verbose >= 3)
{
NSEnumerator *enumer = [variablesDictionary keyEnumerator];
id key;
while ((key = [enumer nextObject]))
{
NSLog(@"Variables: %@=%@",
key,
[variablesDictionary objectForKey: key]);
}
}
}
// Find Files to parse
if (goOn)
{
if ([files count] < 1)
{
NSLog(@"No file names given to parse.");
goOn = NO;
}
else
{
/* NSMutableArray* tmpNewFiles=[NSMutableArray array];
for (i=0;goOn && i<[files count];i++)
{
NSString* file = [files objectAtIndex: i];
BOOL isDirectory=NO;
if (![fileManager fileExistsAtPath:file isDirectory:&isDirectory])
{
NSLog(@"File %@ doesn't exist",file);
goOn=NO;
}
else
{
if (isDirectory)
{
NSArray* tmpFiles=FilesInPathWithExtension(file,PathExtension_EOModel);
[tmpNewFiles addObjectsFromArray:tmpFiles];
tmpFiles=FilesInPathWithExtension(file,PathExtension_Model);
[tmpNewFiles addObjectsFromArray:tmpFiles];
}
else
{
[tmpNewFiles addObject:file];
}
}
}
files=tmpNewFiles;
files=(NSMutableArray*)[files sortedArrayUsingSelector:@selector(compare:)];
NSDebugLog(@"files=%@",files);
*/
}
}
if (goOn)
{
NSString *textTemplate = [NSString stringWithContentsOfFile:
templateFileName];
for (i = 0; goOn && i < [files count]; i++)
{
NSString *file = [files objectAtIndex: i];
NSAutoreleasePool *arp = [NSAutoreleasePool new];
if (verbose >= 1)
{
NSLog(@"File %"PRIuPTR"/%"PRIuPTR" - Processing %@",
(i+1),
[files count],
file);
}
NS_DURING
{
EOModel *model;
// model=[[[EOModel alloc]autorelease]initWithContentsOfFile:file];
model = [[[EOModel alloc] initWithContentsOfFile: file]
autorelease];
if (model)
{
NSString *gsdocModelContent = nil;
NSDictionary *entities = nil;
NSLog(@"Model %@ loaded", file);
gsdocModelContent = [model gsdocContentSplittedByEntities:
(splitByEntities
? &entities : NULL)
idPtr: NULL/*&xmlId*/];//Debugging
if (gsdocModelContent == nil)
{
NSLog(@"File %"PRIuPTR"/%"PRIuPTR" - Error generating doc for %@",
(i+1),
[files count],
file);
goOn = NO;
}
else
{
int iGenerateDoc = 0;
int iGenerateCount = 0;
NSString *fileContent = nil;
NSString *baseFileName = nil;
NSString *fileName = nil;
NSMutableDictionary *variablesMutableDictionary = nil;
NSArray *entitiesNames = [[entities allKeys]
sortedArrayUsingSelector:
@selector(compare:)];
NSMutableString *entitiesIndex = [NSMutableString
stringWithString:
@"\n"];
iGenerateCount = [entitiesNames count] + 1;
variablesMutableDictionary = [variablesDictionary
mutableCopy];
for (iGenerateDoc = 0;
iGenerateDoc < iGenerateCount;
iGenerateDoc++)
{
NSString *theFile = nil;
NSString *content = nil;
if (iGenerateDoc == (iGenerateCount - 1))
{
NSMutableDictionary *tmpVariablesMutableDictionary = nil;
theFile = file;
[entitiesIndex appendString: @"
\n"];
tmpVariablesMutableDictionary =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
entitiesIndex,
@"[[entities]]",
nil];
content = TextByReplacingVariablesInText(gsdocModelContent, tmpVariablesMutableDictionary);
}
else
{
NSString *entityName = [entitiesNames
objectAtIndex:
iGenerateDoc];
theFile = [NSString stringWithFormat: @"%@+%@",
[file stringByDeletingPathExtension],
entityName];
content = [entities objectForKey: entityName];
[entitiesIndex appendFormat:
@"%@ \n",
theFile,
entityName];
}
baseFileName = [theFile
stringByDeletingPathExtension];
fileName = [baseFileName
stringByAppendingPathExtension: PathExtension_GSDoc];
fileName = [documentationDirectory stringByAppendingPathComponent: fileName];
[variablesMutableDictionary setObject: fileName
forKey: @"[[fileName]]"];
[variablesMutableDictionary setObject: baseFileName
forKey:
@"[[baseFileName]]"];
[variablesMutableDictionary setObject: content
forKey: @"[[content]]"];
fileContent = TextByReplacingVariablesInText(textTemplate, variablesMutableDictionary);
[fileContent writeToFile: fileName
atomically: NO];
}
if (verbose >= 1)
{
NSLog(@"File %"PRIuPTR"/%"PRIuPTR" - Generating %@ - OK",
(i+1),
[files count],
file);
}
}
}
else
{
NSLog(@"File %"PRIuPTR"/%"PRIuPTR" - Error parsing '%@'",
(i+1),
[files count],
file);
goOn = NO;
}
}
NS_HANDLER
{
NSLog(@"File %"PRIuPTR"/%"PRIuPTR" - Parsing '%@' - %@",
(i+1),
[files count],
file,
[localException reason]);
goOn = NO;
}
NS_ENDHANDLER;
DESTROY(arp);
}
}
[pool release];
return (goOn ? 0 : 1);
}
gnustep-dl2-0.12.0/Tools/EOJoin+GSDoc.m 0000664 0001750 0001750 00000004733 14636026724 016377 0 ustar yavor yavor /**
EOJoin+GSDoc.m EOJoin+GSDoc
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#ifdef GNUSTEP
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#endif
#include
#include
#include
#include "NSArray+GSDoc.h"
#include "NSDictionary+GSDoc.h"
#include "EOAttribute+GSDoc.h"
#include "EOJoin+GSDoc.h"
@implementation EOJoin (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *content = [NSString string];
NSLog(@"Start: %@", [self class]);
content = [content stringByAppendingFormat:
@"\n",
(xmlIdPtr
? [NSString stringWithFormat: @" debugId=\"%d\"",
(*xmlIdPtr)++] : @""),
@"",//[[self relationship] name],
@"",//[self joinOperatorDescription],
@"",//[self joinSemanticDescription],
[[self sourceAttribute] name],
[[self destinationAttribute] name]];
/* if ([self docComment])
content=[content stringByAppendingFormat:@"%@ \n",[self docComment]];*/
content = [content stringByAppendingString: @" \n"];
NSLog(@"Stop: %@", [self class]);
RETAIN(content);
DESTROY(arp);
return AUTORELEASE(content);
}
@end
gnustep-dl2-0.12.0/Tools/EOEntity+GSDoc.h 0000664 0001750 0001750 00000002452 14632325605 016737 0 ustar yavor yavor /* -*-objc-*-
EOEntity+GSDoc.h
Copyright (C) 2000-2002,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
// $Id$
#ifndef __EOEntity_GSDoc_h__
#define __EOEntity_GSDoc_h__
#include
@interface EOEntity (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr;
@end
#endif /* __EOEntity_GSDoc_h__ */
gnustep-dl2-0.12.0/Tools/NSArray+GSDoc.h 0000664 0001750 0001750 00000003027 14632325605 016555 0 ustar yavor yavor /* -*-objc-*-
NSArray+GSDoc.h
Copyright (C) 2000-2002,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
// $Id$
#ifndef __NSArray_GSDoc_h__
#define __NSArray_GSDoc_h__
#include
@interface NSArray (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr;
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
idPtr: (int *)xmlIdPtr;
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
elementsTagName: (NSString *)elementsTagName
idPtr: (int *)xmlIdPtr;
@end
#endif /* __NSArray_GSDoc_h__ */
gnustep-dl2-0.12.0/Tools/NSArray+GSDoc.m 0000664 0001750 0001750 00000006625 14636026724 016575 0 ustar yavor yavor /**
NSArray+GSDoc.m
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#ifdef GNUSTEP
#include
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#endif
#include "NSArray+GSDoc.h"
@implementation NSArray (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr
{
return [self gsdocContentWithTagName: @"list"
idPtr: NULL];
}
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
idPtr: (int *)xmlIdPtr
{
return [self gsdocContentWithTagName: (NSString *)tagName
elementsTagName: nil
idPtr: xmlIdPtr];
}
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
elementsTagName: (NSString *)elementsTagName
idPtr: (int *)xmlIdPtr
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *content = [NSString string];
int i, count = [self count];
NSLog(@"Start: %@", [self class]);
if (tagName)
content = [content stringByAppendingFormat: @"<%@%@>\n",
tagName,
(!xmlIdPtr
|| [tagName isEqualToString:@"list"] ? @""
: [NSString stringWithFormat: @" debugId=\"%d\"",
(*xmlIdPtr)++])];
for (i = 0; i < count; i++)
{
id elem = [self objectAtIndex: i];
NSLog(@"elem: %@", elem);
if (elementsTagName)
{
if ([elem respondsToSelector: @selector(gsdocContentWithTagName:idPtr:)])
content = [content stringByAppendingString:
[elem gsdocContentWithTagName: elementsTagName
idPtr: xmlIdPtr]];
else if ([elem respondsToSelector: @selector(gsdocContentWithIdPtr:)])
content = [content stringByAppendingString:
[elem gsdocContentWithIdPtr: xmlIdPtr]];
else
content = [content stringByAppendingFormat: @"- %@
\n",
elem];
}
else
{
if ([elem respondsToSelector: @selector(gsdocContentWithIdPtr:)])
content = [content stringByAppendingString:
[elem gsdocContentWithIdPtr: xmlIdPtr]];
else
content = [content stringByAppendingFormat: @"- %@
\n",
elem];
}
}
if (tagName)
content = [content stringByAppendingFormat: @"%@>\n",
tagName];
NSLog(@"Stop: %@", [self class]);
RETAIN(content);
DESTROY(arp);
return AUTORELEASE(content);
}
@end
gnustep-dl2-0.12.0/Tools/EORelationship+GSDoc.m 0000664 0001750 0001750 00000007655 14636026724 020147 0 ustar yavor yavor /**
EORelationship+GSDoc.m
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#ifdef GNUSTEP
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#endif
#include
#include
#include
#include "NSArray+GSDoc.h"
#include "NSDictionary+GSDoc.h"
#include "EORelationship+GSDoc.h"
/*
NSString* definition;
struct {
BOOL isFlattened:1;
BOOL isToMany:1;
BOOL createsMutableObjects:1;
} flags;
*/
@implementation EORelationship (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr
{
return [self gsdocContentWithTagName: @"EORelationship"
idPtr: xmlIdPtr];
}
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
idPtr: (int *)xmlIdPtr
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *content = [NSString string];
NSLog(@"Start: %@: %@", [self class], [self name]);
if ([tagName isEqual: @"EOAttributeRef"])
{
content = [content stringByAppendingFormat:
@"\n",
(xmlIdPtr
? [NSString stringWithFormat: @" debugId=\"%d\"",
(*xmlIdPtr)++] : @""),
[self name]];
}
else
{
content = [content stringByAppendingFormat:
@"<%@%@ name=\"%@\" entityName=\"%@\" destinationEntityName=\"%@\">\n",
tagName,
(xmlIdPtr
? [NSString stringWithFormat: @" id=\"%d\"",
(*xmlIdPtr)++] : @""),
[self name],
[[self entity] name],
[[self destinationEntity] name]];
if ([self isFlattened])
{
int i, count = [[self componentRelationships] count];
for (i = 0; i < count; i++)
{
EORelationship *component;
component = [[self componentRelationships] objectAtIndex: i];
content = [content stringByAppendingFormat:
@"\n",
(xmlIdPtr
? [NSString stringWithFormat: @" id=\"%d\"",
(*xmlIdPtr)++] : @""),
[component name]];
}
for (i = 0; i < count; i++)
content = [content stringByAppendingString:
@" \n"];
}
else if ([self joins])
content = [content stringByAppendingString:
[[self joins]
gsdocContentWithTagName: nil
idPtr: xmlIdPtr]];
if ([[self userInfo] count])
content = [content stringByAppendingString:
[[self userInfo]
gsdocContentWithTagName: @"EOUserDictionary"
idPtr: xmlIdPtr]];
if ([self docComment])
content = [content stringByAppendingFormat: @"%@ \n",
[self docComment]];
content = [content stringByAppendingFormat: @"%@>\n",
tagName];
}
NSLog(@"Stop: %@: %@", [self class], [self name]);
RETAIN(content);
DESTROY(arp);
return AUTORELEASE(content);
}
@end
gnustep-dl2-0.12.0/Tools/EOModel+GSDoc.m 0000664 0001750 0001750 00000010677 14636026724 016544 0 ustar yavor yavor /**
EOModel+GSDoc.m
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#ifdef GNUSTEP
#include
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#endif
#include
#include
#include
#include "NSArray+GSDoc.h"
#include "NSDictionary+GSDoc.h"
#include "EOEntity+GSDoc.h"
#include "EOModel+GSDoc.h"
@implementation EOModel (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr
{
return [self gsdocContentSplittedByEntities: NULL
idPtr: xmlIdPtr];
}
- (NSString *)gsdocContentSplittedByEntities: (NSDictionary **)entitiesPtr
idPtr: (int *)xmlIdPtr
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *content = [NSString string];
NSArray *entities = [self entities];
int i, count = [entities count];
NSString *chapter = [self name]
? [NSString stringWithFormat: @" id=\"%@\"", [self name]]
: @"";
NSString *model = [self name] ? [self name] : @"";
NSString *debugId = xmlIdPtr
? [NSString stringWithFormat: @" debugId=\"%d\"", (*xmlIdPtr)++]
: @"";
NSString *name = ([self name]
? [NSString stringWithFormat: @" name=\"%@\"", [self name]]
: @"");
NSString *adaptorName = [self adaptorName]
? [NSString stringWithFormat: @" adaptorName=\"%@\"", [self adaptorName]]
: @"";
NSString *adaptorClassName = [self adaptorClassName]
? [NSString stringWithFormat: @" adaptorClassName=\"%@\"",
[self adaptorClassName]]
: @" adaptorClassName=\"\"";
NSLog(@"Start: %@", [self class]);
content = [content stringByAppendingFormat:
@"\nEOModel %@ \n\n",
chapter, model,
debugId, name, adaptorName, adaptorClassName];
if ([self connectionDictionary])
content = [content stringByAppendingString:
[[self connectionDictionary]
gsdocContentWithTagName: @"EOConnectionDictionary"
idPtr: xmlIdPtr]];
if (entitiesPtr)
{
*entitiesPtr = [NSMutableDictionary dictionary];
content = [content stringByAppendingString: @"[[entities]]"];
}
for (i = 0; i < count; i++)
{
EOEntity *entity = [entities objectAtIndex: i];
NSString *entityContent = [entity gsdocContentWithIdPtr: xmlIdPtr];
NSAssert(entityContent, @"No entity gsdoc content");
if (entitiesPtr)
{
entityContent = [NSString stringWithFormat:
@"\nEOEntity %@ \n%@\n \n",
[entity name],
[entity name],
entityContent];
[(NSMutableDictionary*)*entitiesPtr setObject: entityContent
forKey: [entity name]];
}
else
content = [content stringByAppendingString: entityContent];
}
if ([[self userInfo] count])
content = [content stringByAppendingString:
[[self userInfo]
gsdocContentWithTagName: @"EOUserDictionary"
idPtr: xmlIdPtr]];
if ([self docComment])
content = [content stringByAppendingFormat: @"%@ \n",
[self docComment]];
content = [content stringByAppendingString: @" \n \n"];
NSLog(@"Stop: %@", [self class]);
RETAIN(content);
if (entitiesPtr)
RETAIN(*entitiesPtr);
DESTROY(arp);
if (entitiesPtr)
AUTORELEASE(*entitiesPtr);
return AUTORELEASE(content);
}
@end
gnustep-dl2-0.12.0/Tools/eoutil.m 0000664 0001750 0001750 00000126054 14754345005 015620 0 ustar yavor yavor /**
eoutil.m eoutil Tool
Copyright (C) 2003,2004,2005 Free Software Foundation, Inc.
Author: Stephane Corthesy
Date: February 2003
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#ifdef GNUSTEP
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#endif
#include
#include
/*
TODO
Implement -ascii option
Test multiple models
Add new option -dateFormat ISO|Apple (has ISO enough precision for microseconds?)
Add new option -nullValue '__NULL__'
Question: is it possible to save/restore sequences (for PK)?
Replace all autorelease/release/retain by macros
Document plist format
Document usage
Optimization: if not -force, do all EOF ops in one go
*/
@interface NSString(eoutil)
- (NSString *) lossyASCIIString;
@end
@implementation NSString(eoutil)
- (NSString *) lossyASCIIString
{
NSData *d;
d = [self dataUsingEncoding: NSASCIIStringEncoding
allowLossyConversion: YES];
return [[[NSString alloc] initWithData: d
encoding: NSASCIIStringEncoding] autorelease];
}
@end
// TODO
// Add support to read/write multiple plists, one per entity
// -source plists where 'plists' is a directory name (created if necessary)
// In the directory, create one plist per entity
static BOOL
usage(BOOL fullUsage)
{
char *usageString;
if (fullUsage)
usageString = "Command line utility to perform database and EOF oriented tasks.\n"
"Syntax: eoutil dump/connect/convert\n"
" eoutil dump [-source [sourcefile]] -dest [destfile] [-schemaCreate ] [-schemaDrop ] [-postInstall] [-force] [-connDict ] [-entities ] [-excludedEntities ] [-modelGroup ] [-ascii]\n"
"\tThis command reads data from and dumps it to . The dump may\n"
"\tinclude bits of DML that create bits of database schema. The -source flag is\n"
"\toptional if only schema is to be created (i.e. no data is being dumped). The\n"
"\tfollowing is a list of possible values for each of the arguments in the command:\n"
"\t model -- must be the name of an eomodel or eomodeld file\n"
"\t source -- 'plist' (read from stdin unless source file is specified) or\n"
"\t 'database' (uses model to connect)\n"
"\t sourcefile -- name of file to read plist from\n"
"\t dest -- 'plist' or 'script' (both are written to stdout unless destfile is\n"
"\t specified) or 'database' (uses model to connect)\n"
"\t destfile -- name of file to write plist or script\n"
"\t options -- 'database', 'tables', 'primaryKeySupport',\n"
"\t 'primaryKeyConstraints' or 'foreignKeyConstraints'\n"
"\t postInstall -- looks in the userInfo dictionary for an array of SQL strings\n"
"\t to process after any schema creation and data dumping is done\n"
"\t force -- Do not quit processing after database error\n"
"\t connDict -- A substitute connection dictionary\n"
"\t entities -- a subset of the entities in the model (all are used by default)\n"
"\t excludedEntities -- a subset of the entities in the model which shall not be used (all are used by default)\n"
"\t modelGroup -- A list of models to create a model group. (Allows you to use\n"
"\t models not in a framework. Model names must be absolute paths.)\n"
"\t ascii -- Convert all non-ASCII characters to their nearest ASCII equivalents.\n"
"\n"
"\tExample: eoutil dump Movies.eomodeld -source plist -dest database -schemaCreate tables primaryKeySupport foreignKeyConstraints < MovieData.plist\n"
"\t Creates the tables in the database, reads data in plist format from,\n"
"\t stdin stores the data in the database listed in the connection\n"
"\t dictionary of model, creates primary key support in the database, and\n"
"\t creates foreign key constraints corresponding to the relationship\n"
"\t definitions.\n"
"\n"
" eoutil convert \n"
"\tThis command converts the type mapping in a model for the data source specified\n"
"\tby the connection dictionary URL. The connection dictionary in the new model is\n"
"\tset to connectionDictionary.\n"
"\n"
"\t model -- must be the name of an eomodel or eomodeld file\n"
"\t adaptorName -- PostgreSQL, FlatFile, etc.\n"
"\t connectionDictionary -- string in property list format representing a\n"
"\t dictionary, specifying the database name for the\n"
"\t data source (required) and username and password (if\n"
"\t required by that data source).\n"
"\t outFileName -- the name of a directory to write the converted model\n"
"\n"
"\tExample: eoutil convert Movies.eomodeld PostgreSQL '{ databaseName = test; hostName = localhost; userName = postgres; password = postgres; }' M.eomodeld\n"
"\t Converts types in Movies.eomodeld file to PostgreSQL types and writes\n"
"\t the converted model to ./M.eomodel\n"
"\n"
" eoutil connect ( | ( ))\n"
"\tThis command attempts to connect to a data source using the adaptor named\n"
"\tadaptorName with connectionDictionary, or using the connection dictionary in\n"
"\tmodel. It returns an exit status of 0 if successful and 1 otherwise. This is\n"
"\tprimarily useful for scripts.\n"
"\n"
"\t model -- must be the name of an eomodel or eomodeld file\n"
"\t adaptorName -- PostgreSQL, FlatFile, etc.\n"
"\t connectionDictionary -- string in property list format representing a\n"
"\t dictionary, specifying the database name for the\n"
"\t data source (required) and username and password (if\n"
"\t required by that data source).\n"
"\n"
"\tExample: eoutil connect PostgreSQL '{ databaseName = test; hostName = localhost; userName = postgres; password = postgres; }'\n"
"\t Attempts to connect to a PostgreSQL database on host localhost.\n"
"\n"
" eoutil help\n"
"\tPrints this text.\n"
"\n";
else
usageString = "Command line utility to perform database and EOF oriented tasks.\n"
"Syntax: eoutil dump/connect/convert/help\n"
" eoutil dump [-source [sourcefile]] -dest [destfile] [-schemaCreate ] [-schemaDrop ] [-postInstall] [-force] [-connDict ] [-entities ] [-modelGroup ] [-ascii]\n"
" eoutil convert \n"
" eoutil connect ( | ( ))\n"
" eoutil help\n";
NSLog(@"%s", usageString);
return YES;
}
enum {
databaseOption = 1 << 0,
tablesOption = 1 << 1,
pkSupportOption = 1 << 2,
pkConstraintsOption = 1 << 3,
fkConstraintsOption = 1 << 4,
};
static void executeSQLStatements(EOModel *srcModel, NSArray *sqlStatements, BOOL force){
EODatabaseContext *aDatabaseContext;
EOEditingContext *anEC = [[EOEditingContext alloc] init];
aDatabaseContext =
[EODatabaseContext registeredDatabaseContextForModel: srcModel
editingContext: anEC];
[aDatabaseContext lock];
NS_DURING
{
EODatabaseChannel *aDatabaseChannel = [aDatabaseContext
availableChannel];
EOAdaptorChannel *anAdaptorChannel = [aDatabaseChannel
adaptorChannel];
NSEnumerator *anEnum;
EOSQLExpression *aStatement;
if (![anAdaptorChannel isOpen])
[anAdaptorChannel openChannel];
anEnum = [sqlStatements objectEnumerator];
while ((aStatement = [anEnum nextObject]))
{
NS_DURING
[anAdaptorChannel evaluateExpression: aStatement];
NS_HANDLER
if(!force)
break;
NS_ENDHANDLER;
}
[aDatabaseContext unlock];
[anEC release];
}
NS_HANDLER
{
[aDatabaseContext unlock];
[anEC release];
[localException raise];
}
NS_ENDHANDLER;
}
static BOOL
dump(NSArray *arguments)
{
int aCount = [arguments count], i = 0;
EOModel *srcModel;
NSString *sourceType = nil, *sourceFilename = nil;
NSString *destType = nil, *destFilename = nil;
int schemaCreateOptions = 0, schemaDropOptions = 0;
BOOL postInstall = NO;
BOOL force = NO;
NSDictionary *aConnectionDictionary = nil;
NSMutableArray *entityNameList = nil, *excludedEntityNameList = nil;
NSMutableArray *entitiesList = nil;
NSMutableArray *modelList = nil;
BOOL convertsNonASCII = NO;
NSMutableString *outputString = [NSMutableString string];
NSArray *initialStatements = nil;
NSArray *endingStatements = nil;
NSDictionary *dataDictionary = nil;
Class exprClass;
NSArray *postInstallSQLExpressions = nil;
// First, let's parse arguments
srcModel = [[EOModel alloc] initWithContentsOfFile: [[arguments objectAtIndex: i++]
stringByStandardizingPath]];
[srcModel autorelease];
while (i < aCount)
{
NSString *anArg = [arguments objectAtIndex: i++];
if ([anArg isEqualToString: @"-source"])
{
if (sourceType != nil)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-source'"];
if (i < aCount)
sourceType = [arguments objectAtIndex: i++];
else
[NSException raise: NSInvalidArgumentException
format: @"Missing argument(s) after '-source'"];
if (![sourceType isEqualToString: @"database"])
{
if ([sourceType isEqualToString: @"plist"])
{
if (i < aCount)
{
sourceFilename = [[arguments objectAtIndex: i++]
stringByStandardizingPath];
if ([sourceFilename hasPrefix: @"-"])
{
// We consider it's an option, not a filename
sourceFilename = nil;
i--;
}
}
}
else
[NSException raise: NSInvalidArgumentException
format: @"Illegal '-source' option: %@",
sourceType];
}
}
else if ([anArg isEqualToString: @"-dest"])
{
if (destType != nil)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-dest'"];
if (i < aCount)
destType = [arguments objectAtIndex: i++];
else
[NSException raise: NSInvalidArgumentException
format: @"Missing argument(s) after '-dest'"];
if (![destType isEqualToString: @"database"])
{
if ([destType isEqualToString: @"script"]
|| [destType isEqualToString: @"plist"])
{
if (i < aCount)
{
destFilename = [[arguments objectAtIndex: i++]
stringByStandardizingPath];
if ([destFilename hasPrefix: @"-"])
{
// We consider it's an option, not a filename
destFilename = nil;
i--;
}
}
}
else
[NSException raise: NSInvalidArgumentException
format: @"Illegal '-dest' option: %@", destType];
}
}
else if ([anArg isEqualToString: @"-schemaCreate"])
{
if (schemaCreateOptions != 0)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-schemaCreate'"];
while (i < aCount)
{
anArg = [arguments objectAtIndex: i++];
if ([anArg isEqualToString: @"database"])
schemaCreateOptions |= databaseOption;
else if ([anArg isEqualToString: @"tables"])
schemaCreateOptions |= tablesOption;
else if ([anArg isEqualToString: @"primaryKeySupport"])
schemaCreateOptions |= pkSupportOption;
else if ([anArg isEqualToString: @"primaryKeyConstraints"])
schemaCreateOptions |= pkConstraintsOption;
else if ([anArg isEqualToString: @"foreignKeyConstraints"])
schemaCreateOptions |= fkConstraintsOption;
else
{
if (![anArg hasPrefix:@"-"])
[NSException raise: NSInvalidArgumentException
format: @"Illegal '-schemaCreate' option: %@", anArg];
i--;
break;
}
}
if (schemaCreateOptions == 0)
[NSException raise: NSInvalidArgumentException
format: @"Missing argument(s) after '-schemaCreate'"];
}
else if ([anArg isEqualToString: @"-schemaDrop"])
{
if (schemaDropOptions != 0)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-schemaDrop'"];
while (i < aCount)
{
anArg = [arguments objectAtIndex: i++];
if ([anArg isEqualToString: @"database"])
schemaDropOptions |= databaseOption;
else if ([anArg isEqualToString: @"tables"])
schemaDropOptions |= tablesOption;
else if ([anArg isEqualToString: @"primaryKeySupport"])
schemaDropOptions |= pkSupportOption;
/* else if ([anArg isEqualToString: @"primaryKeyConstraints"])
schemaDropOptions |= pkConstraintsOption;
else if ([anArg isEqualToString: @"foreignKeyConstraints"])
schemaDropOptions |= fkConstraintsOption;*/
else
{
if (![anArg hasPrefix: @"-"])
[NSException raise: NSInvalidArgumentException
format: @"Illegal '-schemaDrop' option: %@",
anArg];
i--;
break;
}
}
if (schemaDropOptions == 0)
[NSException raise: NSInvalidArgumentException
format: @"Missing argument(s) after '-schemaDrop'"];
}
else if ([anArg isEqualToString: @"-postInstall"])
{
if (postInstall)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-postInstall'"];
postInstall = YES;
}
else if ([anArg isEqualToString: @"-force"])
{
if (force)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-force'"];
force = YES;
}
else if ([anArg isEqualToString: @"-ascii"])
{
if (convertsNonASCII)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-ascii'"];
convertsNonASCII = YES;
}
else if ([anArg isEqualToString: @"-connDict"])
{
if (aConnectionDictionary)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-connDict'"];
if (i < aCount)
{
aConnectionDictionary = [[arguments objectAtIndex: i++]
propertyList];
if (![aConnectionDictionary isKindOfClass: [NSDictionary class]])
[NSException raise: NSInvalidArgumentException
format: @"Invalid '-connDict' argument; must be a NSDictionary"];
}
else
[NSException raise: NSInvalidArgumentException
format: @"Missing argument after '-connDict'"];
}
else if ([anArg isEqualToString: @"-entities"])
{
if (entityNameList)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-entities'"];
entityNameList = [NSMutableArray array];
while (i < aCount)
{
anArg = [arguments objectAtIndex: i++];
if ([anArg hasPrefix: @"-"])
{
// We consider it's an option, not an entity name
i--;
break;
}
if ([entityNameList containsObject: anArg])
[NSException raise: NSInvalidArgumentException
format: @"Entity name argument '%@' occurs more than once", anArg];
[entityNameList addObject: anArg];
}
if ([entityNameList count] == 0)
[NSException raise: NSInvalidArgumentException
format: @"Missing argument(s) after '-entities'"];
}
else if ([anArg isEqualToString: @"-excludedEntities"])
{
if (excludedEntityNameList)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-excludedEntities'"];
excludedEntityNameList = [NSMutableArray array];
while (i < aCount)
{
anArg = [arguments objectAtIndex: i++];
if ([anArg hasPrefix: @"-"])
{
// We consider it's an option, not an entity name
i--;
break;
}
if ([excludedEntityNameList containsObject: anArg])
[NSException raise: NSInvalidArgumentException
format: @"Entity name argument '%@' occurs more than once", anArg];
[excludedEntityNameList addObject: anArg];
}
if ([excludedEntityNameList count] == 0)
[NSException raise: NSInvalidArgumentException
format: @"Missing argument(s) after '-excludedEntities'"];
}
else if ([anArg isEqualToString: @"-modelGroup"])
{
if (modelList)
[NSException raise: NSInvalidArgumentException
format: @"More than one occurence of parameter '-modelGroup'"];
modelList = [NSMutableArray array];
while (i < aCount)
{
anArg = [[arguments objectAtIndex: i++]
stringByStandardizingPath];
if ([anArg hasPrefix: @"-"])
{
// We consider it's an option, not a file name
i--;
break;
}
if ([modelList containsObject: anArg])
[NSException raise: NSInvalidArgumentException
format: @"Model file name argument '%@' occurs more than once", anArg];
if (![anArg isAbsolutePath])
anArg = [[[NSFileManager defaultManager]
currentDirectoryPath]
stringByAppendingPathComponent:anArg];
// [NSException raise:NSInvalidArgumentException format:@"Model file name argument '%@' is not absolute", anArg];
[modelList addObject: anArg];
}
if ([modelList count] == 0)
[NSException raise: NSInvalidArgumentException
format: @"Missing argument(s) after '-modelGroup'"];
}
else
// Else, ignore remaining args
break;
}
// Now check parameter consistency
if (!destType)
[NSException raise: NSInvalidArgumentException
format: @"Missing -dest [destfile] argument"];
if (sourceType == nil && schemaCreateOptions == 0 && schemaDropOptions == 0)
[NSException raise: NSInvalidArgumentException
format: @"Unknown operation"];
if ([destType isEqualToString: @"plist"]
&& (schemaDropOptions != 0 || schemaCreateOptions != 0))
[NSException raise: NSInvalidArgumentException
format: @"Can't declare plist as destination and use schema arguments"];
// Load models
{
EOModelGroup *defaultModelGroup = [EOModelGroup globalModelGroup];
[defaultModelGroup addModel: srcModel];
if (modelList)
{
// Load other models in same model group
NSEnumerator *anEnum = [modelList objectEnumerator];
NSString *aString;
while ((aString = [anEnum nextObject]))
{
(void)[defaultModelGroup addModelWithFile: aString];
}
}
[defaultModelGroup loadAllModelObjects];
[EOModelGroup setDefaultGroup: defaultModelGroup];
}
// Create entity list
if (entityNameList)
{
NSEnumerator *anEnum = [entityNameList objectEnumerator];
NSString *aString;
entitiesList = [NSMutableArray array];
while ((aString = [anEnum nextObject]))
{
if(![excludedEntityNameList containsObject:aString]){
EOEntity *anEntity = [[EOModelGroup defaultGroup]
entityNamed: aString];
if (anEntity == nil)
[NSException raise: NSInvalidArgumentException
format: @"Unknown entity '%@'", aString];
[entitiesList addObject: anEntity];
}
}
}
else
{
NSEnumerator *anEnum = [[srcModel entities] objectEnumerator];
EOEntity *anEntity;
entitiesList = [NSMutableArray array];
while ((anEntity = [anEnum nextObject])){
if(![excludedEntityNameList containsObject:[anEntity name]]){
[entitiesList addObject:anEntity];
}
}
}
if (aConnectionDictionary)
{
[srcModel setConnectionDictionary: aConnectionDictionary];
// Only for srcModel, not for additional models?
}
exprClass = [[EOAdaptor adaptorWithModel: srcModel] expressionClass];
if (schemaDropOptions != 0 || schemaCreateOptions != 0)
{
// We split SQL execution in two parts: first we drop elements, and create tables,
// and in a second phase we create constraints: this allows us to fill in database with data
// and then we set the database constraints.
NSDictionary *aDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
((schemaDropOptions & databaseOption) ? @"YES":@"NO"), EODropDatabaseKey,
((schemaDropOptions & tablesOption) ? @"YES":@"NO"), EODropTablesKey,
((schemaDropOptions & pkSupportOption) ? @"YES":@"NO"), EODropPrimaryKeySupportKey,
// ((schemaDropOptions & pkConstraintsOption) ? @"YES":@"NO"), EOPrimaryKeyConstraintsKey,
// ((schemaDropOptions & fkConstraintsOption) ? @"YES":@"NO"), EOForeignKeyConstraintsKey,
((schemaCreateOptions & databaseOption) ? @"YES":@"NO"), EOCreateDatabaseKey,
((schemaCreateOptions & tablesOption) ? @"YES":@"NO"), EOCreateTablesKey,
@"NO", EOCreatePrimaryKeySupportKey,
@"NO", EOPrimaryKeyConstraintsKey,
@"NO", EOForeignKeyConstraintsKey,
nil];
NSEnumerator *anEnum;
EOSQLExpression *aStatement;
if([aDictionary count] > 0)
initialStatements = [exprClass schemaCreationStatementsForEntities: entitiesList
options: aDictionary];
aDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
@"NO", EODropDatabaseKey,
@"NO", EODropTablesKey,
@"NO", EODropPrimaryKeySupportKey,
// @"NO", EOPrimaryKeyConstraintsKey,
// @"NO", EOForeignKeyConstraintsKey,
@"NO", EOCreateDatabaseKey,
@"NO", EOCreateTablesKey,
((schemaCreateOptions & pkSupportOption) ? @"YES":@"NO"), EOCreatePrimaryKeySupportKey,
((schemaCreateOptions & pkConstraintsOption) ? @"YES":@"NO"), EOPrimaryKeyConstraintsKey,
((schemaCreateOptions & fkConstraintsOption) ? @"YES":@"NO"), EOForeignKeyConstraintsKey,
nil];
if([aDictionary count] > 0)
endingStatements = [exprClass schemaCreationStatementsForEntities: entitiesList
options: aDictionary];
if(initialStatements){
if ([destType isEqualToString: @"database"])
{
executeSQLStatements(srcModel, initialStatements, force);
}
else
{
// script
anEnum = [initialStatements objectEnumerator];
while ((aStatement = [anEnum nextObject]))
[exprClass appendExpression: aStatement toScript: outputString];
}
}
}
if (sourceType)
{
// Dump
if ([sourceType isEqualToString: @"plist"])
{
if (sourceFilename)
{
dataDictionary = [[NSDictionary alloc]
initWithContentsOfFile: sourceFilename];
NSCAssert1(dataDictionary != nil,
@"Unable to read plist from file '%@'",
sourceFilename);
}
#ifndef GNUSTEP
else
{
#warning TODO: test this
NSString *errorString = nil;
NSData *readData = [[NSFileHandle fileHandleWithStandardInput]
readDataToEndOfFile];
dataDictionary = [NSPropertyListSerialization
propertyListFromData: readData
mutabilityOption: NSPropertyListImmutable
format: NULL
errorDescription: &errorString];
if (errorString != nil)
[NSException raise: NSInvalidArgumentException
format: @"Unable to load plist from stdin: %@", errorString];
if (![dataDictionary isKindOfClass:[NSDictionary class]])
[NSException raise: NSInvalidArgumentException
format: @"Invalid plist format from stdin: should be a dictionary"];
[dataDictionary retain];
}
#endif
}
else
{
// database
// We get data from database
NSEnumerator *anEnum = [entitiesList objectEnumerator];
EOEntity *anEntity;
EOEditingContext *aContext = [[EOEditingContext alloc] init];
dataDictionary = [[NSMutableDictionary alloc] init];
while ((anEntity = [anEnum nextObject]))
{
// We don't fetch abstract entities
if (![anEntity isAbstractEntity])
{
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
NSArray *attributes = [anEntity attributes];
NSEnumerator *anAttrEnum = [attributes
objectEnumerator];
EOAttribute *anAttribute;
NSMutableArray *attributeNames = [NSMutableArray
array];
NSArray *rawRows;
NSMutableArray *rows;
EOFetchSpecification *fetchSpec;
NSDictionary *aRawRow;
BOOL usesPlistTypesOnly = [destType isEqualToString: @"plist"];
while ((anAttribute = [anAttrEnum nextObject]))
{
// We do fetch flattened or derived attributes (but we will not write them)
[attributeNames addObject: [anAttribute name]];
}
fetchSpec = [EOFetchSpecification fetchSpecificationWithEntityName: [anEntity name]
qualifier: nil
sortOrderings: nil];
[fetchSpec setFetchesRawRows: YES];
rows = [NSMutableArray array];
// FIXME Problem
// If a raw row contains data which does not respect entity's constraints
// (e.g. doesn't allow NULL attribute), then an exception is raised,
// at least on WO4.5
rawRows = [aContext objectsWithFetchSpecification: fetchSpec];
anAttrEnum = [rawRows objectEnumerator];
while ((aRawRow = [anAttrEnum nextObject]))
{
NSMutableArray *values = [NSMutableArray array];
NSEnumerator *anEnum3 = [attributeNames
objectEnumerator];
NSString *aName;
while ((aName = [anEnum3 nextObject]))
{
id aValue = [aRawRow objectForKey: aName];
if ([aValue isEqual: [EONull null]])
[values addObject: @"__NULL__"];
else
{
if ([aValue isKindOfClass: [NSString class]])
{
if (convertsNonASCII)
[values addObject: [aValue
lossyASCIIString]];
else
[values addObject: aValue];
}
else if(usesPlistTypesOnly){
if ([aValue isKindOfClass:[NSCalendarDate class]]){
// Format is ISO's + milliseconds
[values addObject:[aValue descriptionWithCalendarFormat:@"%Y-%m-%d %H:%M:%S.%F %z" /*local:*/]];
}
else if ([aValue isKindOfClass:[NSData class]])
[values addObject:[aValue description]];
/* else if ([aValue isKindOfClass:[NSDecimalNumber class]])
[values addObject:[aValue stringValue]];*/
else if ([aValue isKindOfClass:[NSNumber class]])
[values addObject:[aValue stringValue]];
else
// FIXME No support for custom data types?
[values addObject: aValue];
}
else
[values addObject: aValue];
}
}
[rows addObject: values];
}
[(NSMutableDictionary *)dataDictionary
setObject: [NSDictionary dictionaryWithObjectsAndKeys: attributeNames, @"attributeNames", rows, @"rows", nil]
forKey: [anEntity name]];
[arp release];
}
}
[aContext release];
}
}
// Else, no sourcefile => schemaDrop and/or schemaCreate
if (postInstall)
{
// Look for a key "AdaptorName"PostInstallExpressions which
// which have an array of SQL expressions
postInstallSQLExpressions = [[srcModel userInfo] objectForKey:[[[EOAdaptor adaptorWithModel: srcModel] name] stringByAppendingString:@"PostInstallExpressions"]];
}
if ([destType isEqualToString: @"plist"])
{
// Write data as plist
NSCAssert(dataDictionary != nil, @"No data to write in plist?!?");
if (destFilename)
NSCAssert1([[dataDictionary description] writeToFile:destFilename atomically:NO], @"Unable to write plist to '%@'", destFilename);
else
[(NSFileHandle *)[NSFileHandle fileHandleWithStandardOutput] writeData:[[dataDictionary description] dataUsingEncoding:NSUTF8StringEncoding]];
}
else if ([destType isEqualToString: @"script"])
{
// Write schemaDrop and/or schemaCreate script, or data creation SQL script
if (dataDictionary)
{
// Generate SQL to create data from dataDictionary
NSEnumerator *entityNameEnum = [dataDictionary keyEnumerator];
NSString *anEntityName;
#warning PROBLEM: we cannot create the statement telling to defer constraints!
// In the script, we miss:
// BEGIN;
// SET CONSTRAINTS ALL DEFERRED;
// ...
// COMMIT
while ((anEntityName = [entityNameEnum nextObject]))
{
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
EOEntity *anEntity = [[EOModelGroup defaultGroup] entityNamed: anEntityName];
NSEnumerator *aRowEnum = [[[dataDictionary objectForKey: anEntityName] objectForKey: @"rows"] objectEnumerator];
NSMutableDictionary *aDict = [NSMutableDictionary dictionary];
NSArray *aRow, *attrNames = [[dataDictionary objectForKey: anEntityName] objectForKey: @"attributeNames"];
while ((aRow = [aRowEnum nextObject]))
{
NSEnumerator *anAttributeEnum = [attrNames objectEnumerator];
NSEnumerator *aValueEnum = [aRow objectEnumerator];
NSString *anAttrName;
while ((anAttrName = [anAttributeEnum nextObject]))
{
id aValue = [aValueEnum nextObject];
if (![aValue isKindOfClass: [NSString class]]
|| ![aValue isEqualToString: @"__NULL__"])
[aDict setObject: aValue forKey: anAttrName];
}
[exprClass appendExpression:
[exprClass insertStatementForRow: aDict
entity: anEntity]
toScript: outputString];
[aDict removeAllObjects];
}
[arp release];
}
}
if (postInstallSQLExpressions)
{
[outputString appendString:[postInstallSQLExpressions componentsJoinedByString:@"\n"]];
}
if (destFilename)
{
if (![outputString writeToFile: destFilename atomically: NO])
[NSException raise: NSInvalidArgumentException
format: @"Unable to save file '%@'", destFilename];
}
else
[(NSFileHandle *)[NSFileHandle fileHandleWithStandardOutput]
writeData: [outputString dataUsingEncoding:
NSUTF8StringEncoding]];
}
else
{
// database
// Execute statements one after the other?
if (dataDictionary)
{
NSEnumerator *entityEnum = [entitiesList objectEnumerator];
EOEntity *anEntity;
EOEditingContext *anEC = [[EOEditingContext alloc] init];
[anEC setUndoManager:nil];
while ((anEntity = [entityEnum nextObject]))
{
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
NSDictionary *aDictionary = [dataDictionary objectForKey: [anEntity name]];
NSArray *attributeNames = [aDictionary objectForKey: @"attributeNames"];
NSEnumerator *anEnum = [attributeNames objectEnumerator];
NSString *aName;
NSMutableSet *newClassProperties = [NSMutableSet set];
EORelationship *aRelationship;
if ([anEntity isReadOnly])
[anEntity setReadOnly: NO];
if (![[anEntity className] isEqualToString: @"EOGenericRecord"])
[anEntity setClassName: @"EOGenericRecord"];
while ((aName = [anEnum nextObject]))
{
EOAttribute *anAttribute = [anEntity attributeNamed: aName];
NSCAssert1(anAttribute != nil,
@"'%@' is not a valid attribute name", aName);
if (![anAttribute isReadOnly] && ![anAttribute isDerived])
[newClassProperties addObject: anAttribute];
}
NSCAssert1([anEntity setClassProperties:[newClassProperties allObjects]], @"Unable to set new class properties from %@", newClassProperties);
anEnum = [[NSArray arrayWithArray: [anEntity relationships]]
objectEnumerator];
while ((aRelationship = [anEnum nextObject]))
{
[anEntity removeRelationship: aRelationship];
}
[arp release];
}
entityEnum = [entitiesList objectEnumerator];
while ((anEntity = [entityEnum nextObject]))
{
NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init];
NSDictionary *aDictionary = [dataDictionary objectForKey: [anEntity name]];
NSEnumerator *rowEnum = [[aDictionary objectForKey: @"rows"] objectEnumerator];
NSArray *aRow;
NSArray *attributeNames = [aDictionary objectForKey: @"attributeNames"];
NSEnumerator *attrNameEnum = [attributeNames objectEnumerator];
NSString *anAttrName;
NSMutableArray *filteredAttributeNames = [NSMutableArray array];
NSArray *classPropertyNames = [anEntity classPropertyNames];
// First, we filter out given attribute names to retain only
// the ones that have a matching class property
// (we already cleaned up entities attributes/relationships)
while ((anAttrName = [attrNameEnum nextObject])){
if([classPropertyNames containsObject:anAttrName])
[filteredAttributeNames addObject:anAttrName];
}
while ((aRow = [rowEnum nextObject]))
{
NSAutoreleasePool *arp2 = [[NSAutoreleasePool alloc] init];
EOGenericRecord *aRecord = [anEC createAndInsertInstanceOfEntityNamed: [anEntity name]];
attrNameEnum = [filteredAttributeNames objectEnumerator];
while ((anAttrName = [attrNameEnum nextObject]))
{
NSString *aStringValue;
id aValue = nil;
i = [attributeNames indexOfObject:anAttrName];
aStringValue = [aRow objectAtIndex: i];
if ([aStringValue isEqualToString: @"__NULL__"])
aValue = [EONull null];
else
{
EOAttribute *anAttribute = [anEntity attributeNamed:
anAttrName];
NSString *internalType = [anAttribute
valueClassName];
if ([internalType isEqualToString: @"NSString"])
{
aValue = aStringValue;
}
else if ([internalType isEqualToString: @"NSNumber"])
{
#if 0
if (![anAttribute valueType]
|| [@"cil" rangeOfString:
[anAttribute valueType]].length != 0)
aValue = [NSNumber numberWithInt: [aStringValue
intValue]];
else if([@"fd" rangeOfString:
[anAttribute valueType]].length != 0)
aValue = [NSNumber numberWithDouble:
[aStringValue
doubleValue]];
else
[NSException raise:NSInvalidArgumentException format:@"Unknown valueType '%@' for attribute %@", [anAttribute valueType], anAttribute];
#else
aValue = [NSNumber numberWithDouble:
[aStringValue doubleValue]];
#endif
}
else if ([internalType isEqualToString:
@"NSDecimalNumber"])
{
aValue = [NSDecimalNumber decimalNumberWithString: aStringValue];
NSCAssert1(aValue != nil, @"Invalid decimal number representation: %@", aStringValue);
}
else if ([internalType isEqualToString:@"NSCalendarDate"])
{
// Format is Apple's eoutil format
aValue = [[NSCalendarDate alloc] initWithString: aStringValue calendarFormat: @"%b %d %Y %H:%M" /*locale:*/];
if(!aValue)
// Format is ISO's
aValue = [[NSCalendarDate alloc] initWithString: aStringValue calendarFormat: @"%Y-%m-%d %H:%M:%S %z" /*locale:*/];
if(!aValue)
// Format is ISO's + milliseconds
aValue = [[NSCalendarDate alloc] initWithString:aStringValue calendarFormat:@"%Y-%m-%d %H:%M:%S.%F %z" /*locale:*/];
NSCAssert1(aValue != nil, @"Unable to parse date from '%@'", aStringValue);
[aValue autorelease];
}
else if ([internalType isEqualToString: @"NSData"])
{
if ([aStringValue isEqualToString: @""])
aValue = [NSData data];
else
{
aValue = [aStringValue propertyList];
NSCAssert1([aValue isKindOfClass:
[NSData class]],
@"Invalid data: %@", aStringValue);
}
}
else
[NSException raise:NSInvalidArgumentException format: @"Unknown attribute (%@) valueClassName: %@", anAttribute, internalType];
}
[aRecord takeStoredValue: aValue forKey: anAttrName];
}
NS_DURING
{
[anEC saveChanges];
}
NS_HANDLER
{
if(!force){
[anEC release];
[arp2 release];
[arp release];
[localException raise];
}
else{
NSLog(@"%@", localException);
[anEC revert];
}
}
NS_ENDHANDLER;
[arp2 release];
}
[arp release];
}
[anEC release];
}
if(endingStatements)
executeSQLStatements(srcModel, endingStatements, force);
if (postInstallSQLExpressions)
{
EODatabaseContext *databaseContext;
EOEditingContext *anEC = [[EOEditingContext alloc] init];
databaseContext =
[EODatabaseContext registeredDatabaseContextForModel: srcModel
editingContext: anEC];
[databaseContext lock];
NS_DURING
{
EODatabaseChannel *databaseChannel = [databaseContext
availableChannel];
EOAdaptorChannel *adaptorChannel = [databaseChannel
adaptorChannel];
NSString *aString;
NSEnumerator *anEnum;
if (![adaptorChannel isOpen])
[adaptorChannel openChannel];
anEnum = [postInstallSQLExpressions objectEnumerator];
while ((aString = [anEnum nextObject]))
{
NS_DURING
EOSQLExpression *aStatement = [exprClass expressionForString:aString];
[adaptorChannel evaluateExpression: aStatement];
NS_HANDLER
if(!force)
break;
NS_ENDHANDLER;
}
[databaseContext unlock];
[anEC release];
}
NS_HANDLER
{
[databaseContext unlock];
[anEC release];
[localException raise];
}
NS_ENDHANDLER;
}
}
return YES;
}
static BOOL
convert(NSArray *arguments)
{
EOModel *aModel;
EOAdaptor *newAdaptor;
NSDictionary *newConnectionDictionary;
NSString *newFilename;
if ([arguments count] < 4)
return NO;
aModel = [[EOModel alloc] initWithContentsOfFile:
[[arguments objectAtIndex: 0]
stringByStandardizingPath]];
newAdaptor = [EOAdaptor adaptorWithName: [arguments objectAtIndex: 1]];
newConnectionDictionary = [[arguments objectAtIndex: 2] propertyList];
newFilename = [[arguments objectAtIndex: 3] stringByStandardizingPath];
[aModel setAdaptorName: [newAdaptor name]];
[aModel setConnectionDictionary: newConnectionDictionary];
[[newAdaptor class] assignExternalInfoForEntireModel: aModel];
[aModel writeToFile: newFilename];
[aModel release];
NSLog(@"Converted %@ to %@", [arguments objectAtIndex: 0], newFilename);
return YES;
}
static BOOL
dbConnect(NSArray *arguments)
{
EOAdaptor *anAdaptor = nil;
NSDictionary *aConnectionDictionary = nil;
EOModel *aModel;
switch ([arguments count])
{
case 1:
aModel = [[EOModel alloc] initWithContentsOfFile:
[[arguments objectAtIndex: 0]
stringByStandardizingPath]];
anAdaptor = [EOAdaptor adaptorWithModel: aModel];
aConnectionDictionary = [aModel connectionDictionary];
[aModel release];
default:
if (anAdaptor == nil)
{
anAdaptor = [EOAdaptor adaptorWithName: [arguments objectAtIndex: 0]];
aConnectionDictionary = [[arguments objectAtIndex: 1] propertyList];
[anAdaptor setConnectionDictionary: aConnectionDictionary];
}
[anAdaptor assertConnectionDictionaryIsValid];
}
return YES;
}
int
main(int arcg, char *argv[], char **envp)
{
NSAutoreleasePool *localAP = [[NSAutoreleasePool alloc] init];
BOOL noUsage = NO;
NSArray *arguments = [[NSProcessInfo processInfo] arguments];
int argc = [arguments count];
BOOL hasError = NO;
if (argc >= 2)
{
NSString *command = [arguments objectAtIndex: 1];
if (argc > 2)
arguments = [arguments subarrayWithRange: NSMakeRange(2, argc - 2)];
else
arguments = [NSArray array];
NS_DURING
{
if ([command isEqualToString: @"dump"])
noUsage = dump(arguments);
else if ([command isEqualToString: @"convert"])
noUsage = convert(arguments);
else if ([command isEqualToString: @"connect"])
noUsage = dbConnect(arguments);
else if ([command isEqualToString: @"help"])
noUsage = usage(YES);
}
NS_HANDLER
{
noUsage = ![[localException name]
isEqualToString: NSInvalidArgumentException];
hasError = YES;
NSLog(@"%@", localException);
}
NS_ENDHANDLER;
}
if (!noUsage)
(void)usage(NO);
[localAP release];
return hasError;
}
gnustep-dl2-0.12.0/Tools/NSDictionary+GSDoc.h 0000664 0001750 0001750 00000002634 14632325605 017607 0 ustar yavor yavor /* -*-objc-*-
NSDictionary+GSDoc.h
Copyright (C) 2000-2002,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
// $Id$
#ifndef __NSDictionary_GSDoc_h__
#define __NSDictionary_GSDoc_h__
#include
@interface NSDictionary (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr;
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
idPtr: (int *)xmlIdPtr;
@end
#endif /* __NSDictionary_GSDoc_h__ */
gnustep-dl2-0.12.0/Tools/EOAttribute+GSDoc.m 0000664 0001750 0001750 00000010106 14636026724 017432 0 ustar yavor yavor /*
EOAttribute+GSDoc.m
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#ifdef GNUSTEP
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#endif
#include
#include
#include
#include "NSArray+GSDoc.h"
#include "NSDictionary+GSDoc.h"
#include "EOAttribute+GSDoc.h"
/*
NSString* calendarFormat;
NSTimeZone* clientTimeZone;
NSTimeZone* serverTimeZone;
NSString* insertFormat;
NSString* selectFormat;
NSString* updateFormat;
NSMutableArray* definitionArray; // These variables are meaningful only
EOAttribute* realAttribute; // if the attribute is flattened
*/
@implementation EOAttribute (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr
{
return [self gsdocContentWithTagName: @"EOAttribute"
idPtr: xmlIdPtr];
}
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
idPtr: (int *)xmlIdPtr
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *content = [NSString string];
NSLog(@"Start: %@: %@ tagName=%@", [self class], [self name], tagName);
if ([tagName isEqual: @"EOAttributeRef"])
{
content = [content stringByAppendingFormat:
@"\n",
[self name],
(xmlIdPtr ? [NSString stringWithFormat:
@" debugId=\"%d\"",
(*xmlIdPtr)++] : @"")];
}
else
{
content = [content stringByAppendingFormat:
@"<%@%@%@%@%@%@%@%@%@%@%@>\n",
tagName,
([self columnName]
? [NSString stringWithFormat: @" columnName=\"%@\"",
[self columnName]] : @""),
([self definition]
? [NSString stringWithFormat: @" definition=\"%@\"",
[self definition]] : @""),
([self externalType]
? [NSString stringWithFormat: @" externalType=\"%@\"",
[self externalType]] : @""),
([self name]
? [NSString stringWithFormat: @" name=\"%@\"",
[self name]] : @""),
([self valueClassName]
? [NSString stringWithFormat:
@" valueClassName=\"%@\"",
[self valueClassName]] : @""),
([self valueType]
? [NSString stringWithFormat: @" valueType=\"%@\"",
[self valueType]] : @""),
([[self entity] name]
? [NSString stringWithFormat: @" entityName=\"%@\"",
[[self entity] name]] : @""),
([self isReadOnly] ? @" isReadOnly=\"YES\"" : @""),
([self isDerived] ? @" isDerived=\"YES\"" : @""),
([self isFlattened] ? @" isFlattened=\"YES\"" : @"")];
if ([[self userInfo] count])
content = [content stringByAppendingString:
[[self userInfo]
gsdocContentWithTagName: @"EOUserDictionary"
idPtr: xmlIdPtr]];
if ([self docComment])
content = [content stringByAppendingFormat: @"%@ \n",
[self docComment]];
content = [content stringByAppendingFormat: @"%@>\n",
tagName];
}
NSLog(@"Stop: %@: %@", [self class], [self name]);
RETAIN(content);
DESTROY(arp);
return AUTORELEASE(content);
}
@end
gnustep-dl2-0.12.0/Tools/Makefile.postamble 0000664 0001750 0001750 00000003447 14632325605 017565 0 ustar yavor yavor #
# Makefile.postamble
#
# Copyright (C) 1997,2002,2005 Free Software Foundation, Inc.
#
# Written by: Scott Christley
#
# This file is part of the GNUstep Database Library.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# Makefile.postamble
#
# Project specific makefile rules
#
# Uncomment the targets you want.
# The double colons (::) are important, do not make them single colons
# otherwise the normal makefile rules will not be performed.
#
# Things to do before compiling
before-all::
# Things to do after compiling
# after-all::
# Things to do before installing
# before-install::
# Things to do after installing
# after-install::
# Things to do before uninstalling
# before-uninstall::
# Things to do after uninstalling
# after-uninstall::
# Things to do before cleaning
# before-clean::
# Things to do after cleaning
# after-clean::
# Things to do before distcleaning
# before-distclean::
# Things to do after distcleaning
# after-distclean::
# Things to do before checking
# before-check::
# Things to do after checking
# after-check:
gnustep-dl2-0.12.0/Tools/EOAttribute+GSDoc.h 0000664 0001750 0001750 00000002665 14632325605 017434 0 ustar yavor yavor /* -*-objc-*-
EOAttribute+GSDoc.h
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
// $Id$
#ifndef __EOAttribute_GSDoc_h__
#define __EOAttribute_GSDoc_h__
#include
@interface EOAttribute (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr;
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
idPtr: (int *)xmlIdPtr;
@end
#endif /* __EOAttribute_GSDoc_h__ */
gnustep-dl2-0.12.0/Tools/EORelationship+GSDoc.h 0000664 0001750 0001750 00000002645 14632325605 020130 0 ustar yavor yavor /* -*-objc-*-
EORelationship+GSDoc.h
Copyright (C) 2000-2002,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
// $Id$
#ifndef __EORelationship_GSDoc_h__
#define __EORelationship_GSDoc_h__
#include
@interface EORelationship (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr;
- (NSString *)gsdocContentWithTagName: (NSString *)tagName
idPtr: (int *)xmlIdPtr;
@end
#endif /* __EORelationship_GSDoc_h__ */
gnustep-dl2-0.12.0/Tools/EOModel+GSDoc.h 0000664 0001750 0001750 00000002630 14632325605 016521 0 ustar yavor yavor /* -*-objc-*-
EOModel+GSDoc.h
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
// $Id$
#ifndef __EOModel_GSDoc_h__
#define __EOModel_GSDoc_h__
#include
@interface EOModel (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr;
- (NSString *)gsdocContentSplittedByEntities: (NSDictionary **)entitiesPtr
idPtr: (int *)xmlIdPtr;
@end
#endif /* __EOModel_GSDoc_h__ */
gnustep-dl2-0.12.0/Tools/EOEntity+GSDoc.m 0000664 0001750 0001750 00000010273 14636026724 016750 0 ustar yavor yavor /*
EOEntity+GSDoc.m
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Manuel Guesdon
Date: August 2000
$Revision$
$Date$
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#ifdef GNUSTEP
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#endif
#include
#include
#include "NSArray+GSDoc.h"
#include "NSDictionary+GSDoc.h"
#include "EOModel+GSDoc.h"
#include "EOEntity+GSDoc.h"
/*
NSString* externalQuery;
NSArray* attributesNamesUsedForInsert;
EOQualifier* qualifier;
NSArray* attributesUsedForInsert; // cache from classProperties
NSArray* attributesUsedForFetch; // cache from classProperties
NSArray* relationsUsedForFetch; // cache from classProperties
*/
@implementation EOEntity (GSDoc)
- (NSString *)gsdocContentWithIdPtr: (int *)xmlIdPtr
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *content = [NSString string];
NSLog(@"Start: %@: %@", [self class], [self name]);
content = [content stringByAppendingFormat: @"\n",
(xmlIdPtr ? [NSString stringWithFormat:
@" debugId=\"%d\"",
(*xmlIdPtr)++] : @""),
([self name]
? [NSString stringWithFormat: @" name=\"%@\"",
[self name]] : @""),
([self externalName]
? [NSString stringWithFormat: @" externalName=\"%@\"",
[self externalName]] : @""),
([self className]
? [NSString stringWithFormat: @" className=\"%@\"",
[self className]] : @""),
([[self model] name]
? [NSString stringWithFormat: @" modelName=\"%@\"",
[[self model] name]] : @""),
([self isReadOnly] ? @"isReadOnly=\"YES\"" : @"")];
if ([self attributes])
content = [content stringByAppendingString: [[self attributes]
gsdocContentWithTagName: nil
idPtr: xmlIdPtr]];
if ([self attributesUsedForLocking])
content = [content stringByAppendingString:
[[self attributesUsedForLocking]
gsdocContentWithTagName:
@"EOAttributesUsedForLocking"
elementsTagName: @"EOAttributeRef"
idPtr: xmlIdPtr]];
if ([self classProperties])
content = [content stringByAppendingString:
[[self classProperties]
gsdocContentWithTagName: @"EOClassProperties"
elementsTagName: @"EOAttributeRef"
idPtr: xmlIdPtr]];
if ([self primaryKeyAttributes])
content = [content stringByAppendingString:
[[self primaryKeyAttributes]
gsdocContentWithTagName:
@"EOPrimaryKeyAttributes"
elementsTagName: @"EOAttributeRef"
idPtr: xmlIdPtr]];
if ([self relationships])
content = [content stringByAppendingString: [[self relationships]
gsdocContentWithTagName: nil
idPtr: xmlIdPtr]];
if ([[self userInfo] count])
content = [content stringByAppendingString:
[[self userInfo]
gsdocContentWithTagName: @"EOUserDictionary"
idPtr: xmlIdPtr]];
if ([self docComment])
content = [content stringByAppendingFormat: @"%@ \n",
[self docComment]];
content = [content stringByAppendingString: @" \n"];
NSLog(@"Stop: %@: %@", [self class], [self name]);
RETAIN(content);
DESTROY(arp);
return AUTORELEASE(content);
}
@end
gnustep-dl2-0.12.0/TODO 0000664 0001750 0001750 00000001353 14636002701 013513 0 ustar yavor yavor GDL2Palette is currently broken, please send patches
EOControl:
Implement & Test: EOControl/EOMultiReaderLocks
Implement & Test: EOControl/EOEvent(Center)
Test: EOSharedEditingContext
Test: validateTakeValue:forKeyPath: (does the method propagate or is it forwarded down to last component?)
EOAccess:
Implement databaseFailedToFetchObject mechanism. (EODatabaseContextDelegation) Cf Developper's guide p 121
Implement & Test: EOAccesss/EOSchemaSynchronization
Test: EOAccess/EOGenericRecord category
Implement & Test: to-one PK to Foreign Key support (Not implemented by WO but it's really cool)
Adaptors:
Documentation:
API Documentation
Tutorials: See Trading example of a Framework usable for EOInterface and GSWeb
Examples:
gnustep-dl2-0.12.0/Examples/ 0000775 0001750 0001750 00000000000 14754345051 014610 5 ustar yavor yavor gnustep-dl2-0.12.0/Examples/example.GNUmakefile 0000664 0001750 0001750 00000000340 14632325605 020307 0 ustar yavor yavor include $(GNUSTEP_MAKEFILES)/common.make
include $(GNUSTEP_MAKEFILES)/Auxiliary/gdl2.make
TOOL_NAME=eoexample
eoexample_OBJC_FILES=eoexample.m
eoexample_RESOURCE_FILES=library.eomodel
include $(GNUSTEP_MAKEFILES)/tool.make
gnustep-dl2-0.12.0/Examples/GNUmakefile 0000664 0001750 0001750 00000001116 14754345005 016660 0 ustar yavor yavor include ../common.make
include $(GNUSTEP_MAKEFILES)/common.make
include $(GNUSTEP_MAKEFILES)/Auxiliary/gdl2.make
SUBPROJECTS = Trading
ADDITIONAL_NATIVE_LIBS=EOAccess EOControl
# This is strictly for integration into the gdl2 build system
# If you are basing a gdl2 application off of these examples
# you won't need the following line in your GNUmakefiles.
ADDITIONAL_NATIVE_LIB_DIRS=../EOAccess ../EOControl
include GNUmakefile.eoexample
include GNUmakefile.connection
include GNUmakefile.eoexample2
include $(GNUSTEP_MAKEFILES)/aggregate.make
include $(GNUSTEP_MAKEFILES)/tool.make
gnustep-dl2-0.12.0/Examples/eoexample.m 0000664 0001750 0001750 00000003103 14754345005 016741 0 ustar yavor yavor #include
#include
#include
int
main(int arcg, char *argv[], char **envp)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
EOModelGroup *group = [EOModelGroup defaultGroup];
EOModel *model;
EOAdaptor *adaptor;
EOAdaptorContext *context;
EOAdaptorChannel *channel;
EOEditingContext *ec;
EODatabaseDataSource *authorsDS;
NSArray *authors;
id author;
model = [group modelNamed:@"library"];
/* Tools don't have resources so we have to add the model manually */
if (!model)
{
NSString *path = @"./library.eomodel";
model = [[EOModel alloc] initWithContentsOfFile: path];
[group addModel:model];
[model release];
}
adaptor = [EOAdaptor adaptorWithModel:model];
context = [adaptor createAdaptorContext];
channel = [context createAdaptorChannel];
ec = [[EOEditingContext alloc] init];
authorsDS
= [[EODatabaseDataSource alloc] initWithEditingContext: ec
entityName:@"authors"];
[channel openChannel];
/* Create a new author object */
author = [authorsDS createObject];
[author takeValue:@"Anonymous" forKey:@"name"];
[authorsDS insertObject:author];
[ec saveChanges];
/* Fetch the newly inserted object from the database */
authors = [authorsDS fetchObjects];
NSLog(@"%@", authors);
/* Update the authors name */
[[authors objectAtIndex:0]
takeValue:@"John Doe" forKey:@"name"];
[ec saveChanges];
NSLog(@"%@", [authorsDS fetchObjects]);
[channel closeChannel];
[pool release];
return 0;
}
gnustep-dl2-0.12.0/Examples/eoexample2.m 0000664 0001750 0001750 00000004115 14632325605 017026 0 ustar yavor yavor #include
#include
#include
int
main(int arcg, char *argv[], char **envp)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
EOModelGroup *group = [EOModelGroup defaultGroup];
EOModel *model;
EOAdaptor *adaptor;
EOAdaptorContext *context;
EOAdaptorChannel *channel;
EOEditingContext *ec;
EODatabaseDataSource *authorsDS;
EODataSource *booksDS;
id author;
id book;
model = [group modelNamed:@"library"];
/* Tools do not have resources so we add the model manually. */
if (!model)
{
NSString *path = @"./library.eomodel";
model = [[EOModel alloc] initWithContentsOfFile: path];
[group addModel:model];
[model release];
}
adaptor = [EOAdaptor adaptorWithModel:model];
context = [adaptor createAdaptorContext];
channel = [context createAdaptorChannel];
ec = [[EOEditingContext alloc] init];
authorsDS
= [[EODatabaseDataSource alloc] initWithEditingContext: ec
entityName:@"authors"];
[channel openChannel];
author = [authorsDS createObject];
[author takeValue:@"Richard Brautigan" forKey:@"name"];
[authorsDS insertObject:author];
booksDS = [authorsDS dataSourceQualifiedByKey:@"toBooks"];
[booksDS qualifyWithRelationshipKey:@"toBooks" ofObject:author];
book = [booksDS createObject];
[book takeValue:@"The Hawkline Monster" forKey:@"title"];
[booksDS insertObject:book];
book = [booksDS createObject];
[book takeValue:@"Trout Fishing in America" forKey:@"title"];
[booksDS insertObject:book];
[ec saveChanges];
/* log the to many relationship from author to books */
NSLog(@"%@ %@",
[author valueForKey:@"name"],
[author valueForKeyPath:@"toBooks.title"]);
/* log the to one relationship from book to author */
NSLog(@"%@", [book valueForKeyPath:@"toAuthor.name"]);
/* traverse to one through the to many through key paths
logging the author once for each book. */
NSLog(@"%@", [author valueForKeyPath:@"toBooks.toAuthor.name"]);
[channel closeChannel];
[pool release];
return 0;
}
gnustep-dl2-0.12.0/Examples/library.eomodel 0000664 0001750 0001750 00000003256 14754345005 017627 0 ustar yavor yavor {
EOModelVersion = 2;
adaptorName = SQLite3;
connectionDictionary = {
databasePath = "/tmp/example.db";
};
entities = (
{
attributes = (
{
columnName = authorID;
externalType = integer;
name = authorID;
valueClassName = NSNumber;
},
{
columnName = name;
externalType = varchar;
name = name;
valueClassName = NSString;
}
);
className = EOGenericRecord;
classProperties = (
name,
toBooks
);
externalName = authors;
name = authors;
primaryKeyAttributes = (
authorID
);
relationships = (
{
destination = books;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = authorID;
sourceAttribute = authorID;
}
);
name = toBooks;
}
);
},
{
attributes = (
{
columnName = authorID;
externalType = integer;
name = authorID;
valueClassName = NSNumber;
},
{
columnName = bookID;
externalType = integer;
name = bookID;
valueClassName = NSNumber;
},
{
columnName = title;
externalType = varchar;
name = title;
valueClassName = NSString;
}
);
className = EOGenericRecord;
classProperties = (
title,
toAuthor
);
externalName = books;
name = books;
primaryKeyAttributes = (
bookID
);
relationships = (
{
destination = authors;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = authorID;
sourceAttribute = authorID;
}
);
name = toAuthor;
}
);
}
);
name = library;
}
gnustep-dl2-0.12.0/Examples/GNUmakefile.eoexample2 0000664 0001750 0001750 00000000174 14632325605 020722 0 ustar yavor yavor TOOL_NAME+=eoexample2
eoexample2_NEEDS_GUI=no
eoexample2_OBJC_FILES=eoexample2.m
eoexample2_RESOURCE_FILES=library.eomodel
gnustep-dl2-0.12.0/Examples/connection.m 0000664 0001750 0001750 00000001644 14754345005 017131 0 ustar yavor yavor #include
#include
#include
int
main(int arcg, char *argv[], char **envp)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
EOModelGroup *modelGroup = [EOModelGroup defaultGroup];
EOModel *model = [modelGroup modelNamed:@"library"];
EOAdaptor *adaptor;
EOAdaptorContext *context;
EOAdaptorChannel *channel;
/* Tools don't have resources so we have to add the model manually. */
if (!model)
{
NSString *path = @"./library.eomodel";
model = [[EOModel alloc] initWithContentsOfFile: path];
[modelGroup addModel:model];
[model release];
}
adaptor = [EOAdaptor adaptorWithName:[model adaptorName]];
context = [adaptor createAdaptorContext];
channel = [context createAdaptorChannel];
[channel openChannel];
/* insert code here */
[channel closeChannel];
[pool release];
return 0;
}
gnustep-dl2-0.12.0/Examples/GNUmakefile.eoexample 0000664 0001750 0001750 00000000167 14632325605 020642 0 ustar yavor yavor TOOL_NAME+=eoexample
eoexample_NEEDS_GUI=no
eoexample_OBJC_FILES=eoexample.m
eoexample_RESOURCE_FILES=library.eomodel
gnustep-dl2-0.12.0/Examples/Trading/ 0000775 0001750 0001750 00000000000 14754345067 016207 5 ustar yavor yavor gnustep-dl2-0.12.0/Examples/Trading/TradingData.m 0000664 0001750 0001750 00000020371 14632325605 020541 0 ustar yavor yavor #include "TradingData.h"
#define PDEC2(x) \
[NSDecimalNumber decimalNumberWithMantissa:x \
exponent:-2 \
isNegative:NO]
@implementation TradingData
- (id) init
{
self = [super init];
if (self)
{
ec = [[EOEditingContext alloc] init];
customerDS = [[EODatabaseDataSource alloc] initWithEditingContext:ec
entityName:@"Customer"];
customerGroupDS = [[EODatabaseDataSource alloc] initWithEditingContext:ec
entityName:@"CustomerGroup"];
productGroupDS = [[EODatabaseDataSource alloc] initWithEditingContext:ec
entityName:@"ProductGroup"];
productDS = [[EODatabaseDataSource alloc] initWithEditingContext:ec
entityName:@"Product"];
suppliersDS = [[EODatabaseDataSource alloc] initWithEditingContext:ec
entityName:@"Supplier"];
priceListDS = [[EODatabaseDataSource alloc] initWithEditingContext:ec
entityName:@"PriceList"];
priceListPosDS = [[EODatabaseDataSource alloc] initWithEditingContext:ec
entityName:@"PriceListPos"];
orderDS = [[EODatabaseDataSource alloc] initWithEditingContext:ec
entityName:@"Order"];
orderPosDS = [[EODatabaseDataSource alloc] initWithEditingContext:ec
entityName:@"OrderPos"];
}
return self;
}
- (void) dealloc
{
[ec release];
[customerDS release];
[customerGroupDS release];
[productGroupDS release];
[productDS release];
[suppliersDS release];
[priceListDS release];
[priceListPosDS release];
[orderDS release];
[orderPosDS release];
}
- (void) fillTables
{
id fsfSup, mysqlSup, postgreSup, publicSup, acmeSup;
id implGrp, softGrp;
id folkGrp;
id rake, shovel, pitchfork, mysql, postgresql, sqlite, gnustep, gcc;
id salePriceList;
id customer;
id order;
implGrp = [self addProductGroup:@"Implements of destruction"];
softGrp = [self addProductGroup:@"Software"];
fsfSup = [self addSupplierNamed:@"The Free Software Foundation"];
gnustep = [self addProduct:@"GNUstep"
price:PDEC2(2595)
supplier:fsfSup
group:softGrp];
gcc = [self addProduct:@"gcc"
price:PDEC2(4995)
supplier:fsfSup
group:softGrp];
mysqlSup = [self addSupplierNamed:@"MySQL AB"];
mysql = [self addProduct:@"MySQL"
price:PDEC2(3000)
supplier:fsfSup
group:softGrp];
postgreSup = [self addSupplierNamed:@"The PostgreSQL Global Development Group"];
postgresql = [self addProduct:@"PostgreSQL"
price:PDEC2(3000)
supplier:postgreSup
group:softGrp];
publicSup = [self addSupplierNamed:@"sqlite.org"];
sqlite = [self addProduct:@"SQLite"
price:PDEC2(1500)
supplier:publicSup
group:softGrp];
acmeSup = [self addSupplierNamed:@"ACME"];
shovel = [self addProduct:@"Shovel"
price:PDEC2(1400)
supplier:acmeSup
group:implGrp];
rake = [self addProduct:@"Rake"
price:PDEC2(1295)
supplier:acmeSup
group:implGrp];
pitchfork = [self addProduct:@"Pitchfork"
price:PDEC2(1800)
supplier:acmeSup
group:implGrp];
folkGrp = [self addCustomerGroup:@"Angry Townfolk"];
[self customer:[self addCustomer:@"Angry Townsperson1" group:folkGrp]
order:rake
quantity:3];
[self customer:[self addCustomer:@"Angry Townsperson2" group:folkGrp]
order:shovel];
[self customer:[self addCustomer:@"Angry Townsperson3" group:folkGrp]
order:rake
quantity:2];
customer = [self addCustomer:@"Test Customer1"];
order = [self createOrderForCustomer:customer];
[self order:order product:mysql quantity:5];
[self order:order product:postgresql quantity:1];
[self order:order product:rake quantity:2];
[self customer:[self addCustomer:@"Test Customer2"]
order:postgresql];
[self customer:[self addCustomer:@"Test Customer3"]
order:sqlite];
salePriceList = [self addPriceList:@"Farm Supply Sale"
forGroup:folkGrp];
[self addProduct:pitchfork
price:PDEC2(1675)
toPriceList:salePriceList];
[self addProduct:rake
price:PDEC2(800)
toPriceList:salePriceList];
[self addProduct:shovel
price:PDEC2(995)
toPriceList:salePriceList];
[self saveChanges];
}
- (id) addPriceList:(NSString *)name
forGroup:(id)grp
{
id record = [priceListDS createObject];
[record takeValue:name forKey:@"name"];
[record addObject:grp toBothSidesOfRelationshipWithKey:@"customerGroup"];
return record;
}
- (id) addProduct:(id)product
price:(NSDecimalNumber *)price
toPriceList:(id)priceList
{
id record = [priceListPosDS createObject];
[record addObject:product toBothSidesOfRelationshipWithKey:@"product"];
[record takeValue:price forKey:@"price"];
[record addObject:priceList toBothSidesOfRelationshipWithKey:@"priceList"];
[priceListPosDS insertObject:record];
return record;
}
- (id) addProductGroup:(NSString *)productGroupName
{
id record = [productGroupDS createObject];
[record takeValue:productGroupName forKey:@"name"];
return record;
}
- (id) addSupplierNamed:(NSString *)name
{
id record = [suppliersDS createObject];
[record takeValue:name forKey:@"name"];
[suppliersDS insertObject:record];
return record;
}
- (id) addProduct:(NSString *)productName
price:(NSDecimalNumber *)price
supplier:(id)supplier
group:(id)productGroup
{
id record = [productDS createObject];
[record takeValue:productName forKey:@"name"];
[record takeValue:price forKey:@"price"];
[record addObject:supplier toBothSidesOfRelationshipWithKey:@"supplier"];
[record addObject:productGroup toBothSidesOfRelationshipWithKey:@"productGroup"];
[productDS insertObject:record];
return record;
}
- (id) addCustomerGroup:(NSString *)name
{
id record = [customerGroupDS createObject];
[record takeValue:name forKey:@"name"];
[customerGroupDS insertObject:record];
return record;
}
- (id) addCustomer:(NSString *)name
{
return [self addCustomer:name group:nil];
}
- (id) addCustomer:(NSString *)name
group:(id)group
{
id record = [customerDS createObject];
[record takeValue:name forKey:@"name"];
[record addObject:group toBothSidesOfRelationshipWithKey:@"customerGroup"];
[customerDS insertObject:record];
return record;
}
- (id) createOrderForCustomer:(id)customer
{
id order = [orderDS createObject];
[order takeValue:[NSDate date] forKey:@"date"];
[order addObject:customer toBothSidesOfRelationshipWithKey:@"customer"];
[orderDS insertObject:order];
return order;
}
- (id) order:(id)order
product:(id)product
quantity:(int)quantity
{
id orderPos = [orderPosDS createObject];
NSNumber *price = [product valueForKey:@"price"];
NSNumber *qNum = [NSNumber numberWithInt:quantity];
/* this should really not be in the database but in some business logic */
NSNumber *value = [NSNumber numberWithDouble:((double)quantity) * [price doubleValue]];
[orderPos addObject:product toBothSidesOfRelationshipWithKey:@"product"];
[orderPos addObject:order toBothSidesOfRelationshipWithKey:@"order"];
/* FIXME customer group pricing */
[orderPos takeValue:price forKey:@"price"];
[orderPos takeValue:qNum forKey:@"quantity"];
[orderPos takeValue:value forKey:@"value"];
/* FIXME this should be a relationship to a pos table */
[orderPos takeValue:[NSNumber numberWithInt:1] forKey:@"posnr"];
return orderPos;
}
- (id) customer:(id)customer
order:(id)product
{
return [self customer:customer order:product quantity:1];
}
- (id) customer:(id)customer
order:(id)product
quantity:(int)quantity
{
return [self customer:customer order:product quantity:quantity posNr:1];
}
- (id) customer:(id)customer
order:(id)product
quantity:(int)quantity
posNr:(int)posNr
{
id order = [orderDS createObject];
id orderPos = [orderPosDS createObject];
NSNumber *price = [product valueForKey:@"price"];
NSNumber *qNum = [NSNumber numberWithInt:quantity];
NSNumber *value = [NSNumber numberWithDouble:((double)quantity) * [price doubleValue]];
[order takeValue:[NSDate date] forKey:@"date"];
[order addObject:customer toBothSidesOfRelationshipWithKey:@"customer"];
[orderPos addObject:order toBothSidesOfRelationshipWithKey:@"order"];
/* FIXME customer group pricing */
[orderPos takeValue:price forKey:@"price"];
[orderPos takeValue:qNum forKey:@"quantity"];
[orderPos takeValue:value forKey:@"value"];
/* fixme this should be a relationship to a pos table */
[orderPos takeValue:[NSNumber numberWithInt:posNr] forKey:@"posnr"];
[orderPos addObject:product toBothSidesOfRelationshipWithKey:@"product"];
return order;
}
- (void) saveChanges
{
[ec saveChanges];
}
@end
gnustep-dl2-0.12.0/Examples/Trading/GNUmakefile 0000664 0001750 0001750 00000001231 14754345067 020256 0 ustar yavor yavor include ../../common.make
include $(GNUSTEP_MAKEFILES)/common.make
include ../../Version
include ../../common.make
NATIVE_LIBRARY_NAME=Trading
TOOL_NAME=createTradingDB
Trading_RESOURCE_FILES=Trading.eomodeld
Trading_HAS_RESOURCE_BUNDLE=yes
Trading_OBJC_FILES=Trading.m TradingData.m
Trading_HEADER_FILES=Trading.h TradingData.h
createTradingDB_OBJC_FILES=create.m
createTradingDB_NATIVE_LIBS+= Trading
ADDITIONAL_INCLUDE_DIRS+=-I../..
ADDITIONAL_NATIVE_LIBS+=EOAccess EOControl
ADDITIONAL_NATIVE_LIB_DIRS+=../../EOAccess ../../EOControl
ADDITIONAL_NATIVE_LIB_DIRS+= .
include $(GNUSTEP_MAKEFILES)/native-library.make
include $(GNUSTEP_MAKEFILES)/tool.make
gnustep-dl2-0.12.0/Examples/Trading/TradingData.h 0000664 0001750 0001750 00000002513 14632325605 020532 0 ustar yavor yavor #import
#include
#include
@interface TradingData : NSObject
{
EOEditingContext *ec;
EODatabaseDataSource *productGroupDS;
EODatabaseDataSource *productDS;
EODatabaseDataSource *suppliersDS;
EODatabaseDataSource *priceListDS;
EODatabaseDataSource *priceListPosDS;
EODatabaseDataSource *orderDS;
EODatabaseDataSource *orderPosDS;
EODatabaseDataSource *customerDS;
EODatabaseDataSource *customerGroupDS;
}
- (void) saveChanges;
- (void) fillTables;
- (id) addSupplierNamed:(NSString *)name;
- (id) addProductGroup:(NSString *)name;
- (id) addProduct:(NSString*)name price:(NSDecimalNumber *)price
supplier:(id)supplier
group:(id)group;
- (id) addProduct:(id)product
price:(NSDecimalNumber *)price
toPriceList:(id)priceList;
- (id) addPriceList:(NSString *)name
forGroup:(id)group;
- (id) addCustomer:(NSString *)customer;
- (id) addCustomer:(NSString *)customer group:(id)group;
- (id) addCustomerGroup:(NSString *)name;
- (id) customer:(id)customer
order:(id)product;
- (id) customer:(id)customer
order:(id)product
quantity:(int)quantity;
- (id) customer:(id)customer
order:(id)product
quantity:(int)quantity
posNr:(int)posNr;
- (id) createOrderForCustomer:(id)customer;
- (id) order:(id)order
product:(id)product
quantity:(int)quantity;
@end
gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/ 0000775 0001750 0001750 00000000000 14635562742 021365 5 ustar yavor yavor gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/Supplier.plist 0000664 0001750 0001750 00000001137 14632325605 024237 0 ustar yavor yavor {
attributes = (
{
columnName = NAME;
name = name;
prototypeName = char;
width = 90;
},
{
columnName = PID;
name = pid;
prototypeName = integer;
}
);
className = EOGenericRecord;
classProperties = (
name,
products
);
externalName = TST_SUPPLIER;
name = Supplier;
primaryKeyAttributes = (
pid
);
relationships = (
{
destination = Product;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = supid;
sourceAttribute = pid;
}
);
name = products;
}
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/EOSQLite3Prototypes.plist 0000664 0001750 0001750 00000001103 14632325605 026206 0 ustar yavor yavor {
attributes = (
{
externalType = TEXT;
name = char;
valueClassName = NSString;
width = 30;
},
{
externalType = DATE;
name = date;
valueClassName = NSCalendarDate;
},
{
externalType = decimal;
name = decimal;
precision = 12;
scale = 2;
valueClassName = NSDecimalNumber;
},
{
externalType = INTEGER;
name = integer;
valueClassName = NSNumber;
valueType = i;
}
);
className = EOGenericRecord;
isAbstractEntity = Y;
name = EOSQLite3Prototypes;
relationships = (
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/PriceList.plist 0000664 0001750 0001750 00000001730 14632325605 024331 0 ustar yavor yavor {
attributes = (
{
columnName = CSTGRPID;
externalType = integer;
name = cstgrpid;
valueClassName = NSNumber;
},
{
columnName = NAME;
externalType = char;
name = name;
prototypeName = char;
},
{
columnName = PID;
name = pid;
prototypeName = integer;
}
);
className = EOGenericRecord;
classProperties = (
customerGroup,
name,
priceListPos
);
externalName = TST_PRICELIST;
name = PriceList;
primaryKeyAttributes = (
pid
);
relationships = (
{
destination = CustomerGroup;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = pid;
sourceAttribute = cstgrpid;
}
);
name = customerGroup;
},
{
destination = PriceListPos;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = prlid;
sourceAttribute = pid;
}
);
name = priceListPos;
}
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/Order.plist 0000664 0001750 0001750 00000001610 14632325605 023503 0 ustar yavor yavor {
attributes = (
{
allowsNull = Y;
columnName = CSTID;
name = cstid;
prototypeName = integer;
},
{
columnName = DATE;
name = date;
prototypeName = date;
},
{
columnName = PID;
name = pid;
prototypeName = integer;
}
);
className = EOGenericRecord;
classProperties = (
customer,
date,
orderPos
);
externalName = TST_ORDER;
name = Order;
primaryKeyAttributes = (
pid
);
relationships = (
{
destination = OrderPos;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = ordid;
sourceAttribute = pid;
}
);
name = orderPos;
},
{
destination = Customer;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = pid;
sourceAttribute = cstid;
}
);
name = customer;
}
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/procName.storedProcedure 0000664 0001750 0001750 00000000410 14632325605 026207 0 ustar yavor yavor {
arguments = (
{
allowsNull = Y;
columnName = "";
externalType = varchar;
name = argument;
parameterDirection = 1;
valueClassName = NSString;
width = 20;
}
);
externalName = externalProcName;
name = procName;
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/PriceListPos.plist 0000664 0001750 0001750 00000001730 14632325605 025013 0 ustar yavor yavor {
attributes = (
{
columnName = PID;
name = pid;
prototypeName = integer;
},
{
columnName = PRDID;
name = prdid;
prototypeName = integer;
},
{
columnName = PRICE;
name = price;
prototypeName = decimal;
},
{
columnName = PRLID;
name = prlid;
prototypeName = integer;
}
);
className = EOGenericRecord;
classProperties = (
price,
priceList,
product
);
externalName = TST_PRICELISTPOS;
name = PriceListPos;
primaryKeyAttributes = (
pid
);
relationships = (
{
destination = Product;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = pid;
sourceAttribute = prdid;
}
);
name = product;
},
{
destination = PriceList;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = pid;
sourceAttribute = prlid;
}
);
name = priceList;
}
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/EOPostgreSQLPrototypes.plist 0000664 0001750 0001750 00000001106 14632325605 026770 0 ustar yavor yavor {
attributes = (
{
externalType = char;
name = char;
valueClassName = NSString;
width = 30;
},
{
externalType = date;
name = date;
valueClassName = NSCalendarDate;
},
{
externalType = decimal;
name = decimal;
precision = 12;
scale = 2;
valueClassName = NSDecimalNumber;
},
{
externalType = integer;
name = integer;
valueClassName = NSNumber;
valueType = i;
}
);
className = EOGenericRecord;
isAbstractEntity = Y;
name = EOPostgreSQLPrototypes;
relationships = (
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/EOPostgres95Prototypes.plist 0000664 0001750 0001750 00000001106 14632325605 026751 0 ustar yavor yavor {
attributes = (
{
externalType = char;
name = char;
valueClassName = NSString;
width = 30;
},
{
externalType = date;
name = date;
valueClassName = NSCalendarDate;
},
{
externalType = decimal;
name = decimal;
precision = 12;
scale = 2;
valueClassName = NSDecimalNumber;
},
{
externalType = integer;
name = integer;
valueClassName = NSNumber;
valueType = i;
}
);
className = EOGenericRecord;
isAbstractEntity = Y;
name = EOPostgres95Prototypes;
relationships = (
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/CustomerGroup.plist 0000664 0001750 0001750 00000001472 14632325605 025254 0 ustar yavor yavor {
attributes = (
{
columnName = NAME;
name = name;
prototypeName = char;
},
{
columnName = PID;
name = pid;
prototypeName = integer;
}
);
className = EOGenericRecord;
classProperties = (
customers,
name,
priceList
);
externalName = TST_CUSTOMERGROUP;
name = CustomerGroup;
primaryKeyAttributes = (
pid
);
relationships = (
{
destination = Customer;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = grpid;
sourceAttribute = pid;
}
);
name = customers;
},
{
destination = PriceList;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = cstgrpid;
sourceAttribute = pid;
}
);
name = priceList;
}
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/Customer.plist 0000664 0001750 0001750 00000001626 14632325605 024240 0 ustar yavor yavor {
attributes = (
{
allowsNull = Y;
columnName = GRPID;
name = grpid;
prototypeName = integer;
},
{
columnName = NAME;
name = name;
prototypeName = char;
},
{
columnName = PID;
name = pid;
prototypeName = integer;
}
);
className = EOGenericRecord;
classProperties = (
customerGroup,
name,
orders
);
externalName = TST_CUSTOMER;
name = Customer;
primaryKeyAttributes = (
pid
);
relationships = (
{
destination = CustomerGroup;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = pid;
sourceAttribute = grpid;
}
);
name = customerGroup;
},
{
destination = Order;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = cstid;
sourceAttribute = pid;
}
);
name = orders;
}
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/Product.plist 0000664 0001750 0001750 00000002622 14632325605 024054 0 ustar yavor yavor {
attributes = (
{
columnName = GRPID;
externalType = integer;
name = grpid;
prototypeName = integer;
},
{
columnName = NAME;
name = name;
prototypeName = char;
},
{
columnName = PID;
name = pid;
prototypeName = integer;
},
{
allowsNull = Y;
columnName = PRICE;
externalType = decimal;
name = price;
valueClassName = NSDecimalNumber;
},
{
allowsNull = Y;
columnName = SUPID;
externalType = integer;
name = supid;
valueClassName = NSNumber;
}
);
className = EOGenericRecord;
classProperties = (
name,
orderPos,
price,
productGroup,
supplier
);
externalName = TST_PRODUCT;
name = Product;
primaryKeyAttributes = (
pid
);
relationships = (
{
destination = ProductGroup;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = pid;
sourceAttribute = grpid;
}
);
name = productGroup;
},
{
destination = Supplier;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = pid;
sourceAttribute = supid;
}
);
name = supplier;
},
{
destination = OrderPos;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = prdid;
sourceAttribute = pid;
}
);
name = orderPos;
}
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/ProductGroup.plist 0000664 0001750 0001750 00000001126 14632325605 025067 0 ustar yavor yavor {
attributes = (
{
columnName = NAME;
name = name;
prototypeName = char;
},
{
columnName = PID;
name = pid;
prototypeName = integer;
}
);
className = EOGenericRecord;
classProperties = (
name,
products
);
externalName = TST_PRODUCTGROUP;
name = ProductGroup;
primaryKeyAttributes = (
pid
);
relationships = (
{
destination = Product;
isToMany = Y;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = grpid;
sourceAttribute = pid;
}
);
name = products;
}
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/OrderPos.plist 0000664 0001750 0001750 00000002404 14632325605 024167 0 ustar yavor yavor {
attributes = (
{
columnName = ORDID;
name = ordid;
prototypeName = integer;
},
{
columnName = PID;
name = pid;
prototypeName = integer;
},
{
columnName = POSNR;
name = posnr;
prototypeName = integer;
},
{
columnName = PRDID;
name = prdid;
prototypeName = integer;
},
{
columnName = PRICE;
name = price;
prototypeName = decimal;
},
{
columnName = QUANTITY;
name = quantity;
prototypeName = decimal;
},
{
columnName = VALUE;
name = value;
prototypeName = decimal;
}
);
className = EOGenericRecord;
classProperties = (
order,
posnr,
price,
product,
quantity,
value
);
externalName = TST_ORDERPOS;
name = OrderPos;
primaryKeyAttributes = (
pid
);
relationships = (
{
destination = Product;
isMandatory = Y;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = pid;
sourceAttribute = prdid;
}
);
name = product;
},
{
destination = Order;
isMandatory = Y;
isToMany = N;
joinSemantic = EOInnerJoin;
joins = (
{
destinationAttribute = pid;
sourceAttribute = ordid;
}
);
name = order;
}
);
} gnustep-dl2-0.12.0/Examples/Trading/Trading.eomodeld/index.eomodeld 0000664 0001750 0001750 00000002227 14635562742 024211 0 ustar yavor yavor {
EOModelVersion = 2;
adaptorName = PostgreSQL;
entities = (
{
className = EOGenericRecord;
name = Customer;
},
{
className = EOGenericRecord;
name = CustomerGroup;
},
{
className = EOGenericRecord;
name = EOPostgreSQLPrototypes;
},
{
className = EOGenericRecord;
name = EOPostgres95Prototypes;
},
{
className = EOGenericRecord;
name = EOSQLite3Prototypes;
},
{
className = EOGenericRecord;
name = Order;
},
{
className = EOGenericRecord;
name = OrderPos;
},
{
className = EOGenericRecord;
name = PriceList;
},
{
className = EOGenericRecord;
name = PriceListPos;
},
{
className = EOGenericRecord;
name = Product;
},
{
className = EOGenericRecord;
name = ProductGroup;
},
{
className = EOGenericRecord;
name = Supplier;
}
);
storedProcedures = (
procName
);
userInfo = {
PostgreSQLConnectionDictionary = {
databaseName = gdl2trading;
};
Postgres95ConnectionDictionary = {
databaseName = gdl2trading;
};
SQLite3ConnectionDictionary = {
databasePath = "/tmp/gdl2trading";
};
};
}
gnustep-dl2-0.12.0/Examples/Trading/Trading.m 0000664 0001750 0001750 00000012562 14754345067 017763 0 ustar yavor yavor #include "Trading.h"
/* Convience class for working with models supporting multiple adaptors */
@implementation Trading : NSObject
+ (EOModel *) defaultModel
{
EOModelGroup *globalGrp = [EOModelGroup globalModelGroup];
EOModel *model = [[EOModelGroup globalModelGroup] modelNamed:@"Trading"];
/*
* globalModelGroup doesn't currently work with non-framework native-libs
*/
if (!model)
{
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *modelPath = [bundle pathForResource:@"Trading"
ofType:@"eomodeld"];
[globalGrp addModelWithFile:modelPath];
model = [globalGrp modelNamed:@"Trading"];
}
return model;
}
/* calls initWithModel: with the default model */
- (id) init
{
return [self initWithModel:[[self class] defaultModel]];
}
- (BOOL) hasAdaptorNamed:(NSString *)adaptorName;
{
NSArray *adaptorNames;
if (adaptorName == nil)
return NO;
adaptorNames = [EOAdaptor availableAdaptorNames];
return [adaptorNames containsObject:adaptorName];
}
/* calls initWithModel:adaptorName:
* looking for an adaptor name in the following order:
* first it looks at the TEST_ADAPTOR environment variable
* then it looks for the GDL2TestAdaptor key
* then it looks for the models -adaptorName.
* finally if all else fails, it uses the first adaptor in the
* +availableAdaptorNames array.
*/
- (id) initWithModel:(EOModel *)model
{
NSArray *adaptorNames;
NSString *adaptorName;
BOOL flag;
adaptorNames = [EOAdaptor availableAdaptorNames];
adaptorName = [[[NSProcessInfo processInfo] environment]
objectForKey:@"TEST_ADAPTOR"];
if (flag == NO && ((flag = [self hasAdaptorNamed:adaptorName]) == NO))
adaptorName = [[NSUserDefaults standardUserDefaults]
stringForKey:@"GDL2TestAdaptorName"];
if (flag == NO && ((flag = [self hasAdaptorNamed:adaptorName]) == NO))
{
adaptorName = [model adaptorName];
}
if (flag == NO && ((flag = [self hasAdaptorNamed:adaptorName]) == NO))
{
adaptorName = [adaptorNames count] ? [adaptorNames objectAtIndex:0]
: nil;
}
return [self initWithModel:model adaptorName:adaptorName];
}
/*
* uses the default model and an 'adaptorName'ConnectionDictionary
* in the models userInfo.
*/
- (id) initWithModel:(EOModel *)model adaptorName:(NSString *)adaptorName
{
NSAssert(adaptorName, @"nil adaptor name");
{
NSString *dictName = [adaptorName stringByAppendingString:
@"ConnectionDictionary"];
NSDictionary *connDict = [[model userInfo] objectForKey: dictName];
return [self initWithModel:model
adaptorName:adaptorName
connectionDictionary:connDict];
}
}
/* designated initializer assigns the models adaptor name, and connection
* dictionary */
- (id) initWithModel:(EOModel *)model
adaptorName:(NSString*)adaptorName
connectionDictionary:(NSDictionary *)connDict
{
self = [super init];
if (self)
{
_model = [model retain];
[model setConnectionDictionary:connDict];
[model setAdaptorName:adaptorName];
_adaptor = [[EOAdaptor adaptorWithModel:_model] retain];
_exprClass = [_adaptor expressionClass];
_context = [[_adaptor createAdaptorContext] retain];
_channel = [[_context createAdaptorChannel] retain];
}
return self;
}
- (void) dealloc
{
[self close];
[_model release];
[_adaptor release];
[_context release];
[_channel release];
[super dealloc];
}
/*
* drops the tables (ignoring any exceptions)
* as the tables may not exist to be dropped.
* then returns the value of [self createTables];
*/
- (void) recreateTables
{
NS_DURING
[self dropTables];
NS_HANDLER
NS_ENDHANDLER
return [self createTables];
}
- (void) dropTables
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSArray *entities = [_model entities];
NSDictionary *dropOptDict
= [NSDictionary dictionaryWithObjectsAndKeys:
@"NO", @"EOPrimaryKeyConstraintsKey",
@"NO", @"EOCreatePrimaryKeySupportKey",
@"NO", @"EOCreateTablesKey",
nil];
NSArray *exprs;
EOSQLExpression *expr;
unsigned i,c;
exprs = [_exprClass schemaCreationStatementsForEntities: entities
options: dropOptDict];
[self open];
for (i=0, c=[exprs count]; i