2002-11-15 22:57:05 +00:00
/ * *
EODatabaseChannel . m < title > EODatabaseChannel < / title >
2005-08-17 08:07:57 +00:00
Copyright ( C ) 2000 -2002 , 2003 , 2004 , 2005 Free Software Foundation , Inc .
2002-11-15 22:57:05 +00:00
2006-09-14 16:06:21 +00:00
Author : Mirko Viviani < mirko . viviani @ gmail . com >
2002-11-15 22:57:05 +00:00
Date : June 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
2007-07-12 06:39:22 +00:00
version 3 of the License , or ( at your option ) any later version .
2002-11-15 22:57:05 +00:00
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 ,
2005-08-17 08:07:57 +00:00
51 Franklin Street , Fifth Floor , Boston , MA 02110 -1301 , USA .
2002-11-15 22:57:05 +00:00
< / license >
* * /
2002-12-31 16:25:21 +00:00
# include "config.h"
2004-03-19 16:41:21 +00:00
# ifdef GNUSTEP
2003-03-31 00:24:15 +00:00
# include < Foundation / NSString . h >
# include < Foundation / NSArray . h >
# include < Foundation / NSDictionary . h >
# include < Foundation / NSEnumerator . h >
# include < Foundation / NSNotification . h >
# include < Foundation / NSException . h >
# include < Foundation / NSObjCRuntime . h >
# include < Foundation / NSDebug . h >
# else
# include < Foundation / Foundation . h >
# endif
2003-07-11 19:04:05 +00:00
# ifndef GNUSTEP
2003-08-25 20:01:59 +00:00
# include < GNUstepBase / GNUstep . h >
2010-04-26 21:52:42 +00:00
# include < GNUstepBase / NSDebug + GNUstepBase . h >
2010-06-09 12:48:33 +00:00
# include < GNUstepBase / NSObject + GNUstepBase . h >
2003-07-11 19:04:05 +00:00
# endif
2003-03-31 00:24:15 +00:00
# include < EOControl / EOEditingContext . h >
# include < EOControl / EOKeyValueCoding . h >
# include < EOControl / EOFetchSpecification . h >
# include < EOControl / EOClassDescription . h >
# include < EOControl / EOKeyGlobalID . h >
# include < EOControl / EOObjectStore . h >
# include < EOControl / EODebug . h >
# include < EOAccess / EODatabaseChannel . h >
# include < EOAccess / EODatabaseContext . h >
2014-06-03 19:04:01 +00:00
# include < EOAccess / EODatabaseContextPriv . h >
2003-03-31 00:24:15 +00:00
# include < EOAccess / EODatabase . h >
# include < EOAccess / EOAdaptor . h >
# include < EOAccess / EOAdaptorChannel . h >
# include < EOAccess / EOAdaptorContext . h >
# include < EOAccess / EOEntity . h >
# include < EOAccess / EOAttribute . h >
# include < EOAccess / EORelationship . h >
# include < EOAccess / EOModel . h >
2014-06-03 19:04:01 +00:00
# include < EOAccess / EOModelGroup . h >
2003-03-31 00:24:15 +00:00
# include < EOAccess / EOAccessFault . h >
# include < EOAccess / EOSQLExpression . h >
2014-06-03 19:04:01 +00:00
# include < EOAccess / EOSQLExpressionFactory . h >
2003-03-31 00:24:15 +00:00
# include < EOAccess / EOSQLQualifier . h >
2002-11-15 22:57:05 +00:00
* 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"
2004-07-23 18:33:29 +00:00
# include "EOEntityPriv.h"
# include "EODatabaseContextPriv.h"
# include "EODatabaseChannelPriv.h"
2002-12-30 22:10:43 +00:00
2002-11-15 22:57:05 +00:00
@ implementation EODatabaseChannel
2003-02-01 15:19:56 +00:00
+ ( void ) initialize
2002-11-15 22:57:05 +00:00
{
COmmit Part 2
* EOAccess/EOAdaptor.m:
o optimization in 'for' loops
* EOAccess/EODatabase.m:
o include <EOCOntrol/EOPriv.h>
o replaced isNilOrEONull() by _isNilOrEONull()
* EOAccess/EODatabaseContext.h:
o added _snapshotForGlobalIDIMP
* EOAccess/EODatabaseContext.m:
o commented NSEmitTODO in
-objectsForSourceGlobalID:relationshipName:editingContext:
o added beter exception format in
qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot:
o fix compiler warning in -relayPrimaryKey:object:entity:
o logs
o optimizations in -objectsWithFetchSpecification:editingContext:
o replaced isNilOrEONull() by _isNilOrEONull()
o replace [EOFault isFault:] by _isFault()
o use _snapshotForGlobalIDIMP
o IMP usage optimization
* EOAccess/EOAttribute.[hm]:
o added EOAdaptorUnknownType
o added _adaptorValueType and avoid recomputing it each time
o added _valueTypeChar to avoid string comparaisons
o use EOPriv classes declarations
o Temporary reverted David changes in
-adaptorValueByConvertingAttributeValue
* EOAccess/EOAttributePriv.h:
o added _valueTypeChar to avoid string comparaisons
* EOAccess/EOEntityPriv.h:
o moved -attributeForPath: and -relationshipForPath: to
EOEntityGDL2Additions category
* EOAccess/EOEntity.h:
o moved private -attributeForPath: and -relationshipForPath: to
EOEntityGDL2Additions category
* EOAccess/EOEntity.m:
o better exception in classProperties
o fix compiler warning in -setClassProperties:,
-setPrimaryKeyAttributes:,
-setAttributesUsedForLocking:
o moved -attributeForPath: and -relationshipForPath: to
EOEntityGDL2Additions category
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLExpression.m:
o optimization in -tableListWithRootEntity:
o optimization in -formatSQLString:format:
o optimization in +sqlPatternFromShellPattern:
o optimization in +sqlPatternFromShellPattern:withEscapeCharacter:
o fix in -sqlStringForKeyValueQualifier:
o added log in -sqlStringForKeyValueQualifier: for not handled
readFormat
o added log -addInsertListAttribute:value: for not handled
writeFormat
o added log -addUpdateListAttribute:value: for not handled
writeFormat
o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond
o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLQualifier.m:
o implemented EOKeyComparisonQualifier
-schemaBasedQualifierWithRootEntity
* EOAccess/EOUtilities.m:
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOControl/EOPriv.[hm]:
o added. Contains various classes/selectors/IMPs
* EOControl/EOClassDescription.m:
o handle EONull case in -propagateDeleteForObject:editingContext:,
-addObject:toPropertyWithKey:, -snapshot,
-removeObject:fromPropertyWithKey:,
_setObject:forBothSidesOfRelationshipWithKey:,
addObject:toBothSidesOfRelationshipWithKey:,
-removeObject:fromBothSidesOfRelationshipWithKey:
o fix compiler warning in
-dictionaryForInstanceProperties, -shallowCopy,
-updateFromSnapshot:, -snapshot
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
o replaced isNilOrEONull() by _isNilOrEONull()
o fix in -validateForSave
o rewritten -validateValue:forKey: selector build
* EOControl/EOEditingContext.h:
o added -hasUnprocessedChanges
* EOControl/EOEditingContext.m:
o added -hasUnprocessedChanges
o added NS_DURING,... to catch exceptions
o replace [EOFault isFault:] by _isFault()
o IMP usage optimization
* EOControl/EOKeyGlobalID.m:
o replaced isNilOrEONull() by _isNilOrEONull()
o include <EOCOntrol/EOPriv.h>
* EOControl/EOGenericRecord.m:
o partially rewritten -description
o include <EOCOntrol/EOPriv.h>
o replaced isNilOrEONull() by _isNilOrEONull()
o replace [EOFault isFault:] by _isFault()
o changed variable name type of
_infoForInstanceVariableNamed:retType:retSize:retOffset:
o rewritten valueForKey:,... to use cString NSKeyValueCoding
* EOControl/EOKeyValueCoding.m:
o changed NSAssert in NSArray -valueForKey:
o optimization in NSDictionary -takeValue:forKeyPath:isSmart:
o optimization in NSDictionary -takeStoredValue:forKeyPath:
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
o include <EOCOntrol/EOPriv.h>
* EOControl/EOKeyValueQualifier.m:
o fixes for EONull/nil in -evaluateWithObject:
o replaced [EONull null] by GDL2EONull
o include <EOCOntrol/EOPriv.h>
* EOControl/EOSortOrdering.m:
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOAdaptors/Postgres95SQLExpression.m:
o float formatting in +formatValue:forAttribute:
o added -externalNameQuoteCharacter
o added +sqlPatternFromShellPattern:
o added +sqlPatternFromShellPattern:withEscapeCharacter:
o replaced isNilOrEONull() by _isNilOrEONull()
* EOAdaptors/Postgres95Channel.m:
o logs
* EOAdaptors/Postgres95Values.m:
o logs
o fix in +setPostgres95Format:
o fix calendard format to handle timezone (%z)
o optimizations
* EOControl/EOMutableKnownKeyDictionary.m
o removed EOMKKDArrayMapping
+dictionaryFromDictionary:subsetMapping:
o include <EOCOntrol/EOPriv.h>
o replaced isNilOrEONull() by _isNilOrEONull()
* EOControl/EONSAddOns.[hm]:
o added NSString(ShellPattern)
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
static BOOL initialized = NO ;
if ( ! initialized )
2003-02-01 15:19:56 +00:00
{
COmmit Part 2
* EOAccess/EOAdaptor.m:
o optimization in 'for' loops
* EOAccess/EODatabase.m:
o include <EOCOntrol/EOPriv.h>
o replaced isNilOrEONull() by _isNilOrEONull()
* EOAccess/EODatabaseContext.h:
o added _snapshotForGlobalIDIMP
* EOAccess/EODatabaseContext.m:
o commented NSEmitTODO in
-objectsForSourceGlobalID:relationshipName:editingContext:
o added beter exception format in
qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot:
o fix compiler warning in -relayPrimaryKey:object:entity:
o logs
o optimizations in -objectsWithFetchSpecification:editingContext:
o replaced isNilOrEONull() by _isNilOrEONull()
o replace [EOFault isFault:] by _isFault()
o use _snapshotForGlobalIDIMP
o IMP usage optimization
* EOAccess/EOAttribute.[hm]:
o added EOAdaptorUnknownType
o added _adaptorValueType and avoid recomputing it each time
o added _valueTypeChar to avoid string comparaisons
o use EOPriv classes declarations
o Temporary reverted David changes in
-adaptorValueByConvertingAttributeValue
* EOAccess/EOAttributePriv.h:
o added _valueTypeChar to avoid string comparaisons
* EOAccess/EOEntityPriv.h:
o moved -attributeForPath: and -relationshipForPath: to
EOEntityGDL2Additions category
* EOAccess/EOEntity.h:
o moved private -attributeForPath: and -relationshipForPath: to
EOEntityGDL2Additions category
* EOAccess/EOEntity.m:
o better exception in classProperties
o fix compiler warning in -setClassProperties:,
-setPrimaryKeyAttributes:,
-setAttributesUsedForLocking:
o moved -attributeForPath: and -relationshipForPath: to
EOEntityGDL2Additions category
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLExpression.m:
o optimization in -tableListWithRootEntity:
o optimization in -formatSQLString:format:
o optimization in +sqlPatternFromShellPattern:
o optimization in +sqlPatternFromShellPattern:withEscapeCharacter:
o fix in -sqlStringForKeyValueQualifier:
o added log in -sqlStringForKeyValueQualifier: for not handled
readFormat
o added log -addInsertListAttribute:value: for not handled
writeFormat
o added log -addUpdateListAttribute:value: for not handled
writeFormat
o changed EOFLOGObjectFnStart to EOFLOGObjectFnStartCond
o changed EOFLOGObjectFnStop to EOFLOGObjectFnStopCond
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLQualifier.m:
o implemented EOKeyComparisonQualifier
-schemaBasedQualifierWithRootEntity
* EOAccess/EOUtilities.m:
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOControl/EOPriv.[hm]:
o added. Contains various classes/selectors/IMPs
* EOControl/EOClassDescription.m:
o handle EONull case in -propagateDeleteForObject:editingContext:,
-addObject:toPropertyWithKey:, -snapshot,
-removeObject:fromPropertyWithKey:,
_setObject:forBothSidesOfRelationshipWithKey:,
addObject:toBothSidesOfRelationshipWithKey:,
-removeObject:fromBothSidesOfRelationshipWithKey:
o fix compiler warning in
-dictionaryForInstanceProperties, -shallowCopy,
-updateFromSnapshot:, -snapshot
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
o replaced isNilOrEONull() by _isNilOrEONull()
o fix in -validateForSave
o rewritten -validateValue:forKey: selector build
* EOControl/EOEditingContext.h:
o added -hasUnprocessedChanges
* EOControl/EOEditingContext.m:
o added -hasUnprocessedChanges
o added NS_DURING,... to catch exceptions
o replace [EOFault isFault:] by _isFault()
o IMP usage optimization
* EOControl/EOKeyGlobalID.m:
o replaced isNilOrEONull() by _isNilOrEONull()
o include <EOCOntrol/EOPriv.h>
* EOControl/EOGenericRecord.m:
o partially rewritten -description
o include <EOCOntrol/EOPriv.h>
o replaced isNilOrEONull() by _isNilOrEONull()
o replace [EOFault isFault:] by _isFault()
o changed variable name type of
_infoForInstanceVariableNamed:retType:retSize:retOffset:
o rewritten valueForKey:,... to use cString NSKeyValueCoding
* EOControl/EOKeyValueCoding.m:
o changed NSAssert in NSArray -valueForKey:
o optimization in NSDictionary -takeValue:forKeyPath:isSmart:
o optimization in NSDictionary -takeStoredValue:forKeyPath:
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
o include <EOCOntrol/EOPriv.h>
* EOControl/EOKeyValueQualifier.m:
o fixes for EONull/nil in -evaluateWithObject:
o replaced [EONull null] by GDL2EONull
o include <EOCOntrol/EOPriv.h>
* EOControl/EOSortOrdering.m:
o include <EOCOntrol/EOPriv.h>
o replaced [EONull null] by GDL2EONull
* EOAdaptors/Postgres95SQLExpression.m:
o float formatting in +formatValue:forAttribute:
o added -externalNameQuoteCharacter
o added +sqlPatternFromShellPattern:
o added +sqlPatternFromShellPattern:withEscapeCharacter:
o replaced isNilOrEONull() by _isNilOrEONull()
* EOAdaptors/Postgres95Channel.m:
o logs
* EOAdaptors/Postgres95Values.m:
o logs
o fix in +setPostgres95Format:
o fix calendard format to handle timezone (%z)
o optimizations
* EOControl/EOMutableKnownKeyDictionary.m
o removed EOMKKDArrayMapping
+dictionaryFromDictionary:subsetMapping:
o include <EOCOntrol/EOPriv.h>
o replaced isNilOrEONull() by _isNilOrEONull()
* EOControl/EONSAddOns.[hm]:
o added NSString(ShellPattern)
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20688 72102866-910b-0410-8b05-ffd578937521
2005-02-11 17:37:23 +00:00
initialized = YES ;
* 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
GDL2_EOAccessPrivateInit ( ) ;
2003-02-01 15:19:56 +00:00
[ [ NSNotificationCenter defaultCenter ]
addObserver : self
selector : @ selector ( _registerDatabaseChannel : )
name : EODatabaseChannelNeededNotification
object : nil ] ;
}
2002-11-15 22:57:05 +00:00
}
+ ( void ) _registerDatabaseChannel : ( NSNotification * ) notification
{
// TODO who release it ?
[ [ EODatabaseChannel alloc ] initWithDatabaseContext : [ notification object ] ] ;
}
+ ( EODatabaseChannel * ) databaseChannelWithDatabaseContext : ( EODatabaseContext * ) databaseContext
{
return [ [ [ self alloc ] initWithDatabaseContext : databaseContext ] autorelease ] ;
}
2010-05-30 18:24:14 +00:00
- ( id ) init
{
[ NSException raise : NSInvalidArgumentException
format : @ "Use initWithDatabaseContext to init an instance of class %@" ,
NSStringFromClass ( [ self class ] ) ] ;
return nil ;
}
2002-11-15 22:57:05 +00:00
- ( id ) initWithDatabaseContext : ( EODatabaseContext * ) databaseContext
{
if ( ( self = [ super init ] ) )
{
2010-05-30 18:24:14 +00:00
ASSIGN ( _adaptorChannel , [ [ databaseContext adaptorContext ]
2002-11-15 22:57:05 +00:00
createAdaptorChannel ] ) ;
2010-05-30 18:24:14 +00:00
if ( ! _adaptorChannel )
{
[ NSException raise : NSInternalInconsistencyException
format : @ "EODatabaseChannel is unable to obtain new channel from %@" ,
[ databaseContext adaptorContext ] ] ;
} else {
ASSIGN ( _databaseContext , databaseContext ) ;
}
2002-11-15 22:57:05 +00:00
}
return self ;
}
- ( void ) dealloc
{
[ _databaseContext unregisterChannel : self ] ;
DESTROY ( _databaseContext ) ;
[ _adaptorChannel closeChannel ] ;
DESTROY ( _adaptorChannel ) ;
DESTROY ( _currentEntity ) ;
DESTROY ( _currentEditingContext ) ;
DESTROY ( _fetchProperties ) ;
DESTROY ( _fetchSpecifications ) ;
2014-06-03 19:04:01 +00:00
DESTROY ( _refreshedGIDs ) ;
2002-11-15 22:57:05 +00:00
[ super dealloc ] ;
}
2014-06-03 19:04:01 +00:00
// MG2014 : OK
2002-11-15 22:57:05 +00:00
- ( void ) setCurrentEntity : ( EOEntity * ) entity
{
2014-06-03 19:04:01 +00:00
if ( entity ! = _currentEntity )
{
DESTROY ( _fetchProperties ) ;
ASSIGN ( _currentEntity , entity ) ;
[ self setEntity : entity ] ;
}
2002-11-15 22:57:05 +00:00
}
2014-06-03 19:04:01 +00:00
// MG2014 : OK
2002-11-15 22:57:05 +00:00
- ( void ) setEntity : ( EOEntity * ) entity
{
NSArray * relationships = [ entity relationships ] ;
2014-06-03 19:04:01 +00:00
NSUInteger relCount = [ relationships count ] ;
if ( relCount > 0 )
2002-11-15 22:57:05 +00:00
{
2014-06-03 19:04:01 +00:00
Class databaseContextClass = [ [ self databaseContext ] class ] ;
NSUInteger i = 0 ;
for ( i = 0 ; i < relCount ; i + + )
{
EORelationship * relationship = [ relationships objectAtIndex : i ] ;
EOModel * model = [ [ relationship destinationEntity ] model ] ;
if ( [ [ relationship entity ] model ] ! = model )
{
[ databaseContextClass registeredDatabaseContextForModel : model
editingContext : [ self currentEditingContext ] ] ;
}
}
2002-11-15 22:57:05 +00:00
}
}
2014-06-03 19:04:01 +00:00
// MG2014 : OK
2002-11-15 22:57:05 +00:00
- ( void ) setCurrentEditingContext : ( EOEditingContext * ) context
{
2014-06-03 19:04:01 +00:00
ASSIGN ( _currentEditingContext , context ) ;
if ( _currentEditingContext ! = nil )
{
_currentEditingContextTimestamp = [ _currentEditingContext fetchTimestamp ] ;
[ ( EOObjectStoreCoordinator * ) [ _currentEditingContext rootObjectStore ]
addCooperatingObjectStore : [ self databaseContext ] ] ;
}
2002-11-15 22:57:05 +00:00
}
2007-01-01 11:52:38 +00:00
- ( void ) selectObjectsWithFetchSpecification : ( EOFetchSpecification * ) fetchSpecification
2002-11-15 22:57:05 +00:00
editingContext : ( EOEditingContext * ) context
{
// should be OK
NSString * entityName = nil ;
EODatabase * database = nil ;
EOEntity * entity = nil ;
EOQualifier * qualifier = nil ;
EOQualifier * schemaBasedQualifier = nil ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
2007-01-01 11:52:38 +00:00
entityName = [ fetchSpecification entityName ] ;
2002-11-15 22:57:05 +00:00
database = [ _databaseContext database ] ;
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "database=%@" , database ) ;
2002-11-15 22:57:05 +00:00
entity = [ database entityNamed : entityName ] ;
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "entity name=%@" , [ entity name ] ) ;
2002-11-15 22:57:05 +00:00
2007-01-01 11:52:38 +00:00
qualifier = [ fetchSpecification qualifier ] ;
2002-11-15 22:57:05 +00:00
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "qualifier=%@" , qualifier ) ;
2002-11-15 22:57:05 +00:00
schemaBasedQualifier =
[ ( id < EOQualifierSQLGeneration > ) qualifier
schemaBasedQualifierWithRootEntity : entity ] ;
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "schemaBasedQualifier=%@" , schemaBasedQualifier ) ;
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "qualifier=%@" , qualifier ) ;
2002-11-15 22:57:05 +00:00
if ( schemaBasedQualifier && schemaBasedQualifier ! = qualifier )
{
EOFetchSpecification * newFetch = nil ;
2007-01-01 11:52:38 +00:00
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "fetchSpecification=%@" , fetchSpecification ) ;
2002-11-15 22:57:05 +00:00
// howto avoid copy of uncopiable qualifiers ( i . e . those who contains uncopiable key or value )
2007-01-01 11:52:38 +00:00
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "fetchSpecification=%@" , fetchSpecification ) ;
2002-11-15 22:57:05 +00:00
2007-01-01 11:52:38 +00:00
newFetch = [ [ fetchSpecification copy ] autorelease ] ;
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "newFetch=%@" , newFetch ) ;
2002-11-15 22:57:05 +00:00
[ newFetch setQualifier : schemaBasedQualifier ] ;
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "newFetch=%@" , newFetch ) ;
2002-11-15 22:57:05 +00:00
2007-01-01 11:52:38 +00:00
fetchSpecification = newFetch ;
2002-11-15 22:57:05 +00:00
}
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs ( @ "gsdb" , @ "%@ -- %@ 0x%x: isFetchInProgress=%s" ,
2002-11-15 22:57:05 +00:00
NSStringFromSelector ( _cmd ) ,
NSStringFromClass ( [ self class ] ) ,
self ,
( [ self isFetchInProgress ] ? "YES" : "NO" ) ) ;
2007-01-01 11:52:38 +00:00
[ self _selectWithFetchSpecification : fetchSpecification
2002-11-15 22:57:05 +00:00
editingContext : context ] ;
2014-06-03 19:04:01 +00:00
[ database setTimestampToNow ] ;
2002-11-15 22:57:05 +00:00
}
2014-06-03 19:04:01 +00:00
// MG2014 : OK
2002-11-15 22:57:05 +00:00
- ( id ) fetchObject
{
2014-06-03 19:04:01 +00:00
EODatabase * database = [ _databaseContext database ] ;
2002-11-15 22:57:05 +00:00
id object = nil ;
2010-06-28 09:31:49 +00:00
2002-11-15 22:57:05 +00:00
if ( ! [ self isFetchInProgress ] )
{
2014-06-03 19:04:01 +00:00
// Exception or just return nil ?
[ NSException raise : NSInvalidArgumentException
format : @ "%@ -- %@ 0x%p: no fetch in progress" ,
NSStringFromSelector ( _cmd ) ,
NSStringFromClass ( [ self class ] ) ,
self ] ;
2010-06-11 12:17:45 +00:00
}
2014-06-03 19:04:01 +00:00
else
2010-06-11 12:17:45 +00:00
{
2014-06-03 19:04:01 +00:00
NSDictionary * row = nil ;
EOEntity * entity = nil ;
2010-06-11 12:17:45 +00:00
2014-06-03 19:04:01 +00:00
NSAssert ( _currentEditingContext , @ "No current editing context" ) ;
NSAssert ( _adaptorChannel , @ "No adaptor channel" ) ;
2010-06-11 12:17:45 +00:00
2014-06-03 19:04:01 +00:00
[ self _propertiesToFetch ] ;
for ( row = [ _adaptorChannel fetchRowWithZone : NULL ] ; row = = nil ; )
{
if ( _fetchSpecifications ! = nil )
{
[ self _cancelInternalFetch ] ;
[ self _selectWithFetchSpecification : nil
editingContext : _currentEditingContext ] ;
[ self _propertiesToFetch ] ;
row = [ _adaptorChannel fetchRowWithZone : NULL ] ;
}
else
{
_isLocking = NO ;
return nil ; // End
}
}
NSLog ( @ "MG-OXYMIUM-TMP %s:%d row=%@" , __PRETTY _FUNCTION __ , __LINE __ , row ) ;
2010-06-11 12:17:45 +00:00
2014-06-03 19:04:01 +00:00
if ( _isFetchingSingleTableEntity )
{
entity = [ _currentEntity _singleTableSubEntityForRow : row ] ;
if ( entity = = nil )
{
[ NSException raise : @ "NSIllegalStateException"
format : @ "%s Unable to determine subentity of '%@' for row: %@. Check that the attribute '%@' is marked as a class property in the EOModel and that the value satisfies some subentity's restricting qualifier." ,
__PRETTY _FUNCTION __ ,
[ _currentEntity name ] ,
row ,
[ _currentEntity _singleTableSubEntityKey ] ] ;
}
}
2002-11-15 22:57:05 +00:00
else
2014-06-03 19:04:01 +00:00
{
entity = _currentEntity ;
}
EOKeyGlobalID * gid = ( EOKeyGlobalID * ) [ entity _globalIDForRow : row
isFinal : YES ] ;
if ( gid = = nil )
{
[ NSException raise : @ "NSIllegalStateException"
format : @ "%s Cannot determine primary key for entity '%@' from row: %@" ,
__PRETTY _FUNCTION __ ,
[ _currentEntity name ] ,
row ] ;
}
else
{
NSDictionary * dbxSnapshot = nil ;
NSDictionary * snapshot = nil ;
NSDictionary * newSnapshot = nil ;
BOOL respondsTo_shouldUpdateCurrentSnapshot = [ _databaseContext _respondsTo _shouldUpdateCurrentSnapshot ] ;
object = [ _currentEditingContext objectForGlobalID : gid ] ;
NSLog ( @ "MG-OXYMIUM-TMP %s:%d gid=%@ object=%@" , __PRETTY _FUNCTION __ , __LINE __ , gid , object ) ;
snapshot = [ database snapshotForGlobalID : gid
after : ( respondsTo_shouldUpdateCurrentSnapshot ?
EODistantPastTimeInterval : _currentEditingContextTimestamp ) ] ;
NSLog ( @ "MG-OXYMIUM-TMP %s:%d gid=%@ snapshot=%@" , __PRETTY _FUNCTION __ , __LINE __ , gid , snapshot ) ;
if ( snapshot ! = nil )
{
if ( respondsTo_shouldUpdateCurrentSnapshot
&& ( newSnapshot = [ _databaseContext _shouldUpdateCurrentSnapshot : snapshot
newSnapshot : row
globalID : gid
databaseChannel : self ] ) ! = nil )
{
NSLog ( @ "MG-OXYMIUM-TMP %s:%d gid=%@ newSnapshot=%@" , __PRETTY _FUNCTION __ , __LINE __ , gid , newSnapshot ) ;
if ( newSnapshot ! = snapshot )
{
snapshot = newSnapshot ;
[ database recordSnapshot : snapshot
forGlobalID : gid ] ;
}
else
{
newSnapshot = nil ;
}
}
else if ( ( _isLocking || _isRefreshingObjects )
&& ! [ _databaseContext isObjectLockedWithGlobalID : gid ]
&& ! [ snapshot isEqual : row ] )
{
if ( _isLocking && ! _isRefreshingObjects )
{
[ NSException raise : @ "NSIllegalStateException"
format : @ "%s attempt to lock object that has out of date snapshot: %@" ,
__PRETTY _FUNCTION __ ,
gid ] ;
}
NSLog ( @ "MG-OXYMIUM-TMP %s:%d gid=%@ row=%@" , __PRETTY _FUNCTION __ , __LINE __ , gid , row ) ;
snapshot = newSnapshot = row ;
[ database recordSnapshot : snapshot
forGlobalID : gid ] ;
}
dbxSnapshot = snapshot ;
}
else
{
NSDictionary * aSnapshot = [ database snapshotForGlobalID : gid ] ;
NSLog ( @ "MG-OXYMIUM-TMP %s:%d gid=%@ aSnapshot=%@" , __PRETTY _FUNCTION __ , __LINE __ , gid , aSnapshot ) ;
[ database recordSnapshot : row
forGlobalID : gid ] ;
if ( aSnapshot ! = nil
&& ! [ aSnapshot isEqualToDictionary : row ] )
newSnapshot = row ;
dbxSnapshot = row ;
}
2010-06-29 03:10:35 +00:00
2014-06-03 19:04:01 +00:00
if ( _isLocking )
[ _databaseContext registerLockedObjectWithGlobalID : gid ] ;
if ( newSnapshot ! = nil )
{
if ( _refreshedGIDs = = nil )
_refreshedGIDs = [ NSMutableArray new ] ;
[ _refreshedGIDs addObject : gid ] ;
}
if ( object ! = nil
&& ! _isFault ( object ) )
{
return object ; // End
}
else
{
if ( object = = nil
&& newSnapshot ! = nil )
{
object = [ _currentEditingContext faultForGlobalID : gid
editingContext : _currentEditingContext ] ;
return object ; // End
}
else
{
if ( object = = nil )
{
EOClassDescription * entityClassDescripton = [ entity classDescriptionForInstances ] ;
object = [ entityClassDescripton createInstanceWithEditingContext : _currentEditingContext
globalID : gid
zone : NULL ] ;
[ _currentEditingContext recordObject : object
globalID : gid ] ;
}
else
{
EOAccessFaultHandler * handler =
( EOAccessFaultHandler * ) [ EOFault handlerForFault : object ] ;
if ( [ ( EOKeyGlobalID * ) [ handler globalID ] isFinal ] )
{
[ EOFault clearFault : object ] ;
}
else
{
[ EOFault clearFault : object ] ;
[ entity initObject : object
editingContext : _currentEditingContext
globalID : gid ] ;
}
}
[ EOObserverCenter suppressObserverNotification ] ;
NS_DURING
{
ASSIGN ( _databaseContext -> _lastEntity , entity ) ;
// TODO
/ *
_databaseContext -> _currentGlobalID = gid ;
_databaseContext -> _currentSnapshot = dbxSnapshot ;
* /
[ _currentEditingContext initializeObject : object
withGlobalID : gid
editingContext : _currentEditingContext ] ;
// TODO
/ *
_databaseContext -> _currentGlobalID = nil ;
* /
}
NS_HANDLER
{
[ EOObserverCenter enableObserverNotification ] ;
[ localException raise ] ;
}
NS_ENDHANDLER ;
[ EOObserverCenter enableObserverNotification ] ;
[ object awakeFromFetchInEditingContext : _currentEditingContext ] ;
}
}
}
2002-11-15 22:57:05 +00:00
}
return object ;
2010-06-28 09:31:49 +00:00
}
2002-11-15 22:57:05 +00:00
- ( BOOL ) isFetchInProgress
{
return [ _adaptorChannel isFetchInProgress ] ;
}
2014-06-03 19:04:01 +00:00
// MG2014 : Near OK ( See TODO )
2002-11-15 22:57:05 +00:00
- ( void ) cancelFetch
{
2014-06-03 19:04:01 +00:00
[ self _cancelInternalFetch ] ;
2010-05-30 19:25:53 +00:00
2014-06-03 19:04:01 +00:00
if ( _fetchSpecifications ! = nil )
DESTROY ( _fetchSpecifications ) ;
2002-11-15 22:57:05 +00:00
[ self _cancelInternalFetch ] ;
2014-06-03 19:04:01 +00:00
if ( _refreshedGIDs ! = nil )
{
IMP oaiIMP = NULL ;
EOEditingContext * editingContext = _currentEditingContext ;
NSMutableArray * refreshedGIDs = _refreshedGIDs ;
EODatabase * database = [ _databaseContext database ] ;
NSUInteger refreshedGIDsCount = [ refreshedGIDs count ] ;
NSUInteger i = 0 ;
_refreshedGIDs = nil ;
2002-11-15 22:57:05 +00:00
2014-06-03 19:04:01 +00:00
for ( i = 0 ; i < refreshedGIDsCount ; i + + )
[ database incrementSnapshotCountForGlobalID : GDL2_ObjectAtIndexWithImpPtr ( refreshedGIDs , & oaiIMP , i ) ] ;
2010-05-30 19:25:53 +00:00
2014-06-03 19:04:01 +00:00
[ editingContext lock ] ;
NS_DURING
{
[ [ NSNotificationCenter defaultCenter ]
postNotificationName : @ "EOObjectsChangedInStoreNotification"
object : _databaseContext
userInfo : [ NSDictionary dictionaryWithObject : refreshedGIDs
forKey : @ "updated" ] ] ;
for ( i = 0 ; i < refreshedGIDsCount ; i + + )
{
EOKeyGlobalID * gid = GDL2_ObjectAtIndexWithImpPtr ( refreshedGIDs , & oaiIMP , i ) ;
// TODO [ [ editingContext objectForGlobalID : gid ] willRead ] ;
[ database decrementSnapshotCountForGlobalID : gid ] ;
}
}
NS_HANDLER
{
[ editingContext unlock ] ;
DESTROY ( refreshedGIDs ) ; // was retained as _refreshedGIDs
[ localException raise ] ;
}
NS_ENDHANDLER ;
[ editingContext unlock ] ;
DESTROY ( refreshedGIDs ) ; // was retained as _refreshedGIDs
}
2002-11-15 22:57:05 +00:00
}
- ( EODatabaseContext * ) databaseContext
{
return _databaseContext ;
}
- ( EOAdaptorChannel * ) adaptorChannel
{
return _adaptorChannel ;
}
- ( BOOL ) isRefreshingObjects
{
return _isRefreshingObjects ;
}
- ( void ) setIsRefreshingObjects : ( BOOL ) yn
{
_isRefreshingObjects = yn ;
}
- ( BOOL ) isLocking
{
return _isLocking ;
}
- ( void ) setIsLocking : ( BOOL ) isLocking
{
_isLocking = isLocking ;
}
@ end
@ implementation EODatabaseChannel ( EODatabaseChannelPrivate )
- ( NSArray * ) _propertiesToFetch
{
// OK
NSArray * attributesToFetch = nil ;
2014-05-22 14:05:51 +00:00
if ( _currentEntity = = nil )
attributesToFetch = [ _adaptorChannel describeResults ] ;
else
attributesToFetch = [ _currentEntity _attributesToFetch ] ;
2002-11-15 22:57:05 +00:00
return attributesToFetch ;
}
- ( void ) _setCurrentEntityAndRelationshipWithFetchSpecification : ( EOFetchSpecification * ) fetch
{
// OK
NSString * entityName = [ fetch entityName ] ;
EODatabase * database = [ _databaseContext database ] ;
EOEntity * entity = [ database entityNamed : entityName ] ;
NSAssert1 ( entity , @ "No Entity named %@" , entityName ) ;
[ self setCurrentEntity : entity ] ;
}
- ( void ) _buildNodeList : ( id ) param0
withParent : ( id ) param1
{
// TODO
[ self notImplemented : _cmd ] ;
}
- ( id ) currentEditingContext
{
return _currentEditingContext ;
}
2014-06-03 19:04:01 +00:00
// MG2014 : OK
2002-11-15 22:57:05 +00:00
- ( void ) _cancelInternalFetch
{
if ( [ _adaptorChannel isFetchInProgress ] )
2014-06-03 19:04:01 +00:00
[ _adaptorChannel cancelFetch ] ;
2002-11-15 22:57:05 +00:00
}
2014-06-03 19:04:01 +00:00
// MG2014 : OK
2002-11-15 22:57:05 +00:00
- ( void ) _closeChannel
{
2014-06-03 19:04:01 +00:00
[ _adaptorChannel closeChannel ] ;
2002-11-15 22:57:05 +00:00
}
2014-06-03 19:04:01 +00:00
// MG2014 : OK
2002-11-15 22:57:05 +00:00
- ( void ) _openChannel
{
2014-06-03 19:04:01 +00:00
if ( ! [ _adaptorChannel isOpen ] )
[ _adaptorChannel openChannel ] ;
2002-11-15 22:57:05 +00:00
}
2014-06-03 19:04:01 +00:00
- ( void ) _selectWithFetchSpecification : ( EOFetchSpecification * ) fetchSpec
editingContext : ( EOEditingContext * ) editingContext
2002-11-15 22:57:05 +00:00
{
2014-06-03 19:04:01 +00:00
EOSQLExpression * sqlExpression = nil ;
_isFetchingSingleTableEntity = NO ;
2002-11-15 22:57:05 +00:00
2014-06-03 19:04:01 +00:00
if ( _fetchSpecifications ! = nil )
2002-11-15 22:57:05 +00:00
{
2014-06-03 19:04:01 +00:00
fetchSpec = [ _fetchSpecifications lastObject ] ;
[ _fetchSpecifications removeLastObject ] ;
[ self setCurrentEntity : [ [ _databaseContext database ] entityNamed : [ fetchSpec entityName ] ] ] ;
_isFetchingSingleTableEntity = [ _currentEntity _isSingleTableEntity ] ;
if ( [ _fetchSpecifications count ] = = 0 )
DESTROY ( _fetchSpecifications ) ;
2002-11-15 22:57:05 +00:00
}
else
{
2014-06-03 19:04:01 +00:00
if ( fetchSpec = = nil )
{
[ NSException raise : @ "NSIllegalArgumentException"
format : @ "%s invoked with nil fetchSpecification" ,
__PRETTY _FUNCTION __ ] ;
}
else
{
NSDictionary * hints = [ fetchSpec hints ] ;
id customQueryExpressionHint = [ hints objectForKey : @ "EOCustomQueryExpressionHintKey" ] ;
if ( customQueryExpressionHint ! = nil )
{
if ( [ customQueryExpressionHint isKindOfClass : [ NSString class ] ] )
{
sqlExpression = [ [ [ [ _databaseContext adaptorContext ] adaptor ]
expressionFactory ]
expressionForString : customQueryExpressionHint ] ;
}
else
sqlExpression = ( EOSQLExpression * ) customQueryExpressionHint ;
}
[ self setCurrentEditingContext : editingContext ] ;
[ self _setCurrentEntityAndRelationshipWithFetchSpecification : fetchSpec ] ;
if ( [ fetchSpec isDeep ]
&& sqlExpression = = nil )
{
_isFetchingSingleTableEntity = [ _currentEntity _isSingleTableEntity ] ;
if ( ! _isFetchingSingleTableEntity
&& [ [ _currentEntity subEntities ] count ] > 0 )
{
NSMutableArray * nodes = [ NSMutableArray array ] ;
NSUInteger nodesCount = 0 ;
[ self _buildNodeList : nodes
withParent : _currentEntity ] ;
nodesCount = [ nodes count ] ;
ASSIGN ( _fetchSpecifications , ( [ NSMutableArray arrayWithCapacity : nodesCount ] ) ) ;
if ( nodesCount > 0 )
{
NSUInteger i = 0 ;
for ( i = 0 ; i < nodesCount ; i + + )
{
EOFetchSpecification * aFetchSpec = AUTORELEASE ( [ fetchSpec copy ] ) ;
[ aFetchSpec setEntityName : [ nodes objectAtIndex : i ] ] ;
[ _fetchSpecifications addObject : aFetchSpec ] ;
}
}
[ self _selectWithFetchSpecification : nil
editingContext : editingContext ] ;
return ; // Finished !
}
}
2002-11-15 22:57:05 +00:00
}
}
2014-06-03 19:04:01 +00:00
NSArray * propertiesToFetch = [ self _propertiesToFetch ] ;
2002-11-15 22:57:05 +00:00
2014-06-03 19:04:01 +00:00
if ( [ _databaseContext _performShouldSelectObjectsWithFetchSpecification : fetchSpec
databaseChannel : self ] )
2002-11-15 22:57:05 +00:00
{
2014-06-03 19:04:01 +00:00
_isLocking = [ _databaseContext _usesPessimisticLockingWithFetchSpecification : fetchSpec
databaseChannel : self ] ;
_isRefreshingObjects = [ fetchSpec refreshesRefetchedObjects ] ;
if ( _isLocking
&& ! [ [ _adaptorChannel adaptorContext ] hasOpenTransaction ] )
{
[ [ _adaptorChannel adaptorContext ] beginTransaction ] ;
}
if ( [ [ _currentEntity primaryKeyAttributes ] count ] = = 0 )
{
[ NSException raise : @ "NSIllegalStateException"
format : @ "%s attempt to select EOs from entity '%@' which has no primary key defined. All entities must have a primary key specified. You should run the EOModeler consistency checker on the model containing this entity and perform whatever actions are necessary to ensure that the model is in a consistent state." ,
__PRETTY _FUNCTION __ ,
[ _currentEntity name ] ] ;
}
else
{
NSDictionary * hints = [ fetchSpec hints ] ;
EOStoredProcedure * storedProcedure = nil ;
NSString * storedProcedureName = [ hints objectForKey : @ "EOStoredProcedureNameHintKey" ] ;
if ( storedProcedureName ! = nil )
{
storedProcedure = [ [ [ _currentEntity model ] modelGroup ] storedProcedureNamed : storedProcedureName ] ;
}
if ( storedProcedure ! = nil )
{
[ _adaptorChannel executeStoredProcedure : storedProcedure
withValues : nil ] ;
[ _adaptorChannel setAttributesToFetch : propertiesToFetch ] ;
}
else if ( sqlExpression ! = nil )
{
[ _adaptorChannel evaluateExpression : sqlExpression ] ;
[ _adaptorChannel setAttributesToFetch : propertiesToFetch ] ;
}
else
{
EOQualifier * qualifier = [ fetchSpec qualifier ] ;
if ( qualifier = = nil
&& ( storedProcedure = [ _currentEntity storedProcedureForOperation : @ "EOFetchAllProcedure" ] ) ! = nil )
{
[ _adaptorChannel executeStoredProcedure : storedProcedure
withValues : nil ] ;
[ _adaptorChannel setAttributesToFetch : propertiesToFetch ] ;
}
else
{
storedProcedure = [ _currentEntity storedProcedureForOperation : @ "EOFetchWithPrimaryKeyProcedure" ] ;
if ( qualifier ! = nil
&& storedProcedure ! = nil
&& [ _currentEntity isQualifierForPrimaryKey : qualifier ] )
{
NSMutableDictionary * keyValues = nil ;
if ( [ qualifier isKindOfClass : [ EOKeyValueQualifier class ] ] )
{
keyValues = [ NSMutableDictionary dictionaryWithObject : [ ( EOKeyValueQualifier * ) qualifier value ]
forKey : [ ( EOKeyValueQualifier * ) qualifier key ] ] ;
}
else
{
NSArray * qualifiers = [ ( EOAndQualifier * ) qualifier qualifiers ] ;
NSUInteger qualifiersCount = [ qualifiers count ] ;
NSUInteger i = 0 ;
keyValues = [ NSMutableDictionary dictionaryWithCapacity : qualifiersCount ] ;
for ( i = 0 ; i < qualifiersCount ; i + + )
{
EOKeyValueQualifier * kvQualifier = [ qualifiers objectAtIndex : i ] ;
[ keyValues setObject : [ kvQualifier value ]
forKey : [ kvQualifier key ] ] ;
}
}
[ _adaptorChannel executeStoredProcedure : storedProcedure
withValues : keyValues ] ;
[ _adaptorChannel setAttributesToFetch : propertiesToFetch ] ;
}
else
{
[ _adaptorChannel selectAttributes : propertiesToFetch
fetchSpecification : fetchSpec
lock : _isLocking
entity : _currentEntity ] ;
}
}
}
[ _databaseContext _performDidSelectObjectsWithFetchSpecification : fetchSpec
databaseChannel : self ] ;
}
}
2002-11-15 22:57:05 +00:00
}
@ end / * EODatabaseChannel * /