Skip to content
Snippets Groups Projects
Commit e82a04d2 authored by juanf's avatar juanf
Browse files

SSDM-2495 : Adding v3 client API to ELN (Last stable version before making...

SSDM-2495 : Adding v3 client API to ELN (Last stable version before making fundamental changes) - Take 2

SVN: 34694
parent 31a92e64
No related branches found
No related tags found
No related merge requests found
...@@ -543,12 +543,45 @@ function ServerFacade(openbisServer) { ...@@ -543,12 +543,45 @@ function ServerFacade(openbisServer) {
// Search Samples // Search Samples
// //
this.searchSamples = function(fechOptions, callbackFunction) this.searchSamples = function(fechOptions, callbackFunction)
{
this.searchSamplesV1(fechOptions, callbackFunction);
}
this.searchSamplesV3DSS = function(fechOptions, callbackFunction)
{
var localReference = this;
fechOptions["method"] = "searchSamples";
fechOptions["openBISURL"] = this.openbisServer._internal.openbisUrl;
this.createReportFromAggregationService(profile.getDefaultDataStoreCode(), fechOptions, function(result) {
if(result && result.result && result.result.rows[0][0].value === "OK") {
var json = result.result.rows[0][2].value;
var jsonParsed = JSON.parse(json);
require(["util/Json"], function(Json){
Json.fromJson(jsonParsed).done(function(data) {
var samples = data.objects;
callbackFunction(samples);
}).fail(function() {
alert("V3 dropbox search failed to be parsed.");
});
});
} else {
alert("V3 dropbox search failed to execute.");
}
});
}
this.searchSamplesV1 = function(fechOptions, callbackFunction)
{ {
//Text Search
var anyFieldContains = fechOptions["anyFieldContains"];
//Attributes //Attributes
var samplePermId = fechOptions["samplePermId"]; var samplePermId = fechOptions["samplePermId"];
var sampleIdentifier = fechOptions["sampleIdentifier"]; var sampleIdentifier = fechOptions["sampleIdentifier"];
var sampleCode = fechOptions["sampleCode"]; var sampleCode = fechOptions["sampleCode"];
var sampleTypeCode = fechOptions["sampleTypeCode"]; var sampleTypeCode = fechOptions["sampleTypeCode"];
var registrationDate = fechOptions["registrationDate"];
var modificationDate = fechOptions["modificationDate"];
//Properties //Properties
var properyKeyValueList = fechOptions["properyKeyValueList"]; var properyKeyValueList = fechOptions["properyKeyValueList"];
...@@ -564,28 +597,18 @@ function ServerFacade(openbisServer) { ...@@ -564,28 +597,18 @@ function ServerFacade(openbisServer) {
var withAncestors = fechOptions["withAncestors"]; var withAncestors = fechOptions["withAncestors"];
var withDescendants = fechOptions["withDescendants"]; var withDescendants = fechOptions["withDescendants"];
// var localReference = this;
// fechOptions["method"] = "searchSamples";
// fechOptions["openBISURL"] = this.openbisServer._internal.openbisUrl;
// this.createReportFromAggregationService(profile.getDefaultDataStoreCode(), fechOptions, function(result) {
// if(result && result.result && result.result.rows[0][0].value === "OK") {
// var json = result.result.rows[0][2].value;
// var jsonParsed = JSON.parse(json);
// require(["util/Json"], function(Json){
// Json.fromJson(jsonParsed).done(function(data) {
// var samples = data.objects;
// callbackFunction(samples);
// }).fail(function() {
// alert("V3 dropbox search failed to be parsed.");
// });
// });
// } else {
// alert("V3 dropbox search failed to execute.");
// }
// });
var matchClauses = []; var matchClauses = [];
// Free Text
if(anyFieldContains) {
matchClauses.push({
"@type": "AnyFieldMatchClause",
fieldType: "ANY_FIELD",
desiredValue: "*" + anyFieldContains.trim() + "*"
});
}
// Attributes
if(samplePermId) { if(samplePermId) {
matchClauses.push({ matchClauses.push({
"@type":"AttributeMatchClause", "@type":"AttributeMatchClause",
...@@ -629,6 +652,31 @@ function ServerFacade(openbisServer) { ...@@ -629,6 +652,31 @@ function ServerFacade(openbisServer) {
}); });
} }
if(registrationDate) {
matchClauses.push({
"@type":"TimeAttributeMatchClause",
fieldType : "ATTRIBUTE",
fieldCode : "REGISTRATION_DATE",
desiredValue : registrationDate,
compareMode : "EQUALS",
timeZone : "+1",
attribute : "REGISTRATION_DATE"
});
}
if(modificationDate) {
matchClauses.push({
"@type":"TimeAttributeMatchClause",
fieldType : "ATTRIBUTE",
fieldCode : "MODIFICATION_DATE",
desiredValue : modificationDate,
compareMode : "EQUALS",
timeZone : "+1",
attribute : "MODIFICATION_DATE"
});
}
//Properties
if(properyKeyValueList) { if(properyKeyValueList) {
for(var kvIdx = 0; kvIdx < properyKeyValueList.length; kvIdx++) { for(var kvIdx = 0; kvIdx < properyKeyValueList.length; kvIdx++) {
var properyKeyValue = properyKeyValueList[kvIdx]; var properyKeyValue = properyKeyValueList[kvIdx];
...@@ -647,6 +695,7 @@ function ServerFacade(openbisServer) { ...@@ -647,6 +695,7 @@ function ServerFacade(openbisServer) {
} }
} }
//Sub Queries
var subCriterias = []; var subCriterias = [];
if(sampleExperimentIdentifier) { if(sampleExperimentIdentifier) {
var sampleExperimentIdentifierParts = sampleExperimentIdentifier.split("/"); var sampleExperimentIdentifierParts = sampleExperimentIdentifier.split("/");
...@@ -697,6 +746,7 @@ function ServerFacade(openbisServer) { ...@@ -697,6 +746,7 @@ function ServerFacade(openbisServer) {
operator : "MATCH_ALL_CLAUSES" operator : "MATCH_ALL_CLAUSES"
}; };
//Hierarchy Options
var options = []; var options = [];
if(withProperties) { if(withProperties) {
...@@ -906,15 +956,6 @@ function ServerFacade(openbisServer) { ...@@ -906,15 +956,6 @@ function ServerFacade(openbisServer) {
// //
// Free Text Search // Free Text Search
// //
// this.searchWithText = function(freeText, callbackFunction)
// {
// this.searchSamples({
// "anyField" : freeText,
// "withProperties" : true,
// "withOrOperator" : true
// }, callbackFunction);
// }
this.searchWithText = function(freeText, callbackFunction) this.searchWithText = function(freeText, callbackFunction)
{ {
var _this = this; var _this = this;
...@@ -922,14 +963,11 @@ function ServerFacade(openbisServer) { ...@@ -922,14 +963,11 @@ function ServerFacade(openbisServer) {
var match = freeText.match(regEx); var match = freeText.match(regEx);
if(match && match.length === 1) { //Search With Date Mode, we merge results with dates found on registration and modification fields what is slow for large number of entities if(match && match.length === 1) { //Search With Date Mode, we merge results with dates found on registration and modification fields what is slow for large number of entities
this.openbisServer.searchForSamplesWithFetchOptions(this._getCriteriaWithDate(freeText, true, false), ["PROPERTIES"], function(data1) { this.searchSamples(this._getCriteriaWithDate(freeText, true, false), function(samples1) {
_this.openbisServer.searchForSamplesWithFetchOptions(_this._getCriteriaWithDate(freeText, false, true), ["PROPERTIES"], function(data2) { _this.searchSamples(_this._getCriteriaWithDate(freeText, false, true), function(samples2) {
_this.openbisServer.searchForSamplesWithFetchOptions(_this._getCriteriaWithDate(freeText, false, false), ["PROPERTIES"], function(data3) { _this.searchSamples(_this._getCriteriaWithDate(freeText, false, false), function(samples3) {
var results1 = _this.getInitializedSamples(data1.result); var results = samples1.concat(samples2).concat(samples3).uniqueOBISEntity();
var results2 = _this.getInitializedSamples(data2.result); callbackFunction(results);
var results3 = _this.getInitializedSamples(data3.result);
var resultsF = results1.concat(results2).concat(results3).uniqueOBISEntity();
callbackFunction(resultsF);
}); });
}); });
}); });
...@@ -937,8 +975,8 @@ function ServerFacade(openbisServer) { ...@@ -937,8 +975,8 @@ function ServerFacade(openbisServer) {
Util.showError("Search only supports one date at a time!"); Util.showError("Search only supports one date at a time!");
callbackFunction([]); callbackFunction([]);
} else { //Normal Search } else { //Normal Search
this.openbisServer.searchForSamplesWithFetchOptions(this._getCriteriaWithDate(freeText, false, false), ["PROPERTIES"], function(data) { this.searchSamples(this._getCriteriaWithDate(freeText, false, false), function(samples) {
callbackFunction(_this.getInitializedSamples(data.result)); callbackFunction(samples);
}); });
callbackFunction([]); callbackFunction([]);
} }
...@@ -957,42 +995,21 @@ function ServerFacade(openbisServer) { ...@@ -957,42 +995,21 @@ function ServerFacade(openbisServer) {
//Build Search //Build Search
var sampleCriteria = { var sampleCriteria = {
matchClauses: [], "withProperties" : true
operator: "MATCH_ALL_CLAUSES"
}; };
if(freeText) { if(freeText) {
sampleCriteria.matchClauses.push({ sampleCriteria["anyFieldContains"] = freeText;
"@type": "AnyFieldMatchClause",
fieldType: "ANY_FIELD",
desiredValue: "*" + freeText.trim() + "*"
});
} }
if(match && match.length > 0) { if(match && match.length > 0) {
for(var mIdx = 0; mIdx < match.length; mIdx++) { for(var mIdx = 0; mIdx < match.length; mIdx++) {
if(isRegistrationDate) { if(isRegistrationDate) {
sampleCriteria.matchClauses.push({ sampleCriteria["registrationDate"] = match[mIdx];
"@type":"TimeAttributeMatchClause",
fieldType : "ATTRIBUTE",
fieldCode : "REGISTRATION_DATE",
desiredValue : match[mIdx],
compareMode : "EQUALS",
timeZone : "+1",
attribute : "REGISTRATION_DATE"
});
} }
if(isModificationDate) { if(isModificationDate) {
sampleCriteria.matchClauses.push({ sampleCriteria["modificationDate"] = match[mIdx];
"@type":"TimeAttributeMatchClause",
fieldType : "ATTRIBUTE",
fieldCode : "MODIFICATION_DATE",
desiredValue : match[mIdx],
compareMode : "EQUALS",
timeZone : "+1",
attribute : "MODIFICATION_DATE"
});
} }
} }
} }
......
...@@ -496,14 +496,16 @@ def searchSamples(tr, parameters, tableBuilder, sessionId): ...@@ -496,14 +496,16 @@ def searchSamples(tr, parameters, tableBuilder, sessionId):
fechOptions = parameters; fechOptions = parameters;
# FreeText # FreeText
anyField = fechOptions.get("anyField"); anyFieldContains = fechOptions.get("anyFieldContains");
# Attributes # Attributes
samplePermId = fechOptions.get("samplePermId"); samplePermId = fechOptions.get("samplePermId");
sampleIdentifier = fechOptions.get("sampleIdentifier"); sampleIdentifier = fechOptions.get("sampleIdentifier");
sampleCode = fechOptions.get("sampleCode"); sampleCode = fechOptions.get("sampleCode");
sampleTypeCode = fechOptions.get("sampleTypeCode"); sampleTypeCode = fechOptions.get("sampleTypeCode");
registrationDate = fechOptions.get("registrationDate");
modificationDate = fechOptions.get("modificationDate");
# Properties # Properties
properyKeyValueList = fechOptions.get("properyKeyValueList"); properyKeyValueList = fechOptions.get("properyKeyValueList");
...@@ -520,18 +522,12 @@ def searchSamples(tr, parameters, tableBuilder, sessionId): ...@@ -520,18 +522,12 @@ def searchSamples(tr, parameters, tableBuilder, sessionId):
#Search Setup #Search Setup
criterion = SampleSearchCriterion(); criterion = SampleSearchCriterion();
criterion.withAndOperator();
fetchOptions = SampleFetchOptions(); fetchOptions = SampleFetchOptions();
#Operator
withOrOperator = fechOptions.get("withOrOperator");
if withOrOperator:
criterion.withOrOperator();
else:
criterion.withAndOperator();
#Free Text #Free Text
if anyField is not None: if anyFieldContains is not None:
criterion.withAnyField().thatContains(anyField); criterion.withAnyField().thatContains(anyFieldContains);
#Attributes #Attributes
if samplePermId is not None: if samplePermId is not None:
...@@ -542,6 +538,10 @@ def searchSamples(tr, parameters, tableBuilder, sessionId): ...@@ -542,6 +538,10 @@ def searchSamples(tr, parameters, tableBuilder, sessionId):
criterion.withCode().thatEquals(sampleCode); criterion.withCode().thatEquals(sampleCode);
if sampleTypeCode is not None: if sampleTypeCode is not None:
criterion.withType().withCode().thatEquals(sampleTypeCode); criterion.withType().withCode().thatEquals(sampleTypeCode);
if registrationDate is not None:
criterion.withRegistrationDate().thatEquals(registrationDate); #TO-DO Convert to Java date from weird JS format
if modificationDate is not None:
criterion.withModificationDate().thatEquals(modificationDate); #TO-DO Convert to Java date from weird JS format
#Properties #Properties
if properyKeyValueList is not None: if properyKeyValueList is not None:
......
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