2002-11-15 22:57:05 +00:00
|
|
|
/**
|
|
|
|
EODatabase.m <title>EODatabase Class</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
|
|
|
|
|
|
|
|
$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"
|
|
|
|
|
|
|
|
RCS_ID("$Id$")
|
2002-11-15 22:57:05 +00:00
|
|
|
|
2004-03-19 16:41:21 +00:00
|
|
|
#ifdef GNUSTEP
|
2003-03-31 00:24:15 +00:00
|
|
|
#include <Foundation/NSArray.h>
|
* EOControl/EOAndQualifier.m,
* EOControl/EOFault.m,
* EOControl/EOFaultHandler.m,
* EOControl/EOKeyComparisonQualifier.m,
* EOControl/EOKeyValueArchiver.m,
* EOControl/EOKeyValueCoding.m,
* EOControl/EOKeyValueCodingBase.m,
* EOControl/EOMutableKnownKeyDictionary.h,
* EOControl/EONotQualifier.m,
* EOControl/EOOrQualifier.m,
* EOControl/EOQualifier.m,
* EOAccess/EOAdaptor.m,
* EOAccess/EOAdaptorContext.m,
* EOAccess/EOAttribute.m,
* EOAccess/EODatabase.m,
* EOAccess/EODatabaseContext.m,
* EOAccess/EOExpressionArray.m,
* EOAccess/EOJoin.m,
* EOAccess/EOModel.m,
* EOAccess/EOModelGroup.m,
* EOAccess/EORelationship.m,
* EOAccess/EOSQLExpression.m,
* EOAccess/EOSQLQualifier.m,
* EOAccess/EOSchemaGeneration.m,
* EOAccess/EOStoredProcedure.m,
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLAdaptor.m,
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLChannel.m,
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLExpression.m,
* EOAdaptors/SQLiteAdaptor/SQLite3Adaptor.m,
* EOAdaptors/SQLiteAdaptor/SQLite3Channel.m,
* EOInterface/EOTableViewAssociation.m,
* EOModeler/EOModelExtensions.m,
* EOModeler/EOModelerApp.m,
* DBModeler/ModelerAttributeEditor.m,
* DBModeler/ModelerEntityEditor.m: Remove references to NSUtilities.h.
Add includes for missing header references.
* DBModeler/Modeler.m (-[showEditor:]): Add cast to avoid compiler
warning.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@25994 72102866-910b-0410-8b05-ffd578937521
2008-01-22 13:57:07 +00:00
|
|
|
#include <Foundation/NSDebug.h>
|
2003-03-31 00:24:15 +00:00
|
|
|
#include <Foundation/NSDictionary.h>
|
* EOControl/EOAndQualifier.m,
* EOControl/EOFault.m,
* EOControl/EOFaultHandler.m,
* EOControl/EOKeyComparisonQualifier.m,
* EOControl/EOKeyValueArchiver.m,
* EOControl/EOKeyValueCoding.m,
* EOControl/EOKeyValueCodingBase.m,
* EOControl/EOMutableKnownKeyDictionary.h,
* EOControl/EONotQualifier.m,
* EOControl/EOOrQualifier.m,
* EOControl/EOQualifier.m,
* EOAccess/EOAdaptor.m,
* EOAccess/EOAdaptorContext.m,
* EOAccess/EOAttribute.m,
* EOAccess/EODatabase.m,
* EOAccess/EODatabaseContext.m,
* EOAccess/EOExpressionArray.m,
* EOAccess/EOJoin.m,
* EOAccess/EOModel.m,
* EOAccess/EOModelGroup.m,
* EOAccess/EORelationship.m,
* EOAccess/EOSQLExpression.m,
* EOAccess/EOSQLQualifier.m,
* EOAccess/EOSchemaGeneration.m,
* EOAccess/EOStoredProcedure.m,
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLAdaptor.m,
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLChannel.m,
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLExpression.m,
* EOAdaptors/SQLiteAdaptor/SQLite3Adaptor.m,
* EOAdaptors/SQLiteAdaptor/SQLite3Channel.m,
* EOInterface/EOTableViewAssociation.m,
* EOModeler/EOModelExtensions.m,
* EOModeler/EOModelerApp.m,
* DBModeler/ModelerAttributeEditor.m,
* DBModeler/ModelerEntityEditor.m: Remove references to NSUtilities.h.
Add includes for missing header references.
* DBModeler/Modeler.m (-[showEditor:]): Add cast to avoid compiler
warning.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@25994 72102866-910b-0410-8b05-ffd578937521
2008-01-22 13:57:07 +00:00
|
|
|
#include <Foundation/NSEnumerator.h>
|
2003-03-31 00:24:15 +00:00
|
|
|
#include <Foundation/NSException.h>
|
|
|
|
#include <Foundation/NSNotification.h>
|
|
|
|
#include <Foundation/NSSet.h>
|
* EOControl/EOAndQualifier.m,
* EOControl/EOFault.m,
* EOControl/EOFaultHandler.m,
* EOControl/EOKeyComparisonQualifier.m,
* EOControl/EOKeyValueArchiver.m,
* EOControl/EOKeyValueCoding.m,
* EOControl/EOKeyValueCodingBase.m,
* EOControl/EOMutableKnownKeyDictionary.h,
* EOControl/EONotQualifier.m,
* EOControl/EOOrQualifier.m,
* EOControl/EOQualifier.m,
* EOAccess/EOAdaptor.m,
* EOAccess/EOAdaptorContext.m,
* EOAccess/EOAttribute.m,
* EOAccess/EODatabase.m,
* EOAccess/EODatabaseContext.m,
* EOAccess/EOExpressionArray.m,
* EOAccess/EOJoin.m,
* EOAccess/EOModel.m,
* EOAccess/EOModelGroup.m,
* EOAccess/EORelationship.m,
* EOAccess/EOSQLExpression.m,
* EOAccess/EOSQLQualifier.m,
* EOAccess/EOSchemaGeneration.m,
* EOAccess/EOStoredProcedure.m,
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLAdaptor.m,
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLChannel.m,
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLExpression.m,
* EOAdaptors/SQLiteAdaptor/SQLite3Adaptor.m,
* EOAdaptors/SQLiteAdaptor/SQLite3Channel.m,
* EOInterface/EOTableViewAssociation.m,
* EOModeler/EOModelExtensions.m,
* EOModeler/EOModelerApp.m,
* DBModeler/ModelerAttributeEditor.m,
* DBModeler/ModelerEntityEditor.m: Remove references to NSUtilities.h.
Add includes for missing header references.
* DBModeler/Modeler.m (-[showEditor:]): Add cast to avoid compiler
warning.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@25994 72102866-910b-0410-8b05-ffd578937521
2008-01-22 13:57:07 +00:00
|
|
|
#include <Foundation/NSString.h>
|
|
|
|
#include <Foundation/NSValue.h>
|
2003-03-31 00:24:15 +00:00
|
|
|
#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>
|
2003-07-11 19:04:05 +00:00
|
|
|
#endif
|
|
|
|
|
2003-03-31 00:24:15 +00:00
|
|
|
#include <EOControl/EOObjectStore.h>
|
|
|
|
#include <EOControl/EOKeyGlobalID.h>
|
|
|
|
#include <EOControl/EONull.h>
|
|
|
|
#include <EOControl/EODebug.h>
|
|
|
|
|
|
|
|
#include <EOAccess/EOAccessFault.h>
|
|
|
|
#include <EOAccess/EOAdaptor.h>
|
|
|
|
#include <EOAccess/EOModel.h>
|
|
|
|
#include <EOAccess/EOEntity.h>
|
|
|
|
#include <EOAccess/EODatabase.h>
|
|
|
|
#include <EOAccess/EODatabaseContext.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"
|
2002-11-15 22:57:05 +00:00
|
|
|
/* TODO
|
|
|
|
|
|
|
|
Controllare il resultCache, ad ogni forget/invalidate deve essere
|
|
|
|
updatato.
|
|
|
|
*/
|
|
|
|
|
|
|
|
NSString *EOGeneralDatabaseException = @"EOGeneralDatabaseException";
|
2005-02-01 17:23:05 +00:00
|
|
|
NSTimeInterval EODistantPastTimeInterval = -603979776.0;
|
2010-06-11 12:17:45 +00:00
|
|
|
static BOOL _doesReleaseUnreferencedSnapshots = YES;
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
@implementation EODatabase
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Database Global Methods
|
|
|
|
*/
|
|
|
|
|
|
|
|
static NSMutableArray *databaseInstances;
|
|
|
|
|
|
|
|
+ (void)initialize
|
|
|
|
{
|
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)
|
|
|
|
{
|
|
|
|
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();
|
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
|
|
|
|
|
|
|
// THREAD
|
|
|
|
databaseInstances = [NSMutableArray new];
|
|
|
|
}
|
2002-11-15 22:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (void)makeAllDatabasesPerform: (SEL)aSelector withObject: anObject
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// THREAD
|
|
|
|
for (i = [databaseInstances count] - 1; i >= 0; i--)
|
|
|
|
[[[databaseInstances objectAtIndex: i] nonretainedObjectValue]
|
|
|
|
performSelector: aSelector withObject: anObject];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initializing new instances
|
|
|
|
*/
|
|
|
|
//OK
|
|
|
|
- initWithAdaptor: (EOAdaptor *)adaptor
|
|
|
|
{
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
if (!adaptor)
|
|
|
|
{
|
|
|
|
[self autorelease];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
addObserver: self
|
|
|
|
selector: @selector(_globalIDChanged:)
|
|
|
|
name: @"EOGlobalIDChangedNotification"
|
|
|
|
object: nil];
|
|
|
|
// [databaseInstances addObject:[NSValue valueWithNonretainedObject:self]];
|
|
|
|
ASSIGN(_adaptor,adaptor);
|
|
|
|
|
|
|
|
_registeredContexts = [NSMutableArray new];
|
|
|
|
_snapshots = [NSMutableDictionary new];
|
|
|
|
_models = [NSMutableArray new];
|
|
|
|
_entityCache = [NSMutableDictionary new];
|
|
|
|
_toManySnapshots = [NSMutableDictionary new];
|
|
|
|
}
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (EODatabase *)databaseWithModel: (EOModel *)model
|
|
|
|
{
|
|
|
|
return [[[self alloc] initWithModel: model] autorelease];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)initWithModel: (EOModel *)model
|
|
|
|
{
|
|
|
|
EOAdaptor *adaptor = [EOAdaptor adaptorWithModel:model]; //Handle exception to deallocate self ?
|
|
|
|
|
|
|
|
if ((self = [self initWithAdaptor: adaptor]))
|
|
|
|
{
|
|
|
|
[self addModel: model];
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
2004-04-17 12:41:32 +00:00
|
|
|
DESTROY(_adaptor);
|
|
|
|
DESTROY(_registeredContexts);
|
|
|
|
DESTROY(_snapshots);
|
|
|
|
DESTROY(_models);
|
|
|
|
DESTROY(_entityCache);
|
|
|
|
DESTROY(_toManySnapshots);
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2010-06-11 12:17:45 +00:00
|
|
|
- (void)incrementSnapshotCountForGlobalID:(EOGlobalID *)globalId
|
|
|
|
{
|
|
|
|
if (!_doesReleaseUnreferencedSnapshots)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
GSOnceFLog(@"TODO: %s", __PRETTY_FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)decrementSnapshotCountForGlobalID:(EOGlobalID *)globalId
|
|
|
|
{
|
|
|
|
if (!_doesReleaseUnreferencedSnapshots)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
GSOnceFLog(@"TODO: %s", __PRETTY_FUNCTION__);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (void)disableSnapshotRefcounting
|
|
|
|
{
|
|
|
|
_doesReleaseUnreferencedSnapshots = NO;
|
|
|
|
}
|
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
- (NSArray *)registeredContexts
|
|
|
|
{
|
|
|
|
NSMutableArray *array = [NSMutableArray array];
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
for (i = 0, n = [_registeredContexts count]; i < n; i++)
|
|
|
|
[array addObject: [[_registeredContexts objectAtIndex: i]
|
|
|
|
nonretainedObjectValue]];
|
|
|
|
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned int) _indexOfRegisteredContext: (EODatabaseContext *)context
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for( i = [_registeredContexts count]-1; i >= 0; i--)
|
|
|
|
if ([[_registeredContexts objectAtIndex: i]
|
|
|
|
nonretainedObjectValue] == context)
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)registerContext: (EODatabaseContext *)context
|
|
|
|
{
|
|
|
|
unsigned int index=0;
|
|
|
|
|
|
|
|
//OK
|
|
|
|
|
|
|
|
NSAssert(([context database] == self),@"Database context is not me");
|
|
|
|
|
|
|
|
index = [self _indexOfRegisteredContext:context];
|
|
|
|
|
|
|
|
NSAssert(index == (unsigned int) -1 , @"DatabaseContext already registred");
|
|
|
|
|
|
|
|
[_registeredContexts addObject:
|
|
|
|
[NSValue valueWithNonretainedObject: context]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)unregisterContext: (EODatabaseContext *)context
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
unsigned int index = [self _indexOfRegisteredContext:context];
|
|
|
|
|
|
|
|
NSAssert(index != (unsigned int) -1, @"DatabaseContext wasn't registred");
|
|
|
|
|
|
|
|
[_registeredContexts removeObjectAtIndex:index];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (EOAdaptor *)adaptor
|
|
|
|
{
|
|
|
|
return _adaptor;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)addModel: (EOModel *)model
|
|
|
|
{
|
|
|
|
[_models addObject: model];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)removeModel: (EOModel *)model
|
|
|
|
{
|
|
|
|
[_models removeObject: model];
|
|
|
|
}
|
|
|
|
|
2007-01-01 11:52:38 +00:00
|
|
|
- (BOOL)addModelIfCompatible: (EOModel *)model
|
2002-11-15 22:57:05 +00:00
|
|
|
{
|
|
|
|
BOOL modelOk = NO;
|
|
|
|
|
|
|
|
NSAssert(model, @"No model");//WO simply return NO (doesn't handle this case).
|
|
|
|
|
|
|
|
if ([_models containsObject:model] == YES)
|
|
|
|
modelOk = YES;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EOAdaptor *adaptor = [self adaptor];
|
|
|
|
|
|
|
|
if ([[model adaptorName] isEqualToString: [adaptor name]] == YES
|
|
|
|
|| [_adaptor canServiceModel: model] == YES)
|
|
|
|
{
|
|
|
|
[_models addObject: model];
|
|
|
|
modelOk = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return modelOk;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *)models
|
|
|
|
{
|
|
|
|
return _models;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (EOEntity *)entityNamed: (NSString *)entityName
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
EOEntity *entity=nil;
|
|
|
|
int i = 0;
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
NSAssert(entityName, @"No entity name");
|
|
|
|
|
|
|
|
count = [_models count];
|
|
|
|
|
|
|
|
for(i = 0; !entity && i < count; i++)
|
|
|
|
{
|
|
|
|
EOModel *model = [_models objectAtIndex: i];
|
|
|
|
|
|
|
|
entity = [model entityNamed: entityName];
|
|
|
|
}
|
|
|
|
|
|
|
|
return entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (EOEntity *)entityForObject: (id)object
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
EOEntity *entity = nil;
|
|
|
|
NSString *entityName = nil;
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"object=%p (of class %@)",
|
|
|
|
object, [object class]);
|
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
|
|
|
NSAssert(!_isNilOrEONull(object), @"No object");
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
if ([EOFault isFault: object])
|
|
|
|
{
|
|
|
|
EOFaultHandler *faultHandler = [EOFault handlerForFault: object];
|
|
|
|
EOKeyGlobalID *gid;
|
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"faultHandler=%p (of class %@)",
|
|
|
|
faultHandler, [faultHandler class]);
|
|
|
|
|
|
|
|
gid = [(EOAccessFaultHandler *)faultHandler globalID];
|
|
|
|
|
|
|
|
NSAssert3(gid, @"No gid for fault handler %p for object %p of class %@",
|
|
|
|
faultHandler, object, [object class]);
|
|
|
|
entityName = [gid entityName];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
entityName = [object entityName];
|
|
|
|
|
|
|
|
NSAssert2(entityName, @"No object entity name for object %@ of class %@",
|
|
|
|
object, [object class]);
|
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"entityName=%@", entityName);
|
|
|
|
|
|
|
|
entity = [self entityNamed: entityName];
|
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"entity=%p", entity);
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
return entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *)resultCacheForEntityNamed: (NSString *)name
|
|
|
|
{
|
|
|
|
return [_entityCache objectForKey: name];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setResultCache: (NSArray *)cache
|
|
|
|
forEntityNamed: (NSString *)name
|
|
|
|
{
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
[_entityCache setObject: cache
|
|
|
|
forKey: name];
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)invalidateResultCacheForEntityNamed: (NSString *)name
|
|
|
|
{
|
|
|
|
[_entityCache removeObjectForKey: name];//??
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)invalidateResultCache
|
|
|
|
{
|
|
|
|
[_entityCache removeAllObjects];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)handleDroppedConnection
|
|
|
|
{
|
|
|
|
NSArray *dbContextArray;
|
|
|
|
NSEnumerator *contextEnum;
|
|
|
|
EODatabaseContext *dbContext;
|
|
|
|
|
|
|
|
EOFLOGObjectFnStartOrCond2(@"DatabaseLevel", @"EODatabase");
|
|
|
|
|
|
|
|
[_adaptor handleDroppedConnection];
|
|
|
|
|
|
|
|
dbContextArray = [self registeredContexts];
|
|
|
|
contextEnum = [dbContextArray objectEnumerator];
|
|
|
|
|
|
|
|
while ((dbContext = [contextEnum nextObject]))
|
|
|
|
[dbContext handleDroppedConnection];
|
|
|
|
|
|
|
|
EOFLOGObjectFnStopOrCond2(@"DatabaseLevel", @"EODatabase");
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation EODatabase (EOUniquing)
|
|
|
|
|
|
|
|
- (void)recordSnapshot: (NSDictionary *)snapshot
|
|
|
|
forGlobalID: (EOGlobalID *)gid
|
|
|
|
{
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"snapshot %p %@", snapshot, snapshot);
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"gid=%@", gid);
|
|
|
|
|
|
|
|
NSAssert(gid, @"No gid");
|
|
|
|
NSAssert(snapshot, @"No snapshot");
|
|
|
|
NSAssert(_snapshots, @"No _snapshots");
|
|
|
|
|
|
|
|
[_snapshots setObject: snapshot
|
|
|
|
forKey: gid];
|
|
|
|
|
|
|
|
NSAssert([_snapshots objectForKey: gid], @"SNAPSHOT not save !!");
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//"Receive EOGlobalIDChangedNotification notification"
|
2004-04-15 10:33:35 +00:00
|
|
|
/*
|
|
|
|
This method is currently only intended to replace EOTemporaryGlobalIDs
|
|
|
|
with corresponding EOKeyGlobalIDs. Since the globalIDs within
|
|
|
|
the _toManySnapshots can only contain EOKeyGlobalIDs from fetched
|
|
|
|
data, they need not be searched yet. This may change if we add support
|
|
|
|
to allow mutable primary key class attributes or recordToManySnapshots:
|
|
|
|
ever gets called with EOTemporaryGlobalIDs for some obscure reasons.
|
|
|
|
*/
|
2002-11-15 22:57:05 +00:00
|
|
|
- (void)_globalIDChanged: (NSNotification *)notification
|
|
|
|
{
|
|
|
|
NSDictionary *snapshot = nil;
|
|
|
|
NSDictionary *userInfo = nil;
|
|
|
|
NSEnumerator *enumerator = nil;
|
|
|
|
EOGlobalID *tempGID = nil;
|
|
|
|
EOGlobalID *gid = nil;
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
userInfo = [notification userInfo];
|
|
|
|
enumerator = [userInfo keyEnumerator];
|
|
|
|
|
|
|
|
while ((tempGID = [enumerator nextObject]))
|
|
|
|
{
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"tempGID=%@", tempGID);
|
|
|
|
|
|
|
|
gid = [userInfo objectForKey: tempGID];
|
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"gid=%@", gid);
|
|
|
|
|
|
|
|
//OK ?
|
|
|
|
snapshot = [_snapshots objectForKey: tempGID];
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"_snapshots snapshot=%@", snapshot);
|
|
|
|
|
|
|
|
if (snapshot)
|
|
|
|
{
|
|
|
|
[_snapshots removeObjectForKey: tempGID];
|
|
|
|
[_snapshots setObject: snapshot
|
|
|
|
forKey: gid];
|
|
|
|
}
|
|
|
|
|
|
|
|
//OK ?
|
|
|
|
snapshot = [_toManySnapshots objectForKey: tempGID];
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"_toManySnapshots snapshot=%@",
|
|
|
|
snapshot);
|
|
|
|
|
|
|
|
if (snapshot)
|
|
|
|
{
|
|
|
|
[_toManySnapshots removeObjectForKey: tempGID];
|
|
|
|
[_toManySnapshots setObject: snapshot
|
|
|
|
forKey: gid];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *)snapshotForGlobalID: (EOGlobalID *)gid
|
2005-02-01 17:23:05 +00:00
|
|
|
{
|
|
|
|
return [self snapshotForGlobalID: gid
|
|
|
|
after: EODistantPastTimeInterval];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *)snapshotForGlobalID: (EOGlobalID *)gid
|
|
|
|
after: (NSTimeInterval)ti
|
2002-11-15 22:57:05 +00:00
|
|
|
{
|
|
|
|
//seems OK
|
|
|
|
NSDictionary *snapshot = nil;
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
NSAssert(gid, @"No gid");
|
|
|
|
|
|
|
|
snapshot = [_snapshots objectForKey: gid];
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
return snapshot;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)recordSnapshot: (NSArray*)gids
|
|
|
|
forSourceGlobalID: (EOGlobalID *)gid
|
|
|
|
relationshipName: (NSString *)name
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
NSMutableDictionary *toMany = nil;
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
NSAssert(gid,@"No snapshot");
|
|
|
|
NSAssert(gid,@"No Source Global ID");
|
|
|
|
NSAssert(name,@"No relationship name");
|
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"self=%p snapshot gids=%@", self, gids);
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"SourceGlobalID gid=%@", gid);
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"relationshipName=%@", name);
|
|
|
|
|
|
|
|
toMany = [_toManySnapshots objectForKey: gid];
|
|
|
|
|
|
|
|
if (!toMany)
|
|
|
|
{
|
|
|
|
toMany = [NSMutableDictionary dictionaryWithCapacity: 10];
|
|
|
|
[_toManySnapshots setObject: toMany
|
|
|
|
forKey: gid];
|
|
|
|
}
|
|
|
|
|
|
|
|
[toMany setObject: gids
|
|
|
|
forKey: name];
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *)snapshotForSourceGlobalID: (EOGlobalID *)gid
|
|
|
|
relationshipName: (NSString *)name
|
|
|
|
{
|
|
|
|
NSAssert(gid, @"No Source Global ID");
|
|
|
|
NSAssert(name, @"No relationship name");
|
|
|
|
|
|
|
|
return [[_toManySnapshots objectForKey: gid] objectForKey: name];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)forgetSnapshotForGlobalID: (EOGlobalID *)gid
|
|
|
|
{
|
|
|
|
//Seems OK
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
NSAssert(gid,@"No Global ID");
|
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"gid=%@", gid);
|
|
|
|
|
|
|
|
[_snapshots removeObjectForKey: gid];
|
|
|
|
[_toManySnapshots removeObjectForKey: gid];
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName: EOObjectsChangedInStoreNotification
|
|
|
|
object: self
|
|
|
|
userInfo: [NSDictionary dictionaryWithObject:
|
|
|
|
[NSArray arrayWithObject: gid]
|
|
|
|
forKey: EOInvalidatedKey]];
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
};
|
|
|
|
|
2007-01-01 11:52:38 +00:00
|
|
|
- (void)forgetSnapshotsForGlobalIDs: (NSArray*)gids
|
2002-11-15 22:57:05 +00:00
|
|
|
{
|
|
|
|
NSEnumerator *gidEnum = nil;
|
|
|
|
id gid = 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
|
|
|
NSAssert(gids, @"No Global IDs");
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"gids=%@", gids);
|
2002-11-15 22:57:05 +00:00
|
|
|
|
2007-01-01 11:52:38 +00:00
|
|
|
gidEnum = [gids objectEnumerator];
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
while ((gid = [gidEnum nextObject]))
|
|
|
|
{
|
|
|
|
[_snapshots removeObjectForKey: gid];
|
|
|
|
[_toManySnapshots removeObjectForKey: gid];
|
|
|
|
}
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName: EOObjectsChangedInStoreNotification
|
|
|
|
object: self
|
2007-01-01 11:52:38 +00:00
|
|
|
userInfo: [NSDictionary dictionaryWithObject: gids
|
2002-11-15 22:57:05 +00:00
|
|
|
forKey: EOInvalidatedKey]];
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)forgetAllSnapshots
|
|
|
|
{
|
|
|
|
NSMutableSet *gidSet = [NSMutableSet new];
|
|
|
|
NSMutableArray *gidArray = [NSMutableArray array];
|
|
|
|
|
|
|
|
EOFLOGObjectFnStartOrCond2(@"DatabaseLevel", @"EODatabase");
|
|
|
|
|
|
|
|
[gidSet addObjectsFromArray: [_snapshots allKeys]];
|
|
|
|
[gidSet addObjectsFromArray: [_toManySnapshots allKeys]];
|
|
|
|
[gidArray addObjectsFromArray: [gidSet allObjects]];
|
|
|
|
[gidSet release];
|
|
|
|
[_snapshots removeAllObjects];
|
|
|
|
[_toManySnapshots removeAllObjects];
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName: EOObjectsChangedInStoreNotification
|
|
|
|
object:self
|
|
|
|
userInfo: [NSDictionary dictionaryWithObject: gidArray
|
|
|
|
forKey: EOInvalidatedKey]];
|
|
|
|
|
|
|
|
EOFLOGObjectFnStopOrCond2(@"DatabaseLevel", @"EODatabase");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)recordSnapshots: (NSDictionary *)snapshots
|
|
|
|
{
|
|
|
|
//OK
|
|
|
|
//VERIFY: be sure to replace all anapshot entries if any !
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
[_snapshots addEntriesFromDictionary: snapshots];
|
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"self=%p _snapshots=%@",
|
|
|
|
self, _snapshots);
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)recordToManySnapshots: (NSDictionary *)snapshots
|
|
|
|
{
|
|
|
|
//Seems OK
|
|
|
|
NSEnumerator *keyEnum = nil;
|
|
|
|
id key = nil;
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"snapshots=%@", snapshots);
|
|
|
|
NSAssert(snapshots, @"No snapshots");
|
|
|
|
|
|
|
|
keyEnum = [snapshots keyEnumerator];
|
|
|
|
|
|
|
|
while ((key = [keyEnum nextObject]))
|
|
|
|
{
|
|
|
|
NSMutableDictionary *toMany = nil;
|
|
|
|
|
|
|
|
toMany = [_toManySnapshots objectForKey: key]; // look if already exists
|
|
|
|
|
|
|
|
if (!toMany)
|
|
|
|
{
|
|
|
|
toMany = [NSMutableDictionary dictionaryWithCapacity: 10];
|
|
|
|
[_toManySnapshots setObject: toMany
|
|
|
|
forKey: key];
|
|
|
|
}
|
|
|
|
|
|
|
|
[toMany addEntriesFromDictionary: [snapshots objectForKey: key]];
|
|
|
|
}
|
|
|
|
|
|
|
|
EOFLOGObjectLevelArgs(@"EODatabaseContext", @"snapshots=%@", snapshots);
|
|
|
|
|
2010-05-30 19:25:53 +00:00
|
|
|
|
2002-11-15 22:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *)snapshots
|
|
|
|
{
|
2006-09-28 17:01:29 +00:00
|
|
|
return AUTORELEASE([_snapshots copy]);
|
2002-11-15 22:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end /* EODatabase (EOUniquing) */
|
|
|
|
|