Skip to content
Snippets Groups Projects
Commit 77f2e4e9 authored by cramakri's avatar cramakri
Browse files

Introduce server communication to the live iPad app

SVN: 27420
parent a5c2e201
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
362B81EC163FFB6C00127554 /* CISDOBIpadServiceManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 362B81EB163FFB6C00127554 /* CISDOBIpadServiceManager.m */; };
364D509E161C6ADB00A739B0 /* openBISData.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 364D509C161C6ADB00A739B0 /* openBISData.sqlite */; }; 364D509E161C6ADB00A739B0 /* openBISData.sqlite in Resources */ = {isa = PBXBuildFile; fileRef = 364D509C161C6ADB00A739B0 /* openBISData.sqlite */; };
3687D8FF162D3AB500622690 /* openbis-icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 3687D8FD162D3AB500622690 /* openbis-icon-72.png */; }; 3687D8FF162D3AB500622690 /* openbis-icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 3687D8FD162D3AB500622690 /* openbis-icon-72.png */; };
3687D900162D3AB500622690 /* openbis-icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 3687D8FE162D3AB500622690 /* openbis-icon-144.png */; }; 3687D900162D3AB500622690 /* openbis-icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 3687D8FE162D3AB500622690 /* openbis-icon-144.png */; };
...@@ -73,6 +74,8 @@ ...@@ -73,6 +74,8 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
362B81EA163FFB6C00127554 /* CISDOBIpadServiceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CISDOBIpadServiceManager.h; sourceTree = "<group>"; };
362B81EB163FFB6C00127554 /* CISDOBIpadServiceManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CISDOBIpadServiceManager.m; sourceTree = "<group>"; };
364D5098161C6A3600A739B0 /* readme.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = readme.md; sourceTree = "<group>"; }; 364D5098161C6A3600A739B0 /* readme.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = readme.md; sourceTree = "<group>"; };
364D509C161C6ADB00A739B0 /* openBISData.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = openBISData.sqlite; sourceTree = "<group>"; }; 364D509C161C6ADB00A739B0 /* openBISData.sqlite */ = {isa = PBXFileReference; lastKnownFileType = file; path = openBISData.sqlite; sourceTree = "<group>"; };
3687D8FD162D3AB500622690 /* openbis-icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "openbis-icon-72.png"; sourceTree = "<group>"; }; 3687D8FD162D3AB500622690 /* openbis-icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "openbis-icon-72.png"; sourceTree = "<group>"; };
...@@ -279,6 +282,8 @@ ...@@ -279,6 +282,8 @@
36F71ED0161C453D00C87277 /* CISDOBIpadEntity.m */, 36F71ED0161C453D00C87277 /* CISDOBIpadEntity.m */,
36F71ED1161C453D00C87277 /* CISDOBIpadService.h */, 36F71ED1161C453D00C87277 /* CISDOBIpadService.h */,
36F71ED2161C453D00C87277 /* CISDOBIpadService.m */, 36F71ED2161C453D00C87277 /* CISDOBIpadService.m */,
362B81EA163FFB6C00127554 /* CISDOBIpadServiceManager.h */,
362B81EB163FFB6C00127554 /* CISDOBIpadServiceManager.m */,
36F71ED3161C453D00C87277 /* CISDOBJsonRpcCall.h */, 36F71ED3161C453D00C87277 /* CISDOBJsonRpcCall.h */,
36F71ED4161C453D00C87277 /* CISDOBJsonRpcCall.m */, 36F71ED4161C453D00C87277 /* CISDOBJsonRpcCall.m */,
36F71ED6161C453D00C87277 /* persistent-data-model.xcdatamodeld */, 36F71ED6161C453D00C87277 /* persistent-data-model.xcdatamodeld */,
...@@ -457,6 +462,7 @@ ...@@ -457,6 +462,7 @@
36F71EE8161C453D00C87277 /* CISDOBJsonRpcCall.m in Sources */, 36F71EE8161C453D00C87277 /* CISDOBJsonRpcCall.m in Sources */,
36F71EE9161C453D00C87277 /* persistent-data-model.xcdatamodeld in Sources */, 36F71EE9161C453D00C87277 /* persistent-data-model.xcdatamodeld in Sources */,
36F97A2E1628123F005D063E /* CISDOBOpenBisModel.m in Sources */, 36F97A2E1628123F005D063E /* CISDOBOpenBisModel.m in Sources */,
362B81EC163FFB6C00127554 /* CISDOBIpadServiceManager.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class CISDOBOpenBisModel; @class CISDOBOpenBisModel, CISDOBIpadServiceManager;
@interface CISDOBAppDelegate : UIResponder <UIApplicationDelegate> @interface CISDOBAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) UIWindow *window;
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (readonly, strong, nonatomic) CISDOBOpenBisModel *rootOpenBisModel; @property (readonly, strong, nonatomic) CISDOBOpenBisModel *rootOpenBisModel;
@property (readonly, strong, nonatomic) CISDOBIpadServiceManager *serviceManager;
- (void)saveContext; - (void)saveContext;
- (NSURL *)applicationDocumentsDirectory; - (NSURL *)applicationDocumentsDirectory;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#import "CISDOBMasterViewController.h" #import "CISDOBMasterViewController.h"
#import "CISDOBOpenBisModel.h" #import "CISDOBOpenBisModel.h"
#import "CISDOBIpadServiceManager.h"
#import "CISDOBAsyncCall.h"
@implementation CISDOBAppDelegate @implementation CISDOBAppDelegate
...@@ -32,6 +34,7 @@ ...@@ -32,6 +34,7 @@
@synthesize managedObjectModel = _managedObjectModel; @synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator; @synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
@synthesize rootOpenBisModel = _rootOpenBisModel; @synthesize rootOpenBisModel = _rootOpenBisModel;
@synthesize serviceManager = _serviceManager;
- (void)configureControllers; - (void)configureControllers;
{ {
...@@ -65,6 +68,14 @@ ...@@ -65,6 +68,14 @@
[self configureControllers]; [self configureControllers];
CISDOBMasterViewController *controller = [self masterViewController]; CISDOBMasterViewController *controller = [self masterViewController];
controller.openBisModel = self.rootOpenBisModel; controller.openBisModel = self.rootOpenBisModel;
// Initialize the connection to openBIS
CISDOBAsyncCall *call = [self.serviceManager loginUser: @"admin" password: @"password"];
call.success = ^(id result) {
[controller didConnectServiceManager: self.serviceManager];
};
[call start];
return YES; return YES;
} }
...@@ -162,10 +173,26 @@ ...@@ -162,10 +173,26 @@
_rootOpenBisModel = [[CISDOBOpenBisModel alloc] init]; _rootOpenBisModel = [[CISDOBOpenBisModel alloc] init];
_rootOpenBisModel.managedObjectContext = self.managedObjectContext; _rootOpenBisModel.managedObjectContext = self.managedObjectContext;
_rootOpenBisModel.serviceManager = self.serviceManager;
return _rootOpenBisModel; return _rootOpenBisModel;
} }
- (CISDOBIpadServiceManager *)serviceManager
{
if (_serviceManager) return _serviceManager;
NSURL *storeUrl = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"openBISData.sqlite"];
NSURL *openbisUrl = [NSURL URLWithString: @"https://localhost:8443"];
NSError *error;
_serviceManager =
[[CISDOBIpadServiceManager alloc]
initWithStoreUrl: storeUrl openbisUrl: openbisUrl trusted: YES error: &error];
return _serviceManager;
}
#pragma mark - Application's Documents directory #pragma mark - Application's Documents directory
// Returns the URL to the application's Documents directory. // Returns the URL to the application's Documents directory.
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class CISDOBDetailViewController, CISDOBOpenBisModel; @class CISDOBDetailViewController, CISDOBOpenBisModel, CISDOBIpadServiceManager;
#import <CoreData/CoreData.h> #import <CoreData/CoreData.h>
...@@ -32,4 +32,7 @@ ...@@ -32,4 +32,7 @@
@property (strong, nonatomic) CISDOBDetailViewController *detailViewController; @property (strong, nonatomic) CISDOBDetailViewController *detailViewController;
@property (strong, nonatomic) CISDOBOpenBisModel *openBisModel; @property (strong, nonatomic) CISDOBOpenBisModel *openBisModel;
// Server Communication
- (void)didConnectServiceManager:(CISDOBIpadServiceManager *)serviceManager;
@end @end
...@@ -227,6 +227,14 @@ ...@@ -227,6 +227,14 @@
} }
*/ */
#pragma mark - Server Communication
- (void)didConnectServiceManager:(CISDOBIpadServiceManager *)serviceManager
{
[self.openBisModel syncRootEntities: ^(id result) {
[self.tableView reloadData];
}];
}
#pragma mark - Properties #pragma mark - Properties
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "CISDOBShared.h" #import "CISDOBShared.h"
@class CISDOBIpadEntity; @class CISDOBIpadEntity, CISDOBIpadServiceManager;
/** /**
* \brief A model for the interaction with openBIS. * \brief A model for the interaction with openBIS.
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
@property (weak, nonatomic) id <NSFetchedResultsControllerDelegate> delegate; @property (weak, nonatomic) id <NSFetchedResultsControllerDelegate> delegate;
@property (weak, nonatomic) CISDOBOpenBisModel *parentModel; @property (weak, nonatomic) CISDOBOpenBisModel *parentModel;
@property (weak, nonatomic) CISDOBIpadServiceManager *serviceManager;
// Initialize // Initialize
- (id)initWithParentModel:(CISDOBOpenBisModel *)parentModel; //!< The designated initializer - (id)initWithParentModel:(CISDOBOpenBisModel *)parentModel; //!< The designated initializer
...@@ -60,6 +61,8 @@ ...@@ -60,6 +61,8 @@
- (BOOL)deleteObjectAtIndexPath:(NSIndexPath *)indexPath error:(NSError **)error; //!< Return YES if operation succeeded - (BOOL)deleteObjectAtIndexPath:(NSIndexPath *)indexPath error:(NSError **)error; //!< Return YES if operation succeeded
// Server Communication // Server Communication
- (void)syncRootEntities:(SuccessBlock)success;
//! Get the full selected object from the server and invoke the success block when the data is here //! Get the full selected object from the server and invoke the success block when the data is here
- (void)syncSelectedObjectForDetailOnSuccess:(SuccessBlock)success; - (void)syncSelectedObjectForDetailOnSuccess:(SuccessBlock)success;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#import "CISDOBOpenBisModel.h" #import "CISDOBOpenBisModel.h"
#import "CISDOBIpadEntity.h" #import "CISDOBIpadEntity.h"
#import "CISDOBIpadServiceManager.h"
#import "CISDOBAsyncCall.h"
@implementation CISDOBOpenBisModel @implementation CISDOBOpenBisModel
...@@ -42,6 +44,7 @@ ...@@ -42,6 +44,7 @@
if (self.parentModel) { if (self.parentModel) {
self.managedObjectContext = parentModel.managedObjectContext; self.managedObjectContext = parentModel.managedObjectContext;
self.serviceManager = parentModel.serviceManager;
} }
return self; return self;
...@@ -120,6 +123,14 @@ ...@@ -120,6 +123,14 @@
} }
#pragma mark - Server Communication #pragma mark - Server Communication
- (void)syncRootEntities:(SuccessBlock)success;
{
// The manager has connected, initialize the root
CISDOBAsyncCall *call = [self.serviceManager retrieveRootLevelEntities];
call.success = success;
[call start];
}
- (void)syncSelectedObjectForDetailOnSuccess:(SuccessBlock)success - (void)syncSelectedObjectForDetailOnSuccess:(SuccessBlock)success
{ {
// Load the image if necessary // Load the image if necessary
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment