Permalink
Browse files

All predicates standardized on '==' . Removed deleted attribute from …

…FTASyncParent entity.
  • Loading branch information...
1 parent fc48628 commit 7fffa35ebce038500d7b15536c6f6b8745f17fbc @itsniper committed May 8, 2012
@@ -132,8 +132,8 @@
8B6D39C4152836E500B296D6 /* NSRelationshipDescription+MagicalDataImport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSRelationshipDescription+MagicalDataImport.m"; sourceTree = "<group>"; };
8B6D39C5152836E500B296D6 /* NSString+MagicalDataImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MagicalDataImport.h"; sourceTree = "<group>"; };
8B6D39C6152836E500B296D6 /* NSString+MagicalDataImport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MagicalDataImport.m"; sourceTree = "<group>"; };
- 8B6D39C7152836E500B296D6 /* NSManagedObject+MagicalDataImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+MagicalDataImport.h"; sourceTree = "<group>"; };
- 8B6D39C8152836E500B296D6 /* NSManagedObject+MagicalDataImport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+MagicalDataImport.m"; sourceTree = "<group>"; };
+ 8B6D39C7152836E500B296D6 /* NSManagedObject+MagicalDataImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSManagedObject+MagicalDataImport.h"; path = "../NSManagedObject+MagicalDataImport.h"; sourceTree = "<group>"; };
+ 8B6D39C8152836E500B296D6 /* NSManagedObject+MagicalDataImport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSManagedObject+MagicalDataImport.m"; path = "../NSManagedObject+MagicalDataImport.m"; sourceTree = "<group>"; };
8B6D39C9152836E500B296D6 /* NSManagedObject+MagicalRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObject+MagicalRecord.h"; sourceTree = "<group>"; };
8B6D39CA152836E500B296D6 /* NSManagedObject+MagicalRecord.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSManagedObject+MagicalRecord.m"; sourceTree = "<group>"; };
8B6D39CB152836E500B296D6 /* NSManagedObjectContext+MagicalRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSManagedObjectContext+MagicalRecord.h"; sourceTree = "<group>"; };
@@ -333,8 +333,6 @@
isa = PBXGroup;
children = (
8B6D39BA152836E500B296D6 /* DataImport */,
- 8B6D39C7152836E500B296D6 /* NSManagedObject+MagicalDataImport.h */,
- 8B6D39C8152836E500B296D6 /* NSManagedObject+MagicalDataImport.m */,
8B6D39C9152836E500B296D6 /* NSManagedObject+MagicalRecord.h */,
8B6D39CA152836E500B296D6 /* NSManagedObject+MagicalRecord.m */,
8B6D39CB152836E500B296D6 /* NSManagedObjectContext+MagicalRecord.h */,
@@ -352,6 +350,8 @@
8B6D39BA152836E500B296D6 /* DataImport */ = {
isa = PBXGroup;
children = (
+ 8B6D39C7152836E500B296D6 /* NSManagedObject+MagicalDataImport.h */,
+ 8B6D39C8152836E500B296D6 /* NSManagedObject+MagicalDataImport.m */,
8B6D39BB152836E500B296D6 /* NSAttributeDescription+MagicalDataImport.h */,
8B6D39BC152836E500B296D6 /* NSAttributeDescription+MagicalDataImport.m */,
8B6D39BD152836E500B296D6 /* NSEntityDescription+MagicalDataImport.h */,
@@ -2,7 +2,6 @@
<model name="" userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="872" systemVersion="10K549" minimumToolsVersion="Automatic" macOSVersion="Automatic" iOSVersion="Automatic">
<entity name="FTASyncParent" representedClassName="FTASyncParent" isAbstract="YES">
<attribute name="createdHere" optional="YES" attributeType="Boolean" defaultValueString="YES"/>
- <attribute name="deleted" optional="YES" attributeType="Boolean" defaultValueString="NO"/>
<attribute name="objectId" optional="YES" attributeType="String"/>
<attribute name="syncStatus" optional="YES" attributeType="Integer 16" defaultValueString="2"/>
<attribute name="updatedAt" optional="YES" attributeType="Date"/>
@@ -12,7 +11,7 @@
<attribute name="priority" optional="YES" attributeType="Integer 16" maxValueString="10" defaultValueString="1"/>
</entity>
<elements>
- <element name="FTASyncParent" positionX="160" positionY="192" width="128" height="120"/>
- <element name="ToDoItem" positionX="160" positionY="357" width="128" height="75"/>
+ <element name="FTASyncParent" positionX="160" positionY="192" width="128" height="105"/>
+ <element name="ToDoItem" positionX="160" positionY="384" width="128" height="75"/>
</elements>
</model>
@@ -122,7 +122,7 @@ - (void)syncEntity:(NSEntityDescription *)entityDesc {
DLog(@"Last update: %@", lastUpdate);
//Add new local objects
- [request setPredicate:[NSPredicate predicateWithFormat:@"syncStatus = 2 OR syncStatus == nil"]];
+ [request setPredicate:[NSPredicate predicateWithFormat:@"syncStatus == 2 OR syncStatus == nil"]];
NSArray *newLocalObjects = [NSManagedObject MR_executeFetchRequest:request];
DLog(@"Number of new local objects: %i", [newLocalObjects count]);
if ([newLocalObjects count] > 0) {
@@ -149,7 +149,7 @@ - (void)syncEntity:(NSEntityDescription *)entityDesc {
newRemotePredicate = [NSPredicate predicateWithFormat:@"createdAt > %@", lastUpdate];
}
else {
- newRemotePredicate = [NSPredicate predicateWithFormat:@"deleted = NO", lastUpdate];
+ newRemotePredicate = [NSPredicate predicateWithFormat:@"deleted == NO OR deleted == nil", lastUpdate];
}
NSArray *newRemoteObjects = [remoteObjectsForSync filteredArrayUsingPredicate:newRemotePredicate];
DLog(@"Number of new remote objects: %i", [newRemoteObjects count]);
@@ -164,7 +164,7 @@ - (void)syncEntity:(NSEntityDescription *)entityDesc {
[remoteObjectsForSync removeObjectsInArray:deletedRemoteObjects];
DLog(@"Number of deleted remote objects: %i", [deletedRemoteObjects count]);
for (PFObject *remoteObject in deletedRemoteObjects) {
- [request setPredicate:[NSPredicate predicateWithFormat:@"objectId = %@", remoteObject.objectId]];
+ [request setPredicate:[NSPredicate predicateWithFormat:@"objectId == %@", remoteObject.objectId]];
FTASyncParent *localObject = [NSManagedObject MR_executeFetchRequestAndReturnFirstObject:request];
if (!localObject) {
DLog(@"Object already removed locally: %@", remoteObject);
@@ -176,7 +176,7 @@ - (void)syncEntity:(NSEntityDescription *)entityDesc {
//Sync objects changed on remote
DLog(@"Number of updated remote objects: %i", [remoteObjectsForSync count]);
for (PFObject *remoteObject in remoteObjectsForSync) {
- [request setPredicate:[NSPredicate predicateWithFormat:@"objectId = %@", remoteObject.objectId]];
+ [request setPredicate:[NSPredicate predicateWithFormat:@"objectId == %@", remoteObject.objectId]];
FTASyncParent *localObject = [NSManagedObject MR_executeFetchRequestAndReturnFirstObject:request];
if (!localObject) {
ALog(@"Could not find local object matching remote object: @%", remoteObject);
@@ -195,7 +195,7 @@ - (void)syncEntity:(NSEntityDescription *)entityDesc {
_syncInProgress = NO;
//Sync objects changed locally
- [request setPredicate:[NSPredicate predicateWithFormat:@"syncStatus = 1"]];
+ [request setPredicate:[NSPredicate predicateWithFormat:@"syncStatus == 1"]];
NSArray *updatedLocalObjects = [NSManagedObject MR_executeFetchRequest:request];
DLog(@"Number of updated local objects: %i", [updatedLocalObjects count]);
[objectsToSync addObjectsFromArray:updatedLocalObjects];
@@ -211,7 +211,7 @@ - (void)syncEntity:(NSEntityDescription *)entityDesc {
return;
}
- //TODO: Call FTAParseSync to push updates to Parse and then update local updatedAt and objectId.
+ //Push changes to remote server and update local object's metadata
DLog(@"Total number of objects to sync: %i", [objectsToSync count]);
NSError *error;
BOOL success = [self.remoteInterface putUpdatedObjects:objectsToSync forClass:entityDesc error:&error];

0 comments on commit 7fffa35

Please sign in to comment.