* EOAccess/EOAccessFault.h/m: Minor cleanups for autogsdoc.

* EOAccess/EOAdaptor.m: Ditto.
	* EOAccess/EOAdaptorChannel.h/m: Ditto.
	* EOAccess/EOAdaptorContext.h: Ditto.
	* EOAccess/EODatabase.h/m: Ditto.
	* EOAccess/EODatabaseChannel.m: Ditto.
	* EOAccess/EODatabaseContext.h/m: Ditto.
	* EOAccess/EODatabaseDataSource.h: Ditto.
	* EOAccess/EODatabaseOperation.h: Ditto.
	* EOAccess/EOEntity.h/m: Ditto.
	* EOAccess/EOModel.h/m: Ditto.
	* EOAccess/EORelationship.h: Ditto.
	* EOAccess/EOSchemaGeneration.h: Ditto.
	* EOAccess/EOUtilities.h/m: Ditto.

	* EOAccess/EOSQLExpression.h/m: Minor cleanups for autogsdoc.
	(EOSchemaGeneration): Move implementation from here to ...
	* EOAccess/EOSchemaGeneration.m: ... new file for autogsdoc.
	* EOAccess/GNUmakefile: Add EOSchemaGeneration.m.

	* EOAccess/EOUtilities.m (EOObjectStoreCoordinator EOModelGroup):
	Move implementation from here to ...
	* EOAccess/EOModelGroup.m: ... to here for autogsdoc.

	* common.make: (GDL2_AGSDOC_FLAGS): Add extern declarations.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@24302 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ayers 2007-01-01 11:52:38 +00:00
parent 3317f1cc5e
commit 4c056a14f2
28 changed files with 1157 additions and 1047 deletions

View file

@ -1,3 +1,31 @@
2007-01-01 David Ayers <ayers@fsfe.org>
* EOAccess/EOAccessFault.h/m: Minor cleanups for autogsdoc.
* EOAccess/EOAdaptor.m: Ditto.
* EOAccess/EOAdaptorChannel.h/m: Ditto.
* EOAccess/EOAdaptorContext.h: Ditto.
* EOAccess/EODatabase.h/m: Ditto.
* EOAccess/EODatabaseChannel.m: Ditto.
* EOAccess/EODatabaseContext.h/m: Ditto.
* EOAccess/EODatabaseDataSource.h: Ditto.
* EOAccess/EODatabaseOperation.h: Ditto.
* EOAccess/EOEntity.h/m: Ditto.
* EOAccess/EOModel.h/m: Ditto.
* EOAccess/EORelationship.h: Ditto.
* EOAccess/EOSchemaGeneration.h: Ditto.
* EOAccess/EOUtilities.h/m: Ditto.
* EOAccess/EOSQLExpression.h/m: Minor cleanups for autogsdoc.
(EOSchemaGeneration): Move implementation from here to ...
* EOAccess/EOSchemaGeneration.m: ... new file for autogsdoc.
* EOAccess/GNUmakefile: Add EOSchemaGeneration.m.
* EOAccess/EOUtilities.m (EOObjectStoreCoordinator EOModelGroup):
Move implementation from here to ...
* EOAccess/EOModelGroup.m: ... to here for autogsdoc.
* common.make: (GDL2_AGSDOC_FLAGS): Add extern declarations.
2006-12-31 David Ayers <ayers@fsfe.org>
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLValues.h/m:

View file

@ -87,12 +87,12 @@
}
+ (EOAccessArrayFaultHandler *)accessArrayFaultHandlerWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
relationshipName: (NSString *)relationshipName
relationshipName: (NSString *)relName
databaseContext: (EODatabaseContext *)dbcontext
editingContext: (EOEditingContext *)ec;
- (id)initWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
relationshipName: (NSString *)relationshipName
relationshipName: (NSString *)relName
databaseContext: (EODatabaseContext *)dbcontext
editingContext: (EOEditingContext *)ec;

View file

@ -285,12 +285,12 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
@implementation EOAccessArrayFaultHandler
+ (EOAccessArrayFaultHandler *)accessArrayFaultHandlerWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
relationshipName: (NSString *)aRelationshipName
relationshipName: (NSString *)relName
databaseContext: (EODatabaseContext *)dbcontext
editingContext: (EOEditingContext *)ec
{
return [[[self alloc] initWithSourceGlobalID: sourceGID
relationshipName: aRelationshipName
relationshipName: relName
databaseContext: dbcontext
editingContext: ec] autorelease];
}
@ -304,10 +304,10 @@ NSString *EOAccessFaultObjectNotAvailableException = @"EOAccessFaultObjectNotAva
return self;
}
- initWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
relationshipName: (NSString *)relName
databaseContext: (EODatabaseContext *)dbcontext
editingContext: (EOEditingContext *)ec
- (id)initWithSourceGlobalID: (EOKeyGlobalID *)sourceGID
relationshipName: (NSString *)relName
databaseContext: (EODatabaseContext *)dbcontext
editingContext: (EOEditingContext *)ec
{
if ((self = [self init]))
{

View file

@ -184,7 +184,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
return adaptor;
}
+ (id) adaptorWithName: (NSString *)adaptorName
+ (id) adaptorWithName: (NSString *)name
{
//OK
NSBundle *bundle = [NSBundle mainBundle];
@ -195,7 +195,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
unsigned i, count;
/* Check error */
if ([adaptorName length] == 0)
if ([name length] == 0)
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: adaptor name can't be nil",
NSStringFromSelector(_cmd),
@ -203,11 +203,11 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
self];
// append EOAdaptor
if ([adaptorName hasSuffix: @"EOAdaptor"] == NO)
adaptorName = [adaptorName stringByAppendingString: @"EOAdaptor"];
if ([name hasSuffix: @"EOAdaptor"] == NO)
name = [name stringByAppendingString: @"EOAdaptor"];
/* Look in application bundle */
adaptorBundlePath = [bundle pathForResource: adaptorName
adaptorBundlePath = [bundle pathForResource: name
ofType: @"framework"];
// should be NSString *path=[NSBundle pathForLibraryResource:libraryResource type:@"framework" directory:@"Frameworks"]; ?
@ -230,7 +230,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
for(i = 0, count = [paths count]; i < count; i++)
{
bundle = [NSBundle bundleWithPath: [paths objectAtIndex: i]];
adaptorBundlePath = [bundle pathForResource: adaptorName
adaptorBundlePath = [bundle pathForResource: name
ofType: @"framework"];
if(adaptorBundlePath && [adaptorBundlePath length])
@ -251,7 +251,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
adaptorName];
name];
/* Get the adaptor bundle "infoDictionary", and pricipal class, ie. the
adaptor class. Other info about the adaptor should be put in the
@ -281,7 +281,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
adaptorName];
name];
}
if ([adaptorClass isSubclassOfClass: [self class]] == NO)
@ -294,7 +294,7 @@ static struct { NSString *name; NSStringEncoding encoding; } encodingMap[] = {
NSStringFromClass([adaptorClass class])];
}
return AUTORELEASE([[adaptorClass alloc] initWithName: adaptorName]);
return AUTORELEASE([[adaptorClass alloc] initWithName: name]);
}
+ (void)setExpressionClassName: (NSString *)sqlExpressionClassName

View file

@ -117,10 +117,10 @@ inRowDescribedByQualifier: (EOQualifier *)qualifier
/* Fetching rows */
- (void)selectAttributes: (NSArray *)attributes
fetchSpecification: (EOFetchSpecification *)fetchSpecification
lock: (BOOL)lockFlag
lock: (BOOL)flag
entity: (EOEntity *)entity;
- (void)lockRowComparingAttributes: (NSArray *)atts
- (void)lockRowComparingAttributes: (NSArray *)attrs
entity: (EOEntity *)entity
qualifier: (EOQualifier *)qualifier
snapshot: (NSDictionary *)snapshot;
@ -150,7 +150,7 @@ inRowDescribedByQualifier: (EOQualifier *)qualifier
- (void)addStoredProceduresNamed: (NSArray *)storedProcedureNames
toModel: (EOModel *)model;
- (void)setDebugEnabled: (BOOL)yn;
- (void)setDebugEnabled: (BOOL)flag;
- (BOOL)isDebugEnabled;
- (id)delegate;

View file

@ -118,13 +118,13 @@ NSString *EOAdaptorOptimisticLockingFailure = @"EOAdaptorOptimisticLockingFailur
[self subclassResponsibility: _cmd];
}
- (void)updateValues: (NSDictionary *)row
- (void)updateValues: (NSDictionary *)values
inRowDescribedByQualifier: (EOQualifier *)qualifier
entity: (EOEntity *)entity
{
int rows;
rows = [self updateValues: row
rows = [self updateValues: values
inRowsDescribedByQualifier: qualifier
entity: entity];

View file

@ -110,7 +110,7 @@ typedef enum {
- (BOOL)canNestTransactions; // override
- (unsigned)transactionNestingLevel;
+ (void)setDebugEnabledDefault: (BOOL)yn;
+ (void)setDebugEnabledDefault: (BOOL)flag;
+ (BOOL)debugEnabledDefault;
- (void)setDebugEnabled: (BOOL)debugEnabled;
- (BOOL)isDebugEnabled;

View file

@ -114,7 +114,7 @@ GDL2ACCESS_EXPORT NSTimeInterval EODistantPastTimeInterval;
- (void)forgetSnapshotForGlobalID: (EOGlobalID *)gid;
- (void)forgetSnapshotsForGlobalIDs: (NSArray *)array;
- (void)forgetSnapshotsForGlobalIDs: (NSArray *)gids;
- (void)forgetAllSnapshots;

View file

@ -239,7 +239,7 @@ static NSMutableArray *databaseInstances;
[_models removeObject: model];
}
- (BOOL)addModelIfCompatible: (EOModel *)model;
- (BOOL)addModelIfCompatible: (EOModel *)model
{
BOOL modelOk = NO;
@ -543,17 +543,17 @@ static NSMutableArray *databaseInstances;
EOFLOGObjectFnStop();
};
- (void)forgetSnapshotsForGlobalIDs: (NSArray*)ids
- (void)forgetSnapshotsForGlobalIDs: (NSArray*)gids
{
NSEnumerator *gidEnum = nil;
id gid = nil;
EOFLOGObjectFnStart();
NSAssert(ids, @"No Global IDs");
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"ids=%@", ids);
NSAssert(gids, @"No Global IDs");
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"gids=%@", gids);
gidEnum = [ids objectEnumerator];
gidEnum = [gids objectEnumerator];
while ((gid = [gidEnum nextObject]))
{
@ -564,7 +564,7 @@ static NSMutableArray *databaseInstances;
[[NSNotificationCenter defaultCenter]
postNotificationName: EOObjectsChangedInStoreNotification
object: self
userInfo: [NSDictionary dictionaryWithObject: ids
userInfo: [NSDictionary dictionaryWithObject: gids
forKey: EOInvalidatedKey]];
EOFLOGObjectFnStop();

View file

@ -223,7 +223,7 @@ RCS_ID("$Id$")
ASSIGN(_currentEditingContext, context);
}
- (void)selectObjectsWithFetchSpecification: (EOFetchSpecification *)fetch
- (void)selectObjectsWithFetchSpecification: (EOFetchSpecification *)fetchSpecification
editingContext: (EOEditingContext *)context
{
//should be OK
@ -235,7 +235,7 @@ RCS_ID("$Id$")
EOFLOGObjectFnStart();
entityName = [fetch entityName];
entityName = [fetchSpecification entityName];
database = [_databaseContext database];
EOFLOGObjectLevelArgs(@"gsdb", @"database=%@", database);
@ -244,7 +244,7 @@ RCS_ID("$Id$")
EOFLOGObjectLevelArgs(@"gsdb", @"entity name=%@", [entity name]);
qualifier=[fetch qualifier];
qualifier=[fetchSpecification qualifier];
EOFLOGObjectLevelArgs(@"gsdb", @"qualifier=%@", qualifier);
@ -259,18 +259,18 @@ RCS_ID("$Id$")
{
EOFetchSpecification *newFetch = nil;
EOFLOGObjectLevelArgs(@"gsdb", @"fetch=%@", fetch);
EOFLOGObjectLevelArgs(@"gsdb", @"fetchSpecification=%@", fetchSpecification);
//howto avoid copy of uncopiable qualifiers (i.e. those who contains uncopiable key or value)
EOFLOGObjectLevelArgs(@"gsdb", @"fetch=%@", fetch);
EOFLOGObjectLevelArgs(@"gsdb", @"fetchSpecification=%@", fetchSpecification);
newFetch = [[fetch copy] autorelease];
newFetch = [[fetchSpecification copy] autorelease];
EOFLOGObjectLevelArgs(@"gsdb", @"newFetch=%@", newFetch);
[newFetch setQualifier: schemaBasedQualifier];
EOFLOGObjectLevelArgs(@"gsdb", @"newFetch=%@", newFetch);
fetch = newFetch;
fetchSpecification = newFetch;
}
EOFLOGObjectLevelArgs(@"gsdb", @"%@ -- %@ 0x%x: isFetchInProgress=%s",
@ -279,7 +279,7 @@ RCS_ID("$Id$")
self,
([self isFetchInProgress] ? "YES" : "NO"));
[self _selectWithFetchSpecification:fetch
[self _selectWithFetchSpecification:fetchSpecification
editingContext:context];
EOFLOGObjectFnStop();

View file

@ -157,7 +157,7 @@ struct _EOTransactionScope;
- (id)faultForRawRow: (NSDictionary *)row
entityNamed: (NSString *)entityName
editingContext: (EOEditingContext *)editingContext;
editingContext: (EOEditingContext *)context;
- (id)entityForGlobalID: (EOGlobalID *)globalID;
@ -165,7 +165,7 @@ struct _EOTransactionScope;
editingContext: (EOEditingContext *)context;
- (NSArray *)arrayFaultWithSourceGlobalID: (EOGlobalID *)globalID
relationshipName: (NSString *)name
relationshipName: (NSString *)relationshipName
editingContext: (EOEditingContext *)context;
- (void)initializeObject: (id)object
@ -192,7 +192,7 @@ struct _EOTransactionScope;
- (BOOL)isObjectLockedWithGlobalID: (EOGlobalID *)gid
editingContext: (EOEditingContext *)context;
- (void)lockObjectWithGlobalID: (EOGlobalID *)gid
- (void)lockObjectWithGlobalID: (EOGlobalID *)globalID
editingContext: (EOEditingContext *)context;
- (void)invalidateAllObjects;
@ -252,8 +252,8 @@ It's invoked after prepareForSaveWithCoordinator:editingContext: and before owns
- (EODatabaseOperation*)databaseOperationForObject: (id)object;
- (EODatabaseOperation*)databaseOperationForGlobalID: (EOGlobalID *)gid;
- (void)recordDatabaseOperation: (EODatabaseOperation*)databaseOpe;
- (void)recordDeleteForObject: (id)param0;
- (void)recordInsertForObject: (id)param0;
- (void)recordDeleteForObject: (id)object;
- (void)recordInsertForObject: (id)object;
- (void)createAdaptorOperationsForDatabaseOperation: (EODatabaseOperation *)dbOpe
attributes: (NSArray *)attributes;
@ -266,7 +266,7 @@ It's invoked after prepareForSaveWithCoordinator:editingContext: and before owns
- (BOOL)isValidQualifierTypeForAttribute: (EOAttribute *)attribute;
- (id)lockingNonQualifiableAttributes: (NSArray *)attributes;
- (NSArray *)lockingAttributesForAttributes: (NSArray *)attributes
entity: (EOEntity *)enity;
entity: (EOEntity *)entity;
- (NSArray *)primaryKeyAttributesForAttributes: (NSArray *)attributes
entity: (EOEntity *)entity;
- (EOQualifier *)qualifierForLockingAttributes: (NSArray *)attributes

View file

@ -1323,7 +1323,7 @@ userInfo = {
EOFLOGObjectFnStop();
}
- (NSArray *)objectsWithFetchSpecification: (EOFetchSpecification *)fetch
- (NSArray *)objectsWithFetchSpecification: (EOFetchSpecification *)fetchSpecification
editingContext: (EOEditingContext *)context
{ // TODO
EODatabaseChannel *channel = nil;
@ -1346,12 +1346,12 @@ userInfo = {
EOFLOGObjectFnStart();
NSDebugMLLog(@"EODatabaseContext", @"fetch=%@", fetch);
NSDebugMLLog(@"EODatabaseContext", @"fetchSpecification=%@", fetchSpecification);
if (_delegateRespondsTo.shouldFetchObjects == YES)
{
array = (id)[_delegate databaseContext: self
shouldFetchObjectsWithFetchSpecification: fetch
shouldFetchObjectsWithFetchSpecification: fetchSpecification
editingContext: context];
}
@ -1360,28 +1360,28 @@ userInfo = {
IMP enumNO=NULL; // nextObject
array = [NSMutableArray arrayWithCapacity: 8];
entityName = [fetch entityName];//OK
entityName = [fetchSpecification entityName];//OK
entity = [_database entityNamed: entityName];//OK
NSAssert1(entity,@"No entity named %@",
entityName);
/* moved in EODatabaseChannel _selectWithFetchSpecification:(EOFetchSpecification *)fetch
/* moved in EODatabaseChannel _selectWithFetchSpecification:(EOFetchSpecification *)fetchSpecification
editingContext:(EOEditingContext *)context
limit = [fetch fetchLimit];
usesDistinct = [fetch usesDistinct];
limit = [fetchSpecification fetchLimit];
usesDistinct = [fetchSpecification usesDistinct];
subEntities = [entity subEntities];
if ([subEntities count] && [fetch isDeep] == YES)
if ([subEntities count] && [fetchSpecification isDeep] == YES)
{
subEntitiesEnum = [subEntities objectEnumerator];
while ((subEntity = [subEntitiesEnum nextObject]))
{
EOFetchSpecification *fetchSubEntity;
fetchSubEntity = AUTORELEASE([fetch copy]);
fetchSubEntity = AUTORELEASE([fetchSpecification copy]);
[fetchSubEntity setEntityName:[entity name]];
[array addObjectsFromArray:[context objectsWithFetchSpecification:
@ -1389,7 +1389,7 @@ userInfo = {
}
}
*/
rawRowKeyPaths = [fetch rawRowKeyPaths];//OK
rawRowKeyPaths = [fetchSpecification rawRowKeyPaths];//OK
if (rawRowKeyPaths)
#if 0
{
@ -1437,15 +1437,15 @@ userInfo = {
NSAutoreleasePool *arp = nil;//To avoid too much memory use when fetching a lot of objects
int limit = 0;
[channel selectObjectsWithFetchSpecification: fetch
[channel selectObjectsWithFetchSpecification: fetchSpecification
editingContext: context];//OK
NSDebugMLLog(@"EODatabaseContext",
@"[channel isFetchInProgress]=%s",
([channel isFetchInProgress] ? "YES" : "NO"));
limit = [fetch fetchLimit];//OK
promptsAfterFetchLimit = [fetch promptsAfterFetchLimit];
limit = [fetchSpecification fetchLimit];//OK
promptsAfterFetchLimit = [fetchSpecification promptsAfterFetchLimit];
NSDebugMLLog(@"EODatabaseContext", @"Will Fetch");
@ -1583,7 +1583,7 @@ userInfo = {
EOGlobalID *gid;
BOOL isFault;
qualifier = [fetch qualifier];
qualifier = [fetchSpecification qualifier];
cache = (id)[_database resultCacheForEntityNamed: entityName];
if (cache == nil)
@ -1739,9 +1739,9 @@ userInfo = {
NSDebugMLLog(@"EODatabaseContext", @"array before sort: %@", array);
if ([fetch sortOrderings])
if ([fetchSpecification sortOrderings])
array = (id)[array sortedArrayUsingKeyOrderArray:
[fetch sortOrderings]];
[fetchSpecification sortOrderings]];
}
else
{
@ -1780,7 +1780,7 @@ userInfo = {
NSAutoreleasePool *arp = nil;//To avoid too much memory use when fetching a lot of objects
int limit = 0;
[channel selectObjectsWithFetchSpecification: fetch
[channel selectObjectsWithFetchSpecification: fetchSpecification
editingContext: context];//OK
NSDebugMLLog(@"EODatabaseContext",
@ -1788,8 +1788,8 @@ userInfo = {
([channel isFetchInProgress]
? "YES" : "NO"));
limit = [fetch fetchLimit];//OK
promptsAfterFetchLimit = [fetch promptsAfterFetchLimit];
limit = [fetchSpecification fetchLimit];//OK
promptsAfterFetchLimit = [fetchSpecification promptsAfterFetchLimit];
NSDebugMLLog(@"EODatabaseContext", @"Will Fetch");
@ -1925,10 +1925,10 @@ userInfo = {
NSDebugMLLog(@"EODatabaseContext",
@"array before prefetchingRelationshipKeyPaths: %@", array);
if ([fetch prefetchingRelationshipKeyPaths]) //OK
if ([fetchSpecification prefetchingRelationshipKeyPaths]) //OK
qualArray = [NSMutableArray arrayWithCapacity: 5];
relationshipKeyPathEnum = [[fetch prefetchingRelationshipKeyPaths]
relationshipKeyPathEnum = [[fetchSpecification prefetchingRelationshipKeyPaths]
objectEnumerator];
enumNO=NULL;
while ((relationshipKeyPath = GDL2_NextObjectWithImpPtr(relationshipKeyPathEnum,&enumNO)))
@ -1958,7 +1958,7 @@ userInfo = {
if (_delegateRespondsTo.didFetchObjects == YES)
[_delegate databaseContext: self
didFetchObjects: array
fetchSpecification: fetch
fetchSpecification: fetchSpecification
editingContext: context];
NSDebugMLLog(@"EODatabaseContext",@"step 1 channel is busy=%d",

View file

@ -67,12 +67,12 @@
- (void)setFetchSpecification: (EOFetchSpecification *)fetchSpecification;
- (EOFetchSpecification *)fetchSpecification;
- (void)setAuxiliaryQualifier: (EOQualifier *)newQualifier;
- (void)setAuxiliaryQualifier: (EOQualifier *)qualifier;
- (EOQualifier *)auxiliaryQualifier;
- (EOFetchSpecification *)fetchSpecificationForFetch;
- (void)setFetchEnabled: (BOOL)yn;
- (void)setFetchEnabled: (BOOL)flag;
- (BOOL)isFetchEnabled;
@end

View file

@ -164,7 +164,7 @@ The newRow dictionary is created when creating the database operation (in EOData
- (EOEntity *)entity;
- (EODatabaseOperator)databaseOperator;
- (void)setDatabaseOperator: (EODatabaseOperator)dbOp;
- (void)setDatabaseOperator: (EODatabaseOperator)dbOpe;
- (NSDictionary *)rowDiffs;
- (NSDictionary *)rowDiffsForAttributes: (NSArray *)attributes;

View file

@ -143,7 +143,7 @@
/* Accessing attributes */
- (NSArray *)attributes;
- (EOAttribute *)attributeNamed: (NSString *)attributeName;
- (EOAttribute *)anyAttributeNamed: (NSString *)relationshipName;
- (EOAttribute *)anyAttributeNamed: (NSString *)attributeName;
/* Accessing relationships */
- (NSArray *)relationships;

View file

@ -1169,12 +1169,12 @@ static void performSelectorOnArrayWithEachObjectOfClass(NSArray *arr, SEL select
return [[self relationshipsByName] objectForKey: relationshipName];
}
- (EORelationship *)anyRelationshipNamed: (NSString *)relationshipNamed
- (EORelationship *)anyRelationshipNamed: (NSString *)relationshipName
{
EORelationship *rel;
NSEnumerator *relEnum = nil;
rel = [self relationshipNamed: relationshipNamed];
rel = [self relationshipNamed: relationshipName];
//VERIFY
if (!rel)
@ -1186,7 +1186,7 @@ static void performSelectorOnArrayWithEachObjectOfClass(NSArray *arr, SEL select
while (!rel && (tmpRel = GDL2_NextObjectWithImpPtr(relEnum,&enumNO)))
{
if ([[tmpRel name] isEqual: relationshipNamed])
if ([[tmpRel name] isEqual: relationshipName])
rel = tmpRel;
}
}
@ -1535,25 +1535,25 @@ static void performSelectorOnArrayWithEachObjectOfClass(NSArray *arr, SEL select
return dict;
}
- (BOOL)isValidAttributeUsedForLocking: (EOAttribute *)anAttribute
- (BOOL)isValidAttributeUsedForLocking: (EOAttribute *)attribute
{
if (!([anAttribute isKindOfClass: GDL2_EOAttributeClass]
&& [[self attributesByName] objectForKey: [anAttribute name]]))
if (!([attribute isKindOfClass: GDL2_EOAttributeClass]
&& [[self attributesByName] objectForKey: [attribute name]]))
return NO;
if ([anAttribute isDerived])
if ([attribute isDerived])
return NO;
return YES;
}
- (BOOL)isValidPrimaryKeyAttribute: (EOAttribute *)anAttribute
- (BOOL)isValidPrimaryKeyAttribute: (EOAttribute *)attribute
{
if (!([anAttribute isKindOfClass: GDL2_EOAttributeClass]
&& [[self attributesByName] objectForKey: [anAttribute name]]))
if (!([attribute isKindOfClass: GDL2_EOAttributeClass]
&& [[self attributesByName] objectForKey: [attribute name]]))
return NO;
if ([anAttribute isDerived])
if ([attribute isDerived])
return NO;
return YES;
@ -1592,15 +1592,15 @@ static void performSelectorOnArrayWithEachObjectOfClass(NSArray *arr, SEL select
return isValid;
}
- (BOOL)isValidClassProperty: (id)aProperty
- (BOOL)isValidClassProperty: (id)property
{
id thePropertyName;
if (!([aProperty isKindOfClass: GDL2_EOAttributeClass]
|| [aProperty isKindOfClass: [EORelationship class]]))
if (!([property isKindOfClass: GDL2_EOAttributeClass]
|| [property isKindOfClass: [EORelationship class]]))
return NO;
thePropertyName = [(EOAttribute *)aProperty name];
thePropertyName = [(EOAttribute *)property name];
if ([[self attributesByName] objectForKey: thePropertyName]
|| [[self relationshipsByName] objectForKey: thePropertyName])

View file

@ -140,12 +140,12 @@
- (void)_classDescriptionNeeded: (NSNotification *)notification;
- (id)_instantiatedEntities;
- (void)_setPath: (NSString *)path;
- (EOEntity *)_entityForClass: (Class)param0;
- (EOEntity *)_entityForClass: (Class)aClass;
- (id)_childrenForEntityNamed: (id)param0;
- (void)_registerChild: (id)param0
forParent: (id)param1;
- (void)_setInheritanceLinks: (id)param0;
- (void)_removeEntity: (id)param0;
- (void)_removeEntity: (EOEntity *)entity;
- (EOEntity *)_addEntityWithPropertyList: (NSDictionary *)propertyList;
- (void)_addFakeEntityWithPropertyList: (NSDictionary *)propertyList;
- (id)_addEntity: (EOEntity *)entity;
@ -161,7 +161,7 @@
- (void)setAdaptorName: (NSString *)adaptorName;
- (void)setConnectionDictionary: (NSDictionary *)connectionDictionary;
- (void)setUserInfo: (NSDictionary *)dictionary;
- (void)setUserInfo: (NSDictionary *)userInfo;
- (void)addEntity: (EOEntity *)entity;
- (void)removeEntity: (EOEntity *)entity;

View file

@ -1011,6 +1011,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
- (void)awakeWithPropertyList: (NSDictionary *)propertyList
{
return;
}
- (void)encodeIntoPropertyList: (NSMutableDictionary *)propertyList
@ -1246,15 +1247,17 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
forParent: (id)param1
{
// TODO [self notImplemented:_cmd];
return;
}
- (void) _setInheritanceLinks: (id)param0
{
// TODO
[self notImplemented: _cmd];
return;
}
- (void) _removeEntity: (id)entity
- (void) _removeEntity: (EOEntity *)entity
{
//should be ok
NSString *entityName = nil;
@ -1262,13 +1265,13 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
if ([entity isKindOfClass: [EOEntity class]])
{
entityName = [(EOEntity*)entity name];
entityName = [entity name];
entityClassName = [entity className];
}
else
{
entityName = [entity objectForKey: @"name"];
entityClassName = [entity objectForKey: @"className"];
entityName = [(NSDictionary *)entity objectForKey: @"name"];
entityClassName = [(NSDictionary *)entity objectForKey: @"className"];
}
[_entitiesByName removeObjectForKey: entityName];
@ -1495,7 +1498,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
}
}
- (void) removeEntityAndReferences: (EOEntity *)entity;
- (void) removeEntityAndReferences: (EOEntity *)entity
{
[self removeEntity: entity];
// TODO;

View file

@ -396,7 +396,7 @@ of the mainBundle, and all bundles and frameworks loaded into the app.
return newFetchSpecification;
}
- (EOStoredProcedure *)storedProcedureNamed: (NSString *)aName
- (EOStoredProcedure *)storedProcedureNamed: (NSString *)name
{
EOStoredProcedure *newStoredProcedure = nil;
NSEnumerator *modelEnum;
@ -407,7 +407,7 @@ of the mainBundle, and all bundles and frameworks loaded into the app.
modelEnum = [_modelsByName objectEnumerator];
while ((model = [modelEnum nextObject]))
{
if ((newStoredProcedure = [model storedProcedureNamed: aName]))
if ((newStoredProcedure = [model storedProcedureNamed: name]))
{
EOFLOGObjectFnStopOrCond2(@"ModelingClasses", @"EOModelGroup");
@ -421,3 +421,53 @@ of the mainBundle, and all bundles and frameworks loaded into the app.
}
@end
@implementation EOObjectStoreCoordinator (EOModelGroup)
- (id)modelGroup
{
//Seems OK
EOModelGroup *modelGroup;
NSDictionary *userInfo;
EOFLOGObjectFnStart();
userInfo = [self userInfo];
modelGroup = [userInfo objectForKey: @"EOModelGroup"];
if (!modelGroup)
{
modelGroup = [EOModelGroup defaultGroup];
[self setModelGroup: modelGroup];
}
EOFLOGObjectFnStop();
return modelGroup;
}
- (void)setModelGroup: (EOModelGroup *)modelGroup
{
NSMutableDictionary *userInfo;
EOFLOGObjectFnStart();
userInfo = (NSMutableDictionary *)[self userInfo];
if (userInfo)
[userInfo setObject: modelGroup
forKey: @"EOModelGroup"];
else
{
userInfo = (id)[NSMutableDictionary dictionary];
[userInfo setObject: modelGroup
forKey: @"EOModelGroup"];
[self setUserInfo: userInfo];
}
EOFLOGObjectFnStop();
}
@end

View file

@ -160,10 +160,10 @@ typedef enum {
- (void)setName: (NSString *)name;
- (void)setDefinition: (NSString *)definition;
- (void)setEntity: (EOEntity *)entity;
- (void)setToMany: (BOOL)yn;
- (void)setPropagatesPrimaryKey: (BOOL)yn;
- (void)setIsBidirectional: (BOOL)yn;
- (void)setOwnsDestination: (BOOL)yn;
- (void)setToMany: (BOOL)flag;
- (void)setPropagatesPrimaryKey: (BOOL)flag;
- (void)setIsBidirectional: (BOOL)flag;
- (void)setOwnsDestination: (BOOL)flag;
- (void)addJoin: (EOJoin *)join;
- (void)removeJoin: (EOJoin *)join;
- (void)setJoinSemantic: (EOJoinSemantic)joinSemantic;

View file

@ -97,7 +97,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
entity: (EOEntity *)entity;
+ (EOSQLExpression *)selectStatementForAttributes: (NSArray *)attributes
lock: (BOOL)yn
lock: (BOOL)flag
fetchSpecification: (EOFetchSpecification *)fetchSpecification
entity: (EOEntity *)entity;
@ -128,7 +128,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
- (void)prepareDeleteExpressionForQualifier: (EOQualifier *)qualifier;
- (void)prepareSelectExpressionWithAttributes: (NSArray *)attributes
lock: (BOOL)yn
lock: (BOOL)flag
fetchSpecification: (EOFetchSpecification *)fetchSpecification;
- (NSString *)assembleJoinClauseWithLeftName: (NSString *)leftName
@ -192,7 +192,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
- (void)addOrderByAttributeOrdering: (EOSortOrdering *)sortOrdering;
+ (BOOL)useQuotedExternalNames;
+ (void)setUseQuotedExternalNames: (BOOL)yn;
+ (void)setUseQuotedExternalNames: (BOOL)flag;
- (NSString *)externalNameQuoteCharacter;
- (void)setUseAliases: (BOOL)useAliases;
@ -201,7 +201,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
- (NSString *)sqlStringForSchemaObjectName: (NSString *)name;
- (NSString *)sqlStringForAttributeNamed: (NSString *)name;
- (NSString *)sqlStringForSelector: (SEL)selector value: (id)value;
- (NSString *)sqlStringForValue: (id)value attributeNamed: (NSString *)string;
- (NSString *)sqlStringForValue: (id)value attributeNamed: (NSString *)attributeName;
- (NSString *)sqlStringForAttribute: (EOAttribute *)attribute;
- (NSString *)sqlStringForAttributePath: (NSArray *)path;
@ -220,7 +220,7 @@ GDL2ACCESS_EXPORT NSString *EOBindVariableColumnKey;
- (BOOL)mustUseBindVariableForAttribute: (EOAttribute *)att;
+ (BOOL)useBindVariables;
+ (void)setUseBindVariables: (BOOL)yn;
+ (void)setUseBindVariables: (BOOL)flag;
- (NSArray *)bindVariableDictionaries;
- (void)addBindVariableDictionary: (NSMutableDictionary *)binding;

View file

@ -75,7 +75,6 @@ RCS_ID("$Id$")
#include <EOAccess/EOSQLExpression.h>
#include <EOAccess/EOSQLQualifier.h>
#include <EOAccess/EOExpressionArray.h>
#include <EOAccess/EOSchemaGeneration.h>
#include "EOPrivate.h"
#include "EOEntityPriv.h"
@ -661,7 +660,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
*/
- (void)prepareSelectExpressionWithAttributes: (NSArray *)attributes
lock: (BOOL)lockFlag
lock: (BOOL)flag
fetchSpecification: (EOFetchSpecification *)fetchSpecification
{
EOQualifier *fetchQualifier = nil;
@ -751,7 +750,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"tableList=%@", tableList);
//Build LockClause
if (lockFlag)
if (flag)
lockClauseString = [self lockClause];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"lockClauseString=%@",
lockClauseString);
@ -767,7 +766,7 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
//Now Build Statement
statement = [self assembleSelectStatementWithAttributes: attributes
lock: lockFlag
lock: flag
qualifier: fetchQualifier
fetchOrder: sortOrderings
selectString: selectCommand
@ -1855,42 +1854,42 @@ NSString *EOBindVariableColumnKey = @"EOBindVariableColumnKey";
return sqlString;
}
- (NSString *)sqlStringForAttribute: (EOAttribute *)anAttribute
- (NSString *)sqlStringForAttribute: (EOAttribute *)attribute
{
NSString *sqlString = nil;
EOFLOGObjectFnStartCond(@"EOSQLExpression");
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"anAttribute=%@",
anAttribute);
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"attribute=%@",
attribute);
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sFlattened=%s",
([anAttribute isFlattened] ? "YES" : "NO"));
([attribute isFlattened] ? "YES" : "NO"));
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_definitionArray=%@",
[anAttribute _definitionArray]);
[attribute _definitionArray]);
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"_definitionArray count=%d",
[[anAttribute _definitionArray]count]);
[[attribute _definitionArray]count]);
if ([anAttribute isFlattened])
if ([attribute isFlattened])
{
sqlString = [self sqlStringForAttributePath:
[anAttribute _definitionArray]];
[attribute _definitionArray]];
NSAssert1(sqlString, @"No sqlString for flattened attribute: %@",
anAttribute);
attribute);
}
//mirko:
/*
else if([anAttribute isDerived] == YES)
return [anAttribute definition];
else if([attribute isDerived] == YES)
return [attribute definition];
*/
else
{
if (![self useAliases])//OK
{
sqlString = [anAttribute columnName];
sqlString = [attribute columnName];
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
}
else
@ -1945,9 +1944,9 @@ else if([anAttribute isDerived] == YES)
if (attrArray)
{
if ([attrArray containsObject: anAttribute])
if ([attrArray containsObject: attribute])
{
NSString *columnName = [anAttribute columnName];
NSString *columnName = [attribute columnName];
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"columnName=%@", columnName);
@ -1957,8 +1956,8 @@ else if([anAttribute isDerived] == YES)
NSEmitTODO(); //TODO what to do when there's no column name (definition only like "((firstName || ' ') || lastName)") ?
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"anAttribute=%@",
anAttribute);
@"attribute=%@",
attribute);
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@"columnName=%@", columnName);
EOFLOGObjectLevelArgs(@"EOSQLExpression",
@ -1969,7 +1968,7 @@ else if([anAttribute isDerived] == YES)
}
NSAssert1(columnName, @"No columnName for attribute %@",
anAttribute);
attribute);
sqlString = [NSString stringWithFormat: @"%@.%@",
[_aliasesByRelationshipPath
@ -1985,7 +1984,7 @@ else if([anAttribute isDerived] == YES)
sqlString);
}
NSAssert1(sqlString, @"No SQLString for attribute %@", anAttribute);
NSAssert1(sqlString, @"No SQLString for attribute %@", attribute);
}
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"sqlString=%@", sqlString);
@ -2525,805 +2524,3 @@ All relationshipPaths in _aliasesByRelationshipPath are direct paths **/
@end
NSString *EOCreateTablesKey = @"EOCreateTablesKey";
NSString *EODropTablesKey = @"EODropTablesKey";
NSString *EOCreatePrimaryKeySupportKey = @"EOCreatePrimaryKeySupportKey";
NSString *EODropPrimaryKeySupportKey = @"EODropPrimaryKeySupportKey";
NSString *EOPrimaryKeyConstraintsKey = @"EOPrimaryKeyConstraintsKey";
NSString *EOForeignKeyConstraintsKey = @"EOForeignKeyConstraintsKey";
NSString *EOCreateDatabaseKey = @"EOCreateDatabaseKey";
NSString *EODropDatabaseKey = @"EODropDatabaseKey";
@implementation EOSQLExpression (EOSchemaGeneration)
+ (NSArray *)_administrativeDatabaseStatementsForSelector:(SEL) sel
forEntityGroup:(NSArray *)group
{
EOEntity *entity;
EOModel *model;
NSDictionary *connDict;
NSDictionary *admDict;
NSArray *stmts;
NSString *notifName;
NSMutableDictionary *notifDict;
entity = [group lastObject];
model = [entity model];
connDict = [model connectionDictionary];
notifDict = (id)[NSMutableDictionary dictionaryWithCapacity: 2];
[notifDict setObject: model forKey: EOModelKey];
notifName = EOAdministrativeConnectionDictionaryNeededNotification;
[[NSNotificationCenter defaultCenter] postNotificationName: notifName
object: notifDict];
admDict = [notifDict objectForKey: EOAdministrativeConnectionDictionaryKey];
/* TODO: ayers
if (admDict == nil && [admDict count] == 0)
{
EOAdaptor *adaptor;
EOLoginPanel *panel;
adaptor = [EOAdaptor adaptorWithModel: model];
panel = [[adaptor class] sharedLoginPanelInstance];
admDict = [panel administrativeConnectionDictionaryForAdaptor: adaptor];
}
*/
stmts = [self performSelector: sel
withObject: connDict
withObject: admDict];
return stmts;
}
+ (NSArray *)_dropDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *cumStmts;
NSArray *stmts;
NSArray *group;
unsigned i,n;
SEL sel;
sel = @selector(dropDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
n = [entityGroups count];
cumStmts = [NSMutableArray arrayWithCapacity: n];
for (i=0; i<n; i++)
{
EOSQLExpression *expr;
unsigned j,m;
group = [entityGroups objectAtIndex: i];
stmts = [self _administrativeDatabaseStatementsForSelector: sel
forEntityGroup: group];
for (j=0, m=[stmts count]; j<m; j++)
{
NSArray *rawStmts;
NSString *stmt;
rawStmts = [cumStmts valueForKey:@"statement"];
expr = [stmts objectAtIndex: j];
stmt = [expr statement];
if ([rawStmts containsObject: stmt] == NO)
{
[cumStmts addObject: expr];
}
}
}
return [NSArray arrayWithArray: cumStmts];
}
+ (NSArray *)_createDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *cumStmts;
NSArray *stmts;
NSArray *group;
unsigned i,n;
SEL sel;
sel = @selector(createDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
n = [entityGroups count];
cumStmts = [NSMutableArray arrayWithCapacity: n];
for (i=0; i<n; i++)
{
EOSQLExpression *expr;
unsigned j,m;
group = [entityGroups objectAtIndex: i];
stmts = [self _administrativeDatabaseStatementsForSelector: sel
forEntityGroup: group];
for (j=0, m=[stmts count]; j<m; j++)
{
NSArray *rawStmts;
NSString *stmt;
rawStmts = [cumStmts valueForKey:@"statement"];
expr = [stmts objectAtIndex: j];
stmt = [expr statement];
if ([rawStmts containsObject: stmt] == NO)
{
[cumStmts addObject: expr];
}
}
}
return [NSArray arrayWithArray: cumStmts];
}
+ (NSArray *)foreignKeyConstraintStatementsForRelationship: (EORelationship *)relationship
{
NSMutableArray *array, *sourceColumns, *destColumns;
EOSQLExpression *sqlExpression;
EOEntity *entity;
NSEnumerator *joinEnum;
EOJoin *join;
unsigned num;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: 1];
if ([[relationship entity] model]
!= [[relationship destinationEntity] model])
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
if ([relationship isToMany] == YES
|| ([relationship inverseRelationship] != nil
&& [[relationship inverseRelationship] isToMany] == NO))
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
entity = [relationship entity];
sqlExpression = [self sqlExpressionWithEntity: entity];
num = [[relationship joins] count];
sourceColumns = [NSMutableArray arrayWithCapacity: num];
destColumns = [NSMutableArray arrayWithCapacity: num];
joinEnum = [[relationship joins] objectEnumerator];
while ((join = [joinEnum nextObject]))
{
[sourceColumns addObject: [join sourceAttribute]];
[destColumns addObject: [join destinationAttribute]];
}
[sqlExpression prepareConstraintStatementForRelationship: relationship
sourceColumns: sourceColumns
destinationColumns: destColumns];
[array addObject: sqlExpression];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)foreignKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup
{
NSMutableArray *sqlExps;
EORelationship *rel;
EOEntity *entity;
EOEntity *parentEntity;
unsigned i,j,n,m;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
sqlExps = [NSMutableArray array];
for (i=0, n=[entityGroup count]; i<n; i++)
{
NSArray *rels;
entity = [entityGroup objectAtIndex: i];
parentEntity = [entity parentEntity];
rels = [entity relationships];
for (j=0, m=[rels count]; parentEntity == nil && j<m; j++)
{
NSArray *stmts;
rel = [rels objectAtIndex: j];
stmts =[self foreignKeyConstraintStatementsForRelationship: rel];
[sqlExps addObjectsFromArray: stmts];
}
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return sqlExps;
}
+ (NSArray *)foreignKeyConstraintStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
NSArray *stmts;
stmts = [self foreignKeyConstraintStatementsForEntityGroup: group];
[array addObjectsFromArray: stmts];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
// default implementation verifies that relationship joins on foreign key
// of destination and calls
// prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
+ (NSArray *)createTableStatementsForEntityGroup: (NSArray *)entityGroup
{
EOSQLExpression *sqlExp;
NSEnumerator *entityEnum, *attrEnum;
EOAttribute *attr;
EOEntity *entity;
NSString *tableName;
NSString *stmt;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
if ([[entityGroup objectAtIndex:0] isAbstractEntity])
return [NSArray array];
sqlExp = [self sqlExpressionWithEntity:[entityGroup objectAtIndex: 0]];
entityEnum = [entityGroup objectEnumerator];
while ((entity = [entityEnum nextObject]))
{
attrEnum = [[entity attributes] objectEnumerator];
while ((attr = [attrEnum nextObject]))
[sqlExp addCreateClauseForAttribute: attr];
}
entity = [entityGroup objectAtIndex: 0];
tableName = [entity externalName];
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
stmt = [NSString stringWithFormat: @"CREATE TABLE %@ (%@)",
tableName,
[sqlExp listString]];
[sqlExp setStatement: stmt];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSArray arrayWithObject: sqlExp];
}
+ (NSArray *)dropTableStatementsForEntityGroup:(NSArray *)entityGroup
{
NSArray *newArray;
NSString *tableName;
EOEntity *entity;
NSString *stmt;
EOSQLExpression *sqlExp;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
entity = [entityGroup objectAtIndex: 0];
if ([entity isAbstractEntity])
return [NSArray array];
sqlExp = [self sqlExpressionWithEntity: entity];
tableName = [entity externalName];
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
stmt = [NSString stringWithFormat: @"DROP TABLE %@", tableName];
[sqlExp setStatement: stmt];
newArray = [NSArray arrayWithObject: sqlExp];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return newArray;
}
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup
{
EOSQLExpression *sqlExp;
NSMutableString *listString;
NSEnumerator *attrEnum;
EOAttribute *attr;
EOEntity *entity;
NSString *tableName;
NSString *stmt;
BOOL first = YES;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
entity = [entityGroup objectAtIndex: 0];
listString = [NSMutableString stringWithCapacity: 30];
attrEnum = [[entity primaryKeyAttributes] objectEnumerator];
while ((attr = [attrEnum nextObject]))
{
NSString *columnName = [attr columnName];
if (!columnName || ![columnName length])
continue;
if (first == NO)
[listString appendString: @", "];
[listString appendString: columnName];
first = NO;
}
if (first == YES)
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSArray array];
}
sqlExp = [self sqlExpressionWithEntity:[entityGroup objectAtIndex: 0]];
tableName = [entity externalName];
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
stmt = [NSString stringWithFormat: @"ALTER TABLE %@ ADD PRIMARY KEY (%@)",
tableName, listString];
[sqlExp setStatement: stmt];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSArray arrayWithObject: sqlExp];
}
+ (NSArray *)primaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup
{
NSArray *newArray;
NSString *seqName;
EOEntity *entity;
NSString *pkRootName;
NSString *stmt;
EOSQLExpression *sqlExp;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
entity = [entityGroup objectAtIndex: 0];
if ([entity isAbstractEntity])
return [NSArray array];
pkRootName = [entity primaryKeyRootName];
seqName = [NSString stringWithFormat: @"%@_SEQ", pkRootName];
sqlExp = [self sqlExpressionWithEntity: nil];
seqName = [sqlExp sqlStringForSchemaObjectName: seqName];
stmt = [NSString stringWithFormat: @"CREATE SEQUENCE %@", seqName];
[sqlExp setStatement: stmt];
newArray = [NSArray arrayWithObject: sqlExp];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return newArray;
}
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup
{
NSArray *newArray;
NSString *seqName;
EOEntity *entity;
NSString *pkRootName;
NSString *stmt;
EOSQLExpression *sqlExp;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
entity = [entityGroup objectAtIndex: 0];
if ([entity isAbstractEntity])
return [NSArray array];
pkRootName = [entity primaryKeyRootName];
seqName = [NSString stringWithFormat: @"%@_SEQ", pkRootName];
sqlExp = [self sqlExpressionWithEntity: nil];
seqName = [sqlExp sqlStringForSchemaObjectName: seqName];
stmt = [NSString stringWithFormat: @"DROP SEQUENCE %@", seqName];
[sqlExp setStatement: stmt];
newArray = [NSArray arrayWithObject: sqlExp];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return newArray;
}
+ (NSArray *)createTableStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self createTableStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)dropTableStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self dropTableStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self primaryKeyConstraintStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)primaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self primaryKeySupportStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self dropPrimaryKeySupportStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (void)appendExpression: (EOSQLExpression *)expression
toScript: (NSMutableString *)script
{
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
[script appendFormat:@"%@;\n", [expression statement]];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
}
+ (NSString *)schemaCreationScriptForEntities: (NSArray *)entities
options: (NSDictionary *)options
{
NSMutableString *script = [NSMutableString stringWithCapacity:50];
NSEnumerator *arrayEnum;
EOSQLExpression *sqlExp;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
arrayEnum = [[self schemaCreationStatementsForEntities: entities
options: options] objectEnumerator];
while ((sqlExp = [arrayEnum nextObject]))
[self appendExpression: sqlExp toScript: script];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return script;
}
struct _schema
{
NSString *key;
NSString *value;
SEL selector;
};
+ (NSArray *)schemaCreationStatementsForEntities: (NSArray *)entities
options: (NSDictionary *)options
{
NSMutableArray *array = [NSMutableArray arrayWithCapacity: 5];
NSMutableArray *groups = [NSMutableArray arrayWithCapacity: 5];
NSMutableArray *group;
NSString *externalName;
EOEntity *entity;
int i, h, count;
struct _schema defaults[] = {
{EODropPrimaryKeySupportKey , @"YES",
@selector(dropPrimaryKeySupportStatementsForEntityGroups:)},
{EODropTablesKey , @"YES",
@selector(dropTableStatementsForEntityGroups:)},
{EODropDatabaseKey , @"NO",
@selector(_dropDatabaseStatementsForEntityGroups:)},
{EOCreateDatabaseKey , @"NO",
@selector(_createDatabaseStatementsForEntityGroups:)},
{EOCreateTablesKey , @"YES",
@selector(createTableStatementsForEntityGroups:)},
{EOCreatePrimaryKeySupportKey, @"YES",
@selector(primaryKeySupportStatementsForEntityGroups:)},
{EOPrimaryKeyConstraintsKey , @"YES",
@selector(primaryKeyConstraintStatementsForEntityGroups:)},
{EOForeignKeyConstraintsKey , @"NO",
@selector(foreignKeyConstraintStatementsForEntityGroups:)},
{nil, nil},
}; // Order is important!
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
count = [entities count];
for (i = 0; i < count; i++)
{
entity = [entities objectAtIndex: i];
externalName = [entity externalName];
group = [NSMutableArray arrayWithCapacity: 1];
[groups addObject: group];
[group addObject: entity];
for (h = i + 1; h < count; h++)
{
if ([[[entities objectAtIndex: h] externalName]
isEqual: externalName])
[group addObject: [entities objectAtIndex: h]];
}
}
for (i = 0; defaults[i].key != nil; i++)
{
NSString *value;
value = [options objectForKey: defaults[i].key];
if (!value)
value = defaults[i].value;
if ([value isEqual: @"YES"] == YES)
{
NSArray *stmts;
stmts = [self performSelector: defaults[i].selector
withObject: groups];
[array addObjectsFromArray: stmts];
}
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
- (NSString *)columnTypeStringForAttribute:(EOAttribute *)attribute
{
NSString *extType = [attribute externalType];
int precision = [attribute precision];
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
if (precision)
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSString stringWithFormat:@"%@(%d, %d)", extType, precision,
[attribute scale]];
}
else if ([attribute width])
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSString stringWithFormat: @"%@(%d)",
extType, [attribute width]];
}
else
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSString stringWithFormat: @"%@", extType];
}
}
- (NSString *)allowsNullClauseForConstraint: (BOOL)allowsNull
{
if (allowsNull == NO)
return @"NOT NULL";
return nil;
}
- (void)addCreateClauseForAttribute: (EOAttribute *)attribute
{
NSString *columnType;
NSString *allowsNull;
NSString *str;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
columnType = [self columnTypeStringForAttribute: attribute];
allowsNull = [self allowsNullClauseForConstraint: [attribute allowsNull]];
if (allowsNull)
str = [NSString stringWithFormat: @"%@ %@ %@", [attribute columnName],
columnType, allowsNull];
else
str = [NSString stringWithFormat: @"%@ %@", [attribute columnName],
columnType];
[self appendItem:str toListString: /*_listString*/[self listString]]; // Else no chance to get inited (lazy)
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
}
- (void)prepareConstraintStatementForRelationship: (EORelationship *)relationship
sourceColumns: (NSArray *)sourceColumns
destinationColumns: (NSArray *)destinationColumns
{
NSMutableString *sourceString, *destinationString;
NSEnumerator *attrEnum;
EOAttribute *attr;
NSString *name, *str, *tableName, *relTableName;
BOOL first = YES;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
name = [NSString stringWithFormat: @"%@_%@_FK", [_entity externalName],
[relationship name]];
sourceString = [NSMutableString stringWithCapacity: 30];
attrEnum = [sourceColumns objectEnumerator];
while ((attr = [attrEnum nextObject]))
{
NSString *columnName = [attr columnName];
if (!columnName || ![columnName length])
continue;
if (first == NO)
[sourceString appendString: @", "];
[sourceString appendString: columnName];
first = NO;
}
first = YES;
destinationString = [NSMutableString stringWithCapacity: 30];
attrEnum = [destinationColumns objectEnumerator];
while ((attr = [attrEnum nextObject]))
{
NSString *columnName = [attr columnName];
if (!columnName || ![columnName length])
continue;
if (first == NO)
[destinationString appendString: @", "];
[destinationString appendString: columnName];
first = NO;
}
tableName = [_entity externalName];
tableName = [self sqlStringForSchemaObjectName: tableName];
relTableName = [[relationship destinationEntity] externalName];
relTableName = [self sqlStringForSchemaObjectName: relTableName];
str = [NSString stringWithFormat: @"ALTER TABLE %@ ADD CONSTRAINT %@ "
@"FOREIGN KEY (%@) REFERENCES %@ (%@)",
tableName,
name,
sourceString,
relTableName,
destinationString];
ASSIGN(_statement, str);
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
}
// Assembles an adaptor specific constraint statement for relationship.
+ (NSArray *)createDatabaseStatementsForConnectionDictionary: (NSDictionary *)connectionDictionary
administrativeConnectionDictionary: (NSDictionary *)administrativeConnectionDictionary
{
[self subclassResponsibility: _cmd];
return nil;
}
+ (NSArray *)dropDatabaseStatementsForConnectionDictionary: (NSDictionary *)connectionDictionary
administrativeConnectionDictionary: (NSDictionary *)administrativeConnectionDictionary
{
[self subclassResponsibility: _cmd];
return nil;
}
+ (EOSQLExpression *)selectStatementForContainerOptions
{
[self notImplemented: _cmd];
return nil;
}
@end

View file

@ -1,4 +1,4 @@
/*
/* -*-objc-*-
EOSchemaGeneration.h
Copyright (C) 2004,2005 Free Software Foundation, Inc.
@ -32,75 +32,100 @@
@interface EOSQLExpression (EOSchemaGeneration)
/** Generates the statements to create a database **/
+ (NSArray *)createDatabaseStatementsForConnectionDictionary:(NSDictionary *)connectionDictionary administrativeConnectionDictionary:(NSDictionary *)administrativeConnectionDictionary;
/**
* Generates the statements to create a database.
*/
+ (NSArray *)createDatabaseStatementsForConnectionDictionary:(NSDictionary *)connectionDictionary
administrativeConnectionDictionary:(NSDictionary *)administrativeConnectionDictionary;
/** Generates the statements to drop the database **/
+ (NSArray *)dropDatabaseStatementsForConnectionDictionary:(NSDictionary *)connectionDictionary administrativeConnectionDictionary:(NSDictionary *)administrativeConnectionDictionary;
/**
* Generates the statements to drop the database.
*/
+ (NSArray *)dropDatabaseStatementsForConnectionDictionary:(NSDictionary *)connectionDictionary
administrativeConnectionDictionary:(NSDictionary *)administrativeConnectionDictionary;
/** Generates the statements necessary to implement the schema generation for
an entityGroup like creating/dropping a table, a primary key constaint or
a primary key generation support such as a sequence. **/
* an entityGroup like creating/dropping a table, a primary key constaint or
* a primary key generation support such as a sequence.
*/
+ (NSArray *)createTableStatementsForEntityGroup: (NSArray *)entityGroup;
+ (NSArray *)dropTableStatementsForEntityGroup: (NSArray *)entityGroup;
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroup: (NSArray *)entityGroup;
+ (NSArray *)primaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup;
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup;
/** Generates statements to create/drop a specific schema generation for a
list of entityGroups. **/
/**
* Generates statements to create/drop a specific schema generation for a
* list of entityGroups.
*/
+ (NSArray *)createTableStatementsForEntityGroups: (NSArray *)entityGroups;
+ (NSArray *)dropTableStatementsForEntityGroups: (NSArray *)entityGroups;
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroups: (NSArray *)entityGroups;
+ (NSArray *)primaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups;
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups;
/** The default implementation verifies the relationship joins and calls
+prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
**/
/**
* The default implementation verifies the relationship joins and calls
* prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
*/
+ (NSArray *)foreignKeyConstraintStatementsForRelationship: (EORelationship *)relationship;
/** Assembles an adaptor specific string for using in a create table
statement. **/
/**
* Assembles an adaptor specific string for using in a create table
* statement.
*/
- (NSString *)columnTypeStringForAttribute: (EOAttribute *)attribute;
/** Generates a string to be used in a create table statement **/
/**
* Generates a string to be used in a create table statement
*/
- (NSString *)allowsNullClauseForConstraint: (BOOL)allowsNull;
/** Assembles the create table statement for the given attribute **/
/**
* Assembles the create table statement for the given attribute
*/
- (void)addCreateClauseForAttribute: (EOAttribute *)attribute;
/** Assembles an adaptor specific constraint statement for relationship and the
given source and destination columns **/
/**
* Assembles an adaptor specific constraint statement for relationship and the
* given source and destination columns
*/
- (void)prepareConstraintStatementForRelationship: (EORelationship *)relationship
sourceColumns: (NSArray *)sourceColumns
destinationColumns: (NSArray *)destinationColumns;
/** Append expression statement to an executable script.
The default implementation appends the ';' **/
/**
* Append expression statement to an executable script.
* The default implementation appends the ';'
*/
+ (void)appendExpression:(EOSQLExpression *)expression toScript:(NSMutableString *)script;
/** Returns a script to create the schema for the given entities specific for
the target db. Options are the same as
-schemaCreationStatementsForEntities:options: **/
/**
* Returns a script to create the schema for the given entities specific for
* the target db. Options are the same as
* [+schemaCreationStatementsForEntities:options:]
*/
+ (NSString *)schemaCreationScriptForEntities:(NSArray *)entities
options:(NSDictionary *)options;
/** Returns an array of EOSQLExpression suitable to create the schema for the
given entities specific for the target db.
Possible options are:
Name Value Default
createTables YES/NO YES
dropTables YES/NO YES
createPrimaryKeySupport YES/NO YES
dropPrimaryKeySupport YES/NO YES
primaryKeyConstraints YES/NO YES
foreignKeyConstraints YES/NO NO
createDatabase YES/NO NO
dropDatabase YES/NO NO
**/
/**
* <p>
* Returns an array of EOSQLExpression suitable to create the schema for the
* given entities specific for the target db.
* Possible options are:</p>
* <list>
* <item>Name Value Default</item>
* <item></item>
* <item>createTables YES/NO YES</item>
* <item>dropTables YES/NO YES</item>
* <item>createPrimaryKeySupport YES/NO YES</item>
* <item>dropPrimaryKeySupport YES/NO YES</item>
* <item>primaryKeyConstraints YES/NO YES</item>
* <item>foreignKeyConstraints YES/NO NO</item>
* <item>createDatabase YES/NO NO</item>
* <item>dropDatabase YES/NO NO</item>
* </list>
*/
+ (NSArray *)schemaCreationStatementsForEntities: (NSArray *)entities
options: (NSDictionary *)options;
@ -110,10 +135,9 @@
/** Keys to use the options dictionary for
+schemaCreationScriptForEntities:options:
and +schemaCreationStatementsForEntities:options: **/
* +schemaCreationScriptForEntities:options:
* and +schemaCreationStatementsForEntities:options:
*/
GDL2ACCESS_EXPORT NSString *EOCreateTablesKey;
GDL2ACCESS_EXPORT NSString *EODropTablesKey;
GDL2ACCESS_EXPORT NSString *EOCreatePrimaryKeySupportKey;

View file

@ -0,0 +1,865 @@
/**
EOSchemaGeneration.m <title>EOSchemaGeneration Class</title>
Copyright (C) 2006 Free Software Foundation, Inc.
Author: David Ayers <ayers@fsfe.org>
Date: February 2006
$Revision: 23653 $
$Date: 2006-09-28 17:25:30 +0200 (Don, 28 Sep 2006) $
<abstract></abstract>
This file is part of the GNUstep Database Library.
<license>
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 2 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.
</license>
**/
#include "config.h"
RCS_ID("$Id: EOSchemaGeneration.m 23653 2006-09-28 15:25:30Z ratmice $")
#include <string.h>
#ifdef GNUSTEP
#include <Foundation/NSString.h>
#include <Foundation/NSNotification.h>
#else
#include <Foundation/Foundation.h>
#endif
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#include <GNUstepBase/GSObjCRuntime.h>
#include <GNUstepBase/GSCategories.h>
#endif
#include <EOControl/EODebug.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOEntity.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOAdaptor.h>
#include <EOAccess/EOAdaptorContext.h>
#include <EOAccess/EOAdaptorChannel.h>
#include <EOAccess/EOJoin.h>
#include <EOAccess/EOSchemaGeneration.h>
NSString *EOCreateTablesKey = @"EOCreateTablesKey";
NSString *EODropTablesKey = @"EODropTablesKey";
NSString *EOCreatePrimaryKeySupportKey = @"EOCreatePrimaryKeySupportKey";
NSString *EODropPrimaryKeySupportKey = @"EODropPrimaryKeySupportKey";
NSString *EOPrimaryKeyConstraintsKey = @"EOPrimaryKeyConstraintsKey";
NSString *EOForeignKeyConstraintsKey = @"EOForeignKeyConstraintsKey";
NSString *EOCreateDatabaseKey = @"EOCreateDatabaseKey";
NSString *EODropDatabaseKey = @"EODropDatabaseKey";
@implementation EOSQLExpression (EOSchemaGeneration)
+ (NSArray *)_administrativeDatabaseStatementsForSelector:(SEL) sel
forEntityGroup:(NSArray *)group
{
EOEntity *entity;
EOModel *model;
NSDictionary *connDict;
NSDictionary *admDict;
NSArray *stmts;
NSString *notifName;
NSMutableDictionary *notifDict;
entity = [group lastObject];
model = [entity model];
connDict = [model connectionDictionary];
notifDict = (id)[NSMutableDictionary dictionaryWithCapacity: 2];
[notifDict setObject: model forKey: EOModelKey];
notifName = EOAdministrativeConnectionDictionaryNeededNotification;
[[NSNotificationCenter defaultCenter] postNotificationName: notifName
object: notifDict];
admDict = [notifDict objectForKey: EOAdministrativeConnectionDictionaryKey];
/* TODO: ayers
if (admDict == nil && [admDict count] == 0)
{
EOAdaptor *adaptor;
EOLoginPanel *panel;
adaptor = [EOAdaptor adaptorWithModel: model];
panel = [[adaptor class] sharedLoginPanelInstance];
admDict = [panel administrativeConnectionDictionaryForAdaptor: adaptor];
}
*/
stmts = [self performSelector: sel
withObject: connDict
withObject: admDict];
return stmts;
}
+ (NSArray *)_dropDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *cumStmts;
NSArray *stmts;
NSArray *group;
unsigned i,n;
SEL sel;
sel = @selector(dropDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
n = [entityGroups count];
cumStmts = [NSMutableArray arrayWithCapacity: n];
for (i=0; i<n; i++)
{
EOSQLExpression *expr;
unsigned j,m;
group = [entityGroups objectAtIndex: i];
stmts = [self _administrativeDatabaseStatementsForSelector: sel
forEntityGroup: group];
for (j=0, m=[stmts count]; j<m; j++)
{
NSArray *rawStmts;
NSString *stmt;
rawStmts = [cumStmts valueForKey:@"statement"];
expr = [stmts objectAtIndex: j];
stmt = [expr statement];
if ([rawStmts containsObject: stmt] == NO)
{
[cumStmts addObject: expr];
}
}
}
return [NSArray arrayWithArray: cumStmts];
}
+ (NSArray *)_createDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *cumStmts;
NSArray *stmts;
NSArray *group;
unsigned i,n;
SEL sel;
sel = @selector(createDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
n = [entityGroups count];
cumStmts = [NSMutableArray arrayWithCapacity: n];
for (i=0; i<n; i++)
{
EOSQLExpression *expr;
unsigned j,m;
group = [entityGroups objectAtIndex: i];
stmts = [self _administrativeDatabaseStatementsForSelector: sel
forEntityGroup: group];
for (j=0, m=[stmts count]; j<m; j++)
{
NSArray *rawStmts;
NSString *stmt;
rawStmts = [cumStmts valueForKey:@"statement"];
expr = [stmts objectAtIndex: j];
stmt = [expr statement];
if ([rawStmts containsObject: stmt] == NO)
{
[cumStmts addObject: expr];
}
}
}
return [NSArray arrayWithArray: cumStmts];
}
+ (NSArray *)foreignKeyConstraintStatementsForRelationship: (EORelationship *)relationship
{
NSMutableArray *array, *sourceColumns, *destColumns;
EOSQLExpression *sqlExpression;
EOEntity *entity;
NSEnumerator *joinEnum;
EOJoin *join;
unsigned num;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: 1];
if ([[relationship entity] model]
!= [[relationship destinationEntity] model])
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
if ([relationship isToMany] == YES
|| ([relationship inverseRelationship] != nil
&& [[relationship inverseRelationship] isToMany] == NO))
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
entity = [relationship entity];
sqlExpression = [self sqlExpressionWithEntity: entity];
num = [[relationship joins] count];
sourceColumns = [NSMutableArray arrayWithCapacity: num];
destColumns = [NSMutableArray arrayWithCapacity: num];
joinEnum = [[relationship joins] objectEnumerator];
while ((join = [joinEnum nextObject]))
{
[sourceColumns addObject: [join sourceAttribute]];
[destColumns addObject: [join destinationAttribute]];
}
[sqlExpression prepareConstraintStatementForRelationship: relationship
sourceColumns: sourceColumns
destinationColumns: destColumns];
[array addObject: sqlExpression];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)foreignKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup
{
NSMutableArray *sqlExps;
EORelationship *rel;
EOEntity *entity;
EOEntity *parentEntity;
unsigned i,j,n,m;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
sqlExps = [NSMutableArray array];
for (i=0, n=[entityGroup count]; i<n; i++)
{
NSArray *rels;
entity = [entityGroup objectAtIndex: i];
parentEntity = [entity parentEntity];
rels = [entity relationships];
for (j=0, m=[rels count]; parentEntity == nil && j<m; j++)
{
NSArray *stmts;
rel = [rels objectAtIndex: j];
stmts =[self foreignKeyConstraintStatementsForRelationship: rel];
[sqlExps addObjectsFromArray: stmts];
}
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return sqlExps;
}
+ (NSArray *)foreignKeyConstraintStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
NSArray *stmts;
stmts = [self foreignKeyConstraintStatementsForEntityGroup: group];
[array addObjectsFromArray: stmts];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
// default implementation verifies that relationship joins on foreign key
// of destination and calls
// prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
+ (NSArray *)createTableStatementsForEntityGroup: (NSArray *)entityGroup
{
EOSQLExpression *sqlExp;
NSEnumerator *entityEnum, *attrEnum;
EOAttribute *attr;
EOEntity *entity;
NSString *tableName;
NSString *stmt;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
if ([[entityGroup objectAtIndex:0] isAbstractEntity])
return [NSArray array];
sqlExp = [self sqlExpressionWithEntity:[entityGroup objectAtIndex: 0]];
entityEnum = [entityGroup objectEnumerator];
while ((entity = [entityEnum nextObject]))
{
attrEnum = [[entity attributes] objectEnumerator];
while ((attr = [attrEnum nextObject]))
[sqlExp addCreateClauseForAttribute: attr];
}
entity = [entityGroup objectAtIndex: 0];
tableName = [entity externalName];
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
stmt = [NSString stringWithFormat: @"CREATE TABLE %@ (%@)",
tableName,
[sqlExp listString]];
[sqlExp setStatement: stmt];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSArray arrayWithObject: sqlExp];
}
+ (NSArray *)dropTableStatementsForEntityGroup:(NSArray *)entityGroup
{
NSArray *newArray;
NSString *tableName;
EOEntity *entity;
NSString *stmt;
EOSQLExpression *sqlExp;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
entity = [entityGroup objectAtIndex: 0];
if ([entity isAbstractEntity])
return [NSArray array];
sqlExp = [self sqlExpressionWithEntity: entity];
tableName = [entity externalName];
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
stmt = [NSString stringWithFormat: @"DROP TABLE %@", tableName];
[sqlExp setStatement: stmt];
newArray = [NSArray arrayWithObject: sqlExp];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return newArray;
}
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroup:(NSArray *)entityGroup
{
EOSQLExpression *sqlExp;
NSMutableString *listString;
NSEnumerator *attrEnum;
EOAttribute *attr;
EOEntity *entity;
NSString *tableName;
NSString *stmt;
BOOL first = YES;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
entity = [entityGroup objectAtIndex: 0];
listString = [NSMutableString stringWithCapacity: 30];
attrEnum = [[entity primaryKeyAttributes] objectEnumerator];
while ((attr = [attrEnum nextObject]))
{
NSString *columnName = [attr columnName];
if (!columnName || ![columnName length])
continue;
if (first == NO)
[listString appendString: @", "];
[listString appendString: columnName];
first = NO;
}
if (first == YES)
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSArray array];
}
sqlExp = [self sqlExpressionWithEntity:[entityGroup objectAtIndex: 0]];
tableName = [entity externalName];
tableName = [sqlExp sqlStringForSchemaObjectName: tableName];
stmt = [NSString stringWithFormat: @"ALTER TABLE %@ ADD PRIMARY KEY (%@)",
tableName, listString];
[sqlExp setStatement: stmt];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSArray arrayWithObject: sqlExp];
}
+ (NSArray *)primaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup
{
NSArray *newArray;
NSString *seqName;
EOEntity *entity;
NSString *pkRootName;
NSString *stmt;
EOSQLExpression *sqlExp;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
entity = [entityGroup objectAtIndex: 0];
if ([entity isAbstractEntity])
return [NSArray array];
pkRootName = [entity primaryKeyRootName];
seqName = [NSString stringWithFormat: @"%@_SEQ", pkRootName];
sqlExp = [self sqlExpressionWithEntity: nil];
seqName = [sqlExp sqlStringForSchemaObjectName: seqName];
stmt = [NSString stringWithFormat: @"CREATE SEQUENCE %@", seqName];
[sqlExp setStatement: stmt];
newArray = [NSArray arrayWithObject: sqlExp];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return newArray;
}
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup: (NSArray *)entityGroup
{
NSArray *newArray;
NSString *seqName;
EOEntity *entity;
NSString *pkRootName;
NSString *stmt;
EOSQLExpression *sqlExp;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
entity = [entityGroup objectAtIndex: 0];
if ([entity isAbstractEntity])
return [NSArray array];
pkRootName = [entity primaryKeyRootName];
seqName = [NSString stringWithFormat: @"%@_SEQ", pkRootName];
sqlExp = [self sqlExpressionWithEntity: nil];
seqName = [sqlExp sqlStringForSchemaObjectName: seqName];
stmt = [NSString stringWithFormat: @"DROP SEQUENCE %@", seqName];
[sqlExp setStatement: stmt];
newArray = [NSArray arrayWithObject: sqlExp];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return newArray;
}
+ (NSArray *)createTableStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self createTableStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)dropTableStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self dropTableStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self primaryKeyConstraintStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)primaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self primaryKeySupportStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups: (NSArray *)entityGroups
{
NSMutableArray *array;
NSEnumerator *groupsEnum;
NSArray *group;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
array = [NSMutableArray arrayWithCapacity: [entityGroups count]];
groupsEnum = [entityGroups objectEnumerator];
while ((group = [groupsEnum nextObject]))
{
[array addObjectsFromArray:
[self dropPrimaryKeySupportStatementsForEntityGroup: group]];
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
+ (void)appendExpression: (EOSQLExpression *)expression
toScript: (NSMutableString *)script
{
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
[script appendFormat:@"%@;\n", [expression statement]];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
}
+ (NSString *)schemaCreationScriptForEntities: (NSArray *)entities
options: (NSDictionary *)options
{
NSMutableString *script = [NSMutableString stringWithCapacity:50];
NSEnumerator *arrayEnum;
EOSQLExpression *sqlExp;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
arrayEnum = [[self schemaCreationStatementsForEntities: entities
options: options] objectEnumerator];
while ((sqlExp = [arrayEnum nextObject]))
[self appendExpression: sqlExp toScript: script];
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return script;
}
struct _schema
{
NSString *key;
NSString *value;
SEL selector;
};
+ (NSArray *)schemaCreationStatementsForEntities: (NSArray *)entities
options: (NSDictionary *)options
{
NSMutableArray *array = [NSMutableArray arrayWithCapacity: 5];
NSMutableArray *groups = [NSMutableArray arrayWithCapacity: 5];
NSMutableArray *group;
NSString *externalName;
EOEntity *entity;
int i, h, count;
struct _schema defaults[] = {
{EODropPrimaryKeySupportKey , @"YES",
@selector(dropPrimaryKeySupportStatementsForEntityGroups:)},
{EODropTablesKey , @"YES",
@selector(dropTableStatementsForEntityGroups:)},
{EODropDatabaseKey , @"NO",
@selector(_dropDatabaseStatementsForEntityGroups:)},
{EOCreateDatabaseKey , @"NO",
@selector(_createDatabaseStatementsForEntityGroups:)},
{EOCreateTablesKey , @"YES",
@selector(createTableStatementsForEntityGroups:)},
{EOCreatePrimaryKeySupportKey, @"YES",
@selector(primaryKeySupportStatementsForEntityGroups:)},
{EOPrimaryKeyConstraintsKey , @"YES",
@selector(primaryKeyConstraintStatementsForEntityGroups:)},
{EOForeignKeyConstraintsKey , @"NO",
@selector(foreignKeyConstraintStatementsForEntityGroups:)},
{nil, nil},
}; // Order is important!
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
count = [entities count];
for (i = 0; i < count; i++)
{
entity = [entities objectAtIndex: i];
externalName = [entity externalName];
group = [NSMutableArray arrayWithCapacity: 1];
[groups addObject: group];
[group addObject: entity];
for (h = i + 1; h < count; h++)
{
if ([[[entities objectAtIndex: h] externalName]
isEqual: externalName])
[group addObject: [entities objectAtIndex: h]];
}
}
for (i = 0; defaults[i].key != nil; i++)
{
NSString *value;
value = [options objectForKey: defaults[i].key];
if (!value)
value = defaults[i].value;
if ([value isEqual: @"YES"] == YES)
{
NSArray *stmts;
stmts = [self performSelector: defaults[i].selector
withObject: groups];
[array addObjectsFromArray: stmts];
}
}
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return array;
}
- (NSString *)columnTypeStringForAttribute:(EOAttribute *)attribute
{
NSString *extType = [attribute externalType];
int precision = [attribute precision];
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
if (precision)
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSString stringWithFormat:@"%@(%d, %d)", extType, precision,
[attribute scale]];
}
else if ([attribute width])
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSString stringWithFormat: @"%@(%d)",
extType, [attribute width]];
}
else
{
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
return [NSString stringWithFormat: @"%@", extType];
}
}
- (NSString *)allowsNullClauseForConstraint: (BOOL)allowsNull
{
if (allowsNull == NO)
return @"NOT NULL";
return nil;
}
- (void)addCreateClauseForAttribute: (EOAttribute *)attribute
{
NSString *columnType;
NSString *allowsNull;
NSString *str;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
columnType = [self columnTypeStringForAttribute: attribute];
allowsNull = [self allowsNullClauseForConstraint: [attribute allowsNull]];
if (allowsNull)
str = [NSString stringWithFormat: @"%@ %@ %@", [attribute columnName],
columnType, allowsNull];
else
str = [NSString stringWithFormat: @"%@ %@", [attribute columnName],
columnType];
[self appendItem:str toListString: /*_listString*/[self listString]]; // Else no chance to get inited (lazy)
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
}
- (void)prepareConstraintStatementForRelationship: (EORelationship *)relationship
sourceColumns: (NSArray *)sourceColumns
destinationColumns: (NSArray *)destinationColumns
{
NSMutableString *sourceString, *destinationString;
NSEnumerator *attrEnum;
EOAttribute *attr;
NSString *name, *str, *tableName, *relTableName;
BOOL first = YES;
EOFLOGClassFnStartOrCond(@"EOSQLExpression");
name = [NSString stringWithFormat: @"%@_%@_FK", [_entity externalName],
[relationship name]];
sourceString = [NSMutableString stringWithCapacity: 30];
attrEnum = [sourceColumns objectEnumerator];
while ((attr = [attrEnum nextObject]))
{
NSString *columnName = [attr columnName];
if (!columnName || ![columnName length])
continue;
if (first == NO)
[sourceString appendString: @", "];
[sourceString appendString: columnName];
first = NO;
}
first = YES;
destinationString = [NSMutableString stringWithCapacity: 30];
attrEnum = [destinationColumns objectEnumerator];
while ((attr = [attrEnum nextObject]))
{
NSString *columnName = [attr columnName];
if (!columnName || ![columnName length])
continue;
if (first == NO)
[destinationString appendString: @", "];
[destinationString appendString: columnName];
first = NO;
}
tableName = [_entity externalName];
tableName = [self sqlStringForSchemaObjectName: tableName];
relTableName = [[relationship destinationEntity] externalName];
relTableName = [self sqlStringForSchemaObjectName: relTableName];
str = [NSString stringWithFormat: @"ALTER TABLE %@ ADD CONSTRAINT %@ "
@"FOREIGN KEY (%@) REFERENCES %@ (%@)",
tableName,
name,
sourceString,
relTableName,
destinationString];
ASSIGN(_statement, str);
EOFLOGClassFnStopOrCond(@"EOSQLExpression");
}
// Assembles an adaptor specific constraint statement for relationship.
+ (NSArray *)createDatabaseStatementsForConnectionDictionary: (NSDictionary *)connectionDictionary
administrativeConnectionDictionary: (NSDictionary *)administrativeConnectionDictionary
{
[self subclassResponsibility: _cmd];
return nil;
}
+ (NSArray *)dropDatabaseStatementsForConnectionDictionary: (NSDictionary *)connectionDictionary
administrativeConnectionDictionary: (NSDictionary *)administrativeConnectionDictionary
{
[self subclassResponsibility: _cmd];
return nil;
}
+ (EOSQLExpression *)selectStatementForContainerOptions
{
[self notImplemented: _cmd];
return nil;
}
@end

View file

@ -49,41 +49,41 @@ GDL2ACCESS_EXPORT NSString *EOMoreThanOneException;
@interface EOEditingContext (EOUtilities)
- (NSArray *)objectsForEntityNamed: (NSString *)name;
- (NSArray *)objectsForEntityNamed: (NSString *)entityName;
- (NSArray *)objectsOfClass: (Class)classObject;
- (NSArray *)objectsWithFetchSpecificationNamed: (NSString *)fetchSpecName
entityNamed: (NSString *)entityName
bindings: (NSDictionary *)bindings;
- (NSArray *)objectsForEntityNamed: (NSString *)name
- (NSArray *)objectsForEntityNamed: (NSString *)entityName
qualifierFormat: (NSString *)format, ...;
- (NSArray *)objectsMatchingValue: (id)value
forKey: (NSString *)key
entityNamed: (NSString *)name;
entityNamed: (NSString *)entityName;
- (NSArray *)objectsMatchingValues: (NSDictionary *)values
entityNamed: (NSString *)name;
entityNamed: (NSString *)entityName;
- (id)objectWithFetchSpecificationNamed: (NSString *)fetchSpecName
entityNamed: (NSString *)entityName
bindings: (NSDictionary *)bindings;
- (id)objectForEntityNamed: (NSString *)name
- (id)objectForEntityNamed: (NSString *)entityName
qualifierFormat: (NSString *)format, ...;
- (id)objectMatchingValue: (id)value
forKey: (NSString *)key
entityNamed: (NSString *)name;
entityNamed: (NSString *)entityName;
- (id)objectMatchingValues: (NSDictionary *)values
entityNamed: (NSString *)name;
entityNamed: (NSString *)entityName;
- (id)objectWithPrimaryKeyValue: (id)value
entityNamed: (NSString *)name;
entityNamed: (NSString *)entityName;
- (id)objectWithPrimaryKey: (NSDictionary *)pkDict
entityNamed: (NSString *)name;
entityNamed: (NSString *)entityName;
- (NSArray *)rawRowsForEntityNamed: (NSString *)name
- (NSArray *)rawRowsForEntityNamed: (NSString *)entityName
qualifierFormat: (NSString *)format, ...;
- (NSArray *)rawRowsMatchingValue: (id)value
forKey: (NSString *)key
entityNamed: (NSString *)name;
entityNamed: (NSString *)entityName;
- (NSArray *)rawRowsMatchingValues: (NSDictionary *)values
entityNamed: (NSString *)name;
entityNamed: (NSString *)entityName;
- (NSArray *)rawRowsWithSQL: (NSString *)sqlString
modelNamed: (NSString *)name;
- (NSArray *)rawRowsWithStoredProcedureNamed: (NSString *)name
@ -91,7 +91,7 @@ GDL2ACCESS_EXPORT NSString *EOMoreThanOneException;
- (NSDictionary *)executeStoredProcedureNamed: (NSString *)name
arguments: (NSDictionary *)args;
- (id)objectFromRawRow: (NSDictionary *)row
entityNamed: (NSString *)name;
entityNamed: (NSString *)entityName;
- (EODatabaseContext *)databaseContextForModelNamed: (NSString *)name;
- (void)connectWithModelNamed: (NSString *)name
@ -107,9 +107,9 @@ connectionDictionaryOverrides: (NSDictionary *)overrides;
- (NSArray *)localInstancesOfObjects: (NSArray *)objects;
- (EOModelGroup *)modelGroup;
- (EOEntity *)entityNamed: (NSString *)name;
- (EOEntity *)entityNamed: (NSString *)entityName;
- (EOEntity *)entityForClass: (Class)classObject;
- (EOEntity *)entityForObject: (id)obj;
- (EOEntity *)entityForObject: (id)object;
@end
@ -122,12 +122,4 @@ connectionDictionaryOverrides: (NSDictionary *)overrides;
@end
@interface EOObjectStoreCoordinator (EOModelGroup)
- (id)modelGroup;
- (void)setModelGroup: (EOModelGroup *)modelGroup;
@end
#endif

View file

@ -758,7 +758,7 @@ NSString *NSObjectNotAvailableException = @"NSObjectNotAvailableException";
entityNamed: entityName];
}
- (EODatabaseContext *)databaseContextForModelNamed: (NSString *)name;
- (EODatabaseContext *)databaseContextForModelNamed: (NSString *)name
{
EOModelGroup *modelGroup;
EOModel *model;
@ -816,7 +816,7 @@ connectionDictionaryOverrides: (NSDictionary *)overrides
return object;
}
- (NSDictionary *)primaryKeyForObject: (id)object;
- (NSDictionary *)primaryKeyForObject: (id)object
{
EOKeyGlobalID *gid;
EOEntity *entity;
@ -1094,53 +1094,3 @@ connectionDictionaryOverrides: (NSDictionary *)overrides
@end
@implementation EOObjectStoreCoordinator (EOModelGroup)
- (id)modelGroup
{
//Seems OK
EOModelGroup *modelGroup;
NSDictionary *userInfo;
EOFLOGObjectFnStart();
userInfo = [self userInfo];
modelGroup = [userInfo objectForKey: @"EOModelGroup"];
if (!modelGroup)
{
modelGroup = [EOModelGroup defaultGroup];
[self setModelGroup: modelGroup];
}
EOFLOGObjectFnStop();
return modelGroup;
}
- (void)setModelGroup: (EOModelGroup *)modelGroup
{
NSMutableDictionary *userInfo;
EOFLOGObjectFnStart();
userInfo = (NSMutableDictionary *)[self userInfo];
if (userInfo)
[userInfo setObject: modelGroup
forKey: @"EOModelGroup"];
else
{
userInfo = (id)[NSMutableDictionary dictionary];
[userInfo setObject: modelGroup
forKey: @"EOModelGroup"];
[self setUserInfo: userInfo];
}
EOFLOGObjectFnStop();
}
@end

View file

@ -49,6 +49,7 @@ EOAdaptorContext.m \
EOAdaptorChannel.m \
EOAdaptorOperation.m \
EODatabaseOperation.m \
EOSchemaGeneration.m \
EOSQLExpression.m \
EOSQLQualifier.m \
EODatabase.m \

View file

@ -3,6 +3,6 @@ GDL2_AGSDOC_FLAGS = \
-WordMap '{ \
RCS_ID = "//"; \
GDL2CONTROL_EXPORT = extern; \
GDL2ACCESS_EXPORT = extern; \
GDL2INTERFACE_EXPORT = extern; \
}'
# -SystemProjects System \