diff --git a/openbis-ipad/source/objc/BisKit/Classes/CISDOBIpadServiceManager.h b/openbis-ipad/source/objc/BisKit/Classes/CISDOBIpadServiceManager.h index 156816357d796fbda3b70094f1f399fe2703fdfe..08cca8141558895e37b5066fab174aae5780864d 100644 --- a/openbis-ipad/source/objc/BisKit/Classes/CISDOBIpadServiceManager.h +++ b/openbis-ipad/source/objc/BisKit/Classes/CISDOBIpadServiceManager.h @@ -46,10 +46,12 @@ FOUNDATION_EXPORT NSString *const CISDOBIpadServiceDidRetrieveDetailsForEntityNo FOUNDATION_EXPORT NSString *const CISDOBIpadServiceWillSynchEntitiesNotification; FOUNDATION_EXPORT NSString *const CISDOBIpadServiceDidSynchEntitiesNotification; +FOUNDATION_EXPORT NSString *const CISDOBIpadServiceWillSynchPruningEntitiesNotification; +FOUNDATION_EXPORT NSString *const CISDOBIpadServiceDidSynchPruningEntitiesNotification; + FOUNDATION_EXPORT NSString *const CISDOBIpadServiceWillSearchForEntitiesNotification; FOUNDATION_EXPORT NSString *const CISDOBIpadServiceDidSearchForEntitiesNotification; - // // Errors that can happen in the service manager // @@ -88,6 +90,7 @@ typedef void (^MocSaveBlock)(CISDOBIpadServiceManager *serviceManager, NSArray * @property (readonly) NSOperationQueue *queue; @property (readonly) NSString *sessionToken; @property (nonatomic, getter=isOnline) BOOL online; +@property (nonatomic, getter=isSyncDone) BOOL syncDone; @property(strong, nonatomic) NSDate *lastRootSetUpdateDate; diff --git a/openbis-ipad/source/objc/BisKit/Classes/CISDOBIpadServiceManager.m b/openbis-ipad/source/objc/BisKit/Classes/CISDOBIpadServiceManager.m index 5f33869793d176b230953d554610a9874dad8af3..fb6b3a3553f5cf661e08206ba8d718a77c457848 100644 --- a/openbis-ipad/source/objc/BisKit/Classes/CISDOBIpadServiceManager.m +++ b/openbis-ipad/source/objc/BisKit/Classes/CISDOBIpadServiceManager.m @@ -39,6 +39,8 @@ NSString *const CISDOBIpadServiceWillRetrieveDetailsForEntityNotification = @"CI NSString *const CISDOBIpadServiceDidRetrieveDetailsForEntityNotification = @"CISDOBIpadServiceDidRetrieveDetailsForEntityNotification"; NSString *const CISDOBIpadServiceWillSynchEntitiesNotification = @"CISDOBIpadServiceWillSynchEntitiesNotification"; NSString *const CISDOBIpadServiceDidSynchEntitiesNotification = @"CISDOBIpadServiceDidSynchEntitiesNotification"; +NSString *const CISDOBIpadServiceWillSynchPruningEntitiesNotification = @"CISDOBIpadServiceWillSynchPruningEntitiesNotification"; +NSString *const CISDOBIpadServiceDidSynchPruningEntitiesNotification = @"CISDOBIpadServiceDidSynchPruningEntitiesNotification"; NSString *const CISDOBIpadServiceWillSearchForEntitiesNotification = @"CISDOBIpadServiceWillSearchForEntitiesNotification"; NSString *const CISDOBIpadServiceDidSearchForEntitiesNotification = @"CISDOBIpadServiceDidSearchForEntitiesNotification"; @@ -126,7 +128,7 @@ static NSManagedObjectContext* GetMainThreadManagedObjectContext(NSURL* storeUrl // Restrict this queue to processing operations serially [_queue setMaxConcurrentOperationCount: 1]; self.online = NO; - + self.syncDone = NO; return self; } @@ -644,7 +646,7 @@ static NSManagedObjectContext* GetMainThreadManagedObjectContext(NSURL* storeUrl - (void)run { if (!self.pruneCutoffDate) return; - + [[NSNotificationCenter defaultCenter] postNotificationName: CISDOBIpadServiceWillSynchPruningEntitiesNotification object: self]; BOOL success; NSError *error; // Remove entities that were not updated since the prune cutoff date @@ -655,7 +657,8 @@ static NSManagedObjectContext* GetMainThreadManagedObjectContext(NSURL* storeUrl [(NSMutableArray *)_deletedEntityPermIds addObject: entity.permId]; [self.managedObjectContext deleteObject: entity]; } - + self.serviceManager.syncDone = YES; + [[NSNotificationCenter defaultCenter] postNotificationName: CISDOBIpadServiceDidSynchPruningEntitiesNotification object: self]; success = [self.managedObjectContext save: &error]; if (!success) { self.error = error; diff --git a/openbis-ipad/source/objc/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/juanf.xcuserdatad/UserInterfaceState.xcuserstate b/openbis-ipad/source/objc/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/juanf.xcuserdatad/UserInterfaceState.xcuserstate index 3ebd4f609bca7d45d1b29939a76dc19b9dfe413d..0fe81a140016828bf27d26df9fa19bcf4b2c51ab 100644 Binary files a/openbis-ipad/source/objc/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/juanf.xcuserdatad/UserInterfaceState.xcuserstate and b/openbis-ipad/source/objc/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/juanf.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBAppDelegate.m b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBAppDelegate.m index b09f18db207808fe34f0b0654024999532c4c4b4..10e77f1eb6c03b44c140d5995db1cafff06a9bad 100644 --- a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBAppDelegate.m +++ b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBAppDelegate.m @@ -32,6 +32,16 @@ #import "CISDOBAuthenticationChallengeConfirmationDialog.h" #import "CISDOBIpadEntity.h" +NSURL *StoreUrlFromOpenbisUrl(NSURL *applicationDocumentsDirectory, NSURL *openbisUrl) +{ + NSString *host = [openbisUrl host]; + NSNumber *port = [openbisUrl port]; + + NSString *pathString = (port) ? [NSString stringWithFormat: @"%@_%@-data.sqlite", host, port] : [NSString stringWithFormat: @"%@-data.sqlite", host]; + NSURL *storeUrl = [applicationDocumentsDirectory URLByAppendingPathComponent: pathString]; + return storeUrl; +} + @implementation CISDOBAppDelegate @synthesize rootOpenBisModel = _rootOpenBisModel; @@ -67,6 +77,7 @@ - (void)verifyLoginURL:(NSURL *)openbisUrl username:(NSString *)username password:(NSString *)password sender:(CISDOBLoginViewController *)controller { + NSError *error; if (![self initializeServiceManager: openbisUrl error: &error]) { [controller showError: error]; @@ -247,7 +258,7 @@ - (BOOL)initializeServiceManager:(NSURL *)openbisUrl error:(NSError **)error { - NSURL *storeUrl = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"openBISData.sqlite"]; + NSURL *storeUrl = StoreUrlFromOpenbisUrl([self applicationDocumentsDirectory], openbisUrl); _serviceManager = [[CISDOBIpadServiceManager alloc] diff --git a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBDetailViewController.m b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBDetailViewController.m index bf7b8d8d8c053e56813c3ec30fd61267c2ec4c39..a0831032f034dfce1dc182254184898dcb64a4f3 100644 --- a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBDetailViewController.m +++ b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBDetailViewController.m @@ -404,6 +404,10 @@ [self setStatusText: @"Synching entities with cache..."]; } else if ([CISDOBIpadServiceDidSynchEntitiesNotification isEqualToString: [note name]]) { [self clearStatusText]; + } else if ([CISDOBIpadServiceWillSynchPruningEntitiesNotification isEqualToString: [note name]]) { + [self setStatusText: @"Pruning entities from cache..."]; + } else if ([CISDOBIpadServiceDidSynchPruningEntitiesNotification isEqualToString: [note name]]) { + [self clearStatusText]; } else if ([CISDOBIpadServiceWillDrillOnEntityNotification isEqualToString: [note name]]) { [self setStatusText: @"Retrieving drill information..."]; } else if ([CISDOBIpadServiceDidDrillOnEntityNotification isEqualToString: [note name]]) { diff --git a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBOpenBisModel.m b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBOpenBisModel.m index 50b5ef986d6f3aab6aa5c567cbac8c0b6e816104..0b277213868ad66af014ca3cf6bb38da9dea0188 100644 --- a/openbis-ipad/source/objc/openBIS/openBIS/CISDOBOpenBisModel.m +++ b/openbis-ipad/source/objc/openBIS/openBIS/CISDOBOpenBisModel.m @@ -66,7 +66,7 @@ NSString *filterScope = @"Filter"; // Search is only possible if we are online - if (self.isOnline) { + if (self.isOnline && self.serviceManager.isSyncDone) { NSArray *searchDomains = self.serviceManager.service.clientPreferences.searchDomains; for (NSDictionary *domain in searchDomains) { NSString *label = [domain objectForKey: @"label"];