mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-04-22 12:55:44 +00:00
* EOAccess/EOAttribute.m (-[copyWithZone:]): Override
implementation of GCObject as it isn't safe to copy EOAttributes. * EOAccess/EOEntity.m (-[addAttribute:]); Use NSAsserts to check integrity of parameters. Insure that attribute is not used by other entity or stored procedure. (-[_setModel:]): Rename from -setModel:. Assert that entity is not used by another model. * EOAccess/EOEntityPriv.h (-[_setModel:]): Rename from -setModel:. * EOAccess/EOModel.m (-[_addEntity:]): Use -_setModel: instead of -setModel:. (-[removeEntity:]): Ditto. (-[addEntity:)): Use NSAssert to insure that entity name is unique and that the entity is not being used by other mode. Use -_setModel: instead of -setModel:. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20032 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f91bdc5723
commit
77c1bef3ee
5 changed files with 58 additions and 30 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2004-09-08 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* EOAccess/EOAttribute.m (-[copyWithZone:]): Override
|
||||
implementation of GCObject as it isn't safe to copy EOAttributes.
|
||||
* EOAccess/EOEntity.m (-[addAttribute:]); Use NSAsserts to check
|
||||
integrity of parameters. Insure that attribute is not used by
|
||||
other entity or stored procedure.
|
||||
(-[_setModel:]): Rename from -setModel:. Assert that entity is
|
||||
not used by another model.
|
||||
* EOAccess/EOEntityPriv.h (-[_setModel:]): Rename from
|
||||
-setModel:.
|
||||
* EOAccess/EOModel.m (-[_addEntity:]): Use -_setModel: instead of
|
||||
-setModel:.
|
||||
(-[removeEntity:]): Ditto.
|
||||
(-[addEntity:)): Use NSAssert to insure that entity name is unique
|
||||
and that the entity is not being used by other mode. Use
|
||||
-_setModel: instead of -setModel:.
|
||||
|
||||
2004-09-07 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* EOAccess/EOAttribute.h
|
||||
|
|
|
@ -461,6 +461,14 @@ static Class NSCalendarDateClass;
|
|||
|
||||
return dscr;
|
||||
}
|
||||
|
||||
/* We override GCObjects default implementation
|
||||
as attributes cannot be copied */
|
||||
- (id)copyWithZone:(NSZone *)zone
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (EOEntity *)entity
|
||||
{
|
||||
|
|
|
@ -1926,24 +1926,22 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
{
|
||||
NSString *attributeName = [attribute name];
|
||||
|
||||
if ([[self attributesByName] objectForKey: attributeName])
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"%@ -- %@ 0x%x: \"%@\" already used in the model",
|
||||
NSStringFromSelector(_cmd),
|
||||
NSStringFromClass([self class]),
|
||||
self,
|
||||
attributeName];
|
||||
}
|
||||
if ([[self relationshipsByName] objectForKey: attributeName])
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException format:
|
||||
@"%@ -- %@ 0x%x: \"%@\" already used in the model as relationship",
|
||||
NSStringFromSelector(_cmd),
|
||||
NSStringFromClass([self class]),
|
||||
self,
|
||||
attributeName];
|
||||
}
|
||||
NSAssert2([[self attributesByName] objectForKey: attributeName] == nil,
|
||||
@"'%@': attribute '%@' already used in the entity",
|
||||
[self name],
|
||||
attributeName);
|
||||
|
||||
NSAssert2([[self relationshipsByName] objectForKey: attributeName] == nil,
|
||||
@"'%@': attribute '%@' already used in entity as relationship",
|
||||
[self name],
|
||||
attributeName);
|
||||
|
||||
NSAssert4([attribute parent] == nil,
|
||||
@"'%@': attribute '%@' already owned by '%@' '%@'",
|
||||
[self name],
|
||||
attributeName,
|
||||
NSStringFromClass([[attribute parent] class]),
|
||||
[(EOEntity *)[attribute parent] name]);
|
||||
|
||||
if ([self createsMutableObjects])
|
||||
[(GCMutableArray *)_attributes addObject: attribute];
|
||||
|
@ -2464,7 +2462,7 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
return _flags.createsMutableObjects;
|
||||
}
|
||||
|
||||
- (void)setModel: (EOModel *)model
|
||||
- (void)_setModel: (EOModel *)model
|
||||
{
|
||||
EOFLOGObjectLevelArgs(@"EOEntity", @"setModel=%p", model);
|
||||
|
||||
|
@ -2476,6 +2474,10 @@ createInstanceWithEditingContext:globalID:zone:
|
|||
[_attributesToFetch class],
|
||||
_attributesToFetch);
|
||||
|
||||
NSAssert3((_model == nil || _model == model),
|
||||
@"Attempt to set entity: %@ owned by model: %@ to model: @%.",
|
||||
[self name], [_model name], [model name]);
|
||||
|
||||
_model = model;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
- (void)setCreateMutableObjects: (BOOL)flag;
|
||||
- (BOOL)createsMutableObjects;
|
||||
|
||||
- (void)setModel: (EOModel *)model;
|
||||
- (void)_setModel: (EOModel *)model;
|
||||
- (void)setParentEntity: (EOEntity *)parent;
|
||||
|
||||
-(Class)_classForInstances;
|
||||
|
|
|
@ -1361,7 +1361,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
|||
[self _setEntity: entity
|
||||
forEntityName: [entity name]
|
||||
className: entityClassName];
|
||||
[entity setModel: self];
|
||||
[entity _setModel: self];
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
@ -1438,13 +1438,13 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
|||
// int count;
|
||||
NSString *className = nil;
|
||||
|
||||
if ([self entityNamed: [entity name]])
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"%@ -- %@ 0x%x: \"%@\" already registered as entity name ",
|
||||
NSStringFromSelector(_cmd),
|
||||
NSStringFromClass([self class]),
|
||||
self,
|
||||
entityName];
|
||||
NSAssert1([self entityNamed: [entity name]] == nil,
|
||||
@"Entity '%@' already registered as with this model",
|
||||
entityName);
|
||||
|
||||
NSAssert2([entity model]==nil,
|
||||
@"Entity '%@' is already owned by model '%@'.",
|
||||
[entity name], [[entity model] name]);
|
||||
|
||||
/* Do not access _entities until cache is triggered */
|
||||
if ([self createsMutableObjects])
|
||||
|
@ -1469,14 +1469,14 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
|
|||
|
||||
[_entitiesByName setObject: entity
|
||||
forKey: entityName];
|
||||
[entity setModel: self];
|
||||
[entity _setModel: self];
|
||||
}
|
||||
|
||||
- (void) removeEntity: (EOEntity *)entity
|
||||
{
|
||||
NSString *className = nil;
|
||||
|
||||
[entity setModel: nil];
|
||||
[entity _setModel: nil];
|
||||
[_entitiesByName removeObjectForKey: [entity name]];
|
||||
|
||||
NSAssert(_entitiesByClass, @"No _entitiesByClass");
|
||||
|
|
Loading…
Reference in a new issue