You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by to...@apache.org on 2006/08/29 23:57:26 UTC

svn commit: r438245 - in /incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne: ./ CocoaCayenne.xcodeproj/

Author: torehalset
Date: Tue Aug 29 14:57:25 2006
New Revision: 438245

URL: http://svn.apache.org/viewvc?rev=438245&view=rev
Log:
 * made CAYPersistentObject key value coding compliant
 * started to implement insert/delete
 * fixed NSNull/nil bug in CAYObjectId

Added:
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.h
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.m
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.h
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.m
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.h
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.m
Modified:
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYCompoundDiff.m
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.h
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToManyFault.m
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToOneFault.m
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYCompoundDiff.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYCompoundDiff.m?rev=438245&r1=438244&r2=438245&view=diff
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYCompoundDiff.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYCompoundDiff.m Tue Aug 29 14:57:25 2006
@@ -53,6 +53,14 @@
     return diffs;
 }
 
+-(NSString *)description
+{
+    NSString *result;
+    result = [[NSString alloc] initWithFormat:@"CAYCompoundDiff {diffs = %@}", [self diffs]];
+    [result autorelease];
+    return result;
+}
+
 -(void)dealloc
 {
 	[diffs release];

Added: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.h
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.h?rev=438245&view=auto
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.h (added)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.h Tue Aug 29 14:57:25 2006
@@ -0,0 +1,27 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+#import <Cocoa/Cocoa.h>
+#import "CAYNodeDiff.h"
+
+@interface CAYNodeCreateOperation : CAYNodeDiff <NSCoding> {
+
+}
+
+@end

Added: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.m?rev=438245&view=auto
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.m (added)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeCreateOperation.m Tue Aug 29 14:57:25 2006
@@ -0,0 +1,35 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+#import "CAYNodeCreateOperation.h"
+
+@implementation CAYNodeCreateOperation
+
+-(id)initWithCoder:(NSCoder*)coder
+{
+	[super initWithCoder:coder];
+	return self;
+}
+
+-(void)encodeWithCoder:(NSCoder*)coder
+{
+    [super encodeWithCoder:coder];
+}
+
+@end

Added: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.h
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.h?rev=438245&view=auto
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.h (added)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.h Tue Aug 29 14:57:25 2006
@@ -0,0 +1,27 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+#import <Cocoa/Cocoa.h>
+#import "CAYNodeDiff.h"
+
+@interface CAYNodeDeleteOperation : CAYNodeDiff <NSCoding> {
+
+}
+
+@end

Added: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.m?rev=438245&view=auto
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.m (added)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeDeleteOperation.m Tue Aug 29 14:57:25 2006
@@ -0,0 +1,36 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+#import "CAYNodeDeleteOperation.h"
+
+
+@implementation CAYNodeDeleteOperation
+
+-(id)initWithCoder:(NSCoder*)coder
+{
+	[super initWithCoder:coder];
+	return self;
+}
+
+-(void)encodeWithCoder:(NSCoder*)coder
+{
+    [super encodeWithCoder:coder];
+}
+
+@end

Added: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.h
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.h?rev=438245&view=auto
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.h (added)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.h Tue Aug 29 14:57:25 2006
@@ -0,0 +1,32 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+#import <Cocoa/Cocoa.h>
+#import "CAYNodeDiff.h"
+
+@interface CAYNodeIdChangeOperation : CAYNodeDiff <NSCoding> {
+
+    NSObject *newNodeId;
+
+}
+
+-(void)setNewNodeId:(NSObject *)nid;
+-(NSObject *)newNodeId;
+
+@end

Added: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.m?rev=438245&view=auto
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.m (added)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYNodeIdChangeOperation.m Tue Aug 29 14:57:25 2006
@@ -0,0 +1,57 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+#import "CAYNodeIdChangeOperation.h"
+
+
+@implementation CAYNodeIdChangeOperation
+
+-(id)initWithCoder:(NSCoder*)coder
+{
+	[super initWithCoder:coder];
+    [self setNewNodeId:[coder decodeObjectForKey:@"newNodeId"]];
+	return self;
+}
+
+-(void)encodeWithCoder:(NSCoder*)coder
+{
+    [super encodeWithCoder:coder];
+	[coder encodeObject:newNodeId forKey:@"newNodeId"];
+}
+
+-(void)setNewNodeId:(NSObject *)nid
+{
+    [nid retain];
+    [newNodeId release];
+    newNodeId = nid;
+}
+
+-(NSObject *)newNodeId
+{
+    return newNodeId;
+}
+
+-(void)dealloc
+{
+	[self setNewNodeId:nil];
+	[super dealloc];
+}
+
+
+@end

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h?rev=438245&r1=438244&r2=438245&view=diff
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h Tue Aug 29 14:57:25 2006
@@ -20,8 +20,9 @@
 #import <Cocoa/Cocoa.h>
 #import "CAYQuery.h"
 #import "CAYEntityResolver.h"
+#import "CAYPersistentObject.h"
 
-@class CAYPersistentObject, CAYClientConnection;
+@class CAYPersistentObject, CAYClientConnection, CAYPersistentObject;
 
 @interface CAYObjectContext : NSObject {
 	CAYClientConnection *connection;
@@ -40,5 +41,9 @@
 
 -(void)setEntityResolver:(CAYEntityResolver *)er;
 -(CAYEntityResolver *)entityResolver;
+
+-(CAYPersistentObject *)newObject:(Class)pc;
+-(void)deleteObject:(CAYPersistentObject *)o;
+-(void)registerNewObject:(CAYPersistentObject *)o;
 
 @end

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m?rev=438245&r1=438244&r2=438245&view=diff
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m Tue Aug 29 14:57:25 2006
@@ -20,7 +20,6 @@
 #import "CAYObjectContext.h"
 #import "CAYQueryMessage.h"
 #import "CAYQuery.h"
-#import "CAYPersistentObject.h"
 #import "CAYClientConnection.h"
 #import "CAYNodeDiff.h"
 #import "CAYNodePropertyChangeOperation.h"
@@ -31,6 +30,8 @@
 #import "CAYFault.h"
 #import "CAYToManyFault.h"
 #import "CAYToOneFault.h"
+#import "CAYNodeCreateOperation.h"
+#import "CAYNodeDeleteOperation.h"
 
 @implementation CAYObjectContext
 
@@ -149,6 +150,59 @@
 -(CAYEntityResolver *)entityResolver
 {
     return entityResolver;
+}
+
+-(CAYPersistentObject *)newObject:(Class)pc
+{
+    CAYPersistentObject *o = [[pc alloc] init];
+    [self registerNewObject:o];
+    return [o autorelease];
+}
+
+-(void)registerNewObject:(CAYPersistentObject *)o
+{
+    NSLog(@"register new object");
+    // TODO: check existing data context?
+    [o retain];
+    [o setObjectContext:self];
+    // TODO: set persistant state
+
+    // create random data for key
+    int randombytes[8];
+    int i;
+    for(i = 0; i < 8; i++)
+    {
+        randombytes[i] = rand();
+    }
+    NSData *randomdata = [[NSData alloc] initWithBytesNoCopy:&randombytes length:8];
+    
+    CAYObjectId *oid = [[CAYObjectId alloc] init];
+    CAYObjEntity *objEntity = [[self entityResolver] objEntityForClass:[o class]];
+    [oid setEntityName:[objEntity name]];
+    [oid setTempKey:randomdata];
+    [o setObjectId:oid];
+    
+    CAYNodeDiff *diff = [[CAYNodeCreateOperation alloc] initWithNodeId:oid];
+    [diffs addObject:diff];
+    [diff release];
+    
+    // TODO: init values with NSNull objects?
+    [randomdata release];
+    [oid release];
+    [o release];
+}
+
+-(void)deleteObject:(CAYPersistentObject *)o
+{
+    CAYNodeDiff *diff = [[CAYNodeDeleteOperation alloc] initWithNodeId:[o objectId]];
+    [diffs addObject:diff];
+    [diff release];
+
+    // TODO set persistent state?
+    
+    // cleanup and remove
+    [o setObjectContext:nil];
+    [o setObjectId:nil];
 }
 
 -(void)dealloc

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m?rev=438245&r1=438244&r2=438245&view=diff
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m Tue Aug 29 14:57:25 2006
@@ -30,6 +30,14 @@
 	[self setSingleKey:[coder decodeObjectForKey:@"singleKey"]];
 	[self setSingleValue:[coder decodeObjectForKey:@"singleValue"]];
 	[self setTempKey:[coder decodeObjectForKey:@"key"]];
+    
+    // TODO: fix in HessianObjC or elsewere..
+    if([[self tempKey] isKindOfClass:[NSNull class]])
+    {
+        NSLog(@"HACK: switching tempKey from NSNull to nil");
+        [self setTempKey:nil];
+    }
+    
 	[self setReplacementIdMap:[coder decodeObjectForKey:@"replacementIdMap"]];
 	return self;
 }
@@ -41,7 +49,15 @@
     [coder encodeObject:singleValue forKey:@"singleValue"];
     [coder encodeObject:objectIdKeys forKey:@"objectIdKeys"];
     // TODO: fix problem: the key "key" result in a ugly unserialize exception at the server side.
-    //[coder encodeObject:tempKey forKey:@"key"];
+    if([self tempKey])
+    {
+        NSLog(@"encoding key");
+        [coder encodeObject:tempKey forKey:@"key"];
+    }
+    else
+    {
+        NSLog(@"not encoding key");
+    }
     [coder encodeObject:replacementIdMap forKey:@"replacementIdMap"];
 }
 
@@ -174,7 +190,7 @@
 -(NSString *)description
 {
     NSString *result;
-    result = [[NSString alloc] initWithFormat:@"{entityName = %@; objectIdKeys = %@; singleKey = %@; singleValue = %@}", [self entityName], [self objectIdKeys], [self singleKey], [self singleValue]];
+    result = [[NSString alloc] initWithFormat:@"{entityName = %@; objectIdKeys = %@; singleKey = %@; singleValue = %@; tempKey = %@}", [self entityName], [self objectIdKeys], [self singleKey], [self singleValue], [self tempKey]];
     [result autorelease];
     return result;
 }

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.h
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.h?rev=438245&r1=438244&r2=438245&view=diff
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.h (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.h Tue Aug 29 14:57:25 2006
@@ -21,6 +21,8 @@
 #import "CAYObjectId.h"
 #import "CAYObjectContext.h"
 
+@class CAYObjectContext;
+
 @interface CAYPersistentObject : NSObject <NSCoding> {
 	CAYObjectId *objectId;
 	unsigned int persistenceState;
@@ -35,7 +37,9 @@
 -(void)setObjectContext:(CAYObjectContext *)ctxt;
 -(CAYObjectContext *)objectContext;
 
-// used for raw access to the value dictionary. use with care!
 -(NSMutableDictionary *)valuesRaw;
+
+- (void)setValue:(id)value forKey:(NSString *)key;
+- (id)valueForKey:(NSString *)key;
 
 @end

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m?rev=438245&r1=438244&r2=438245&view=diff
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m Tue Aug 29 14:57:25 2006
@@ -20,14 +20,24 @@
 #import "CAYPersistentObject.h"
 #import "CAYObjectId.h"
 #import "CAYObjectContext.h"
+#import "CAYFault.h"
 
 
 @implementation CAYPersistentObject
 
+-(id)init
+{
+    self = [super init];
+    if(self)
+    {
+        values = [[NSMutableDictionary dictionary] retain];
+    }
+    return self;
+}
+
 -(id)initWithCoder:(NSCoder*)coder
 {
-	[super init];
-    values = [[NSMutableDictionary dictionary] retain];
+	[self init];
 	[self setObjectId:[coder decodeObjectForKey:@"objectId"]];
 	return self;
 }
@@ -74,7 +84,7 @@
 -(NSString *)description
 {
     NSString *result;
-    result = [[NSString alloc] initWithFormat:@"{objectId = %@; values = %@}", [self objectId], values];
+    result = [[NSString alloc] initWithFormat:@"{objectContext = %@; objectId = %@; values = %@}", [self objectContext], [self objectId], values];
     [result autorelease];
     return result;
 }
@@ -82,6 +92,45 @@
 -(NSMutableDictionary *)valuesRaw
 {
     return values;
+}
+
+- (void)setValue:(id)value forKey:(NSString *)key
+{
+    NSLog(@"set value %@ for key %@ of type %@", value, key, [value class]);
+    
+    if([value isKindOfClass:[NSArray class]])
+    {
+        NSEnumerator *enumerator = [value objectEnumerator];
+        // TODO: handle and give error if not CAYPersistentObject
+        CAYPersistentObject *element;
+        while(element = [enumerator nextObject])
+        {
+            if(![element objectContext])
+            {
+                [[self objectContext] registerNewObject:element];
+                // TODO: set relation both ways
+            }
+        }
+        // TODO: check for objects that are not present any more
+    }
+
+    // TODO: is this for simple properties only? not for relations?
+    [[self objectContext] propertyChanged:self forProperty:key fromOld:[values objectForKey:key] toNew:value];
+
+    [values setValue:value forKey:key];
+}
+
+- (id)valueForKey:(NSString *)key
+{
+    id val = [values objectForKey:key];
+    if([val isKindOfClass:[CAYFault class]])
+    {
+        CAYFault *fault = (CAYFault *)val;
+        NSLog(@"resolve fault %@", fault);
+        val = [fault resolveFault];
+        [values setValue:val forKey:key];
+    }
+	return [values objectForKey:key];
 }
 
 -(void)dealloc

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToManyFault.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToManyFault.m?rev=438245&r1=438244&r2=438245&view=diff
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToManyFault.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToManyFault.m Tue Aug 29 14:57:25 2006
@@ -34,11 +34,17 @@
     
     CAYObjectContext *ctxt = [[self sourceObject] objectContext];
     NSArray *rows = (NSArray *)[ctxt performQyery:q];
+    [q release];
+    return rows;
     
     // TODO: create a collection that will autoadd new objects to the context? check with Core Data
+    /*
+    CAYManagedArray *managedRows = [[CAYManagedArray alloc] init];
+    [managedRows setArray:rows];
+    [managedRows setObjectContext:ctxt];
     
-    [q release];
-    return rows;
+    return [managedRows autorelease];
+    */
 }
 
 @end

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToOneFault.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToOneFault.m?rev=438245&r1=438244&r2=438245&view=diff
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToOneFault.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYToOneFault.m Tue Aug 29 14:57:25 2006
@@ -43,6 +43,7 @@
     {
         NSLog(@"ERROR: toOne fault resolve returned %i rows", [rows count]);
     }
+    // TODO: check in local ObjectContext first
     
     [q release];
     return row;

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj?rev=438245&r1=438244&r2=438245&view=diff
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj Tue Aug 29 14:57:25 2006
@@ -7,6 +7,10 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		4421E61E0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4421E61C0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.h */; };
+		4421E61F0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4421E61D0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.m */; };
+		442607380AA4B8DE00F0A01F /* CAYNodeCreateOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 442607360AA4B8DE00F0A01F /* CAYNodeCreateOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		442607390AA4B8DE00F0A01F /* CAYNodeCreateOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 442607370AA4B8DE00F0A01F /* CAYNodeCreateOperation.m */; };
 		44463D9B0AA37577006BAA58 /* CAYBootstrapMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = 44463D6B0AA37577006BAA58 /* CAYBootstrapMessage.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		44463D9C0AA37577006BAA58 /* CAYBootstrapMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 44463D6C0AA37577006BAA58 /* CAYBootstrapMessage.m */; };
 		44463D9D0AA37577006BAA58 /* CAYClientConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 44463D6D0AA37577006BAA58 /* CAYClientConnection.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -55,6 +59,8 @@
 		44463DC80AA37577006BAA58 /* CAYToManyFault.m in Sources */ = {isa = PBXBuildFile; fileRef = 44463D980AA37577006BAA58 /* CAYToManyFault.m */; };
 		44463DC90AA37577006BAA58 /* CAYToOneFault.h in Headers */ = {isa = PBXBuildFile; fileRef = 44463D990AA37577006BAA58 /* CAYToOneFault.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		44463DCA0AA37577006BAA58 /* CAYToOneFault.m in Sources */ = {isa = PBXBuildFile; fileRef = 44463D9A0AA37577006BAA58 /* CAYToOneFault.m */; };
+		4448AA430AA4C55F002C2FA7 /* CAYNodeDeleteOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4448AA410AA4C55F002C2FA7 /* CAYNodeDeleteOperation.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		4448AA440AA4C55F002C2FA7 /* CAYNodeDeleteOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4448AA420AA4C55F002C2FA7 /* CAYNodeDeleteOperation.m */; };
 		44FE798F0AA3790C0040BB78 /* HessianObjC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 44FE798E0AA3790C0040BB78 /* HessianObjC.framework */; };
 		8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
 		8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; };
@@ -66,6 +72,10 @@
 		089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
 		1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
 		32DBCF5E0370ADEE00C91783 /* CocoaCayenne_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoaCayenne_Prefix.pch; sourceTree = "<group>"; };
+		4421E61C0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAYNodeIdChangeOperation.h; sourceTree = "<group>"; };
+		4421E61D0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYNodeIdChangeOperation.m; sourceTree = "<group>"; };
+		442607360AA4B8DE00F0A01F /* CAYNodeCreateOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAYNodeCreateOperation.h; sourceTree = "<group>"; };
+		442607370AA4B8DE00F0A01F /* CAYNodeCreateOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYNodeCreateOperation.m; sourceTree = "<group>"; };
 		44463D6B0AA37577006BAA58 /* CAYBootstrapMessage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CAYBootstrapMessage.h; sourceTree = "<group>"; };
 		44463D6C0AA37577006BAA58 /* CAYBootstrapMessage.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = CAYBootstrapMessage.m; sourceTree = "<group>"; };
 		44463D6D0AA37577006BAA58 /* CAYClientConnection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CAYClientConnection.h; sourceTree = "<group>"; };
@@ -114,6 +124,8 @@
 		44463D980AA37577006BAA58 /* CAYToManyFault.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = CAYToManyFault.m; sourceTree = "<group>"; };
 		44463D990AA37577006BAA58 /* CAYToOneFault.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CAYToOneFault.h; sourceTree = "<group>"; };
 		44463D9A0AA37577006BAA58 /* CAYToOneFault.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = CAYToOneFault.m; sourceTree = "<group>"; };
+		4448AA410AA4C55F002C2FA7 /* CAYNodeDeleteOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAYNodeDeleteOperation.h; sourceTree = "<group>"; };
+		4448AA420AA4C55F002C2FA7 /* CAYNodeDeleteOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYNodeDeleteOperation.m; sourceTree = "<group>"; };
 		44FE798E0AA3790C0040BB78 /* HessianObjC.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HessianObjC.framework; path = /Library/Frameworks/HessianObjC.framework; sourceTree = "<absolute>"; };
 		8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
 		8DC2EF5B0486A6940098B216 /* CocoaCayenne.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CocoaCayenne.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -268,6 +280,12 @@
 				44463D820AA37577006BAA58 /* CAYNodeDiff.m */,
 				44463D830AA37577006BAA58 /* CAYNodePropertyChangeOperation.h */,
 				44463D840AA37577006BAA58 /* CAYNodePropertyChangeOperation.m */,
+				442607360AA4B8DE00F0A01F /* CAYNodeCreateOperation.h */,
+				442607370AA4B8DE00F0A01F /* CAYNodeCreateOperation.m */,
+				4448AA410AA4C55F002C2FA7 /* CAYNodeDeleteOperation.h */,
+				4448AA420AA4C55F002C2FA7 /* CAYNodeDeleteOperation.m */,
+				4421E61C0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.h */,
+				4421E61D0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.m */,
 			);
 			name = graph;
 			sourceTree = "<group>";
@@ -316,6 +334,9 @@
 				44463DC50AA37577006BAA58 /* CAYSyncMessage.h in Headers */,
 				44463DC70AA37577006BAA58 /* CAYToManyFault.h in Headers */,
 				44463DC90AA37577006BAA58 /* CAYToOneFault.h in Headers */,
+				442607380AA4B8DE00F0A01F /* CAYNodeCreateOperation.h in Headers */,
+				4448AA430AA4C55F002C2FA7 /* CAYNodeDeleteOperation.h in Headers */,
+				4421E61E0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -397,6 +418,9 @@
 				44463DC60AA37577006BAA58 /* CAYSyncMessage.m in Sources */,
 				44463DC80AA37577006BAA58 /* CAYToManyFault.m in Sources */,
 				44463DCA0AA37577006BAA58 /* CAYToOneFault.m in Sources */,
+				442607390AA4B8DE00F0A01F /* CAYNodeCreateOperation.m in Sources */,
+				4448AA440AA4C55F002C2FA7 /* CAYNodeDeleteOperation.m in Sources */,
+				4421E61F0AA4EE2D00FBE975 /* CAYNodeIdChangeOperation.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};