* EOAccess/EORelationship.m (validateValue:): Document.

Remove unnecessary comments and code.  Handle EONulls.
        (+initialize): Implement.
        (+relationshipWithPropertyList:owner:): Move to top.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20840 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2005-03-03 17:36:16 +00:00
parent 1f9afe4934
commit c1baf1e562
2 changed files with 35 additions and 32 deletions

View file

@ -5,6 +5,11 @@
(-forgetSnapshotsForGlobalIDs:): Ditto.
(-_commitTransaction, -_beginTransaction): Ditto.
(-_rollbackTransaction): Implement.
* EOAccess/EORelationship.m (validateValue:): Document. Remove
unnecessary comments and code. Handle EONulls.
(+initialize): Implement.
(+relationshipWithPropertyList:owner:): Move to top.
2005-03-03 Matt Rice <ratmice@yahoo.com>
David Ayers <d.ayers@inode.at>

View file

@ -73,7 +73,25 @@ RCS_ID("$Id$")
@implementation EORelationship
- init
+ (void)initialize
{
static BOOL initialized = NO;
if (!initialized)
{
initialized = YES;
GDL2_EOAccessPrivateInit();
}
}
+ (id) relationshipWithPropertyList: (NSDictionary *)propertyList
owner: (id)owner
{
return AUTORELEASE([[self alloc] initWithPropertyList: propertyList
owner: owner]);
}
- (id)init
{
//OK
if ((self = [super init]))
@ -185,13 +203,6 @@ RCS_ID("$Id$")
return [_name hash];
}
+ (id) relationshipWithPropertyList: (NSDictionary *)propertyList
owner: (id)owner
{
return [[[self alloc] initWithPropertyList: propertyList
owner: owner] autorelease];
}
- (id) initWithPropertyList: (NSDictionary *)propertyList
owner: (id)owner
{
@ -1722,8 +1733,17 @@ becomes "name", and "FIRST_NAME" becomes "firstName".*/
@end
@implementation EORelationship(EORelationshipValueMapping)
@implementation EORelationship (EORelationshipValueMapping)
/**
* If the reciever is a manditory relationship, this method
* returns an exception if the value pointed to by VALUEP is
* either nil or the EONull instance for to-one relationships
* or an empty NSArray for to-many relationships. Otherwise
* it returns nil. EOClassDescription adds further information
* to this exception before it gets passed to the application or
* user.
*/
- (NSException *)validateValue: (id*)valueP
{
//OK
@ -1737,7 +1757,7 @@ becomes "name", and "FIRST_NAME" becomes "firstName".*/
{
BOOL isToMany = [self isToMany];
if ((isToMany == NO && *valueP == nil)
if ((isToMany == NO && _isNilOrEONull(*valueP))
|| (isToMany == YES && [*valueP count] == 0))
{
EOEntity *destinationEntity = [self destinationEntity];
@ -1748,31 +1768,9 @@ becomes "name", and "FIRST_NAME" becomes "firstName".*/
[self name],
[entity name],
[destinationEntity name]];
/* //TODO userinfo:
userInfo {
EOValidatedObjectUserInfoKey = {
...
};
};
EOValidatedPropertyUserInfoKey = quotationPlace;
}EOValidatedObjectUserInfoKey={
...
};
}
EOValidatedPropertyUserInfoKey=quotationPlace
*/
}
}
if (!exception)
{
NSEmitTODO(); //TODO
NSDebugMLog(@"relationship=%@ valueP=%p",self,valueP);
if (valueP)
NSDebugMLog(@"*valueP=%@",*valueP);
//[self notImplemented:_cmd]; //TODO
}
EOFLOGObjectFnStop();
return exception;