* EOAccess/EOEntity.m

- createInstanceWithEditingContext:globalID:zone:
reformat, remove logs
* EOAccess/EODatabaseContext.m
-initializeObject:withGlobalID:editingContext:
rewritten, add exceptions
* EOAccess/EODatabaseChannel.m
-fetchObject
remove logs, add exceptions
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLAdaptor.m
postgresClientVersion()
use stringWithCString:encoding: not stringWithCString:
* Apps/EOModelEditor/CodeGenerator.m
don't add <NSCoding> to generated code
* EOControl/EOCustomObject.h
* EOControl/EOCustomObject.m
add -encodeWithCoder:
add -initWithCoder:



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@30875 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Dave Wetzel 2010-06-28 09:31:49 +00:00
parent a5a47b954d
commit f14aafa3fc
8 changed files with 114 additions and 96 deletions

View file

@ -330,7 +330,7 @@ void addToUsedClasses(NSMutableArray * mutArray,NSSet * knownNames, NSArray * ot
[cs appendString:[self classDummysForEntity:entity]];
[cs appendFormat:@"@interface _%@ : EOCustomObject <NSCoding>\n{\n", className];
[cs appendFormat:@"@interface _%@ : EOCustomObject\n{\n", className];
while ((eoAttr = [enumer nextObject])) {
[cs appendFormat:@" %@ _%@;\n", [eoAttr cScalarTypeString], [eoAttr name]];

View file

@ -1,3 +1,23 @@
2010-06-28 David Wetzel <dave@turbocat.de>
* EOAccess/EOEntity.m
- createInstanceWithEditingContext:globalID:zone:
reformat, remove logs
* EOAccess/EODatabaseContext.m
-initializeObject:withGlobalID:editingContext:
rewritten, add exceptions
* EOAccess/EODatabaseChannel.m
-fetchObject
remove logs, add exceptions
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLAdaptor.m
postgresClientVersion()
use stringWithCString:encoding: not stringWithCString:
* Apps/EOModelEditor/CodeGenerator.m
don't add <NSCoding> to generated code
* EOControl/EOCustomObject.h
* EOControl/EOCustomObject.m
add -encodeWithCoder:
add -initWithCoder:
2010-06-27 David Wetzel <dave@turbocat.de>
* EOAccess/EODatabaseContext.m
-isValidQualifierTypeForAttribute:

View file

@ -302,14 +302,11 @@ RCS_ID("$Id$")
//seems OK
EODatabase *database=nil;
id object = nil;
database = [_databaseContext database];
if (![self isFetchInProgress])
{
NSLog(@"No Fetch in progress");
NSDebugMLog(@"No Fetch in progress", "");
{
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: no fetch in progress",
NSStringFromSelector(_cmd),
@ -326,12 +323,8 @@ RCS_ID("$Id$")
propertiesToFetch = [self _propertiesToFetch];
EOFLOGObjectLevel(@"gsdb", @"Will fetchRow");
row = [_adaptorChannel fetchRowWithZone: NULL];
EOFLOGObjectLevelArgs(@"gsdb", @"row=%@", row);
if (!row)
{
//TODO
@ -359,12 +352,8 @@ RCS_ID("$Id$")
gid = [_currentEntity globalIDForRow: row
isFinal: YES];//OK
EOFLOGObjectLevelArgs(@"gsdb", @"gid=%@", gid);
object = [_currentEditingContext objectForGlobalID: gid]; //OK //nil
EOFLOGObjectLevelArgs(@"gsdb", @"object=%@", object);
if (object)
isObjectNew = NO;
@ -372,17 +361,8 @@ RCS_ID("$Id$")
snapshot = [_databaseContext snapshotForGlobalID: gid]; //OK
EOFLOGObjectLevelArgs(@"gsdb", @"snapshot=%@", snapshot);
if (snapshot)
{
EOFLOGObjectLevelArgs(@"gsdb", @"_delegateRespondsTo.shouldUpdateSnapshot=%d",
(int)_delegateRespondsTo.shouldUpdateSnapshot);
EOFLOGObjectLevelArgs(@"gsdb", @"[self isLocking]=%d",
(int)[self isLocking]);
EOFLOGObjectLevelArgs(@"gsdb", @"[self isRefreshingObjects]=%d",
(int)[self isRefreshingObjects]);
{
//mirko:
if((_delegateRespondsTo.shouldUpdateSnapshot == NO
&& ([self isLocking] == YES
@ -394,8 +374,6 @@ RCS_ID("$Id$")
globalID: gid
databaseChannel: self])))
{ // TODO delegate not correct !
EOFLOGObjectLevelArgs(@"gsdb", @"Updating Snapshot=%@", snapshot);
EOFLOGObjectLevelArgs(@"gsdb", @"row=%@", row);
[_databaseContext recordSnapshot: row
forGlobalID: gid];
@ -404,17 +382,12 @@ RCS_ID("$Id$")
}
else
{
EOFLOGObjectLevelArgs(@"gsdb", @"database class=%@", [database class]);
NSAssert(database, @"No database-context database");
[database recordSnapshot: row
forGlobalID: gid];
}
EOFLOGObjectLevelArgs(@"gsdb", @"[self isRefreshingObjects]=%d",
(int)[self isRefreshingObjects]);
//From mirko
if ([self isRefreshingObjects] == YES)
{
@ -434,7 +407,6 @@ RCS_ID("$Id$")
globalID: gid
zone: NULL];
EOFLOGObjectLevelArgs(@"gsdb", @"object=%@", object);
NSAssert1(object, @"No Object. entityClassDescripton=%@", entityClassDescripton);
EOEditingContext_recordObjectGlobalIDWithImpPtr(_currentEditingContext,
@ -447,7 +419,6 @@ RCS_ID("$Id$")
EOKeyGlobalID *handlerGID = (EOKeyGlobalID *)[handler globalID];
isObjectNew = YES; //TODO
[handlerGID isFinal]; //YES //TODO
[EOFault clearFault: object];
@ -461,11 +432,14 @@ RCS_ID("$Id$")
if (isObjectNew) //TODO
{
if ((!object) || ([object isKindOfClass:[EOCustomObject class]] == NO)) {
[NSException raise: NSInternalInconsistencyException
format: @"%s:%d cannot initialize nil/non EOCustomObject object!", __FILE__, __LINE__];
}
[EOObserverCenter suppressObserverNotification];
NS_DURING
{
EOFLOGObjectLevelArgs(@"gsdb", @"Initialize %p", object);
[_currentEditingContext initializeObject: object
withGlobalID: gid
@ -479,15 +453,19 @@ RCS_ID("$Id$")
NS_ENDHANDLER;
[EOObserverCenter enableObserverNotification];
if ((!object) || ([object isKindOfClass:[EOCustomObject class]] == NO)) {
[NSException raise: NSInternalInconsistencyException
format: @"%s:%d cannot initialize nil/non EOCustomObject object!", __FILE__, __LINE__];
}
[object awakeFromFetchInEditingContext: _currentEditingContext];
}
}
}
return object;
};
}
- (BOOL)isFetchInProgress
{

View file

@ -820,45 +820,64 @@ classPropertyNames = [entity classPropertyNames];
}
- (void)initializeObject: (id)object
withGlobalID: (EOGlobalID *)globalID
withGlobalID: (EOGlobalID *)globalID
editingContext: (EOEditingContext *)context
{
//near OK
EOEntity *entity = nil;
NSDictionary * snapDict = nil;
EOEntity * entity = nil;
/*
TODO use this stuff -- dw
if (globalID == _currentGlobalID)
{
snapDict = _currentSnapshot;
entity = _lastEntity;
} else ...
*/
if ([globalID isTemporary])
{
return;
}
snapDict = [self snapshotForGlobalID:globalID];
if ([(EOKeyGlobalID *)globalID isFinal])
{
entity = [self entityForGlobalID:globalID];
} else {
object = [context objectForGlobalID:globalID];
if (!object)
{
NSEmitTODO();
[self notImplemented: _cmd]; //TODO
[NSException raise: NSInternalInconsistencyException
format: @"%s No object for gid %@ in %@", __PRETTY_FUNCTION__, globalID, context];
}
entity = [_database entityForObject:object];
}
if (![(EOKeyGlobalID *)globalID isFinal])
{
NSEmitTODO();
[self notImplemented: _cmd]; //TODO
if (!snapDict)
{
[NSException raise: NSInternalInconsistencyException
format: @"%s No snapshot for gid %@", __PRETTY_FUNCTION__, globalID];
} else {
if ((!object) || ([object isKindOfClass:[EOCustomObject class]] == NO)) {
[NSException raise: NSInternalInconsistencyException
format: @"%s:%d cannot initialize nil/non EOCustomObject object!", __FILE__, __LINE__];
}
//mirko:
if (_updateStrategy == EOUpdateWithPessimisticLocking)
[self registerLockedObjectWithGlobalID: globalID];
entity = [self entityForGlobalID: globalID];
/*Mirko:
if ([object respondsToSelector:@selector(entity)])
entity = [object entity];
else
entity = [_database entityNamed:[globalID entityName]];
*/
[self initializeObject: object
row: EODatabaseContext_snapshotForGlobalIDWithImpPtr(self,NULL,globalID) //shound be _currentSnapshot
entity: entity
editingContext: context];
[self initializeObject: object
row: snapDict
entity: entity
editingContext: context];
if ((!object) || ([object isKindOfClass:[EOCustomObject class]] == NO)) {
[NSException raise: NSInternalInconsistencyException
format: @"%s:%d Something went wrong!", __FILE__, __LINE__];
}
[_database incrementSnapshotCountForGlobalID:globalID];
}
}
- (void) _objectsChanged: (NSNotification*)notification
@ -6124,15 +6143,9 @@ Raises an exception is the adaptor is unable to perform the operations.
IMP objectTakeStoredValueForKeyIMP=NULL;
IMP rowObjectForKeyIMP=NULL;
classPropertyAttributeNames = [entity classPropertyAttributeNames];
count = [classPropertyAttributeNames count];
//row is usuallly a EOMutableKnownKeyDictionary so will use EOMKKD_objectForKeyWithImpPtr
if (count>0)

View file

@ -4206,29 +4206,22 @@ fromInsertionInEditingContext: (EOEditingContext *)context
{
id obj = nil;
Class objectClass;
NSAssert1(_entity, @"No _entity in %@", self);
objectClass = [_entity classForObjectWithGlobalID: (EOKeyGlobalID*)globalID];
EOFLOGObjectLevelArgs(@"EOEntity", @"objectClass=%p", objectClass);
NSAssert2(objectClass, @"No objectClass for globalID=%@. EntityName=%@",
globalID, [_entity name]);
globalID, [_entity name]);
if (objectClass)
{
EOFLOGObjectLevelArgs(@"EOEntity", @"objectClass=%@", objectClass);
obj = AUTORELEASE([[objectClass allocWithZone:zone]
initWithEditingContext: editingContext
classDescription: self
globalID: globalID]);
}
{
obj = AUTORELEASE([[objectClass allocWithZone:zone]
initWithEditingContext: editingContext
classDescription: self
globalID: globalID]);
}
return obj;
}

View file

@ -87,7 +87,8 @@ postgresClientVersion()
static int version = 0;
if (version == 0)
{
NSString *versionString = [NSString stringWithCString: PG_VERSION];
NSString *versionString = [NSString stringWithCString:PG_VERSION
encoding:NSASCIIStringEncoding];
version = [versionString parsedFirstVersionSubstring];
}
return version;

View file

@ -39,7 +39,7 @@
@class EOEditingContext;
@interface EOCustomObject : NSObject
@interface EOCustomObject : NSObject <NSCoding>
{
}
@ -119,6 +119,9 @@
- (NSString *)eoShallowDescription;
- (NSString *)eoDescription;
- (void)encodeWithCoder:(NSCoder *)aCoder;
- (id)initWithCoder:(NSCoder *)aDecoder;
@end
#endif // __EOCustomObject_h__

View file

@ -1057,7 +1057,17 @@ RCS_ID("$Id: EOGenericRecord.m 30111 2010-04-09 10:09:41Z ayers $")
return ret; //TODO
}
// -----------------------------------------------
- (void)encodeWithCoder:(NSCoder *)aCoder
{
[EOEditingContext encodeObject:self
withCoder:aCoder];
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
return [EOEditingContext initObject:self
withCoder:aDecoder];
}
@end