Modified: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYClient.xcodeproj/project.pbxproj URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYClient.xcodeproj/project.pbxproj?rev=434550&r1=434549&r2=434550&view=diff ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYClient.xcodeproj/project.pbxproj (original) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYClient.xcodeproj/project.pbxproj Thu Aug 24 15:35:05 2006 @@ -27,6 +27,10 @@ 443968FE0A90A0D0005BD842 /* Gallery.m in Sources */ = {isa = PBXBuildFile; fileRef = 443968FD0A90A0D0005BD842 /* Gallery.m */; }; 44A6F8E10A965F1F00E04AE1 /* CAYObjEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 44A6F8E00A965F1F00E04AE1 /* CAYObjEntity.m */; }; 44A6F8FA0A98EB5800E04AE1 /* CAYClientObjRelationship.m in Sources */ = {isa = PBXBuildFile; fileRef = 44A6F8F90A98EB5800E04AE1 /* CAYClientObjRelationship.m */; }; + 44DA7D960A9D017F0073B37F /* CAYNodePropertyChangeOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 44DA7D950A9D017F0073B37F /* CAYNodePropertyChangeOperation.m */; }; + 44DA7DA80A9D02010073B37F /* CAYNodeDiff.m in Sources */ = {isa = PBXBuildFile; fileRef = 44DA7DA70A9D02010073B37F /* CAYNodeDiff.m */; }; + 44DA7DBC0A9D02840073B37F /* CAYSyncMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 44DA7DBB0A9D02840073B37F /* CAYSyncMessage.m */; }; + 44DA7F260A9E3EAA0073B37F /* CAYCompoundDiff.m in Sources */ = {isa = PBXBuildFile; fileRef = 44DA7F250A9E3EAA0073B37F /* CAYCompoundDiff.m */; }; 44FC06CA0A911A3200704DDC /* CAYEntityResolver.m in Sources */ = {isa = PBXBuildFile; fileRef = 44FC06C90A911A3200704DDC /* CAYEntityResolver.m */; }; 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; @@ -82,6 +86,14 @@ 44A6F8E00A965F1F00E04AE1 /* CAYObjEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYObjEntity.m; sourceTree = "<group>"; }; 44A6F8F80A98EB5800E04AE1 /* CAYClientObjRelationship.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAYClientObjRelationship.h; sourceTree = "<group>"; }; 44A6F8F90A98EB5800E04AE1 /* CAYClientObjRelationship.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYClientObjRelationship.m; sourceTree = "<group>"; }; + 44DA7D940A9D017F0073B37F /* CAYNodePropertyChangeOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAYNodePropertyChangeOperation.h; sourceTree = "<group>"; }; + 44DA7D950A9D017F0073B37F /* CAYNodePropertyChangeOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYNodePropertyChangeOperation.m; sourceTree = "<group>"; }; + 44DA7DA60A9D02010073B37F /* CAYNodeDiff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAYNodeDiff.h; sourceTree = "<group>"; }; + 44DA7DA70A9D02010073B37F /* CAYNodeDiff.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYNodeDiff.m; sourceTree = "<group>"; }; + 44DA7DBA0A9D02840073B37F /* CAYSyncMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAYSyncMessage.h; sourceTree = "<group>"; }; + 44DA7DBB0A9D02840073B37F /* CAYSyncMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYSyncMessage.m; sourceTree = "<group>"; }; + 44DA7F240A9E3EAA0073B37F /* CAYCompoundDiff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAYCompoundDiff.h; sourceTree = "<group>"; }; + 44DA7F250A9E3EAA0073B37F /* CAYCompoundDiff.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYCompoundDiff.m; sourceTree = "<group>"; }; 44FC06C80A911A3200704DDC /* CAYEntityResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAYEntityResolver.h; sourceTree = "<group>"; }; 44FC06C90A911A3200704DDC /* CAYEntityResolver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CAYEntityResolver.m; sourceTree = "<group>"; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; @@ -182,14 +194,12 @@ 443968F40A90A07F005BD842 /* cayenne */ = { isa = PBXGroup; children = ( + 44DA7DC10A9D02C00073B37F /* message */, + 44DA7D6E0A9D01620073B37F /* graph */, 443968460A9099AD005BD842 /* CAYObjectContext.h */, 443968470A9099AD005BD842 /* CAYObjectContext.m */, 443968480A9099AD005BD842 /* CAYPersistentObject.h */, 443968490A9099AD005BD842 /* CAYPersistentObject.m */, - 4417DBF50A8D427E000FE4DB /* CAYBootstrapMessage.h */, - 4417DBF60A8D427E000FE4DB /* CAYBootstrapMessage.m */, - 4417DC2C0A8D45D1000FE4DB /* CAYQueryMessage.h */, - 4417DC2D0A8D45D1000FE4DB /* CAYQueryMessage.m */, 4417DC8A0A8D488A000FE4DB /* CAYNamedQuery.h */, 4417DC8B0A8D488A000FE4DB /* CAYNamedQuery.m */, 4417DD740A8D52BC000FE4DB /* CAYGenericResponse.h */, @@ -204,8 +214,6 @@ 4417E0620A8FCAA3000FE4DB /* CAYQuery.m */, 4417E0640A8FCABD000FE4DB /* CAYClientConnection.h */, 4417E0650A8FCABD000FE4DB /* CAYClientConnection.m */, - 4417E07C0A8FCB5A000FE4DB /* CAYClientMessage.h */, - 4417E07D0A8FCB5A000FE4DB /* CAYClientMessage.m */, 4417E1E30A8FD520000FE4DB /* CAYRelationshipQuery.h */, 4417E1E40A8FD520000FE4DB /* CAYRelationshipQuery.m */, 44FC06C80A911A3200704DDC /* CAYEntityResolver.h */, @@ -231,6 +239,34 @@ name = tutorial; sourceTree = "<group>"; }; + 44DA7D6E0A9D01620073B37F /* graph */ = { + isa = PBXGroup; + children = ( + 44DA7D940A9D017F0073B37F /* CAYNodePropertyChangeOperation.h */, + 44DA7D950A9D017F0073B37F /* CAYNodePropertyChangeOperation.m */, + 44DA7DA60A9D02010073B37F /* CAYNodeDiff.h */, + 44DA7DA70A9D02010073B37F /* CAYNodeDiff.m */, + 44DA7F240A9E3EAA0073B37F /* CAYCompoundDiff.h */, + 44DA7F250A9E3EAA0073B37F /* CAYCompoundDiff.m */, + ); + name = graph; + sourceTree = "<group>"; + }; + 44DA7DC10A9D02C00073B37F /* message */ = { + isa = PBXGroup; + children = ( + 44DA7DBA0A9D02840073B37F /* CAYSyncMessage.h */, + 44DA7DBB0A9D02840073B37F /* CAYSyncMessage.m */, + 4417DBF50A8D427E000FE4DB /* CAYBootstrapMessage.h */, + 4417DBF60A8D427E000FE4DB /* CAYBootstrapMessage.m */, + 4417DC2C0A8D45D1000FE4DB /* CAYQueryMessage.h */, + 4417DC2D0A8D45D1000FE4DB /* CAYQueryMessage.m */, + 4417E07C0A8FCB5A000FE4DB /* CAYClientMessage.h */, + 4417E07D0A8FCB5A000FE4DB /* CAYClientMessage.m */, + ); + name = message; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -305,6 +341,10 @@ 44FC06CA0A911A3200704DDC /* CAYEntityResolver.m in Sources */, 44A6F8E10A965F1F00E04AE1 /* CAYObjEntity.m in Sources */, 44A6F8FA0A98EB5800E04AE1 /* CAYClientObjRelationship.m in Sources */, + 44DA7D960A9D017F0073B37F /* CAYNodePropertyChangeOperation.m in Sources */, + 44DA7DA80A9D02010073B37F /* CAYNodeDiff.m in Sources */, + 44DA7DBC0A9D02840073B37F /* CAYSyncMessage.m in Sources */, + 44DA7F260A9E3EAA0073B37F /* CAYCompoundDiff.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };
Added: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYCompoundDiff.h URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYCompoundDiff.h?rev=434550&view=auto ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYCompoundDiff.h (added) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYCompoundDiff.h Thu Aug 24 15:35:05 2006 @@ -0,0 +1,21 @@ +// +// CAYCompoundDiff.h +// CAYClient +// +// Created by Tore Halset on 8/24/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import <Cocoa/Cocoa.h> + + [EMAIL PROTECTED] CAYCompoundDiff : NSObject <NSCoding> { + NSMutableArray *diffs; +} + +-(id)initWithDiffs:(NSMutableArray *)ds; + +-(void)setDiffs:(NSMutableArray *)ds; +-(NSMutableArray *)diffs; + [EMAIL PROTECTED] Added: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYCompoundDiff.m URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYCompoundDiff.m?rev=434550&view=auto ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYCompoundDiff.m (added) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYCompoundDiff.m Thu Aug 24 15:35:05 2006 @@ -0,0 +1,51 @@ +// +// CAYCompoundDiff.m +// CAYClient +// +// Created by Tore Halset on 8/24/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import "CAYCompoundDiff.h" + + [EMAIL PROTECTED] CAYCompoundDiff + +-(id)initWithDiffs:(NSMutableArray *)ds +{ + [super init]; + [self setDiffs:ds]; + return self; +} + +-(id)initWithCoder:(NSCoder*)coder +{ + [super init]; + [self setDiffs:[coder decodeObjectForKey:@"diffs"]]; + return self; +} + +-(void)encodeWithCoder:(NSCoder*)coder +{ + [coder encodeObject:diffs forKey:@"diffs"]; +} + +-(void)setDiffs:(NSMutableArray *)ds +{ + [ds retain]; + [diffs release]; + diffs = ds; +} + +-(NSMutableArray *)diffs +{ + return diffs; +} + +-(void)dealloc +{ + [diffs release]; + [super dealloc]; +} + [EMAIL PROTECTED] Added: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodeDiff.h URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodeDiff.h?rev=434550&view=auto ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodeDiff.h (added) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodeDiff.h Thu Aug 24 15:35:05 2006 @@ -0,0 +1,23 @@ +// +// CAYNodeDiff.h +// CAYClient +// +// Created by Tore Halset on 8/23/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import <Cocoa/Cocoa.h> + + [EMAIL PROTECTED] CAYNodeDiff : NSObject <NSCoding> { + int diffId; + NSObject *nodeId; +} + +-(id)initWithNodeId:(id)nid; +-(id)initWithNodeId:(id)nid diffId:(int)did; + +-(void)setNodeId:(NSObject *)nid; +-(NSObject *)nodeId; + [EMAIL PROTECTED] Added: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodeDiff.m URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodeDiff.m?rev=434550&view=auto ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodeDiff.m (added) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodeDiff.m Thu Aug 24 15:35:05 2006 @@ -0,0 +1,61 @@ +// +// CAYNodeDiff.m +// CAYClient +// +// Created by Tore Halset on 8/23/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import "CAYNodeDiff.h" + + [EMAIL PROTECTED] CAYNodeDiff + +-(id)initWithNodeId:(id)nid +{ + [super init]; + [self setNodeId:nid]; + return self; +} + +-(id)initWithNodeId:(id)nid diffId:(int)did +{ + [self initWithNodeId:nid]; + diffId = did; + return self; +} + +-(id)initWithCoder:(NSCoder*)coder +{ + [super init]; + diffId = [coder decodeIntForKey:@"diffId"]; + [self setNodeId:[coder decodeObjectForKey:@"nodeId"]]; + return self; +} + +-(void)encodeWithCoder:(NSCoder*)coder +{ + [coder encodeInt:diffId forKey:@"diffId"]; + [coder encodeObject:nodeId forKey:@"nodeId"]; +} + +-(void)setNodeId:(NSObject *)nid +{ + [nid retain]; + [nodeId release]; + nodeId = nid; +} + +-(NSObject *)nodeId +{ + return nodeId; +} + +-(void)dealloc +{ + [nodeId release]; + [super dealloc]; +} + + [EMAIL PROTECTED] Added: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodePropertyChangeOperation.h URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodePropertyChangeOperation.h?rev=434550&view=auto ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodePropertyChangeOperation.h (added) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodePropertyChangeOperation.h Thu Aug 24 15:35:05 2006 @@ -0,0 +1,28 @@ +// +// CAYNodePropertyChangeOperation.h +// CAYClient +// +// Created by Tore Halset on 8/23/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import <Cocoa/Cocoa.h> +#import "CAYNodeDiff.h" + [EMAIL PROTECTED] CAYNodePropertyChangeOperation : CAYNodeDiff <NSCoding> { + NSString *property; + NSObject *oldValue; + NSObject *newValue; +} + +-(id)initWithNodeId:(NSObject *)nid property:(NSString *)prop oldValue:(NSObject *)oldVal newValue:(NSObject *)newVal; +-(id)initWithNodeId:(NSObject *)nid property:(NSString *)prop oldValue:(NSObject *)oldVal newValue:(NSObject *)newVal diffId:(int)did; + +-(void)setProperty:(NSString *)p; +-(NSString *)property; +-(void)setOldValue:(NSObject *)o; +-(NSObject *)oldValue; +-(void)setNewValue:(NSObject *)o; +-(NSObject *)newValue; + [EMAIL PROTECTED] Added: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodePropertyChangeOperation.m URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodePropertyChangeOperation.m?rev=434550&view=auto ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodePropertyChangeOperation.m (added) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYNodePropertyChangeOperation.m Thu Aug 24 15:35:05 2006 @@ -0,0 +1,92 @@ +// +// CAYNodePropertyChangeOperation.m +// CAYClient +// +// Created by Tore Halset on 8/23/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import "CAYNodePropertyChangeOperation.h" +#import "CAYNodeDiff.h" + [EMAIL PROTECTED] CAYNodePropertyChangeOperation + +-(id)initWithNodeId:(NSObject *)nid property:(NSString *)prop oldValue:(NSObject *)oldVal newValue:(NSObject *)newVal +{ + [super initWithNodeId:nid]; + [self setProperty:prop]; + [self setOldValue:oldVal]; + [self setNewValue:newVal]; + return self; +} + +-(id)initWithNodeId:(NSObject *)nid property:(NSString *)prop oldValue:(NSObject *)oldVal newValue:(NSObject *)newVal diffId:(int)did +{ + [self initWithNodeId:nid property:prop oldValue:oldVal newValue:newVal]; + diffId = did; + return self; +} + +-(id)initWithCoder:(NSCoder*)coder +{ + [super initWithCoder:coder]; + [self setProperty:[coder decodeObjectForKey:@"property"]]; + [self setOldValue:[coder decodeObjectForKey:@"oldValue"]]; + [self setNewValue:[coder decodeObjectForKey:@"newValue"]]; + return self; +} + +-(void)encodeWithCoder:(NSCoder*)coder +{ + [super encodeWithCoder:coder]; + [coder encodeObject:property forKey:@"property"]; + [coder encodeObject:oldValue forKey:@"oldValue"]; + [coder encodeObject:newValue forKey:@"newValue"]; +} + +-(void)setProperty:(NSString *)p +{ + [p retain]; + [property release]; + property = p; +} + +-(NSString *)property +{ + return property; +} + +-(void)setOldValue:(NSObject *)o +{ + [o retain]; + [oldValue release]; + oldValue = o; +} + +-(NSObject *)oldValue +{ + return oldValue; +} + +-(void)setNewValue:(NSObject *)o +{ + [o retain]; + [newValue release]; + newValue = o; +} + +-(NSObject *)newValue +{ + return newValue; +} + +-(void)dealloc +{ + [property release]; + [oldValue release]; + [newValue release]; + [super dealloc]; +} + + [EMAIL PROTECTED] Modified: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectContext.h URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectContext.h?rev=434550&r1=434549&r2=434550&view=diff ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectContext.h (original) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectContext.h Thu Aug 24 15:35:05 2006 @@ -13,6 +13,7 @@ @interface CAYObjectContext : NSObject { CAYClientConnection *connection; + NSMutableArray *diffs; } -(NSArray *)performQyery:(CAYQuery *)q; @@ -20,6 +21,8 @@ -(void)setConnection:(CAYClientConnection *)c; -(CAYClientConnection *)connection; --(void) propertyChanged:(CAYPersistentObject *)object forProperty:(NSString *)property fromOld:(id)oldValue toNew:(id)newValue; +-(void) propertyChanged:(CAYPersistentObject *)object forProperty:(NSString *)property fromOld:(NSObject *)oldValue toNew:(NSObject *)newValue; + +-(void)commitChanges; @end Modified: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectContext.m URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectContext.m?rev=434550&r1=434549&r2=434550&view=diff ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectContext.m (original) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectContext.m Thu Aug 24 15:35:05 2006 @@ -11,9 +11,23 @@ #import "CAYQuery.h" #import "CAYPersistentObject.h" #import "CAYClientConnection.h" +#import "CAYNodeDiff.h" +#import "CAYNodePropertyChangeOperation.h" +#import "CAYCompoundDiff.h" +#import "CAYSyncMessage.h" @implementation CAYObjectContext +-(id)init +{ + self = [super init]; + if(self != nil) + { + diffs = [[NSMutableArray array] retain]; + } + return self; +} + -(NSArray *)performQyery:(CAYQuery *)query { CAYQueryMessage *queryMessage = [[CAYQueryMessage alloc] init]; @@ -41,9 +55,15 @@ return rows; } --(void) propertyChanged:(CAYPersistentObject *)object forProperty:(NSString *)property fromOld:(id)oldValue toNew:(id)newValue +-(void) propertyChanged:(CAYPersistentObject *)object forProperty:(NSString *)property fromOld:(NSObject *)oldValue toNew:(NSObject *)newValue { NSLog(@"prop %@ changed from %@ to %@", property, oldValue, newValue); + + //CAYNodeDiff *diff = [[CAYNodePropertyChangeOperation alloc] initWithNodeId:[object objectId] property:property oldValue:oldValue newValue:newValue]; + CAYNodePropertyChangeOperation *diff = [[CAYNodePropertyChangeOperation alloc] initWithNodeId:[object objectId] property:property oldValue:oldValue newValue:newValue]; + [diffs addObject:diff]; + [diff release]; + NSLog(@"%i unsaved changes", [diffs count]); } -(void)setConnection:(CAYClientConnection *)c @@ -58,9 +78,27 @@ return connection; } +-(void)commitChanges +{ + NSLog(@"%i unsaved changes before commit", [diffs count]); + CAYCompoundDiff *diffWithDiffs = [[CAYCompoundDiff alloc] initWithDiffs:diffs]; + // TODO: handle different types? + CAYSyncMessage *msg = [[CAYSyncMessage alloc] initWithObjectSource:nil type:2 senderChanges:diffWithDiffs]; + + // TODO: handle result? + id result = [[self connection] sendMessage:msg]; + NSLog(@"commit result: %@", result); + [diffs removeAllObjects]; + + [msg release]; + [diffWithDiffs release]; + NSLog(@"%i unsaved changes after commit", [diffs count]); +} + -(void)dealloc { [connection release]; + [diffs release]; [super dealloc]; } Modified: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectId.h URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectId.h?rev=434550&r1=434549&r2=434550&view=diff ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectId.h (original) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectId.h Thu Aug 24 15:35:05 2006 @@ -16,7 +16,7 @@ NSString *singleKey; NSObject *singleValue; NSData *tempKey; - //NSDictionary *replacementIdMap; + NSDictionary *replacementIdMap; } -(void)setEntityName:(NSString *)en; @@ -29,7 +29,7 @@ -(NSObject *)singleValue; -(void)setTempKey:(NSData *)k; -(NSData *)tempKey; -//-(void)setReplacementIdMap:(NSDictionary *)rm; -//-(NSDictionary *)replacementIdMap; +-(void)setReplacementIdMap:(NSDictionary *)rm; +-(NSDictionary *)replacementIdMap; @end Modified: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectId.m URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectId.m?rev=434550&r1=434549&r2=434550&view=diff ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectId.m (original) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYObjectId.m Thu Aug 24 15:35:05 2006 @@ -19,16 +19,19 @@ [self setSingleKey:[coder decodeObjectForKey:@"singleKey"]]; [self setSingleValue:[coder decodeObjectForKey:@"singleValue"]]; [self setTempKey:[coder decodeObjectForKey:@"key"]]; + [self setReplacementIdMap:[coder decodeObjectForKey:@"replacementIdMap"]]; return self; } -(void)encodeWithCoder:(NSCoder*)coder { [coder encodeObject:entityName forKey:@"entityName"]; - [coder encodeObject:objectIdKeys forKey:@"objectIdKeys"]; - [coder encodeObject:singleKey forKey:@"singleKey"]; - [coder encodeObject:singleValue forKey:@"singleValue"]; - [coder encodeObject:tempKey forKey:@"key"]; + [coder encodeObject:singleKey forKey:@"singleKey"]; + [coder encodeObject:singleValue forKey:@"singleValue"]; + [coder encodeObject:objectIdKeys forKey:@"objectIdKeys"]; + // TODO: fix problem: the key "key" result in a ugly unserialize hack at the server side. + //[coder encodeObject:tempKey forKey:@"key"]; + [coder encodeObject:replacementIdMap forKey:@"replacementIdMap"]; } - (id)copyWithZone:(NSZone *)zone @@ -39,7 +42,7 @@ [copy setSingleKey:[self singleKey]]; [copy setSingleValue:[self singleValue]]; [copy setTempKey:[self tempKey]]; - + return copy; } @@ -103,7 +106,6 @@ return tempKey; } -/* -(void)setReplacementIdMap:(NSDictionary *)rm { [rm retain]; @@ -115,7 +117,6 @@ { return replacementIdMap; } - */ - (unsigned)hash { @@ -162,13 +163,6 @@ -(NSString *)description { NSString *result; - /* - NSString *entityName; - NSDictionary *objectIdKeys; - NSString *singleKey; - NSObject *singleValue; - NSData *tempKey; -*/ result = [[NSString alloc] initWithFormat:@"{entityName = %@; objectIdKeys = %@; singleKey = %@; singleValue = [EMAIL PROTECTED]", [self entityName], [self objectIdKeys], [self singleKey], [self singleValue]]; [result autorelease]; return result; Added: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYSyncMessage.h URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYSyncMessage.h?rev=434550&view=auto ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYSyncMessage.h (added) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYSyncMessage.h Thu Aug 24 15:35:05 2006 @@ -0,0 +1,29 @@ +// +// CAYSyncMessage.h +// CAYClient +// +// Created by Tore Halset on 8/23/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import <Cocoa/Cocoa.h> +#import "CAYClientMessage.h" +#import "CAYObjectContext.h" + [EMAIL PROTECTED] CAYSyncMessage : CAYClientMessage <NSCoding> { + + CAYObjectContext *source; + int type; + // TODO: create CAYGraphDiff? + NSObject *senderChanges; + +} + +-(id)initWithObjectSource:(CAYObjectContext *)ctxt type:(int)t senderChanges:(NSObject *)changes; + +-(void)setSource:(CAYObjectContext *)s; +-(CAYObjectContext *)source; +-(void)setSenderChanges:(NSObject *)s; +-(NSObject *)senderChanges; + [EMAIL PROTECTED] Added: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYSyncMessage.m URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYSyncMessage.m?rev=434550&view=auto ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYSyncMessage.m (added) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/CAYSyncMessage.m Thu Aug 24 15:35:05 2006 @@ -0,0 +1,74 @@ +// +// CAYSyncMessage.m +// CAYClient +// +// Created by Tore Halset on 8/23/06. +// Copyright 2006 __MyCompanyName__. All rights reserved. +// + +#import "CAYSyncMessage.h" +#import "CAYClientMessage.h" +#import "CAYObjectContext.h" + [EMAIL PROTECTED] CAYSyncMessage + +-(id)initWithObjectSource:(CAYObjectContext *)ctxt type:(int)t senderChanges:(NSObject *)changes +{ + [super init]; + // source is transient + // [self setSource:ctxt]; + type = t; + [self setSenderChanges:changes]; + return self; +} + +-(id)initWithCoder:(NSCoder*)coder +{ + [super init]; + // source is transient + //[self setSource:[coder decodeObjectForKey:@"source"]]; + type = [coder decodeIntForKey:@"type"]; + [self setSenderChanges:[coder decodeObjectForKey:@"senderChanges"]]; + return self; +} + +-(void)encodeWithCoder:(NSCoder*)coder +{ + [coder encodeObject:source forKey:@"source"]; + [coder encodeInt:type forKey:@"type"]; + [coder encodeObject:senderChanges forKey:@"senderChanges"]; +} + +-(void)setSource:(CAYObjectContext *)s +{ + [s retain]; + [source release]; + source = s; +} + +-(CAYObjectContext *)source +{ + return source; +} + +-(void)setSenderChanges:(NSObject *)s +{ + [s retain]; + [senderChanges release]; + senderChanges = s; +} + +-(NSObject *)senderChanges +{ + return senderChanges; +} + +-(void)dealloc +{ + [source release]; + [senderChanges release]; + [super dealloc]; +} + + [EMAIL PROTECTED] Modified: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/classes.nib URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/classes.nib?rev=434550&r1=434549&r2=434550&view=diff ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/classes.nib (original) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/classes.nib Thu Aug 24 15:35:05 2006 @@ -1,10 +1,10 @@ { IBClasses = ( { - ACTIONS = {query = id; }; + ACTIONS = {commit = id; query = id; }; CLASS = AppController; LANGUAGE = ObjC; - OUTLETS = {queryResult = NSArray; queryResultController = NSArrayController; }; + OUTLETS = {queryResultController = NSArrayController; }; SUPERCLASS = NSObject; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; } Modified: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/info.nib URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/info.nib?rev=434550&r1=434549&r2=434550&view=diff ============================================================================== --- incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/info.nib (original) +++ incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/info.nib Thu Aug 24 15:35:05 2006 @@ -3,7 +3,7 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>108 203 356 240 0 0 1680 1028 </string> + <string>451 147 356 240 0 0 1680 1028 </string> <key>IBEditorPositions</key> <dict> <key>29</key> @@ -13,8 +13,8 @@ <string>446.1</string> <key>IBOpenObjects</key> <array> - <integer>29</integer> <integer>21</integer> + <integer>29</integer> </array> <key>IBSystem Version</key> <string>8J2135</string> Modified: incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/keyedobjects.nib URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CAYClient/English.lproj/MainMenu.nib/keyedobjects.nib?rev=434550&r1=434549&r2=434550&view=diff ============================================================================== Binary files - no diff available.
