libs-gdl2/EOAccess/EORelationship.m

2396 lines
65 KiB
Mathematica
Raw Normal View History

/**
EORelationship.m <title>EORelationship</title>
Copyright (C) 2000-2002,2003,2004,2005 Free Software Foundation, Inc.
Author: Mirko Viviani <mirko.viviani@gmail.com>
Date: February 2000
Author: Manuel Guesdon <mguesdon@orange-concept.com>
Date: October 2000
$Revision$
$Date$
<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 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</license>
**/
#include "config.h"
RCS_ID("$Id$")
#ifdef GNUSTEP
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#include <Foundation/NSArray.h>
#include <Foundation/NSException.h>
#include <Foundation/NSDebug.h>
#else
#include <Foundation/Foundation.h>
#endif
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#include <GNUstepBase/GSObjCRuntime.h>
* EOAccess/EOAdaptor.m: Include GNUstep-specific headers for non-GNUstep systems. * EOAccess/EOAdaptorChannel.m: Ditto. * EOAccess/EOAdaptorContext.m: Ditto. * EOAccess/EOAttribute.m: Ditto. * EOAccess/EODatabaseChannel.m: Ditto. * EOAccess/EODatabaseDataSource.m: Ditto. * EOAccess/EOEntity.m: Ditto. * EOAccess/EOModel.m: Ditto. * EOAccess/EOModelGroup.m: Ditto. * EOAccess/EORelationship.m: Ditto. * EOAccess/EOSQLQualifier.m: Ditto. * EOAccess/EOUtilities.m: Ditto. * EOControl/EOAndQualifier.m: Ditto. * EOControl/EOClassDescription.m: Ditto. * EOControl/EODataSource.m: Ditto. * EOControl/EOEditingContext.m: Ditto. * EOControl/EOFault.m: Ditto. * EOControl/EOFaultHandler.m: Ditto. * EOControl/EOFetchSpecification.m: Ditto. * EOControl/EOKeyValueArchiver.m: Ditto. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EOMutableKnownKeyDictionary.m: Ditto. * EOControl/EONSAddOns.m: Ditto. * EOControl/EOObjectStore.m: Ditto. * EOControl/EOObjectStoreCoordinator.m: Ditto. * EOControl/EOObserver.m: Ditto. * EOControl/EOOrQualifier.m: Ditto. * EOControl/EOQualifier.m: Ditto. * EOControl/EOUndoManager.m: Ditto. * EOModeler/EOModelExtensions.m: Ditto. * EOAccess/EOModel.h/m (+/-[EOModel version]) Remove. ([EOModel init]): Handle version internally. ([EOModel encodeTableOfContentsIntoPropertyList:]): Ditto. ([EOModel encodeIntoPropertyList:]): Ditto. * EOAccess/EODatabaseContext.m ([EODatabaseContext dealloc]): Use NSCountHashTable instead of NSCountMapTable on hash table. * EOAccess/EOAttribute.m ([EOAttribute newValueForBytes:length:]): Added casts to avoid warnings. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@18500 72102866-910b-0410-8b05-ffd578937521
2004-01-29 13:23:22 +00:00
#include <GNUstepBase/GSCategories.h>
#endif
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#include <EOControl/EOObserver.h>
#include <EOControl/EOMutableKnownKeyDictionary.h>
#include <EOControl/EONSAddOns.h>
#include <EOControl/EODebug.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOEntity.h>
#include <EOAccess/EOStoredProcedure.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOJoin.h>
#include <EOAccess/EOExpressionArray.h>
* EOControl/EOPriv.h/m: Split into... * EOControl/EOPrivat.h/m: ... and ... * EOAccess/EOPrivat.h/m: ... files. * EOAccess/EOAdaptorChannel.m: Include new privat header. * EOAccess/EOAttribute.m, EOAccess/EODatabase.m, * EOAccess/EODatabaseChannel.m, EOAccess/EOEntity.m, * EOAccess/EORelationship.m, EOAccess/EOSQLExpression.m, * EOAccess/EOSQLQualifier.m, EOAccess/EOUtilities.m: Ditto. (+initialize): Call new private function. * EOAccess/EODatabaseContext.m: Ditto. (EODatabaseContext_snapshotForGlobalIDWithImpPtr) (EODatabaseContext_globalIDForObjectWithImpPtr): Move to EOPrivate.m. * EOAccess/EODatabaseContextPriv.h: (EODatabaseContext_snapshotForGlobalIDWithImpPtr) (EODatabaseContext_globalIDForObjectWithImpPtr): Move to EOPrivate.h. * EOAccess/GNUmakefile: Compile EOPrivate.m. * EOControl/EOClassDescription.m, EOControl/EOGenericRecord.m * EOControl/EOKeyGlobalID.m, EOControl/EOKeyValueCoding.m * EOControl/EOKeyValueQualifier.m, EOControl/EONSAddOns.m * EOControl/EOSortOrdering.m: Include new private header. * EOControl/EOEditingContext.h/m: Ditto. (EOEditingContext_objectForGlobalIDWithImpPtr) (EOEditingContext_recordObjectGlobalIDWithImpPtr): Move to EOPrivate.h/m. * EOControl/EOMutableKnownKeyDictionary.h/m: Include new private header. (EOMKKD_objectForKeyWithImpPtr, EOMKKD_setObjectForKeyWithImpPtr) (EOMKKD_removeObjectForKeyWithImpPtr, EOMKKD_hasKeyWithImpPtr) (EOMKKD_indexForKeyWithImpPtr) (EOMKKDInitializer_indexForKeyWithImpPtr): Move to EOPrivate.m * EOControl/EOFault.m: (+isFault:): Update comment. * EOControl/GNUmakefile: Build EOPrivate.m instead of EOPriv.m. Do not install private header. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20759 72102866-910b-0410-8b05-ffd578937521
2005-02-20 10:52:57 +00:00
#include "EOPrivate.h"
* EOAccess/EOAccessFault.m: Include privat headers locally. * EOAccess/EOAdaptor.m: Ditto. * EOAccess/EOAdaptorChannel.m: Ditto. * EOAccess/EOAdaptorContext.m: Ditto. * EOAccess/EOAttribute.m: Ditto. * EOAccess/EODatabaseChannel.m: Ditto. * EOAccess/EODatabaseContext.m: Ditto. * EOAccess/EODatabaseOperation.m: Ditto. * EOAccess/EOModel.m: Ditto. * EOAccess/EORelationship.m: Ditto. * EOAccess/EOSQLExpression.m: Ditto. * EOAccess/EOSQLQualifier.m: Ditto. * EOAccess/EOEntity.h: Remove declarations of privat methods. Reorder declaraions. (+[entity], +[entityWithPropertyList:owner:]): Deprecate. (-[sharedObjectFetchSpecificationNames]): New method. (-[setSharedObjectFetchSpecificationsByName:]: Ditto. (-[addSharedObjectFetchSpecificationByName:]: Ditto. (-[removeSharedObjectFetchSpecificationByName:]: Ditto. * EOAccess/EOEntityPriv.h: Add declarations of privat methods. Reorder declarations. * EOAccess/EOEntity.m: Reorder implementations according to headers. Include privat headers locally. (+[entity], +[entityWithPropertyList:owner:]): Deprecate. (-[sharedObjectFetchSpecificationNames]): New method. (-[setSharedObjectFetchSpecificationsByName:]: Ditto. (-[addSharedObjectFetchSpecificationByName:]: Ditto. (-[removeSharedObjectFetchSpecificationByName:]: Ditto. * EOAccess/EOEntity.m: Adapt usage of deprecated -[entity...] and privat methods. * EOAccess/EOModel.m: Ditto. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: Ditto. * TODO: Add comment. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@19772 72102866-910b-0410-8b05-ffd578937521
2004-07-23 18:33:29 +00:00
#include "EOAttributePriv.h"
#include "EOEntityPriv.h"
@implementation EORelationship
+ (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]))
{
/* _sourceNames = [NSMutableDictionary new];
_destinationNames = [NSMutableDictionary new];
_userInfo = [NSDictionary new];
_sourceToDestinationKeyMap = [NSDictionary new];
_joins = [NSMutableArray new];
*/
}
return self;
}
- (void)dealloc
{
DESTROY(_name);
DESTROY(_qualifier);
DESTROY(_sourceNames);
DESTROY(_destinationNames);
DESTROY(_userInfo);
DESTROY(_internalInfo);
DESTROY(_docComment);
DESTROY(_sourceToDestinationKeyMap);
DESTROY(_sourceRowToForeignKeyMapping);
[super dealloc];
}
- (unsigned)hash
{
return [_name hash];
}
- (id) initWithPropertyList: (NSDictionary *)propertyList
owner: (id)owner
{
//Near OK
if ((self = [self init]))
{
NSString *joinSemanticString = nil;
EOModel *model;
NSString* destinationEntityName = nil;
EOEntity* destinationEntity = nil;
NSString* deleteRuleString = nil;
NSString* relationshipName;
EOFLOGObjectFnStart();
model = [owner model];
relationshipName = [propertyList objectForKey: @"name"];
[self setName: relationshipName];
[self setEntity: owner];
[self setCreateMutableObjects: YES];
destinationEntityName = [propertyList objectForKey: @"destination"];
if (destinationEntityName) //If not, this is because it's a definition
{
destinationEntity = [model entityNamed: destinationEntityName];
GDL2DestinationEntitiesRemoveRelationship(_destination, self);
GDL2DestinationEntitiesAddRelationship(destinationEntity, self);
_destination = destinationEntity;
}
[self setToMany: [[propertyList objectForKey: @"isToMany"]
isEqual: @"Y"]];
[self setIsMandatory: [[propertyList objectForKey: @"isMandatory"]
isEqual:@"Y"]];
[self setOwnsDestination: [[propertyList
objectForKey: @"ownsDestination"]
isEqual: @"Y"]];
[self setPropagatesPrimaryKey: [[propertyList
objectForKey: @"propagatesPrimaryKey"]
isEqual: @"Y"]];
[self setIsBidirectional: [[propertyList objectForKey: @"isBidirectional"]
isEqual: @"Y"]];
[self setUserInfo: [propertyList objectForKey: @"userInfo"]];
if(!_userInfo)
[self setUserInfo: [propertyList objectForKey: @"userDictionary"]];
[self setInternalInfo: [propertyList objectForKey: @"internalInfo"]];
[self setDocComment: [propertyList objectForKey: @"docComment"]];
joinSemanticString = [propertyList objectForKey: @"joinSemantic"];
if (joinSemanticString)
{
if ([joinSemanticString isEqual: @"EOInnerJoin"])
[self setJoinSemantic: EOInnerJoin];
else if ([joinSemanticString isEqual: @"EOFullOuterJoin"])
[self setJoinSemantic: EOFullOuterJoin];
else if ([joinSemanticString isEqual: @"EOLeftOuterJoin"])
[self setJoinSemantic: EOLeftOuterJoin];
else if ([joinSemanticString isEqual: @"EORightOuterJoin"])
[self setJoinSemantic: EORightOuterJoin];
else
{
EOFLOGObjectLevelArgs(@"EORelationship", @"Unknown joinSemanticString=%@. entityName=%@ relationshipName=%@",
joinSemanticString,
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
[(EOEntity*)owner name],
relationshipName);
NSEmitTODO(); //TODO
[self notImplemented: _cmd]; //TODO
}
}
else
{
if (destinationEntityName)
{
EOFLOGObjectLevelArgs(@"EORelationship", @"!joinSemanticString but destinationEntityName. entityName=%@ relationshipName=%@",
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
[(EOEntity*)owner name],
relationshipName);
NSEmitTODO(); //TODO
[self notImplemented: _cmd]; //TODO
}
}
deleteRuleString = [propertyList objectForKey: @"deleteRule"];
EOFLOGObjectLevelArgs(@"EORelationship", @"entityName=%@ relationshipName=%@ deleteRuleString=%@",
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
[(EOEntity*)owner name],
relationshipName,
deleteRuleString);
if (deleteRuleString)
{
EODeleteRule deleteRule = [self _deleteRuleFromString:
deleteRuleString];
EOFLOGObjectLevelArgs(@"EORelationship",
@"entityName=%@ relationshipName=%@ deleteRule=%d",
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
[(EOEntity*)owner name],
relationshipName,
(int)deleteRule);
NSAssert2(deleteRule >= 0 && deleteRule < 4,
@"Bad deleteRule numeric value: %@ (%d)",
deleteRuleString,
deleteRule);
[self setDeleteRule: deleteRule];
}
}
EOFLOGObjectFnStop();
return self;
}
- (void)awakeWithPropertyList: (NSDictionary *)propertyList //TODO
{
//OK for definition
NSString *definition;
EOFLOGObjectFnStart();
EOFLOGObjectLevelArgs(@"EORelationship", @"self=%@", self);
definition = [propertyList objectForKey: @"definition"];
EOFLOGObjectLevelArgs(@"EORelationship", @"definition=%@", definition);
if (definition)
{
[self setDefinition: definition];
}
else
{
NSString *dataPath = [propertyList objectForKey: @"dataPath"];
EOFLOGObjectLevelArgs(@"EORelationship", @"dataPath=%@", dataPath);
if (dataPath)
{
NSEmitTODO(); //TODO
[self notImplemented: _cmd]; // TODO
}
else
{
NSArray *joins = [propertyList objectForKey: @"joins"];
int count = [joins count];
EOFLOGObjectLevelArgs(@"EORelationship", @"joins=%@", joins);
if (count > 0)
{
int i;
for (i = 0; i < count; i++)
{
NSDictionary *joinPList;
NSString *joinSemantic;
NSString *sourceAttributeName;
EOAttribute *sourceAttribute;
EOEntity *destinationEntity;
NSString *destinationAttributeName = nil;
EOAttribute *destinationAttribute = nil;
EOJoin *join = nil;
joinPList = [joins objectAtIndex: i];
joinSemantic = [joinPList objectForKey: @"joinSemantic"];
sourceAttributeName = [joinPList objectForKey:
@"sourceAttribute"];
sourceAttribute = [_entity attributeNamed:
sourceAttributeName];
NSAssert4(sourceAttribute, @"No sourceAttribute named \"%@\" in entity \"%@\" in relationship %@\nEntity: %@",
sourceAttributeName,
[_entity name],
self,
_entity);
destinationEntity = [self destinationEntity];
NSAssert3(destinationEntity,@"No destination entity for relationship named '%@' in entity named '%@': %@",
[self name],
[[self entity]name],
self);
destinationAttributeName = [joinPList
objectForKey:
@"destinationAttribute"];
destinationAttribute = [destinationEntity
attributeNamed:
destinationAttributeName];
NSAssert4(destinationAttribute, @"No destinationAttribute named \"%@\" in entity \"%@\" in relationship %@\nEntity: %@",
destinationAttributeName,
[destinationEntity name],
self,
destinationEntity);
NS_DURING
{
join = [EOJoin joinWithSourceAttribute: sourceAttribute
destinationAttribute: destinationAttribute];
}
NS_HANDLER
{
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: cannot create join for relationship '%@': %@",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
[self name],
[localException reason]];
}
NS_ENDHANDLER;
EOFLOGObjectLevelArgs(@"EORelationship", @"join=%@", join);
[self addJoin: join];
}
}
/*
NSArray *array;
NSEnumerator *enumerator;
EOModel *model = [_entity model];
id joinPList;
if(_destination)
{
id destinationEntityName = [_destination autorelease];
_destination = [[model entityNamed:destinationEntityName] retain];
if(!_destination)
{
NSEmitTODO(); //TODO
[self notImplemented:_cmd]; // TODO
}
}
*/
}
}
/* ??
if(!(_destination || _definitionArray))
{
NSEmitTODO(); //TODO
[self notImplemented:_cmd]; // TODO
};
*/
[self setCreateMutableObjects: NO]; //?? tc say yes, mirko no
EOFLOGObjectFnStop();
}
- (void)encodeIntoPropertyList: (NSMutableDictionary *)propertyList
{
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
NS_DURING //Just for debugging
{
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
//VERIFY
[propertyList setObject: [self name]
forKey: @"name"];
if ([self isFlattened])
{
NSString *definition = [self definition];
NSAssert(definition,@"No definition");
[propertyList setObject: definition
forKey: @"definition"];
}
else
{
[propertyList setObject: ([self isToMany] ? @"Y" : @"N")
forKey: @"isToMany"];
if ([self destinationEntity])
{
NSAssert2([[self destinationEntity] name],
@"No entity name in relationship named %@ entity named %@",
[self name],
[[self entity]name]);
[propertyList setObject: [[self destinationEntity] name] // if we put entity, it loops !!
forKey: @"destination"];
};
}
if ([self isMandatory])
[propertyList setObject: @"Y"
forKey: @"isMandatory"];
if ([self ownsDestination])
{
NSEmitTODO(); //TODO
}
if ([self propagatesPrimaryKey])
{
NSEmitTODO(); //TODO
}
{
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
int joinsCount = [_joins count];
if (joinsCount > 0)
{
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
NSMutableArray *joinsArray = [NSMutableArray array];
int i = 0;
for(i = 0; i < joinsCount; i++)
{
NSMutableDictionary *joinDict = [NSMutableDictionary dictionary];
EOJoin *join = [_joins objectAtIndex: i];
NSAssert([[join sourceAttribute] name],
@"No source attribute name");
[joinDict setObject: [[join sourceAttribute] name]
forKey: @"sourceAttribute"];
NSAssert([[join destinationAttribute] name],
@"No destination attribute name");
[joinDict setObject: [[join destinationAttribute] name]
forKey: @"destinationAttribute"];
[joinsArray addObject: joinDict];
}
[propertyList setObject: joinsArray
forKey: @"joins"];
}
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
NSAssert([self joinSemanticString],
@"No joinSemanticString");
[propertyList setObject: [self joinSemanticString]
forKey: @"joinSemantic"];
}
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
}
NS_HANDLER
{
NSLog(@"exception in EORelationship encodeIntoPropertyList: self=%p class=%@",
self, [self class]);
NSDebugMLog(@"exception in EORelationship encodeIntoPropertyList: self=%p class=%@",
self, [self class]);
NSLog(@"exception=%@", localException);
NSDebugMLog(@"exception=%@", localException);
[localException raise];
}
NS_ENDHANDLER;
}
- (NSString *)description
{
NSString *dscr = nil;
NS_DURING //Just for debugging
{
dscr = [NSString stringWithFormat: @"<%s %p - name=%@ entity=%@ destinationEntity=%@ definition=%@",
object_get_class_name(self),
(void*)self,
[self name],
[[self entity]name],
[[self destinationEntity] name],
[self definition]];
dscr = [dscr stringByAppendingFormat: @" userInfo=%@",
[self userInfo]];
dscr = [dscr stringByAppendingFormat: @" joins=%@",
[self joins]];
dscr = [dscr stringByAppendingFormat: @" sourceAttributes=%@",
[self sourceAttributes]];
dscr = [dscr stringByAppendingFormat: @" destinationAttributes=%@",
[self destinationAttributes]];
/*TODO dscr = [dscr stringByAppendingFormat:@" componentRelationships=%@",
[self componentRelationships]];*/
dscr = [dscr stringByAppendingFormat: @" isCompound=%s isFlattened=%s isToMany=%s isBidirectional=%s>",
([self isCompound] ? "YES" : "NO"),
([self isFlattened] ? "YES" : "NO"),
([self isToMany] ? "YES" : "NO"),
([self isBidirectional] ? "YES" : "NO")];
}
NS_HANDLER
{
NSLog(@"exception in EORelationship description: self=%p class=%@",
self, [self class]);
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
NSDebugMLog(@"exception in EORelationship description: self=%p class=%@",
self, [self class]);
NSLog(@"exception=%@", localException);
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
NSDebugMLog(@"exception=%@", localException);
[localException raise];
}
NS_ENDHANDLER;
return dscr;
}
- (NSString *)name
{
return _name;
}
/** Returns the relationship's source entity. **/
- (EOEntity *)entity
{
return _entity;
}
/** Returns the relationship's destination entity (direct destination entity or
destination entity of the last relationship in definition. **/
- (EOEntity *)destinationEntity
{
//OK
// May be we could cache destination ? Hard to do because klast relationship may have its destination entity change.
EOEntity *destinationEntity = _destination;
if (!destinationEntity)
{
if ([self isFlattened])
{
EORelationship *lastRelationship = [_definitionArray lastObject];
destinationEntity = [lastRelationship destinationEntity];
NSAssert3(destinationEntity, @"No destinationEntity in last relationship: %@ of relationship %@ in entity %@",
lastRelationship, self, [_entity name]);
}
}
else if ([destinationEntity isKindOfClass: [NSString class]] == YES)
destinationEntity = [[_entity model]
entityNamed: (NSString*)destinationEntity];
return destinationEntity;
}
- (BOOL) isParentRelationship
{
BOOL isParentRelationship = NO;
/*EOEntity *destinationEntity = [self destinationEntity];
EOEntity *parentEntity = [_entity parentEntity];*///nil
NSEmitTODO(); //TODO
// [self notImplemented:_cmd]; //TODO...
return isParentRelationship;
}
/** Returns YES when the relationship traverses at least two entities
(exemple: aRelationship.anotherRelationship), NO otherwise.
**/
- (BOOL)isFlattened
{
if (_definitionArray)
return [_definitionArray isFlattened];
else
return NO;
}
/** return YES if the relation if a to-many one, NO otherwise (please read books
to know what to-many mean :-) **/
- (BOOL)isToMany
{
return _flags.isToMany;
}
/** Returns YES if the relationship have more than 1 join (i.e. join on more that one (sourceAttribute/destinationAttribute), NO otherwise (1 or less join) **/
- (BOOL)isCompound
{
//OK
return [_joins count] > 1;
}
- (NSArray *)joins
{
return _joins;
}
- (NSArray *)sourceAttributes
{
//OK
if (!_sourceAttributes)
{
int i, count = [_joins count];
_sourceAttributes = [NSMutableArray new];
for (i = 0; i < count; i++)
{
EOJoin *join = [_joins objectAtIndex: i];
[(NSMutableArray*)_sourceAttributes addObject:
[join sourceAttribute]];
}
}
return _sourceAttributes;
}
- (NSArray *)destinationAttributes
{
//OK
if (!_destinationAttributes)
{
int i, count = [_joins count];
_destinationAttributes = [NSMutableArray new];
for (i = 0; i < count; i++)
{
EOJoin *join = [_joins objectAtIndex: i];
[(NSMutableArray *)_destinationAttributes addObject:
[join destinationAttribute]];
}
}
return _destinationAttributes;
}
- (EOJoinSemantic)joinSemantic
{
return _joinSemantic;
}
- (NSString*)joinSemanticString
{
NSString *joinSemanticString = nil;
switch ([self joinSemantic])
{
case EOInnerJoin:
joinSemanticString = @"EOInnerJoin";
break;
case EOFullOuterJoin:
joinSemanticString = @"EOFullOuterJoin";
break;
case EOLeftOuterJoin:
joinSemanticString = @"EOLeftOuterJoin";
break;
case EORightOuterJoin:
joinSemanticString = @"EORightOuterJoin";
break;
default:
NSAssert1(NO, @"Unknwon join semantic code %d",
(int)[self joinSemantic]);
break;
}
return joinSemanticString;
}
- (NSArray *)componentRelationships
{
if (!_componentRelationships)
{
return _definitionArray; //OK ??????
NSEmitTODO(); //TODO
[self notImplemented: _cmd]; //TODO
}
return _componentRelationships;
}
- (NSDictionary *)userInfo
{
return _userInfo;
}
- (NSString *)docComment
{
return _docComment;
}
- (NSString *)definition
{
//OK
NSString *definition = nil;
NS_DURING //Just for debugging
{
definition = [_definitionArray valueForSQLExpression: nil];
}
NS_HANDLER
{
NSLog(@"exception in EORelationship definition: self=%p class=%@",
self, [self class]);
NSLog(@"exception in EORelationship definition: self=%@ _definitionArray=%@",
self, _definitionArray);
NSLog(@"exception=%@", localException);
[localException raise];
}
NS_ENDHANDLER;
return definition;
}
/** Returns the value to use in an EOSQLExpression. **/
- (NSString*) valueForSQLExpression: (EOSQLExpression*)sqlExpression
{
EOFLOGObjectLevelArgs(@"EORelationship", @"EORelationship %p", self);
NSEmitTODO(); //TODO
// return [self notImplemented:_cmd]; //TODO
//return name ??
return [self name];
}
- (BOOL)referencesProperty: (id)property
{
BOOL referencesProperty = NO;
NSArray *srcAttribs = [self sourceAttributes];
NSArray *destAttribs = [self destinationAttributes];
NSArray *compRels = [self componentRelationships];
NSEmitTODO(); //TODO
EOFLOGObjectLevelArgs(@"EORelationship", @"in referencesProperty:%@",
property);
referencesProperty =
((srcAttribs
&& [srcAttribs indexOfObject: property] != NSNotFound)
|| (destAttribs
&& [destAttribs indexOfObject: property] != NSNotFound)
|| (compRels
&& [compRels indexOfObject: property] != NSNotFound));
return referencesProperty;
}
- (EODeleteRule)deleteRule
{
EOFLOGObjectFnStart();
EOFLOGObjectFnStop();
return _flags.deleteRule;
}
- (BOOL)isMandatory
{
return _flags.isMandatory;
}
- (BOOL)propagatesPrimaryKey
{
return _flags.propagatesPrimaryKey;
}
- (BOOL)isBidirectional
{
return _flags.isBidirectional;
}
- (BOOL)isReciprocalToRelationship: (EORelationship *)relationship
{
//Should be OK
//Ayers: Review
BOOL isReciprocal = NO;
EOEntity *entity;
EOEntity *relationshipDestinationEntity = nil;
EOFLOGObjectFnStart();
entity = [self entity]; //OK
relationshipDestinationEntity = [relationship destinationEntity];
EOFLOGObjectLevelArgs(@"EORelationship", @"entity %p name=%@",
entity, [entity name]);
EOFLOGObjectLevelArgs(@"EORelationship",
@"relationshipDestinationEntity %p name=%@",
relationshipDestinationEntity,
[relationshipDestinationEntity name]);
if (entity == relationshipDestinationEntity) //Test like that ?
{
if ([self isFlattened]) //OK
{
if ([relationship isFlattened]) //OK
{
//Now compare each components in reversed order
NSArray *selfComponentRelationships =
[self componentRelationships];
NSArray *relationshipComponentRelationships =
[relationship componentRelationships];
int selfComponentRelationshipsCount =
[selfComponentRelationships count];
int relationshipComponentRelationshipsCount =
[relationshipComponentRelationships count];
//May be we can imagine that they may not have the same number of components //TODO
if (selfComponentRelationshipsCount
== relationshipComponentRelationshipsCount)
{
int i, j;
BOOL foundEachInverseComponent = YES;
for(i = (selfComponentRelationshipsCount - 1), j = 0;
foundEachInverseComponent && i >= 0;
i--, j++)
{
EORelationship *selfRel =
[selfComponentRelationships objectAtIndex: i];
EORelationship *relationshipRel =
[relationshipComponentRelationships objectAtIndex: j];
foundEachInverseComponent =
[selfRel isReciprocalToRelationship: relationshipRel];
}
if (foundEachInverseComponent)
isReciprocal = YES;
}
}
else
{
//Just do nothing and try another relationship.
// Is it the good way ?
/*
NSEmitTODO(); //TODO
NSDebugMLog(@"entity %p name=%@ self name=%@ relationship name=%@ relationshipDestinationEntity %p name=%@",
entity, [entity name],
[self name],
[relationship name],
relationshipDestinationEntity,
[relationshipDestinationEntity name]);
[self notImplemented: _cmd]; //TODO
*/
}
}
else
{
//WO doens't test inverses entity
EOEntity *relationshipEntity = [relationship entity];
EOEntity *destinationEntity = [self destinationEntity];
EOFLOGObjectLevelArgs(@"EORelationship",
@"relationshipEntity %p name=%@",
relationshipEntity, [relationshipEntity name]);
EOFLOGObjectLevelArgs(@"EORelationship",
@"destinationEntity %p name=%@",
destinationEntity, [destinationEntity name]);
if (relationshipEntity == destinationEntity)
{
NSArray *joins = [self joins];
NSArray *relationshipJoins = [relationship joins];
int joinsCount = [joins count];
int relationshipJoinsCount = [relationshipJoins count];
EOFLOGObjectLevelArgs(@"EORelationship",
@"joinsCount=%d,relationshipJoinsCount=%d",
joinsCount, relationshipJoinsCount);
if (joinsCount == relationshipJoinsCount)
{
BOOL foundEachInverseJoin = YES;
int iJoin;
for (iJoin = 0;
foundEachInverseJoin && iJoin < joinsCount;
iJoin++)
{
EOJoin *join = [joins objectAtIndex: iJoin];
int iRelationshipJoin;
BOOL foundInverseJoin = NO;
EOFLOGObjectLevelArgs(@"EORelationship", @"%d join=%@",
iJoin, join);
for (iRelationshipJoin = 0;
!foundInverseJoin && iRelationshipJoin < joinsCount;
iRelationshipJoin++)
{
EOJoin *relationshipJoin =
[relationshipJoins objectAtIndex:iRelationshipJoin];
EOFLOGObjectLevelArgs(@"EORelationship",
@"%d relationshipJoin=%@",
iRelationshipJoin,
relationshipJoin);
foundInverseJoin = [relationshipJoin
isReciprocalToJoin: join];
EOFLOGObjectLevelArgs(@"EORelationship",
@"%d foundInverseJoin=%s",
iRelationshipJoin,
(foundInverseJoin ? "YES" : "NO"));
}
if (!foundInverseJoin)
foundEachInverseJoin = NO;
EOFLOGObjectLevelArgs(@"EORelationship",
@"%d foundEachInverseJoin=%s",
iJoin,
(foundEachInverseJoin ? "YES" : "NO"));
}
EOFLOGObjectLevelArgs(@"EORelationship",
@"foundEachInverseJoin=%s",
(foundEachInverseJoin ? "YES" : "NO"));
if (foundEachInverseJoin)
isReciprocal = YES;
}
}
}
}
EOFLOGObjectFnStop();
return isReciprocal;
}
/** "Search only already created inverse relationship in destination entity
relationships. Nil if none" **/
- (EORelationship *)inverseRelationship
{
//OK
EOFLOGObjectFnStart();
if (!_inverseRelationship)
{
EOEntity *destinationEntity;
NSArray *destinationEntityRelationships;
destinationEntity = [self destinationEntity];
NSDebugLog(@"destinationEntity name=%@", [destinationEntity name]);
destinationEntityRelationships = [destinationEntity relationships];
NSDebugLog(@"destinationEntityRelationships=%@",
destinationEntityRelationships);
if ([destinationEntityRelationships count] > 0)
{
int i, count = [destinationEntityRelationships count];
for (i = 0; !_inverseRelationship && i < count; i++)
{
EORelationship *testRelationship =
[destinationEntityRelationships objectAtIndex: i];
NSDebugLog(@"testRelationship=%@", testRelationship);
if ([self isReciprocalToRelationship: testRelationship])
{
ASSIGN(_inverseRelationship, testRelationship);
}
}
}
NSDebugLog(@"_inverseRelationship=%@", _inverseRelationship);
}
EOFLOGObjectFnStop();
return _inverseRelationship;
}
- (EORelationship *) _makeFlattenedInverseRelationship
{
//OK
EORelationship *inverseRelationship = nil;
NSMutableString *invDefinition = nil;
NSString *name = nil;
int i, count;
EOFLOGObjectFnStart();
NSAssert([self isFlattened], @"Not Flatten Relationship");
EOFLOGObjectLevel(@"EORelationship", @"add joins");
count = [_definitionArray count];
for (i = count - 1; i >= 0; i--)
{
EORelationship *rel = [_definitionArray objectAtIndex: i];
EORelationship *invRel = [rel anyInverseRelationship];
NSString *invRelName = [invRel name];
if (invDefinition)
{
if (i < (count - 1))
[invDefinition appendString: @"."];
[invDefinition appendString: invRelName];
}
else
invDefinition = [NSMutableString stringWithString: invRelName];
}
inverseRelationship = [[EORelationship new] autorelease];
[inverseRelationship setEntity: [self destinationEntity]];
name = [NSString stringWithFormat: @"_eofInv_%@_%@",
[_entity name],
_name];
[inverseRelationship setName: name];
[inverseRelationship setDefinition: invDefinition];
EOFLOGObjectLevel(@"EORelationship", @"add inverse rel");
[(NSMutableArray*)[[self destinationEntity] _hiddenRelationships]
addObject: inverseRelationship]; //not very clean !!!
EOFLOGObjectLevel(@"EORelationship", @"set inverse rel");
[inverseRelationship setInverseRelationship: self];
EOFLOGObjectFnStop();
return inverseRelationship;
}
- (EORelationship*) _makeInverseRelationship
{
//OK
EORelationship *inverseRelationship;
NSString *name;
NSArray *joins = nil;
int i, count;
EOFLOGObjectFnStart();
NSAssert(![self isFlattened], @"Flatten Relationship");
inverseRelationship = [[EORelationship new] autorelease];
[inverseRelationship setEntity: _destination];
name = [NSString stringWithFormat: @"_eofInv_%@_%@",
[_entity name],
_name];
[inverseRelationship setName: name];
joins = [self joins];
count = [joins count];
EOFLOGObjectLevel(@"EORelationship", @"add joins");
for (i = 0; i < count; i++)
{
EOJoin *join = [joins objectAtIndex: i];
EOAttribute *sourceAttribute = [join sourceAttribute];
EOAttribute *destinationAttribute = [join destinationAttribute];
EOJoin *inverseJoin = [EOJoin joinWithSourceAttribute:
destinationAttribute //inverse souce<->destination attributes
destinationAttribute: sourceAttribute];
[inverseRelationship addJoin: inverseJoin];
}
EOFLOGObjectLevel(@"EORelationship",@"add inverse rel");
[(NSMutableArray*)[[self destinationEntity] _hiddenRelationships]
addObject: inverseRelationship]; //not very clean !!!
EOFLOGObjectLevel(@"EORelationship", @"set inverse rel");
[inverseRelationship setInverseRelationship: self];
EOFLOGObjectFnStop();
return inverseRelationship;
}
- (EORelationship*) hiddenInverseRelationship
{
//OK
EOFLOGObjectFnStart();
if (!_hiddenInverseRelationship)
{
if ([self isFlattened])
_hiddenInverseRelationship = [self _makeFlattenedInverseRelationship];
else
_hiddenInverseRelationship = [self _makeInverseRelationship];
}
EOFLOGObjectFnStop();
return _hiddenInverseRelationship;
}
- (EORelationship *)anyInverseRelationship
{
//OK
EORelationship *inverseRelationship = [self inverseRelationship];
if (!inverseRelationship)
inverseRelationship = [self hiddenInverseRelationship];
return inverseRelationship;
}
- (unsigned int)numberOfToManyFaultsToBatchFetch
{
return _batchCount;
}
- (BOOL)ownsDestination
{
return _flags.ownsDestination;
}
- (EOQualifier *)qualifierWithSourceRow: (NSDictionary *)sourceRow
{
[self notImplemented: _cmd];//TODO
return nil;
}
@end /* EORelationship */
@implementation EORelationship (EORelationshipEditing)
- (NSException *)validateName: (NSString *)name
{
//Seems OK
const char *p, *s = [name cString];
int exc = 0;
NSArray *storedProcedures = nil;
if ([_name isEqual:name]) return nil;
if (!name || ![name length])
exc++;
if (!exc)
{
p = s;
while (*p)
{
if(!isalnum(*p) &&
*p != '@' && *p != '#' && *p != '_' && *p != '$')
{
exc++;
break;
}
p++;
}
if (!exc && *s == '$')
exc++;
if (exc)
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat: @"%@ -- %@ 0x%x: argument \"%@\" contains invalid char '%c'",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name,
*p]
userInfo: nil];
if ([[self entity] anyAttributeNamed: name])
exc++;
else if ([[self entity] anyRelationshipNamed: name])
exc++;
else if ((storedProcedures = [[[self entity] model] storedProcedures]))
{
NSEnumerator *stEnum = [storedProcedures objectEnumerator];
EOStoredProcedure *st;
while ((st = [stEnum nextObject]))
{
NSEnumerator *attrEnum;
EOAttribute *attr;
attrEnum = [[st arguments] objectEnumerator];
while ((attr = [attrEnum nextObject]))
{
if ([name isEqualToString: [attr name]])
{
exc++;
break;
}
}
if (exc)
break;
}
}
}
if (exc)
{
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat: @"%@ -- %@ 0x%x: \"%@\" already used in the model",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name]
userInfo: nil];
}
return nil;
}
- (void)setToMany: (BOOL)flag
{
//OK
if ([self isFlattened])
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: receiver is a flattened relationship",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
[self willChange];
_flags.isToMany = flag;
}
- (void)setName: (NSString *)name
{
//OK
[[self validateName: name] raise];
[self willChange];
[_entity _setIsEdited];
ASSIGN(_name, name);
}
- (void)setDefinition: (NSString *)definition
{
//Near OK
EOFLOGObjectFnStart();
EOFLOGObjectLevelArgs(@"EORelationship", @"definition=%@", definition);
[self _flushCache];
[self willChange];
if (definition)
{
_flags.isToMany = NO;
NSAssert1(_entity,@"No entity for relationship %@",
self);
ASSIGN(_definitionArray, [_entity _parseRelationshipPath: definition]);
EOFLOGObjectLevelArgs(@"EORelationship", @"_definitionArray=%@", _definitionArray);
EOFLOGObjectLevelArgs(@"EORelationship", @"[self definition]=%@", [self definition]);
GDL2DestinationEntitiesRemoveRelationship(_destination, self);
_destination = nil;
{
//TODO VERIFY
//TODO better ?
int i, count = [_definitionArray count];
EOFLOGObjectLevelArgs(@"EORelationship", @"==> _definitionArray=%@",
_definitionArray);
for (i = 0; !_flags.isToMany && i < count; i++)
{
EORelationship *rel = [_definitionArray objectAtIndex: i];
if ([rel isKindOfClass: [EORelationship class]])
{
if ([rel isToMany])
_flags.isToMany = YES;
}
else
break;
}
}
}
else /* definition == nil */
{
DESTROY(_definitionArray);
}
/* Ayers: Not sure what justifies this. */
[_entity _setIsEdited];
EOFLOGObjectFnStop();
}
- (void)setEntity: (EOEntity *)entity
{
//OK
if (entity != _entity)
{
[self _flushCache];
[self willChange];
/* FIXME docs say we should... but currently -removeRelationship
* calls us, so it would cause an infinite loop */
// [_entity removeRelationship:self];
[_entity _setIsEdited];
[entity _setIsEdited];
_entity = entity;
}
}
- (void)setUserInfo: (NSDictionary *)dictionary
{
//OK
[self willChange];
ASSIGN(_userInfo, dictionary);
/* Ayers: Not sure what justifies this. */
[_entity _setIsEdited];
}
- (void)setInternalInfo: (NSDictionary *)dictionary
{
//OK
[self willChange];
ASSIGN(_internalInfo, dictionary);
/* Ayers: Not sure what justifies this. */
[_entity _setIsEdited];
}
- (void)setDocComment: (NSString *)docComment
{
//OK
[self willChange];
ASSIGN(_docComment, docComment);
/* Ayers: Not sure what justifies this. */
[_entity _setIsEdited];
}
- (void)setPropagatesPrimaryKey: (BOOL)flag
{
//OK
if (_flags.propagatesPrimaryKey != flag)
[self willChange];
_flags.propagatesPrimaryKey = flag;
}
- (void)setIsBidirectional: (BOOL)flag
{
//OK
if (_flags.isBidirectional != flag)
[self willChange];
_flags.isBidirectional = flag;
}
- (void)setOwnsDestination: (BOOL)flag
{
if (_flags.ownsDestination != flag)
[self willChange];
_flags.ownsDestination = flag;
}
- (void)addJoin: (EOJoin *)join
{
EOAttribute *sourceAttribute = nil;
EOAttribute *destinationAttribute = nil;
EOFLOGObjectFnStart();
EOFLOGObjectLevelArgs(@"EORelationship", @"Add join: %@\nto %@", join, self);
if ([self isFlattened] == YES)
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: receiver is a flattened relationship",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
else
{
EOEntity *destinationEntity = [self destinationEntity];
EOEntity *sourceEntity = [self entity];
EOFLOGObjectLevelArgs(@"EORelationship", @"destinationEntity=%@", destinationEntity);
if (!destinationEntity)
{
NSEmitTODO(); //TODO
EOFLOGObjectLevelArgs(@"EORelationship", @"self=%@", self);
//TODO ??
};
sourceAttribute = [join sourceAttribute];
NSAssert3(sourceAttribute, @"No source attribute in join %@ in relationship %@ of entity %@",
join,
self,
sourceEntity);
destinationAttribute = [join destinationAttribute];
NSAssert3(destinationAttribute, @"No destination attribute in join %@ in relationship %@ of entity %@",
join,
self,
sourceEntity);
if ([sourceAttribute isFlattened] == YES
|| [destinationAttribute isFlattened] == YES)
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: join's attributes are flattened",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
else
{
EOEntity *joinDestinationEntity = [destinationAttribute entity];
EOEntity *joinSourceEntity = [sourceAttribute entity];
/* if (destinationEntity && ![[destinationEntity name] isEqual:[joinSourceEntity name]])
{
[NSException raise:NSInvalidArgumentException
format:@"%@ -- %@ 0x%x: join source entity (%@) is not equal to last join entity (%@)",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
[joinSourceEntity name],
[destinationEntity name]];
}*/
if (sourceEntity
&& ![[joinSourceEntity name] isEqual: [sourceEntity name]])
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x (%@): join source entity (%@) is not equal to relationship entity (%@)",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
[self name],
[joinSourceEntity name],
[sourceEntity name]];
else if (destinationEntity
&& ![[joinDestinationEntity name]
isEqual: [destinationEntity name]])
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x (%@): join destination entity (%@) is not equal to relationship destination entity (%@)",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
[self name],
[joinDestinationEntity name],
[destinationEntity name]];
else
{
if ([_sourceAttributes count])
{
EOAttribute *sourceAttribute = [join sourceAttribute];
EOAttribute *destinationAttribute;
destinationAttribute = [join destinationAttribute];
if (([_sourceAttributes indexOfObject: sourceAttribute]
!= NSNotFound)
&& ([_destinationAttributes
indexOfObject: destinationAttribute]
!= NSNotFound))
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: TODO",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
}
[self _flushCache];
[self willChange];
EOFLOGObjectLevel(@"EORelationship", @"really add");
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
if ([self createsMutableObjects])
{
if (!_joins)
_joins = [NSMutableArray new];
[(NSMutableArray *)_joins addObject: join];
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
}
else
{
if (_joins)
_joins = RETAIN([[_joins autorelease]
arrayByAddingObject: join]);
else
_joins = RETAIN([NSArray arrayWithObject: join]);
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
/*NO: will be recomputed _sourceAttributes = [[[_sourceAttributes autorelease]
arrayByAddingObject:[join sourceAttribute]]
retain];
_destinationAttributes = [[[_destinationAttributes autorelease]
arrayByAddingObject:
[join destinationAttribute]]
retain];
*/
}
EOFLOGObjectLevel(@"EORelationship", @"added");
[self _joinsChanged];
/* Ayers: Not sure what justifies this. */
[_entity _setIsEdited];
}
}
}
EOFLOGObjectFnStop();
}
- (void)removeJoin: (EOJoin *)join
{
EOFLOGObjectFnStart();
[self _flushCache];
if ([self isFlattened] == YES)
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: receiver is a flattened relationship",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
else
{
[self willChange];
if ([self createsMutableObjects])
{
[(NSMutableArray *)_joins removeObject: join];
/*NO: will be recomputed [(NSMutableArray *)_sourceAttributes
removeObject:[join sourceAttribute]];
[(NSMutableArray *)_destinationAttributes
removeObject:[join destinationAttribute]];
*/
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
}
else
{
NSMutableArray *ma = [_joins mutableCopy];
NSArray *a = _joins;
[ma removeObject: join];
_joins = ma;
[a release];
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
/*NO: will be recomputed
_sourceAttributes = [[_sourceAttributes autorelease] mutableCopy];
[(NSMutableArray *)_sourceAttributes
removeObject:[join sourceAttribute]];
_sourceAttributes = [[_sourceAttributes autorelease] copy];
_destinationAttributes = [[_destinationAttributes autorelease]
mutableCopy];
[(NSMutableArray *)_destinationAttributes
removeObject:[join destinationAttribute]];
_destinationAttributes = [[_destinationAttributes autorelease] copy];
*/
}
[self _joinsChanged];
/* Ayers: Not sure what justifies this. */
[_entity _setIsEdited];
}
EOFLOGObjectFnStop();
}
- (void)setJoinSemantic: (EOJoinSemantic)joinSemantic
{
//OK
[self willChange];
_joinSemantic = joinSemantic;
}
- (void)beautifyName
{
/*+ Make the name conform to the Next naming style
NAME -> name, FIRST_NAME -> firstName +*/
NSArray *listItems;
NSString *newString = [NSString string];
int anz, i;
EOFLOGObjectFnStartOrCond2(@"ModelingClasses", @"EORelationship");
/* Makes the receiver's name conform to a standard convention. Names that
conform to this style are all lower-case except for the initial letter of
each embedded word other than the first, which is upper case. Thus, "NAME"
becomes "name", and "FIRST_NAME" becomes "firstName".*/
if ((_name) && ([_name length] > 0))
{
listItems = [_name componentsSeparatedByString: @"_"];
newString = [newString stringByAppendingString:
[[listItems objectAtIndex: 0] lowercaseString]];
anz = [listItems count];
for (i = 1; i < anz; i++)
{
newString = [newString stringByAppendingString:
[[listItems objectAtIndex: i]
capitalizedString]];
}
// Exception abfangen
NS_DURING
{
[self setName:newString];
}
NS_HANDLER
{
NSLog(@"%@ in Class: EORlationship , Method: beautifyName >> error : %@",
[localException name], [localException reason]);
}
NS_ENDHANDLER;
}
EOFLOGObjectFnStopOrCond2(@"ModelingClasses", @"EORelationship");
}
- (void)setNumberOfToManyFaultsToBatchFetch: (unsigned int)size
{
[self willChange];
_batchCount = size;
}
- (void)setDeleteRule: (EODeleteRule)deleteRule
{
NSAssert1(deleteRule >= 0 && deleteRule < 4,
@"Bad deleteRule numeric value: %d",
deleteRule);
[self willChange];
_flags.deleteRule = deleteRule;
}
- (void)setIsMandatory: (BOOL)isMandatory
{
//OK
[self willChange];
_flags.isMandatory = isMandatory;
}
@end
@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
NSException *exception = nil;
EOFLOGObjectFnStart();
NSAssert(valueP, @"No value pointer");
if ([self isMandatory])
{
BOOL isToMany = [self isToMany];
if ((isToMany == NO && _isNilOrEONull(*valueP))
|| (isToMany == YES && [*valueP count] == 0))
{
EOEntity *destinationEntity = [self destinationEntity];
EOEntity *entity = [self entity];
exception = [NSException validationExceptionWithFormat:
@"The %@ property of %@ must have a %@ assigned",
[self name],
[entity name],
[destinationEntity name]];
}
}
EOFLOGObjectFnStop();
return exception;
}
@end
@implementation EORelationship (EORelationshipPrivate)
- (void)setCreateMutableObjects: (BOOL)flag
{
if (_flags.createsMutableObjects != flag)
{
_flags.createsMutableObjects = flag;
if (_flags.createsMutableObjects)
{
_joins = [[_joins autorelease] mutableCopy];
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
DESTROY(_sourceAttributes);
DESTROY(_destinationAttributes);
/*Will be recomputed later _sourceAttributes = [[_sourceAttributes autorelease] mutableCopy];
_destinationAttributes = [[_destinationAttributes autorelease]
mutableCopy];
*/
}
else
{
_joins = [[NSArray alloc] initWithArray:[_joins autorelease] copyItems:NO];
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
DESTROY(_sourceAttributes);
DESTROY(_destinationAttributes);
/*Will be recomputed later _sourceAttributes = [[_sourceAttributes autorelease] copy];
_destinationAttributes = [[_destinationAttributes autorelease] copy];
*/
}
}
}
- (BOOL)createsMutableObjects
{
return _flags.createsMutableObjects;
}
/* TODO this method should probably be private. */
- (void)setInverseRelationship: (EORelationship*)relationship
{
[self willChange]; // TODO: verify
ASSIGN(_inverseRelationship,relationship);
}
@end
@implementation EORelationship (EORelationshipXX)
- (NSArray*) _intermediateAttributes
{
//Verify !!
NSMutableArray *intermediateAttributes;
EORelationship *rel;
NSArray *joins;
//all this works on flattened and non flattened relationship.
intermediateAttributes = [NSMutableArray array];
rel = [self firstRelationship];
joins = [rel joins];
//??
[intermediateAttributes addObjectsFromArray:
[joins resultsOfPerformingSelector:
@selector(destinationAttribute)]];
rel = [self lastRelationship];
joins = [rel joins];
// attribute = [joins sourceAttribute];
//??
[intermediateAttributes addObjectsFromArray:
[joins resultsOfPerformingSelector:
@selector(sourceAttribute)]];
return [NSArray arrayWithArray: intermediateAttributes];
}
/** Return the last relationship if self is flattened, self otherwise.
**/
- (EORelationship*) lastRelationship
{
EORelationship *lastRel;
if ([self isFlattened])
{
NSAssert(!_definitionArray || [_definitionArray count] > 0,
@"Definition array is empty");
lastRel = [[self _definitionArray] lastObject];
}
else
lastRel = self;
return lastRel;
}
/** Return the 1st relationship if self is flattened, self otherwise.
**/
- (EORelationship*) firstRelationship
{
EORelationship *firstRel;
if ([self isFlattened])
{
NSAssert(!_definitionArray || [_definitionArray count] > 0,
@"Definition array is empty");
firstRel = [[self _definitionArray] objectAtIndex: 0];
}
else
firstRel = self;
return firstRel;
}
- (EOEntity*) intermediateEntity
{
//TODO verify
id intermediateEntity = nil;
if ([self isToManyToOne])
{
int i, count = [_definitionArray count];
for (i = (count - 1); !intermediateEntity && i >= 0; i--)
{
EORelationship *rel = [_definitionArray objectAtIndex: i];
if ([rel isToMany])
intermediateEntity = [rel destinationEntity];
}
}
return intermediateEntity;
}
- (BOOL) isMultiHop
{
//TODO verify
BOOL isMultiHop = NO;
if ([self isFlattened])
{
isMultiHop = YES;
}
return isMultiHop;
}
- (void) _setSourceToDestinationKeyMap: (id)param0
{
[self notImplemented: _cmd]; // TODO
}
- (id) qualifierForDBSnapshot: (id)param0
{
return [self notImplemented: _cmd]; // TODO
}
- (id) primaryKeyForTargetRowFromSourceDBSnapshot: (id)param0
{
return [self notImplemented:_cmd]; // TODO
}
/** Return relationship path (like toRel1.toRel2) if self is flattened, slef name otherwise.
**/
- (NSString*)relationshipPath
{
//Seems OK
NSString *relationshipPath = nil;
EOFLOGObjectFnStart();
if ([self isFlattened])
{
int i, count = [_definitionArray count];
for (i = 0; i < count; i++)
{
EORelationship *relationship = [_definitionArray objectAtIndex: i];
NSString *relationshipName = [relationship name];
if (relationshipPath)
[(NSMutableString*)relationshipPath appendString: @"."];
else
relationshipPath = [NSMutableString string];
[(NSMutableString*)relationshipPath appendString: relationshipName];
}
}
else
relationshipPath = [self name];
EOFLOGObjectFnStop();
return relationshipPath;
}
-(BOOL)isToManyToOne
{
BOOL isToManyToOne = NO;
EOFLOGObjectFnStart();
if ([self isFlattened])
{
BOOL isToMany = YES;
int count = [_definitionArray count];
if (count >= 2)
{
EORelationship *firstRelationship = [_definitionArray
objectAtIndex: 0];
isToMany = [firstRelationship isToMany];
if (!isToMany)
{
if ([firstRelationship isParentRelationship])
{
NSEmitTODO(); //TODO
EOFLOGObjectLevelArgs(@"EORelationship", @"self=%@", self);
EOFLOGObjectLevelArgs(@"EORelationship", @"firstRelationship=%@",
firstRelationship);
[self notImplemented: _cmd]; //TODO
}
}
if (isToMany)
{
EORelationship *secondRelationship = [_definitionArray
objectAtIndex: 0];
if (![secondRelationship isToMany])
{
EORelationship *invRel = [secondRelationship
anyInverseRelationship];
if (invRel)
secondRelationship = invRel;
isToManyToOne = YES;
if ([secondRelationship isParentRelationship])
{
NSEmitTODO(); //TODO
EOFLOGObjectLevelArgs(@"EORelationship", @"self=%@", self);
EOFLOGObjectLevelArgs(@"EORelationship", @"secondRelationship=%@",
secondRelationship);
[self notImplemented: _cmd]; //TODO
}
}
}
}
}
EOFLOGObjectFnStop();
return isToManyToOne;
}
-(NSDictionary*)_sourceToDestinationKeyMap
{
//OK
EOFLOGObjectFnStart();
if (!_sourceToDestinationKeyMap)
{
NSString *relationshipPath = [self relationshipPath];
ASSIGN(_sourceToDestinationKeyMap,
[_entity _keyMapForRelationshipPath: relationshipPath]);
}
EOFLOGObjectFnStop();
return _sourceToDestinationKeyMap;
}
- (BOOL)foreignKeyInDestination
{
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
NSArray *destAttributes = nil;
NSArray *primaryKeyAttributes = nil;
int destAttributesCount = 0;
int primaryKeyAttributesCount = 0;
BOOL foreignKeyInDestination = NO;
EOFLOGObjectFnStart();
destAttributes = [self destinationAttributes];
primaryKeyAttributes = [[self destinationEntity] primaryKeyAttributes];
destAttributesCount = [destAttributes count];
primaryKeyAttributesCount = [primaryKeyAttributes count];
EOFLOGObjectLevelArgs(@"EORelationship", @"destAttributes=%@",
destAttributes);
EOFLOGObjectLevelArgs(@"EORelationship", @"primaryKeyAttributes=%@",
primaryKeyAttributes);
if (destAttributesCount > 0 && primaryKeyAttributesCount > 0)
{
int i;
for (i = 0;
!foreignKeyInDestination && i < destAttributesCount;
i++)
{
EOAttribute *attribute = [destAttributes objectAtIndex: i];
int pkAttrIndex = [primaryKeyAttributes
indexOfObjectIdenticalTo: attribute];
foreignKeyInDestination = (pkAttrIndex == NSNotFound);
}
}
EOFLOGObjectFnStop();
EOFLOGObjectLevelArgs(@"EORelationship", @"foreignKeyInDestination=%s",
(foreignKeyInDestination ? "YES" : "NO"));
return foreignKeyInDestination;
}
@end
@implementation EORelationship (EORelationshipPrivate2)
- (BOOL) isPropagatesPrimaryKeyPossible
{
/*
NSArray* joins=[self joins];
NSArray* joinsSourceAttributes=[joins resultsOfPerformingSelector:@selector(sourceAttribute)];
NSArray* joinsDestinationAttributes=[joins resultsOfPerformingSelector:@selector(destinationAttribute)];
joinsSourceAttributes names
sortedArrayUsingSelector:compare:
result count
joinsDestinationAttributes names
sortedArrayUsingSelector:compare:
inverseRelationship
inv entity [EOEntity]:
inv ventity primaryKeyAttributeNames
count
dest entity
dst entity primaryKeyAttributeNames
*/
EOFLOGObjectFnStart();
[self notImplemented: _cmd]; // TODO
EOFLOGObjectFnStop();
return NO;
};
- (id) qualifierOmittingAuxiliaryQualifierWithSourceRow: (id)param0
{
return [self notImplemented: _cmd]; // TODO
}
- (id) auxiliaryQualifier
{
return nil; //[self notImplemented:_cmd]; // TODO
}
- (void) setAuxiliaryQualifier: (id)param0
{
[self notImplemented:_cmd]; // TODO
}
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
/** Return dictionary of key/value for destination object of source row/object **/
* EOAccess/EOSQLExpression.h (deleteStatementWithQualifier:entity:) * EOAccess/EOSQLExpressionPriv.h (_aliasForRelationshipPath:) (_flattenRelPath:entity:, _aliasForRelatedAttribute:relationshipPath:) * EOAccess/EOSQLExpression.m (insertStatementForRow:entity:) (updateStatementForRow:qualifier:entity:) (deleteStatementWithQualifier:entity:) (selectStatementForAttributes:lock:fetchSpecification:entity:) (_aliasForRelationshipPath:) * EOAccess/EORelationship.h (intermediateEntity) (_foreignKeyForSourceRow:) * EOAccess/EORelationship.m (_foreignKeyForSourceRow:, _leftSideKeyMap) * EOAccess/EODatabaseContext.h (databaseOperationForObject:) (databaseOperationForGlobalID:, recordDatabaseOperation:) (_openChannelWithLoginPanel:) * EOAccess/EODatabaseContextPriv.h (primaryKeyForObject:) (_currentCommittedSnapshotForObject:) * EOAccess/EOEntityPriv.h (_keyMapForRelationshipPath:) (_keyMapForIdenticalKeyRelationshipPath:, _mapAttribute:) (_relationshipPathIsToMany: valueForSQLExpression:) (_parsePropertyName:, classPropertyAttributeNames) (classPropertyToManyRelationshipNames) (classPropertyToOneRelationshipNames, dbSnapshotKeys) * EOAccess/EOUtilities.m (rawRowsForEntityNamed:qualifierFormat:) (rawRowsMatchingValue:forKey:entityNamed:) (rawRowsMatchingValues:entityNamed:, rawRowsWithSQL:modelNamed:) (rawRowsWithStoredProcedureNamed:arguments:) (executeStoredProcedureNamed:arguments:, databaseContextForModelNamed:) (primaryKeyForObject:) (destinationKeyForSourceObject:relationshipNamed:) * EOAccess/EOEntity.m (_mapAttribute:toDestinationAttributeInLastComponentOfRelationshipPath:) * EOAccess/EOAdaptor.h (adaptorWithModel:,adaptorWithName:) * EOAccess/EOModel.h (_classDescriptionNeeded:,_entityForClass:) (_addEntityWithPropertyList:) * EOAdaptors/Postgres95/Postgres95Channel.h (_evaluateExpression:withAttributes:) * EOControl/EOMutableKnownKeyDictionary.h/m (arrayMappingForKeys:) (subsetMappingForSourceDictionaryInitializer:sourceKeys:destinationKeys:) (subsetMappingForSourceDictionaryInitializer:) (setObject:forKey:, removeObjectForKey:, indexForKey:, objectForKey:) * EOControl/EOEditingContext.m (handleErrors:,setSharedEditingContext:) (faultForRawRow:entityNamed:) * GDL2Palette/KeyWrapper.h (setKey:, _key): * EOModeler/EOModelerEditor.h (selectionWithinViewedObject) * EOModeler/EOModelerEditor.m (initWithDocument:) (initWithParentEditor:) Correct method signatures. Add necessary forward @class declations. * EOInterface/EOMasterDetailAssociation.m (establishConnection): * DBModeler/ModelerTableEmbedibleEditor.m (addDefaultTableColumnsForTableView:displayGroup:) * DBModeler/DefaultColumnProvider.m (setupTitleForColumn:named:) Cast types to avoid compiler warnings. * EOControl/EOCheapArray.m (dealloc): Supress compiler warning. * EOAdaptors/Postgres95/LoginPanel/Postgres95LoginPanel.m (dealloc) * EOModeler/EOModelerEditor.m (dealloc): * DBModeler/ModelerAttributeEditor.m (dealloc): Add missing call to super. * DBModeler/Preferences.m (sharedPreferences): Fix implementation for new compiler semantics. * EOControl/EOMultiReaderLock.m (init): Correct NSConditionLock initialization. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@23472 72102866-910b-0410-8b05-ffd578937521
2006-09-12 19:36:24 +00:00
- (EOMutableKnownKeyDictionary *) _foreignKeyForSourceRow: (NSDictionary*)row
{
* EOAccess/EOSQLExpression.h (deleteStatementWithQualifier:entity:) * EOAccess/EOSQLExpressionPriv.h (_aliasForRelationshipPath:) (_flattenRelPath:entity:, _aliasForRelatedAttribute:relationshipPath:) * EOAccess/EOSQLExpression.m (insertStatementForRow:entity:) (updateStatementForRow:qualifier:entity:) (deleteStatementWithQualifier:entity:) (selectStatementForAttributes:lock:fetchSpecification:entity:) (_aliasForRelationshipPath:) * EOAccess/EORelationship.h (intermediateEntity) (_foreignKeyForSourceRow:) * EOAccess/EORelationship.m (_foreignKeyForSourceRow:, _leftSideKeyMap) * EOAccess/EODatabaseContext.h (databaseOperationForObject:) (databaseOperationForGlobalID:, recordDatabaseOperation:) (_openChannelWithLoginPanel:) * EOAccess/EODatabaseContextPriv.h (primaryKeyForObject:) (_currentCommittedSnapshotForObject:) * EOAccess/EOEntityPriv.h (_keyMapForRelationshipPath:) (_keyMapForIdenticalKeyRelationshipPath:, _mapAttribute:) (_relationshipPathIsToMany: valueForSQLExpression:) (_parsePropertyName:, classPropertyAttributeNames) (classPropertyToManyRelationshipNames) (classPropertyToOneRelationshipNames, dbSnapshotKeys) * EOAccess/EOUtilities.m (rawRowsForEntityNamed:qualifierFormat:) (rawRowsMatchingValue:forKey:entityNamed:) (rawRowsMatchingValues:entityNamed:, rawRowsWithSQL:modelNamed:) (rawRowsWithStoredProcedureNamed:arguments:) (executeStoredProcedureNamed:arguments:, databaseContextForModelNamed:) (primaryKeyForObject:) (destinationKeyForSourceObject:relationshipNamed:) * EOAccess/EOEntity.m (_mapAttribute:toDestinationAttributeInLastComponentOfRelationshipPath:) * EOAccess/EOAdaptor.h (adaptorWithModel:,adaptorWithName:) * EOAccess/EOModel.h (_classDescriptionNeeded:,_entityForClass:) (_addEntityWithPropertyList:) * EOAdaptors/Postgres95/Postgres95Channel.h (_evaluateExpression:withAttributes:) * EOControl/EOMutableKnownKeyDictionary.h/m (arrayMappingForKeys:) (subsetMappingForSourceDictionaryInitializer:sourceKeys:destinationKeys:) (subsetMappingForSourceDictionaryInitializer:) (setObject:forKey:, removeObjectForKey:, indexForKey:, objectForKey:) * EOControl/EOEditingContext.m (handleErrors:,setSharedEditingContext:) (faultForRawRow:entityNamed:) * GDL2Palette/KeyWrapper.h (setKey:, _key): * EOModeler/EOModelerEditor.h (selectionWithinViewedObject) * EOModeler/EOModelerEditor.m (initWithDocument:) (initWithParentEditor:) Correct method signatures. Add necessary forward @class declations. * EOInterface/EOMasterDetailAssociation.m (establishConnection): * DBModeler/ModelerTableEmbedibleEditor.m (addDefaultTableColumnsForTableView:displayGroup:) * DBModeler/DefaultColumnProvider.m (setupTitleForColumn:named:) Cast types to avoid compiler warnings. * EOControl/EOCheapArray.m (dealloc): Supress compiler warning. * EOAdaptors/Postgres95/LoginPanel/Postgres95LoginPanel.m (dealloc) * EOModeler/EOModelerEditor.m (dealloc): * DBModeler/ModelerAttributeEditor.m (dealloc): Add missing call to super. * DBModeler/Preferences.m (sharedPreferences): Fix implementation for new compiler semantics. * EOControl/EOMultiReaderLock.m (init): Correct NSConditionLock initialization. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@23472 72102866-910b-0410-8b05-ffd578937521
2006-09-12 19:36:24 +00:00
EOMutableKnownKeyDictionary *foreignKey = nil;
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
EOMKKDSubsetMapping *sourceRowToForeignKeyMapping = nil;
EOFLOGObjectFnStart();
sourceRowToForeignKeyMapping = [self _sourceRowToForeignKeyMapping];
EOFLOGObjectLevelArgs(@"EORelationship", @"self=%@",self);
EOFLOGObjectLevelArgs(@"EORelationship", @"sourceRowToForeignKeyMapping=%@",
sourceRowToForeignKeyMapping);
foreignKey = [EOMutableKnownKeyDictionary dictionaryFromDictionary: row
subsetMapping:
sourceRowToForeignKeyMapping];
EOFLOGObjectLevelArgs(@"EORelationship", @"row=%@\nforeignKey=%@", row, foreignKey);
EOFLOGObjectFnStop();
return foreignKey;
}
- (EOMKKDSubsetMapping*) _sourceRowToForeignKeyMapping
{
EOFLOGObjectFnStart();
if (!_sourceRowToForeignKeyMapping)
{
NSDictionary *sourceToDestinationKeyMap;
NSArray *sourceKeys;
NSArray *destinationKeys;
EOEntity *destinationEntity;
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
EOMKKDInitializer *destinationDictionaryInitializer = nil;
EOMKKDInitializer *adaptorDictionaryInitializer;
EOMKKDSubsetMapping *sourceRowToForeignKeyMapping;
sourceToDestinationKeyMap = [self _sourceToDestinationKeyMap];
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
EOFLOGObjectLevelArgs(@"EORelationship", @"rel=%@ sourceToDestinationKeyMap=%@",
[self name], sourceToDestinationKeyMap);
sourceKeys = [sourceToDestinationKeyMap objectForKey: @"sourceKeys"];
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
EOFLOGObjectLevelArgs(@"EORelationship", @"rel=%@ sourceKeys=%@",
[self name], sourceKeys);
destinationKeys = [sourceToDestinationKeyMap
objectForKey: @"destinationKeys"];
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
EOFLOGObjectLevelArgs(@"EORelationship", @"rel=%@ destinationKeys=%@",
[self name], destinationKeys);
destinationEntity = [self destinationEntity];
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
destinationDictionaryInitializer = [destinationEntity _adaptorDictionaryInitializer];
EOFLOGObjectLevelArgs(@"EORelationship", @"destinationEntity named %@ primaryKeyDictionaryInitializer=%@",
[destinationEntity name],
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
destinationDictionaryInitializer);
adaptorDictionaryInitializer = [_entity _adaptorDictionaryInitializer];
EOFLOGObjectLevelArgs(@"EORelationship",@"entity named %@ adaptorDictionaryInitializer=%@",
[_entity name],
adaptorDictionaryInitializer);
sourceRowToForeignKeyMapping =
2003-03-21 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EODatabaseContext.m: o added assert in _primaryKeyForObject: o in -recordChangesInEditingContext test nil/eonull on relationshipCommitedSnapshotValue and relationshipSnapshotValue instead of only nil testing o in -recordChangesInEditingContext fix for value changing testing when commitedSnapshotValue is nil/EONull * EOAccess/EOEntity.m: o logs o fix in inverseRelationshipClassPropertyNames to test on destination entity property names * EOControl/EOClassDescription.m: o logs * EOControl/GNUmakefile: o added EONSAddOns.h * EOCOntrol/EOKeyValueCoding.m: o fixes in NSArray -computeXXForKey: * EOAccess/EOSQLExpression.m: o assert in -sqlStringForKeyValueQualifier: o -sqlStringForArrayOfQualifiers:operation: hanlde different qualifier cases using isKindOfClass: may probably be improved o logs * EOControl/EOEditingContext.m: o fix in unprocessedInfo (invert/change swap). * EOControl/EOQualifier.m o -qualifierWithQualifierFormat:varargList: raise exception if operator is unknwon * EOControl/EOMutableKnownKeyDictionary.m: o add precision in exception message * EOAccess/EORelationship.m: o more info in some logs o fix in -_sourceRowToForeignKeyMapping for foreign keys which are not in primaryKey. * EOControl/EODatabaseOperation.m: o in -setDatabaseOperator: Don't Delete a not inserted object * EOControl/EOAccessFault.m: o logs o EOAccessFaultHandler: -dealloc fix: call super dealloc o implement faultWillFire: This fix a hard memory problem * EOControl/EOFault.m: o -dealloc: fix possible infinite loop o logs * EOCheapCopyArray.m: o ucomment retain/release/... o fix shallowCopy for memory management. This was causing hard memory trouble git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16217 72102866-910b-0410-8b05-ffd578937521
2003-03-21 20:41:07 +00:00
[destinationDictionaryInitializer
subsetMappingForSourceDictionaryInitializer:
adaptorDictionaryInitializer
sourceKeys: sourceKeys
destinationKeys: destinationKeys];
ASSIGN(_sourceRowToForeignKeyMapping, sourceRowToForeignKeyMapping);
EOFLOGObjectLevelArgs(@"EORelationship",@"%@ to %@: _sourceRowToForeignKeyMapping=%@",
[_entity name],
[destinationEntity name],
_sourceRowToForeignKeyMapping);
}
EOFLOGObjectFnStop();
return _sourceRowToForeignKeyMapping;
}
- (NSArray*) _sourceAttributeNames
{
//Seems OK
return [[self sourceAttributes]
resultsOfPerformingSelector: @selector(name)];
}
- (EOJoin*) joinForAttribute: (EOAttribute*)attribute
{
//OK
EOJoin *join = nil;
int i, count = [_joins count];
for (i = 0; !join && i < count; i++)
{
EOJoin *aJoin = [_joins objectAtIndex: i];
EOAttribute *sourceAttribute = [aJoin sourceAttribute];
if ([attribute isEqual: sourceAttribute])
join = aJoin;
}
return join;
}
- (void) _flushCache
{
//VERIFY
//[self notImplemented:_cmd]; // TODO
DESTROY(_sourceAttributes);
DESTROY(_destinationAttributes);
DESTROY(_inverseRelationship);
DESTROY(_hiddenInverseRelationship);
}
- (EOExpressionArray*) _definitionArray
{
//VERIFY
return _definitionArray;
}
- (NSString*) _stringFromDeleteRule: (EODeleteRule)deleteRule
{
NSString *deleteRuleString = nil;
switch(deleteRule)
{
case EODeleteRuleNullify:
deleteRuleString = @"";
break;
case EODeleteRuleCascade:
deleteRuleString = @"";
break;
case EODeleteRuleDeny:
deleteRuleString = @"";
break;
case EODeleteRuleNoAction:
deleteRuleString = @"";
break;
default:
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: invalid deleteRule code for relationship '%@': %d",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
[self name],
(int)deleteRule];
break;
}
return deleteRuleString;
}
- (EODeleteRule) _deleteRuleFromString: (NSString*)deleteRuleString
{
EODeleteRule deleteRule = 0;
if ([deleteRuleString isEqualToString: @"EODeleteRuleNullify"])
deleteRule = EODeleteRuleNullify;
else if ([deleteRuleString isEqualToString: @"EODeleteRuleCascade"])
deleteRule = EODeleteRuleCascade;
else if ([deleteRuleString isEqualToString: @"EODeleteRuleDeny"])
deleteRule = EODeleteRuleDeny;
else if ([deleteRuleString isEqualToString: @"EODeleteRuleNoAction"])
deleteRule = EODeleteRuleNoAction;
else
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: invalid deleteRule string for relationship '%@': %@",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
[self name],
deleteRuleString];
return deleteRule;
}
- (NSDictionary*) _rightSideKeyMap
{
NSDictionary *keyMap = nil;
NSEmitTODO(); //TODO
[self notImplemented: _cmd]; // TODO
if ([self isToManyToOne])
{
int count = [_definitionArray count];
if (count >= 2) //??
{
EORelationship *rel0 = [_definitionArray objectAtIndex: 0];
if ([rel0 isToMany]) //??
{
EOEntity *entity = [rel0 destinationEntity];
EORelationship *rel1 = [_definitionArray objectAtIndex: 1];
keyMap = [entity _keyMapForIdenticalKeyRelationshipPath:
[rel1 name]];
}
}
}
return keyMap;
}
* EOAccess/EOSQLExpression.h (deleteStatementWithQualifier:entity:) * EOAccess/EOSQLExpressionPriv.h (_aliasForRelationshipPath:) (_flattenRelPath:entity:, _aliasForRelatedAttribute:relationshipPath:) * EOAccess/EOSQLExpression.m (insertStatementForRow:entity:) (updateStatementForRow:qualifier:entity:) (deleteStatementWithQualifier:entity:) (selectStatementForAttributes:lock:fetchSpecification:entity:) (_aliasForRelationshipPath:) * EOAccess/EORelationship.h (intermediateEntity) (_foreignKeyForSourceRow:) * EOAccess/EORelationship.m (_foreignKeyForSourceRow:, _leftSideKeyMap) * EOAccess/EODatabaseContext.h (databaseOperationForObject:) (databaseOperationForGlobalID:, recordDatabaseOperation:) (_openChannelWithLoginPanel:) * EOAccess/EODatabaseContextPriv.h (primaryKeyForObject:) (_currentCommittedSnapshotForObject:) * EOAccess/EOEntityPriv.h (_keyMapForRelationshipPath:) (_keyMapForIdenticalKeyRelationshipPath:, _mapAttribute:) (_relationshipPathIsToMany: valueForSQLExpression:) (_parsePropertyName:, classPropertyAttributeNames) (classPropertyToManyRelationshipNames) (classPropertyToOneRelationshipNames, dbSnapshotKeys) * EOAccess/EOUtilities.m (rawRowsForEntityNamed:qualifierFormat:) (rawRowsMatchingValue:forKey:entityNamed:) (rawRowsMatchingValues:entityNamed:, rawRowsWithSQL:modelNamed:) (rawRowsWithStoredProcedureNamed:arguments:) (executeStoredProcedureNamed:arguments:, databaseContextForModelNamed:) (primaryKeyForObject:) (destinationKeyForSourceObject:relationshipNamed:) * EOAccess/EOEntity.m (_mapAttribute:toDestinationAttributeInLastComponentOfRelationshipPath:) * EOAccess/EOAdaptor.h (adaptorWithModel:,adaptorWithName:) * EOAccess/EOModel.h (_classDescriptionNeeded:,_entityForClass:) (_addEntityWithPropertyList:) * EOAdaptors/Postgres95/Postgres95Channel.h (_evaluateExpression:withAttributes:) * EOControl/EOMutableKnownKeyDictionary.h/m (arrayMappingForKeys:) (subsetMappingForSourceDictionaryInitializer:sourceKeys:destinationKeys:) (subsetMappingForSourceDictionaryInitializer:) (setObject:forKey:, removeObjectForKey:, indexForKey:, objectForKey:) * EOControl/EOEditingContext.m (handleErrors:,setSharedEditingContext:) (faultForRawRow:entityNamed:) * GDL2Palette/KeyWrapper.h (setKey:, _key): * EOModeler/EOModelerEditor.h (selectionWithinViewedObject) * EOModeler/EOModelerEditor.m (initWithDocument:) (initWithParentEditor:) Correct method signatures. Add necessary forward @class declations. * EOInterface/EOMasterDetailAssociation.m (establishConnection): * DBModeler/ModelerTableEmbedibleEditor.m (addDefaultTableColumnsForTableView:displayGroup:) * DBModeler/DefaultColumnProvider.m (setupTitleForColumn:named:) Cast types to avoid compiler warnings. * EOControl/EOCheapArray.m (dealloc): Supress compiler warning. * EOAdaptors/Postgres95/LoginPanel/Postgres95LoginPanel.m (dealloc) * EOModeler/EOModelerEditor.m (dealloc): * DBModeler/ModelerAttributeEditor.m (dealloc): Add missing call to super. * DBModeler/Preferences.m (sharedPreferences): Fix implementation for new compiler semantics. * EOControl/EOMultiReaderLock.m (init): Correct NSConditionLock initialization. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@23472 72102866-910b-0410-8b05-ffd578937521
2006-09-12 19:36:24 +00:00
- (NSDictionary *) _leftSideKeyMap
{
NSDictionary *keyMap = nil;
NSEmitTODO(); //TODO
[self notImplemented: _cmd]; // TODO
if ([self isToManyToOne])
{
int count = [_definitionArray count];
if (count >= 2) //??
{
EORelationship *rel = [_definitionArray objectAtIndex: 0];
if ([rel isToMany]) //??
{
EOEntity *entity = [rel entity];
keyMap = [entity _keyMapForIdenticalKeyRelationshipPath:
[rel name]];
}
}
}
return keyMap;
}
- (EORelationship*)_substitutionRelationshipForRow: (NSDictionary*)row
{
EOEntity *entity = [self entity];
EOModel *model = [entity model];
EOModelGroup *modelGroup = [model modelGroup];
if (modelGroup)
{
//??
//NSEmitTODO(); //TODO
}
return self;
}
- (void) _joinsChanged
{
//TODO VERIFY
int count;
EOFLOGObjectFnStart();
count = [_joins count];
EOFLOGObjectLevelArgs(@"EORelationship", @"_joinsChanged:%@\nin %@", _joins, self);
if (count > 0)
{
int i;
for (i = 0; i < count; i++)
{
EOJoin *join = [_joins objectAtIndex: i];
EOAttribute *destinationAttribute = [join destinationAttribute];
EOEntity *destinationEntity = [destinationAttribute entity];
GDL2DestinationEntitiesRemoveRelationship(_destination, self);
GDL2DestinationEntitiesAddRelationship(destinationEntity, self);
_destination = destinationEntity;
}
}
else
{
_destination = nil;
}
//_joins count
//[self notImplemented:_cmd]; // TODO-NOW
/*
join destinationAttribute
attr entity
*/
EOFLOGObjectFnStop();
}
@end