cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From torehal...@apache.org
Subject svn commit: r452622 - in /incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne: CAYObjectId.h CAYObjectId.m
Date Tue, 03 Oct 2006 21:03:55 GMT
Author: torehalset
Date: Tue Oct  3 14:03:54 2006
New Revision: 452622

URL: http://svn.apache.org/viewvc?view=rev&rev=452622
Log:
 * removed replacementIdMap as it looks like it is only useable on
   the server
 * handle compound primary key in isEqual

Modified:
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.h
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.h
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.h?view=diff&rev=452622&r1=452621&r2=452622
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.h (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.h Tue Oct  3 14:03:54
2006
@@ -27,7 +27,7 @@
 	NSString *singleKey;
 	NSObject *singleValue;
 	NSData *tempKey;
-	NSDictionary *replacementIdMap;
+
 }
 
 -(void)setEntityName:(NSString *)en;
@@ -40,7 +40,5 @@
 -(NSObject *)singleValue;
 -(void)setTempKey:(NSData *)k;
 -(NSData *)tempKey;
--(void)setReplacementIdMap:(NSDictionary *)rm;
--(NSDictionary *)replacementIdMap;
 
 @end

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m?view=diff&rev=452622&r1=452621&r2=452622
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectId.m Tue Oct  3 14:03:54
2006
@@ -30,7 +30,9 @@
 	[self setSingleKey:[coder decodeObjectForKey:@"singleKey"]];
 	[self setSingleValue:[coder decodeObjectForKey:@"singleValue"]];
 	[self setTempKey:[coder decodeObjectForKey:@"key"]];
-	[self setReplacementIdMap:[coder decodeObjectForKey:@"replacementIdMap"]];
+    
+    // TODO: should not need to convert NSNull to nil. create
+    // a nicer solution
     
     // check/repair tempKey
     if([[self tempKey] isKindOfClass:[NSNull class]])
@@ -39,7 +41,19 @@
     }
     else if([self tempKey])
     {
-        NSLog(@"ERROR: got tempKey from server %@", self);
+        NSLog(@"WARN: got tempKey from server %@", self);
+    }
+    
+    // repair singleKey
+    if([[self singleKey] isKindOfClass:[NSNull class]])
+    {
+        [self setSingleKey:nil];
+    }
+    
+    // repair objectIdKeys
+    if([[self objectIdKeys] isKindOfClass:[NSNull class]])
+    {
+        [self setObjectIdKeys:nil];
     }
     
 	return self;
@@ -47,15 +61,15 @@
 
 -(void)encodeWithCoder:(NSCoder*)coder
 {
-	[coder encodeObject:entityName forKey:@"entityName"];
-    [coder encodeObject:singleKey forKey:@"singleKey"];
-    [coder encodeObject:singleValue forKey:@"singleValue"];
-    [coder encodeObject:objectIdKeys forKey:@"objectIdKeys"];
-    [coder encodeObject:replacementIdMap forKey:@"replacementIdMap"];
+	[coder encodeObject:[self entityName] forKey:@"entityName"];
+    [coder encodeObject:[self singleKey] forKey:@"singleKey"];
+    [coder encodeObject:[self singleValue] forKey:@"singleValue"];
+    [coder encodeObject:[self objectIdKeys] forKey:@"objectIdKeys"];
+    
     // TODO: fix problem: the key "key" result in a ugly unserialize exception at the server
side.
     if([self tempKey])
     {
-        [coder encodeObject:tempKey forKey:@"key"];
+        [coder encodeObject:[self tempKey] forKey:@"key"];
     }
 }
 
@@ -131,18 +145,6 @@
 	return tempKey;
 }
 
- -(void)setReplacementIdMap:(NSDictionary *)rm
- {
-	 [rm retain];
-	 [replacementIdMap release];
-	 replacementIdMap = rm;
- }
- 
- -(NSDictionary *)replacementIdMap
- {
-	 return replacementIdMap;
- }
-
 - (unsigned)hash
 {
 	/*
@@ -179,6 +181,13 @@
             return NO;
         }
     }
+    if([self objectIdKeys])
+    {
+        if(![[self objectIdKeys] isEqualToDictionary:[anObject objectIdKeys]])
+        {
+            return NO;
+        }
+    }
     if([self tempKey])
     {
         if(![[self tempKey] isEqualToData:[anObject tempKey]])
@@ -195,16 +204,20 @@
     NSString *result;
     if([self tempKey])
     {
-        result = [[NSString alloc] initWithFormat:@"CAYObjectId {%@; tempKey = %@}", [self
entityName], [self tempKey]];
+        result = [[NSString alloc] initWithFormat:@"%@ {%@; TEMP: %@}", [self class], [self
entityName], [self tempKey]];
     }
     else if ([self singleKey])
     {
-        result = [[NSString alloc] initWithFormat:@"CAYObjectId {%@; %@ = %@}", [self entityName],
[self singleKey], [self singleValue]];
+        result = [[NSString alloc] initWithFormat:@"%@ {%@; %@ = %@}", [self class], [self
entityName], [self singleKey], [self singleValue]];
+    }
+    else if ([self objectIdKeys])
+    {
+        result = [[NSString alloc] initWithFormat:@"%@ {%@; objectIdKeys = %@}", [self class],
[self entityName], [self objectIdKeys]];
     }
     else
     {
         // should match one of the above. if not, output all values
-        result = [[NSString alloc] initWithFormat:@"CAYObjectId {%@; objectIdKeys = %@; singleKey
= %@; singleValue = %@; tempKey = %@}", [self entityName], [self objectIdKeys], [self singleKey],
[self singleValue], [self tempKey]];
+        result = [[NSString alloc] initWithFormat:@"%@ {%@; objectIdKeys = %@; singleKey
= %@; singleValue = %@}", [self class], [self entityName], [self objectIdKeys], [self singleKey],
[self singleValue]];
     }
     [result autorelease];
     return result;
@@ -217,7 +230,6 @@
     [self setSingleKey:nil];
     [self setSingleValue:nil];
     [self setTempKey:nil];
-    [self setReplacementIdMap:nil];
 	[super dealloc];
 }
 



Mime
View raw message