From c1baf1e5623d75e2df9a50526323871a558cf6a3 Mon Sep 17 00:00:00 2001 From: David Ayers Date: Thu, 3 Mar 2005 17:36:16 +0000 Subject: [PATCH] * 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 --- ChangeLog | 5 ++++ EOAccess/EORelationship.m | 62 +++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7dfb4e1..2066323 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 David Ayers diff --git a/EOAccess/EORelationship.m b/EOAccess/EORelationship.m index 2daaf54..47d3933 100644 --- a/EOAccess/EORelationship.m +++ b/EOAccess/EORelationship.m @@ -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;