Skip to content
Snippets Groups Projects
Commit 5f462c55 authored by cramakri's avatar cramakri
Browse files

Initial version of drill

SVN: 27274
parent 485fb73e
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,9 @@ enum CISOBIpadServiceErrorCode {
//! Get all root-level entities from the openBIS ipad service, possibly along with some children as well. The success message will be invoked with a collection of CISDOBIpadRawEntity objects.
- (CISDOBAsyncCall *)listRootLevelEntities;
//! Get drill information from the openBIS ipad service -- this will include information about the children of the entity and possibly their children as well. The success message will be invoked with a collection of CISDOBIpadRawEntity objects.
- (CISDOBAsyncCall *)drillOnEntityWithPermId:(NSString *)permId refcon:(NSString *)refcon;
@end
......
......@@ -175,6 +175,34 @@ NSString *const CISDOBIpadServiceErrorDomain = @"CISDOBIpadServiceErrorDomain";
return iPadCall;
}
- (CISDOBAsyncCall *)drillOnEntityWithPermId:(NSString *)permId refcon:(NSString *)refcon
{
// A simple version of the method that just request data for one entity.
NSDictionary *entity =
[NSDictionary dictionaryWithObjectsAndKeys:
permId, @"PERM_ID",
refcon, @"REFCON", nil];
NSArray *entities = [NSArray arrayWithObject: entity];
NSDictionary *parameters =
[NSDictionary dictionaryWithObjectsAndKeys:
@"DRILL", @"requestKey",
entities, @"entities", nil];
CISDOBAsyncCall *connectionCall =
[_connection
createReportFromDataStore: [_ipadReadService objectForKey: @"dataStoreCode"]
aggregationService: [_ipadReadService objectForKey: @"serviceKey"]
parameters: parameters];
CISDOBIpadServiceCall *iPadCall = [self iPadCallWrappingConnectionCall: connectionCall];
connectionCall.success = ^(id result) {
if (iPadCall.success) {
iPadCall.success([self rawEntitiesFromResult: result]);
}
};
return iPadCall;
}
@end
@implementation CISDOBIpadServiceCall
......
......@@ -52,7 +52,7 @@
[self waitSeconds: waitTime forCallToComplete: call];
}
- (void)testListAllEntities
- (void)testListRootEntities
{
CISDOBAsyncCall *call;
call = [_service loginUser: GetDefaultUserName() password: GetDefaultUserPassword()];
......@@ -81,4 +81,35 @@
}
}
- (void)testDrill
{
CISDOBAsyncCall *call;
call = [_service loginUser: GetDefaultUserName() password: GetDefaultUserPassword()];
[self configureAndRunCallSynchronously: call];
call = [_service listRootLevelEntities];
[self configureAndRunCallSynchronously: call];
STAssertNotNil(_callResult, @"The iPad service should have returned some entities.");
NSArray *rawEntities = _callResult;
STAssertTrue([rawEntities count] > 0, @"The Pad service should have returned some entities.");
// Find an entity with children and drill on it
CISDOBIpadRawEntity *entityWithChildren = nil;
for (CISDOBIpadRawEntity *rawEntity in rawEntities) {
if ([rawEntity.children length] > 2) {
entityWithChildren = rawEntity;
break;
}
}
// Drill
call = [_service drillOnEntityWithPermId: entityWithChildren.permId refcon: entityWithChildren.refcon];
[self configureAndRunCallSynchronously: call];
rawEntities = _callResult;
STAssertTrue([rawEntities count] > 0, @"The Pad service should have returned some entities.");
}
@end
......@@ -11,6 +11,10 @@ def json_encoded_value(coll):
"""Utility function for converting a list into a json-encoded list"""
return ObjectMapper().writeValueAsString(coll)
def json_string_to_dict(string):
"""Utility function for converting a json-encoded dictionary into a Java/Jython dictionary."""
return ObjectMapper().readValue(string, dict)
class RequestHandler:
"""Abstract superclass for the handlers for concrete requests like ROOT.
......@@ -200,10 +204,10 @@ def samples_to_dict(samples, material_by_perm_id):
result = [sample_to_dict(sample, material_by_perm_id) for sample in samples]
return result
def retrieve_samples(sample_perm_id_and_ref_cons):
def retrieve_samples(sample_perm_ids_and_ref_cons):
sc = SearchCriteria()
for sample in sample_perm_id_and_ref_con:
code = sample['REFCON']['code']
for sample in sample_perm_ids_and_ref_cons:
code = json_string_to_dict(sample['REFCON'])['code']
sc.addMatchClause(sc.MatchClause.createAttributeMatch(sc.MatchClauseAttribute.CODE, code))
return searchService.searchForSamples(sc)
......
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