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

SSDM-2495 : Refactoring, removing/merging/categorizing sample search calls

SVN: 34671
parent 98a31033
No related branches found
No related tags found
No related merge requests found
...@@ -523,19 +523,33 @@ function ServerFacade(openbisServer) { ...@@ -523,19 +523,33 @@ function ServerFacade(openbisServer) {
this.openbisServer.searchForDataSets(dataSetCriteria, callbackFunction) this.openbisServer.searchForDataSets(dataSetCriteria, callbackFunction)
} }
// Used for blast search datasets
this.getSamplesForDataSets = function(dataSetCodes, callback) {
this.openbisServer.getDataSetMetaDataWithFetchOptions(dataSetCodes, [ 'SAMPLE' ], callback);
}
// //
// Search Samples // Search Samples
// //
this.searchSamples = function(fechOptions, callbackFunction) this.searchSamples = function(fechOptions, callbackFunction)
{ {
//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"];
//Properties
var properyKeyValueList = fechOptions["properyKeyValueList"]; var properyKeyValueList = fechOptions["properyKeyValueList"];
//Sub Queries
var sampleExperimentIdentifier = fechOptions["sampleExperimentIdentifier"]; var sampleExperimentIdentifier = fechOptions["sampleExperimentIdentifier"];
var sampleContainer = fechOptions["sampleContainer"];
//Hierarchy Options
var withProperties = fechOptions["withProperties"]; var withProperties = fechOptions["withProperties"];
var withParents = fechOptions["withParents"]; var withParents = fechOptions["withParents"];
var withChildren = fechOptions["withChildren"];
var withAncestors = fechOptions["withAncestors"]; var withAncestors = fechOptions["withAncestors"];
var withDescendants = fechOptions["withDescendants"]; var withDescendants = fechOptions["withDescendants"];
...@@ -630,6 +644,22 @@ function ServerFacade(openbisServer) { ...@@ -630,6 +644,22 @@ function ServerFacade(openbisServer) {
}); });
} }
if(sampleContainer) {
subCriterias.push({
"@type" : "SearchSubCriteria",
"targetEntityKind" : "SAMPLE_CONTAINER",
"criteria" : {
matchClauses : [{
"@type":"AttributeMatchClause",
fieldType : "ATTRIBUTE",
attribute : "PERM_ID",
desiredValue : sampleContainer
}],
operator : "MATCH_ALL_CLAUSES"
}
});
}
var sampleCriteria = { var sampleCriteria = {
matchClauses : matchClauses, matchClauses : matchClauses,
subCriterias : subCriterias, subCriterias : subCriterias,
...@@ -654,6 +684,10 @@ function ServerFacade(openbisServer) { ...@@ -654,6 +684,10 @@ function ServerFacade(openbisServer) {
options.push("PARENTS"); options.push("PARENTS");
} }
if(withChildren) {
options.push("CHILDREN");
}
var localReference = this; var localReference = this;
this.openbisServer.searchForSamplesWithFetchOptions(sampleCriteria, options, function(data) { this.openbisServer.searchForSamplesWithFetchOptions(sampleCriteria, options, function(data) {
callbackFunction(localReference.getInitializedSamples(data.result)); callbackFunction(localReference.getInitializedSamples(data.result));
...@@ -742,6 +776,15 @@ function ServerFacade(openbisServer) { ...@@ -742,6 +776,15 @@ function ServerFacade(openbisServer) {
searchNext(); searchNext();
} }
this.searchContained = function(permId, callbackFunction) {
this.searchSamples({
"sampleContainer" : permId,
"withProperties" : true,
"withParents" : true,
"withChildren" : true
}, callbackFunction);
}
this.getInitializedSamples = function(result) { this.getInitializedSamples = function(result) {
// //
...@@ -830,47 +873,7 @@ function ServerFacade(openbisServer) { ...@@ -830,47 +873,7 @@ function ServerFacade(openbisServer) {
} }
// //
// Sample Search Very Specific cases // Free Text Search
//
// Used for Plates
this.searchContained = function(permId, callbackFunction) {
var matchClauses = [];
var subCriteria = {
"@type" : "SearchSubCriteria",
"targetEntityKind" : "SAMPLE_CONTAINER",
"criteria" : {
matchClauses : [{
"@type":"AttributeMatchClause",
fieldType : "ATTRIBUTE",
attribute : "PERM_ID",
desiredValue : permId
}],
operator : "MATCH_ALL_CLAUSES"
}
}
var sampleCriteria =
{
matchClauses : matchClauses,
subCriterias : [ subCriteria ],
operator : "MATCH_ALL_CLAUSES"
};
var localReference = this;
this.openbisServer.searchForSamplesWithFetchOptions(sampleCriteria, ["PROPERTIES", "PARENTS", "CHILDREN"], function(data) {
callbackFunction(localReference.getInitializedSamples(data.result));
});
}
// Used for blast search datasets
this.getSamplesForDataSets = function(dataSetCodes, callback) {
this.openbisServer.getDataSetMetaDataWithFetchOptions(dataSetCodes, [ 'SAMPLE' ], callback);
}
//
// Free Search
// //
this.searchWithText = function(freeText, callbackFunction) this.searchWithText = function(freeText, callbackFunction)
{ {
......
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