2002-11-15 22:57:05 +00:00
/ * *
EOUtilities . m
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
Author : Manuel Guesdon < mguesdon @ orange - concept . com >
Date : Sep 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 / NSString . h >
# include < Foundation / NSArray . h >
# include < Foundation / NSDictionary . h >
# include < Foundation / NSEnumerator . 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 / EOKeyGlobalID . h >
# include < EOControl / EOQualifier . h >
# include < EOControl / EONull . h >
# include < EOControl / EOGenericRecord . h >
# include < EOControl / EODebug . h >
# include < EOAccess / EOAttribute . h >
# include < EOAccess / EORelationship . h >
# include < EOAccess / EOJoin . h >
# include < EOAccess / EOEntity . h >
# include < EOAccess / EOModel . h >
# include < EOAccess / EOModelGroup . h >
# include < EOAccess / EODatabase . h >
# include < EOAccess / EODatabaseContext . h >
# include < EOAccess / EODatabaseChannel . h >
# include < EOAccess / EOSQLExpression . h >
# include < EOAccess / EOAdaptorChannel . h >
# include < EOAccess / EOStoredProcedure . h >
# include < EOAccess / EOUtilities . 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
2005-07-04 06:17:18 +00:00
NSString * EOMoreThanOneException = @ "EOMoreThanOneException" ;
2002-11-15 22:57:05 +00:00
@ implementation EOEditingContext ( EOUtilities )
2005-01-26 14:11:31 +00:00
- ( NSArray * ) objectsForEntityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
NSArray * objects ;
EOFetchSpecification * fetchSpecif ;
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
fetchSpecif = [ EOFetchSpecification
fetchSpecificationWithEntityName : entityName
qualifier : nil
sortOrderings : nil ] ;
objects = [ self objectsWithFetchSpecification : fetchSpecif ] ;
return objects ;
}
2005-01-26 14:11:31 +00:00
- ( NSArray * ) objectsOfClass : ( Class ) classObject
2002-11-15 22:57:05 +00:00
{
EOEntity * entity ;
NSArray * objects ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
entity = [ self entityForClass : classObject ] ;
objects = [ self objectsForEntityNamed : [ entity name ] ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return objects ;
}
2005-01-26 14:11:31 +00:00
- ( NSArray * ) objectsWithFetchSpecificationNamed : ( NSString * ) fetchSpecName
entityNamed : ( NSString * ) entityName
bindings : ( NSDictionary * ) bindings
2002-11-15 22:57:05 +00:00
{
EOModelGroup * modelGroup ;
EOFetchSpecification * unboundFetchSpec ;
EOFetchSpecification * boundFetchSpec ;
NSArray * results ;
modelGroup = [ self modelGroup ] ;
unboundFetchSpec = [ modelGroup fetchSpecificationNamed : fetchSpecName
entityNamed : entityName ] ;
if ( ! unboundFetchSpec )
{
2005-01-26 14:11:31 +00:00
[ NSException raise : NSObjectNotAvailableException
2002-11-15 22:57:05 +00:00
format : @ "%@: Fetch specification '%@' not found in entity named '%@'" ,
NSStringFromSelector ( _cmd ) , fetchSpecName , entityName ] ;
}
boundFetchSpec = [ unboundFetchSpec fetchSpecificationWithQualifierBindings :
bindings ] ;
results = [ self objectsWithFetchSpecification : boundFetchSpec ] ;
return results ;
}
2005-01-26 14:11:31 +00:00
- ( NSArray * ) objectsForEntityNamed : ( NSString * ) entityName
qualifierFormat : ( NSString * ) format , . . .
2002-11-15 22:57:05 +00:00
{
EOQualifier * qualifier ;
EOFetchSpecification * fetchSpec ;
NSArray * results ;
va_list args ;
va_start ( args , format ) ;
qualifier = [ EOQualifier qualifierWithQualifierFormat : format
varargList : args ] ;
va_end ( args ) ;
fetchSpec = [ EOFetchSpecification fetchSpecificationWithEntityName :
entityName
qualifier : qualifier
sortOrderings : nil ] ;
results = [ self objectsWithFetchSpecification : fetchSpec ] ;
return results ;
}
2005-01-26 14:11:31 +00:00
- ( NSArray * ) objectsMatchingValue : ( id ) value
forKey : ( NSString * ) key
entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
// OK
NSArray * objects ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
NSDebugMLLog ( @ "gsdb" , @ "START value=%@ key=%@ entityName=%@" ,
value , key , entityName ) ;
if ( ! value )
* EOAccess/EOAttribute.m, EOAccess/EODatabaseContext.m,
* EOAccess/EOEntity.m, EOAccess/EOSQLExpression.m
* EOAccess/EOPrivate.h, EOAccess/EOPrivate.m,
* EOAccess/EOSQLQualifier.m, EOAccess/EOUtilities.m
* EOControl/EOClassDescription.m, EOControl/EOEditingContext.m
* EOControl/EOGenericRecord.m, EOControl/EOKeyGlobalID.m
* EOControl/EOKeyValueCoding.m,
* EOControl/EOKeyValueQualifier.m
* EOControl/EOMutableKnownKeyDictionary.m,
* EOControl/EOPrivate.h, EOControl/EOPrivate.m
Unify GDL2 identifiers with GDL2_ prefix. Replace
GDL2NSClass_alloc with GDL2_alloc(NSClass). Replace
GDL2NSClassWith* calls with
AUTORELEASE([GDL2_alloc(NSCLass) initWith* calls]).
Rename GDL2PrivInit to GDL2_PrivateInit.
(GDL2_NSArray, GDL2_NSMutableArray_allocWithZoneIMP)
(GDL2_NSMutableDictionary_allocWithZoneIMP): New globals.
(GDL2_alloc): New macro.
(GDL2NSString_alloc, GDL2NSDecimalNumber_alloc)
(GDL2NSNumber_alloc, GDL2NSCalendarDate_alloc, GDL2NSData_alloc)
(GDL2DataWithBytesAndLength, GDL2MutableArrayWithCapacity)
(GDL2MutableArrayWithArray, GDL2MutableArray, GDL2Array)
(GDL2MutableDictionaryWithCapacity): Remove.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20779 72102866-910b-0410-8b05-ffd578937521
2005-02-22 16:14:03 +00:00
value = GDL2_EONull ;
2002-11-15 22:57:05 +00:00
NSAssert ( value , @ "No Value" ) ; // Transform it to EONull ?
NSAssert ( key , @ "No Key" ) ;
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
objects = [ self objectsMatchingValues :
[ NSDictionary dictionaryWithObject : value
forKey : key ]
entityNamed : entityName ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return objects ;
// TC :
/ *
EOKeyValueQualifier * qualifier ;
EOFetchSpecification * fetch ;
NSArray * newArray ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
qualifier = [ [ EOKeyValueQualifier alloc ]
initWithKey : key
operatorSelector : EOQualifierOperatorEqual
value : value ] ;
fetch = [ EOFetchSpecification fetchSpecificationWithEntityName : name
qualifier : [ qualifier autorelease ]
sortOrderings : nil ] ;
newArray = [ self objectsWithFetchSpecification : fetch ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return newArray ;
* /
}
2005-01-26 14:11:31 +00:00
- ( NSArray * ) objectsMatchingValues : ( NSDictionary * ) values
entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
// OK
NSArray * objects = nil ;
EOFetchSpecification * fetchSpec ;
EOQualifier * qualifier ;
NSEnumerator * valuesEnum ;
id key = nil ;
NSMutableArray * kvQualifiers = nil ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
NS_DURING
{
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
valuesEnum = [ values keyEnumerator ] ;
kvQualifiers = [ NSMutableArray array ] ;
while ( ( key = [ valuesEnum nextObject ] ) )
{
id value = [ values objectForKey : key ] ;
EOKeyValueQualifier * tmpQualifier = [ EOKeyValueQualifier
qualifierWithKey : key
operatorSelector :
@ selector ( isEqualTo : )
value : value ] ;
[ kvQualifiers addObject : tmpQualifier ] ;
}
qualifier = [ EOAndQualifier qualifierWithQualifierArray : kvQualifiers ] ;
fetchSpec = [ EOFetchSpecification fetchSpecificationWithEntityName :
entityName
qualifier : qualifier
sortOrderings : nil ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
objects = [ self objectsWithFetchSpecification : fetchSpec ] ;
}
NS_HANDLER
{
2003-02-03 14:53:03 +00:00
NSDebugMLog ( @ "exception in EOEditingContext (EOUtilities) objectsMatchingValues:entityNamed:" , "" ) ;
2002-11-15 22:57:05 +00:00
NSLog ( @ "exception in EOEditingContext (EOUtilities) objectsMatchingValues:entityNamed:" ) ;
2002-12-30 22:10:43 +00:00
NSDebugMLog ( @ "exception=%@" , localException ) ;
2002-11-15 22:57:05 +00:00
NSLog ( @ "exception=%@" , localException ) ;
/ * localException = ExceptionByAddingUserInfoObjectFrameInfo ( localException ,
@ "In EOEditingContext (EOUtilities) objectsMatchingValues:entityNamed:" ) ;
* /
NSLog ( @ "exception=%@" , localException ) ;
[ localException raise ] ;
}
NS_ENDHANDLER ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return objects ;
// TC :
/ *
EOQualifier * qualifier ;
EOFetchSpecification * fetchSpec ;
NSArray * results ;
qualifier = [ EOQualifier qualifierToMatchAllValues : values ] ;
fetchSpec = [ EOFetchSpecification fetchSpecificationWithEntityName : name qualifier : qualifier sortOrderings : nil ] ;
results = [ self objectsWithFetchSpecification : fetchSpec ] ;
return results ;
* /
}
2005-01-26 14:11:31 +00:00
- ( id ) objectWithFetchSpecificationNamed : ( NSString * ) fetchSpecName
entityNamed : ( NSString * ) entityName
bindings : ( NSDictionary * ) bindings
2002-11-15 22:57:05 +00:00
{
id object = nil ;
int count ;
NSArray * objects ;
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
objects = [ self objectsWithFetchSpecificationNamed : fetchSpecName
entityNamed : entityName
bindings : bindings ] ;
count = [ objects count ] ;
switch ( count )
{
case 0 :
[ NSException raise : NSInvalidArgumentException
format : @ "%@: No item selected for fetch specification %@ in entity %@ with bindings %@" ,
NSStringFromSelector ( _cmd ) ,
fetchSpecName ,
entityName ,
bindings ] ;
break ;
case 1 :
object = [ objects objectAtIndex : 0 ] ;
break ;
default :
[ NSException raise : EOMoreThanOneException
format : @ "%@: Selected more than one item for fetch specification %@ in entity %@ with bindings %@" ,
NSStringFromSelector ( _cmd ) ,
fetchSpecName ,
entityName ,
bindings ] ;
break ;
}
return object ;
}
2005-01-26 14:11:31 +00:00
- ( id ) objectForEntityNamed : ( NSString * ) entityName
qualifierFormat : ( NSString * ) format , . . .
2002-11-15 22:57:05 +00:00
{
id object = nil ;
int count ;
EOQualifier * qualifier ;
EOFetchSpecification * fetchSpec ;
NSArray * objects ;
va_list args ;
va_start ( args , format ) ;
qualifier = [ EOQualifier qualifierWithQualifierFormat : format
varargList : args ] ;
va_end ( args ) ;
fetchSpec = [ EOFetchSpecification fetchSpecificationWithEntityName :
entityName
qualifier : qualifier
sortOrderings : nil ] ;
objects = [ self objectsWithFetchSpecification : fetchSpec ] ;
count = [ objects count ] ;
switch ( count )
{
case 0 :
[ NSException raise : NSInvalidArgumentException
format : @ "%@: No item selected for entity %@ qualified by %@" ,
NSStringFromSelector ( _cmd ) ,
entityName ,
format ] ;
break ;
case 1 :
object = [ objects objectAtIndex : 0 ] ;
break ;
default :
[ NSException raise : EOMoreThanOneException
format : @ "%@: Selected more than one item for entity %@ qualified by %@" ,
NSStringFromSelector ( _cmd ) ,
entityName ,
format ] ;
}
return object ;
}
- ( id ) objectMatchingValue : ( id ) value
2005-01-26 14:11:31 +00:00
forKey : ( NSString * ) key
entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
// OK
id object = nil ;
int count ;
NSArray * objects ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
NSDebugMLLog ( @ "gsdb" , @ "START value=%@ key=%@ entityName=%@" ,
value , key , entityName ) ;
NS_DURING // Debugging Purpose
{
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
objects = [ self objectsMatchingValue : value
forKey : key
entityNamed : entityName ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
count = [ objects count ] ;
switch ( count )
{
case 0 :
2005-01-26 14:11:31 +00:00
[ NSException raise : NSObjectNotAvailableException
2002-11-15 22:57:05 +00:00
format : @ "%@: No %@ found with key %@ matching %@" ,
NSStringFromSelector ( _cmd ) ,
entityName ,
key ,
value ] ;
break ;
case 1 :
object = [ objects objectAtIndex : 0 ] ;
break ;
default :
[ NSException raise : EOMoreThanOneException
format : @ "%@: Selected more than one %@ with key %@ matching %@" ,
NSStringFromSelector ( _cmd ) ,
entityName ,
key ,
value ] ;
break ;
}
}
NS_HANDLER
{
NSLog ( @ "exception in EOEditingContext (EOUtilities) objectMatchingValue:forKey:entityNamed:" ) ;
NSLog ( @ "exception=%@" , localException ) ;
/ * localException = ExceptionByAddingUserInfoObjectFrameInfo ( localException ,
@ "In EOEditingContext (EOUtilities) objectMatchingValue:forKey:entityNamed:" ) ;
* /
NSLog ( @ "exception=%@" , localException ) ;
[ localException raise ] ;
}
NS_ENDHANDLER ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return object ;
}
2005-01-26 14:11:31 +00:00
- ( id ) objectMatchingValues : ( NSDictionary * ) values
entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
id object = nil ;
int count ;
NSArray * objects ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
objects = [ self objectsMatchingValues : values
entityNamed : entityName ] ;
count = [ objects count ] ;
switch ( count )
{
case 0 :
[ NSException raise : NSInvalidArgumentException
format : @ "%@: No %@ found matching %@" ,
NSStringFromSelector ( _cmd ) ,
entityName ,
values ] ;
break ;
case 1 :
object = [ objects objectAtIndex : 0 ] ;
break ;
default :
[ NSException raise : EOMoreThanOneException
format : @ "%@: Selected more than one %@ matching %@" ,
NSStringFromSelector ( _cmd ) ,
entityName ,
values ] ;
break ;
}
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return object ;
}
- ( id ) objectWithPrimaryKeyValue : ( id ) value
2005-01-26 14:11:31 +00:00
entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
// OK
id object = nil ;
EOEntity * entity ;
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
entity = [ self entityNamed : entityName ] ;
if ( ! entity )
[ NSException raise : NSInvalidArgumentException
format : @ "objectWithPrimaryKeyValue:%@ entityNamed:%@; no entity" ,
value ,
entityName ] ;
else
{
NSArray * primaryKeyAttributes = [ entity primaryKeyAttributes ] ;
if ( [ primaryKeyAttributes count ] ! = 1 )
{
[ NSException raise : NSInvalidArgumentException
format : @ "objectWithPrimaryKeyValue:%@ entityNamed:%@ may only be called for entities with one primary key attribute. For entities with compound primary keys, use objectWithPrimaryKey:entityNamed and provide a dictionary for the primary key." ,
value ,
entityName ] ;
}
else
{
NSDictionary * pk ;
if ( ! value )
* EOAccess/EOAttribute.m, EOAccess/EODatabaseContext.m,
* EOAccess/EOEntity.m, EOAccess/EOSQLExpression.m
* EOAccess/EOPrivate.h, EOAccess/EOPrivate.m,
* EOAccess/EOSQLQualifier.m, EOAccess/EOUtilities.m
* EOControl/EOClassDescription.m, EOControl/EOEditingContext.m
* EOControl/EOGenericRecord.m, EOControl/EOKeyGlobalID.m
* EOControl/EOKeyValueCoding.m,
* EOControl/EOKeyValueQualifier.m
* EOControl/EOMutableKnownKeyDictionary.m,
* EOControl/EOPrivate.h, EOControl/EOPrivate.m
Unify GDL2 identifiers with GDL2_ prefix. Replace
GDL2NSClass_alloc with GDL2_alloc(NSClass). Replace
GDL2NSClassWith* calls with
AUTORELEASE([GDL2_alloc(NSCLass) initWith* calls]).
Rename GDL2PrivInit to GDL2_PrivateInit.
(GDL2_NSArray, GDL2_NSMutableArray_allocWithZoneIMP)
(GDL2_NSMutableDictionary_allocWithZoneIMP): New globals.
(GDL2_alloc): New macro.
(GDL2NSString_alloc, GDL2NSDecimalNumber_alloc)
(GDL2NSNumber_alloc, GDL2NSCalendarDate_alloc, GDL2NSData_alloc)
(GDL2DataWithBytesAndLength, GDL2MutableArrayWithCapacity)
(GDL2MutableArrayWithArray, GDL2MutableArray, GDL2Array)
(GDL2MutableDictionaryWithCapacity): Remove.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20779 72102866-910b-0410-8b05-ffd578937521
2005-02-22 16:14:03 +00:00
value = GDL2_EONull ;
2002-11-15 22:57:05 +00:00
pk = [ NSDictionary dictionaryWithObject : value
forKey : [ ( EOAttribute * ) [ primaryKeyAttributes
objectAtIndex : 0 ]
name ] ] ;
object = [ self objectWithPrimaryKey : pk
entityNamed : entityName ] ;
}
}
return object ;
}
2005-01-26 14:11:31 +00:00
- ( id ) objectWithPrimaryKey : ( NSDictionary * ) pkDict
entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
// OK
id object = nil ;
EOEntity * entity ;
NSAssert ( [ pkDict count ] > 0 , @ "Empty primary key." ) ;
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
entity = [ self entityNamed : entityName ] ;
if ( ! entity )
[ NSException raise : NSInvalidArgumentException
format : @ "objectWithPrimaryKeyValue:%@ entityNamed:%@; no entity" ,
pkDict ,
entityName ] ;
else
{
EOGlobalID * gid = [ entity globalIDForRow : pkDict ] ;
object = [ self faultForGlobalID : gid
editingContext : self ] ;
}
return 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
- ( NSArray * ) rawRowsForEntityNamed : ( NSString * ) entityName
qualifierFormat : ( NSString * ) format , . . .
2002-11-15 22:57:05 +00:00
{
EOQualifier * qualifier ;
EOFetchSpecification * fetchSpec ;
NSArray * results ;
va_list args ;
va_start ( args , format ) ;
qualifier = [ EOQualifier qualifierWithQualifierFormat : format
varargList : args ] ;
va_end ( args ) ;
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
fetchSpec = [ EOFetchSpecification fetchSpecificationWithEntityName :
entityName
qualifier : qualifier
sortOrderings : nil ] ;
[ fetchSpec setFetchesRawRows : YES ] ;
results = [ self objectsWithFetchSpecification : fetchSpec ] ;
return results ;
}
* 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
- ( NSArray * ) rawRowsMatchingValue : ( id ) value
forKey : ( NSString * ) key
entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
NSDictionary * valueDict ;
NSArray * results ;
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
if ( ! value )
* EOAccess/EOAttribute.m, EOAccess/EODatabaseContext.m,
* EOAccess/EOEntity.m, EOAccess/EOSQLExpression.m
* EOAccess/EOPrivate.h, EOAccess/EOPrivate.m,
* EOAccess/EOSQLQualifier.m, EOAccess/EOUtilities.m
* EOControl/EOClassDescription.m, EOControl/EOEditingContext.m
* EOControl/EOGenericRecord.m, EOControl/EOKeyGlobalID.m
* EOControl/EOKeyValueCoding.m,
* EOControl/EOKeyValueQualifier.m
* EOControl/EOMutableKnownKeyDictionary.m,
* EOControl/EOPrivate.h, EOControl/EOPrivate.m
Unify GDL2 identifiers with GDL2_ prefix. Replace
GDL2NSClass_alloc with GDL2_alloc(NSClass). Replace
GDL2NSClassWith* calls with
AUTORELEASE([GDL2_alloc(NSCLass) initWith* calls]).
Rename GDL2PrivInit to GDL2_PrivateInit.
(GDL2_NSArray, GDL2_NSMutableArray_allocWithZoneIMP)
(GDL2_NSMutableDictionary_allocWithZoneIMP): New globals.
(GDL2_alloc): New macro.
(GDL2NSString_alloc, GDL2NSDecimalNumber_alloc)
(GDL2NSNumber_alloc, GDL2NSCalendarDate_alloc, GDL2NSData_alloc)
(GDL2DataWithBytesAndLength, GDL2MutableArrayWithCapacity)
(GDL2MutableArrayWithArray, GDL2MutableArray, GDL2Array)
(GDL2MutableDictionaryWithCapacity): Remove.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20779 72102866-910b-0410-8b05-ffd578937521
2005-02-22 16:14:03 +00:00
value = GDL2_EONull ;
2002-11-15 22:57:05 +00:00
valueDict = [ NSDictionary dictionaryWithObject : value
forKey : key ] ;
results = [ self rawRowsMatchingValues : valueDict
entityNamed : entityName ] ;
return results ;
}
* 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
- ( NSArray * ) rawRowsMatchingValues : ( NSDictionary * ) values
entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
EOQualifier * qualifier ;
EOFetchSpecification * fetchSpec ;
NSArray * results ;
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
qualifier = [ EOQualifier qualifierToMatchAllValues : values ] ;
fetchSpec = [ EOFetchSpecification fetchSpecificationWithEntityName :
entityName
qualifier : qualifier
sortOrderings : nil ] ;
[ fetchSpec setFetchesRawRows : YES ] ;
results = [ self objectsWithFetchSpecification : fetchSpec ] ;
return results ;
}
* 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
- ( NSArray * ) rawRowsWithSQL : ( NSString * ) sqlString
modelNamed : ( NSString * ) name
2002-11-15 22:57:05 +00:00
{
EODatabaseContext * databaseContext ;
EODatabaseChannel * databaseChannel ;
2010-06-06 08:52:37 +00:00
EOAdaptorChannel * adaptorChannel ;
NSMutableArray * results = nil ;
NSArray * attributes = nil ;
2002-11-15 22:57:05 +00:00
NSDictionary * row ;
databaseContext = [ self databaseContextForModelNamed : name ] ;
[ databaseContext lock ] ;
NS_DURING
{
databaseChannel = [ databaseContext availableChannel ] ;
adaptorChannel = [ databaseChannel adaptorChannel ] ;
if ( ! [ adaptorChannel isOpen ] )
[ adaptorChannel openChannel ] ;
[ adaptorChannel evaluateExpression :
[ EOSQLExpression expressionForString : sqlString ] ] ;
2010-06-06 08:52:37 +00:00
attributes = [ adaptorChannel describeResults ] ;
[ adaptorChannel setAttributesToFetch : attributes ] ;
2002-11-15 22:57:05 +00:00
results = [ NSMutableArray array ] ;
while ( ( row = [ adaptorChannel fetchRowWithZone : [ self zone ] ] ) )
[ results addObject : row ] ;
[ databaseContext unlock ] ;
}
NS_HANDLER
{
[ databaseContext unlock ] ;
[ localException raise ] ;
}
NS_ENDHANDLER ;
return results ;
}
* 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
- ( NSArray * ) rawRowsWithStoredProcedureNamed : ( NSString * ) name
arguments : ( NSDictionary * ) args
2002-11-15 22:57:05 +00:00
{
EODatabaseContext * databaseContext ;
EODatabaseChannel * databaseChannel ;
EOAdaptorChannel * adaptorChannel ;
EOStoredProcedure * storedProcedure ;
2010-04-09 10:43:59 +00:00
NSMutableArray * results = nil ;
2002-11-15 22:57:05 +00:00
NSDictionary * row ;
storedProcedure = [ [ self modelGroup ] storedProcedureNamed : name ] ;
databaseContext = [ self databaseContextForModelNamed :
[ [ storedProcedure model ] name ] ] ;
[ databaseContext lock ] ;
NS_DURING
{
databaseChannel = [ databaseContext availableChannel ] ;
adaptorChannel = [ databaseChannel adaptorChannel ] ;
if ( ! [ adaptorChannel isOpen ] )
[ adaptorChannel openChannel ] ;
[ adaptorChannel executeStoredProcedure : storedProcedure
withValues : args ] ;
[ adaptorChannel setAttributesToFetch : [ adaptorChannel describeResults ] ] ;
results = [ NSMutableArray array ] ;
while ( ( row = [ adaptorChannel fetchRowWithZone : [ self zone ] ] ) )
[ results addObject : row ] ;
[ databaseContext unlock ] ;
}
NS_HANDLER
{
[ databaseContext unlock ] ;
[ localException raise ] ;
}
NS_ENDHANDLER ;
return results ;
}
* 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 * ) executeStoredProcedureNamed : ( NSString * ) name
arguments : ( NSDictionary * ) args
2002-11-15 22:57:05 +00:00
{
EODatabaseContext * databaseContext ;
EODatabaseChannel * databaseChannel ;
EOAdaptorChannel * adaptorChannel ;
EOStoredProcedure * storedProcedure ;
NSDictionary * returnValues = nil ;
storedProcedure = [ [ self modelGroup ] storedProcedureNamed : name ] ;
databaseContext = [ self databaseContextForModelNamed :
[ [ storedProcedure model ] name ] ] ;
[ databaseContext lock ] ;
NS_DURING
{
databaseChannel = [ databaseContext availableChannel ] ;
adaptorChannel = [ databaseChannel adaptorChannel ] ;
if ( ! [ adaptorChannel isOpen ] )
[ adaptorChannel openChannel ] ;
[ adaptorChannel executeStoredProcedure : storedProcedure
withValues : args ] ;
returnValues = [ adaptorChannel
returnValuesForLastStoredProcedureInvocation ] ;
[ databaseContext unlock ] ;
}
NS_HANDLER
{
[ databaseContext unlock ] ;
[ localException raise ] ;
}
NS_ENDHANDLER ;
return returnValues ;
}
2005-01-26 14:11:31 +00:00
- ( id ) objectFromRawRow : ( NSDictionary * ) row
entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
return [ self faultForRawRow : row
entityNamed : entityName ] ;
}
2007-01-01 11:52:38 +00:00
- ( EODatabaseContext * ) databaseContextForModelNamed : ( NSString * ) name
2002-11-15 22:57:05 +00:00
{
EOModelGroup * modelGroup ;
EOModel * model ;
EODatabaseContext * databaseContext ;
modelGroup = [ self modelGroup ] ;
model = [ modelGroup modelNamed : name ] ;
if ( ! model )
[ NSException raise : NSInvalidArgumentException
format : @ "%@: cannot find model named %@ associated with this EOEditingContext" ,
NSStringFromSelector ( _cmd ) ,
name ] ;
databaseContext = [ EODatabaseContext registeredDatabaseContextForModel : model
editingContext : self ] ;
return databaseContext ;
}
- ( void ) connectWithModelNamed : ( NSString * ) name
connectionDictionaryOverrides : ( NSDictionary * ) overrides
{
EOModel * model ;
model = [ [ self modelGroup ] modelNamed : name ] ;
[ self notImplemented : _cmd ] ;
}
- ( id ) createAndInsertInstanceOfEntityNamed : ( NSString * ) entityName
{
id object ;
EOClassDescription * classDescription ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
classDescription = [ EOClassDescription classDescriptionForEntityName :
entityName ] ;
if ( ! classDescription )
[ NSException raise : NSInvalidArgumentException
format : @ "%@ could not find class description for entity named %@" ,
NSStringFromSelector ( _cmd ) ,
entityName ] ;
object = [ classDescription createInstanceWithEditingContext : self
globalID : nil
zone : [ self zone ] ] ;
[ self insertObject : object ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return object ;
}
2007-01-01 11:52:38 +00:00
- ( NSDictionary * ) primaryKeyForObject : ( id ) object
2002-11-15 22:57:05 +00:00
{
EOKeyGlobalID * gid ;
EOEntity * entity ;
NSDictionary * newDict ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
gid = ( EOKeyGlobalID * ) [ self globalIDForObject : object ] ;
entity = [ self entityForObject : object ] ;
newDict = [ entity primaryKeyForGlobalID : gid ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return newDict ;
}
* 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 * ) destinationKeyForSourceObject : ( id ) object
relationshipNamed : ( NSString * ) name
2002-11-15 22:57:05 +00:00
{
EODatabaseContext * databaseContext ;
EODatabase * database ;
EOEntity * sourceEntity ;
EORelationship * relationship ;
NSArray * joins ;
EOJoin * join ;
NSString * sourceAttributeName ;
NSString * destinationAttributeName ;
NSDictionary * snapshot ;
NSMutableDictionary * result = nil ;
int i , count ;
sourceEntity = [ self entityForObject : object ] ;
relationship = [ sourceEntity relationshipNamed : name ] ;
if ( ! relationship )
[ NSException raise : NSInvalidArgumentException
format : @ "%@: entity %@ does not have relationship named %@" ,
NSStringFromSelector ( _cmd ) ,
[ sourceEntity name ] ,
name ] ;
databaseContext = [ self databaseContextForModelNamed :
[ [ sourceEntity model ] name ] ] ;
[ databaseContext lock ] ;
NS_DURING
{
database = [ databaseContext database ] ;
snapshot = [ database snapshotForGlobalID : [ self globalIDForObject :
object ] ] ;
joins = [ relationship joins ] ;
count = [ joins count ] ;
result = ( NSMutableDictionary * ) [ NSMutableDictionary dictionary ] ;
for ( i = 0 ; i < count ; i + + )
{
join = [ joins objectAtIndex : i ] ;
sourceAttributeName = [ [ join sourceAttribute ] name ] ;
destinationAttributeName = [ [ join destinationAttribute ] name ] ;
[ result setObject : [ snapshot objectForKey : sourceAttributeName ]
forKey : destinationAttributeName ] ;
}
[ databaseContext unlock ] ;
}
NS_HANDLER
{
[ databaseContext unlock ] ;
[ localException raise ] ;
}
NS_ENDHANDLER ;
return result ;
}
- ( id ) localInstanceOfObject : ( id ) object
{
EOGlobalID * gid ;
id newInstance ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
gid = [ [ object editingContext ] globalIDForObject : object ] ;
newInstance = [ self faultForGlobalID : gid
editingContext : self ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return newInstance ;
}
2005-01-26 14:11:31 +00:00
- ( NSArray * ) localInstancesOfObjects : ( NSArray * ) objects
2002-11-15 22:57:05 +00:00
{
NSMutableArray * array ;
int i , count = [ objects count ] ;
id obj ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
array = [ NSMutableArray arrayWithCapacity : count ] ;
for ( i = 0 ; i < count ; i + + )
{
obj = [ self localInstanceOfObject : [ objects objectAtIndex : i ] ] ;
[ array addObject : obj ] ;
}
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return array ;
}
2005-01-26 14:11:31 +00:00
- ( EOModelGroup * ) modelGroup
2002-11-15 22:57:05 +00:00
{
EOObjectStore * rootObjectStore ;
EOObjectStoreCoordinator * objectStoreCoordinator ;
EOModelGroup * modelGroup ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
rootObjectStore = [ self rootObjectStore ] ;
if ( ! [ rootObjectStore isKindOfClass : [ EOObjectStoreCoordinator class ] ] )
[ NSException raise : NSInvalidArgumentException
format : @ "%@: an EOEditingContext's root object store must be an EOObjectStoreCoordinator for this method to function." ,
NSStringFromSelector ( _cmd ) ] ;
objectStoreCoordinator = ( EOObjectStoreCoordinator * ) rootObjectStore ;
modelGroup = [ objectStoreCoordinator modelGroup ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return modelGroup ;
}
2005-01-26 14:11:31 +00:00
- ( EOEntity * ) entityNamed : ( NSString * ) entityName
2002-11-15 22:57:05 +00:00
{
EOEntity * entity ;
EOModelGroup * modelGroup ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
NSAssert ( [ entityName length ] > 0 , @ "No entity name" ) ;
modelGroup = [ self modelGroup ] ;
NSAssert ( modelGroup , @ "No model group" ) ;
entity = [ modelGroup entityNamed : entityName ] ;
if ( ! entity )
[ NSException raise : NSInvalidArgumentException
format : @ "%@: could not find entity named:%@" ,
NSStringFromSelector ( _cmd ) ,
entityName ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return entity ;
}
2005-01-26 14:11:31 +00:00
- ( EOEntity * ) entityForClass : ( Class ) classObject
2002-11-15 22:57:05 +00:00
{
EOModelGroup * modelGroup ;
NSArray * models ;
EOModel * model ;
int modelCount ;
NSArray * entities ;
EOEntity * entity ;
NSString * className ;
NSString * entityClassName ;
int i , j , entityCount ;
EOEntity * result = nil ;
BOOL matchesClassName ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
className = NSStringFromClass ( classObject ) ;
modelGroup = [ self modelGroup ] ;
models = [ modelGroup models ] ;
modelCount = [ models count ] ;
for ( i = 0 ; i < modelCount ; i + + )
{
model = [ models objectAtIndex : i ] ;
entities = [ model entities ] ;
entityCount = [ entities count ] ;
for ( j = 0 ; j < entityCount ; j + + )
{
entity = [ entities objectAtIndex : j ] ;
entityClassName = [ entity className ] ;
matchesClassName = [ className isEqualToString : entityClassName ] ;
// Java class names in the Objective - C run - time system use ' / ' instead of ' . ' to separate package names , so we also check for a class name in which we replaced ' . ' with ' / ' .
if ( ! matchesClassName
&& ( [ entityClassName rangeOfString : @ "." ] . length ! = 0 ) )
matchesClassName = [ className
isEqualToString :
[ [ entityClassName componentsSeparatedByString : @ "." ]
componentsJoinedByString : @ "/" ] ] ;
if ( matchesClassName )
{
if ( result )
[ NSException raise : EOMoreThanOneException
format : @ "%@ found more than one entity for class named %@" ,
NSStringFromSelector ( _cmd ) ,
className ] ;
else
result = entity ;
}
}
}
if ( ! result )
2005-01-26 14:11:31 +00:00
[ NSException raise : NSObjectNotAvailableException
2002-11-15 22:57:05 +00:00
format : @ "%@ could not find entity for class named %@" ,
NSStringFromSelector ( _cmd ) , className ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return result ;
}
2005-01-26 14:11:31 +00:00
- ( EOEntity * ) entityForObject : ( id ) object
2002-11-15 22:57:05 +00:00
{
EOClassDescription * classDesc ;
EOEntity * newEntity ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
2003-02-03 14:53:03 +00:00
classDesc = [ ( EOGenericRecord * ) object classDescription ] ;
2002-11-15 22:57:05 +00:00
if ( [ classDesc isKindOfClass : [ EOEntityClassDescription class ] ] = = NO )
[ NSException raise : NSInvalidArgumentException
format : @ "%@ - %@: the object's class description must be an EOEntityClassDescription" ,
NSStringFromSelector ( _cmd ) ,
object ] ;
newEntity = [ ( EOEntityClassDescription * ) classDesc entity ] ;
2010-05-30 19:25:53 +00:00
2002-11-15 22:57:05 +00:00
return newEntity ;
}
@ end
2002-12-31 16:25:21 +00:00
@ implementation EOFetchSpecification ( EOAccess )
+ ( EOFetchSpecification * ) fetchSpecificationNamed : ( NSString * ) name
entityNamed : ( NSString * ) entityName
{
EOFetchSpecification * newEOFetchSpecification = nil ;
EOModelGroup * anModelGroup ;
2010-05-30 19:25:53 +00:00
2002-12-31 16:25:21 +00:00
anModelGroup = [ EOModelGroup defaultGroup ] ;
if ( anModelGroup )
newEOFetchSpecification = [ anModelGroup fetchSpecificationNamed : name
entityNamed : entityName ] ;
2010-05-30 19:25:53 +00:00
2002-12-31 16:25:21 +00:00
return newEOFetchSpecification ;
}
@ end