Skip to content
Snippets Groups Projects
Commit 98009538 authored by parkera's avatar parkera
Browse files

SSDM-3024 : Search call for samples (ongoing work)

SVN: 35886
parent cb300fe8
No related branches found
No related tags found
No related merge requests found
...@@ -602,7 +602,8 @@ function ServerFacade(openbisServer) { ...@@ -602,7 +602,8 @@ function ServerFacade(openbisServer) {
this.searchForSamplesAdvanced = function(advancedSearchCriteria, callback) { this.searchForSamplesAdvanced = function(advancedSearchCriteria, callback) {
require(['openbis', require(['openbis',
'as/dto/sample/search/SampleSearchCriteria', 'as/dto/sample/search/SampleSearchCriteria',
'as/dto/sample/fetchoptions/SampleFetchOptions'], function(openbis, SampleSearchCriteria, SampleFetchOptions) { 'as/dto/sample/fetchoptions/SampleFetchOptions',
'as/dto/common/search/DateObjectEqualToValue'], function(openbis, SampleSearchCriteria, SampleFetchOptions, DateObjectEqualToValue) {
//Boilerplate //Boilerplate
var testProtocol = window.location.protocol; var testProtocol = window.location.protocol;
...@@ -615,175 +616,105 @@ function ServerFacade(openbisServer) { ...@@ -615,175 +616,105 @@ function ServerFacade(openbisServer) {
var v3Api = new openbis(testApiUrl); var v3Api = new openbis(testApiUrl);
v3Api._private.sessionToken = mainController.serverFacade.getSession(); v3Api._private.sessionToken = mainController.serverFacade.getSession();
//SearchResult<Sample> searchSamples(String sessionToken, SampleSearchCriteria searchCriteria, SampleFetchOptions fetchOptions); //Setting the searchCriteria given the advancedSearchCriteria model
//TO-DO Setting the searchCriteria given the advancedSearchCriteria model
var searchCriteria = new SampleSearchCriteria(); var searchCriteria = new SampleSearchCriteria();
//Setting the fetchOptions given standard settings
var fetchOptions = new SampleFetchOptions();
fetchOptions.withTags();
fetchOptions.withType();
fetchOptions.withSpace();
fetchOptions.withExperiment();
fetchOptions.withRegistrator();
fetchOptions.withModifier();
fetchOptions.withParents();
fetchOptions.withProperties();
//Operator
var operator = advancedSearchCriteria.logicalOperator; var operator = advancedSearchCriteria.logicalOperator;
if (!operator) { if (!operator) {
operator = "AND"; operator = "AND";
} }
searchCriteria.withOperator(operator); searchCriteria.withOperator(operator);
//Rules
var ruleKeys = Object.keys(advancedSearchCriteria.rules); var ruleKeys = Object.keys(advancedSearchCriteria.rules);
for (var idx = 0; idx < ruleKeys.length; idx++) for (var idx = 0; idx < ruleKeys.length; idx++)
{ {
var fieldType = null; var fieldType = advancedSearchCriteria.rules[ruleKeys[idx]].type;
var fieldNameUnparsed = null; var fieldName = advancedSearchCriteria.rules[ruleKeys[idx]].name;
var fieldName = null; var fieldNameType = null;
var fieldValue = null; var fieldValue = advancedSearchCriteria.rules[ruleKeys[idx]].value;
fieldType = advancedSearchCriteria.rules[ruleKeys[idx]].type; if(fieldName) {
fieldNameUnparsed = advancedSearchCriteria.rules[ruleKeys[idx]].name; var firstDotIndex = fieldName.indexOf(".");
if (fieldNameUnparsed === undefined) { fieldNameType = fieldName.substring(0, firstDotIndex);
fieldNameUnparsed = null; fieldName = fieldName.substring(firstDotIndex + 1, fieldName.length);
} else if (fieldNameUnparsed.indexOf(".") != -1) {
fieldName = fieldNameUnparsed.substring(fieldNameUnparsed.indexOf(".") + 1, fieldNameUnparsed.length);
} }
fieldValue = advancedSearchCriteria.rules[ruleKeys[idx]].value;
//alert("fieldType is " + fieldType + " fieldName is " + fieldName + " fieldValue is " + fieldValue + " fieldNameUnparsed is " + fieldNameUnparsed);
//Case 1: fieldType = all var setPropertyCriteria = function(criteria, propertyName, propertyValue) {
if(fieldType === "All") { criteria.withProperty(propertyName).thatEquals(propertyValue);
searchCriteria.withAnyField().thatEquals(fieldValue);
} }
//Case 2: fieldType = property var setAttributeCriteria = function(criteria, attributeName, attributeValue) {
else if(fieldType === "Property") { switch(attributeName) {
searchCriteria.withProperty(fieldName).thatEquals(fieldValue);
}
//Case 3: fieldType = attribute
else if(fieldType === "Attribute"){
switch(fieldName) {
case "CODE": case "CODE":
searchCriteria.withCode().thatEquals(fieldValue); criteria.withCode().thatEquals(attributeValue);
break; break;
case "SAMPLE_TYPE": case "SAMPLE_TYPE":
searchCriteria.withType().withCode().thatEquals(fieldValue); criteria.withType().withCode().thatEquals(attributeValue);
break; break;
case "PERM_ID": case "PERM_ID":
searchCriteria.withPermId().thatEquals(fieldValue); criteria.withPermId().thatEquals(attributeValue);
break; break;
case "SPACE": case "SPACE":
searchCriteria.withSpace().withCode().thatEquals(fieldValue); criteria.withSpace().withCode().thatEquals(attributeValue);
break;
case "PROJECT":
searchCriteria.withProject().withCode().thatEquals(fieldValue);
break;
case "PROJECT_PERM_ID":
searchCriteria.withProject().withPermId().thatEquals(fieldValue);
break; break;
case "METAPROJECT": case "METAPROJECT":
searchCriteria.withTag().withCode().thatEquals(fieldValue); criteria.withTag().withCode().thatEquals(attributeValue);
break; break;
case "REGISTRATION_DATE": //must be format 2009-08-18 case "REGISTRATION_DATE": //must be format 2009-08-18 ?
searchCriteria.withRegistrationDate().thatEquals(fieldValue); criteria.withRegistrationDate().thatEquals(new DateObjectEqualToValue(attributeValue));
break; break;
case "MODIFICATION_DATE": //must be format 2009-08-18 case "MODIFICATION_DATE": //must be format 2009-08-18 ?
searchCriteria.withModificationDate().thatEquals(fieldValue); criteria.withModificationDate().thatEquals(new DateObjectEqualToValue(attributeValue));
break; break;
default:
//Do Nothing
} }
} }
//Case 4: Parents switch(fieldType) {
else if (fieldType === "Parent"){ case "All":
if(fieldNameUnparsed.indexOf("ATTR.") != -1){ searchCriteria.withAnyField().thatEquals(fieldValue);
switch(fieldName) { break;
case "CODE": case "Property":
searchCriteria.withParents().withCode().thatEquals(fieldValue); setPropertyCriteria(searchCriteria, fieldName, fieldValue);
break; break;
case "SAMPLE_TYPE": case "Attribute":
searchCriteria.withParents().withType().withCode().thatEquals(fieldValue); setAttributeCriteria(searchCriteria, fieldName, fieldValue);
break; break;
case "PERM_ID": case "Parent":
searchCriteria.withParents().withPermId().thatEquals(fieldValue); switch(fieldNameType) {
break; case "PROP":
case "SPACE": setPropertyCriteria(searchCriteria.withParents(), fieldName, fieldValue);
searchCriteria.withParents().withSpace().withCode().thatEquals(fieldValue);
break;
case "PROJECT":
searchCriteria.withParents().withProject().withCode().thatEquals(fieldValue);
break;
case "PROJECT_PERM_ID":
searchCriteria.withParents().withProject().withPermId().thatEquals(fieldValue);
break;
case "METAPROJECT":
searchCriteria.withParents().withTag().withCode().thatEquals(fieldValue);
break;
case "REGISTRATION_DATE": //must be format 2009-08-18
searchCriteria.withParents().withRegistrationDate().thatEquals(fieldValue);
break; break;
case "MODIFICATION_DATE": //must be format 2009-08-18 case "ATTR":
searchCriteria.withParents().withModificationDate().thatEquals(fieldValue); setAttributeCriteria(searchCriteria.withParents(), fieldName, fieldValue);
break; break;
default: }
//Do Nothing break;
} case "Children":
}else if(fieldNameUnparsed.indexOf("PROP.") != -1){ switch(fieldNameType) {
searchCriteria.withParents().withProperty(fieldName).thatEquals(fieldValue); case "PROP":
} setPropertyCriteria(searchCriteria.withChildren(), fieldName, fieldValue);
}//end parent
//Case 5: CHildren
else if (fieldType === "Children"){
if(fieldNameUnparsed.indexOf("ATTR.") != -1){
switch(fieldName) {
case "CODE":
searchCriteria.withChildren().withCode().thatEquals(fieldValue);
break;
case "SAMPLE_TYPE":
searchCriteria.withChildren().withType().withCode().thatEquals(fieldValue);
break;
case "PERM_ID":
searchCriteria.withChildren().withPermId().thatEquals(fieldValue);
break;
case "SPACE":
searchCriteria.withChildren().withSpace().withCode().thatEquals(fieldValue);
break;
case "PROJECT":
searchCriteria.withChildren().withProject().withCode().thatEquals(fieldValue);
break;
case "PROJECT_PERM_ID":
searchCriteria.withChildren().withProject().withPermId().thatEquals(fieldValue);
break;
case "METAPROJECT":
searchCriteria.withChildren().withTag().withCode().thatEquals(fieldValue);
break;
case "REGISTRATION_DATE": //must be format 2009-08-18
searchCriteria.withChildren().withRegistrationDate().thatEquals(fieldValue);
break; break;
case "MODIFICATION_DATE": //must be format 2009-08-18 case "ATTR":
searchCriteria.withChildren().withModificationDate().thatEquals(fieldValue); setAttributeCriteria(searchCriteria.withChildren(), fieldName, fieldValue);
break; break;
default: }
//Do Nothing break;
} }
} else if(fieldNameUnparsed.indexOf("PROP.") != -1){
searchCriteria.withChildren().withProperty(fieldName).thatEquals(fieldValue);
}
} //end children
} }
//TO-DO Setting the fetchOptions given standard settings
var fetchOptions = new SampleFetchOptions();
fetchOptions.withTags();
fetchOptions.withType();
fetchOptions.withSpace();
fetchOptions.withExperiment();
fetchOptions.withRegistrator();
fetchOptions.withModifier();
fetchOptions.withParents();
fetchOptions.withProperties();
//to get all levels
//fetchOptions.withParentsWith(fetchOptions);
v3Api.searchSamples(searchCriteria, fetchOptions) v3Api.searchSamples(searchCriteria, fetchOptions)
.done(function(result) { .done(function(result) {
callback(result); //this will call the method defined in the AdvancedSearchController which will display the table callback(result); //this will call the method defined in the AdvancedSearchController which will display the table
......
...@@ -148,7 +148,7 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { ...@@ -148,7 +148,7 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) {
//how to make an on-select event?? //how to make an on-select event??
this._getNewFieldTypeDropdownComponent = function($newFieldNameContainer) { this._getNewFieldTypeDropdownComponent = function($newFieldNameContainer) {
var _this = this; var _this = this;
var fieldTypeOptions = [{value : "All", label : "All", selected : true }, {value : "Property", label : "Property"}, {value : "Attribute", label : "Attribute"}, {value : "Parent", label : "Parent"}, {value : "Children", label : "Children"}, {value : "Space", label : "Space"}]; var fieldTypeOptions = [{value : "All", label : "All", selected : true }, {value : "Property", label : "Property"}, {value : "Attribute", label : "Attribute"}, {value : "Parent", label : "Parent"}, {value : "Children", label : "Children"}];
var $fieldTypeComponent = FormUtil.getDropdown(fieldTypeOptions, "Select Field Type"); var $fieldTypeComponent = FormUtil.getDropdown(fieldTypeOptions, "Select Field Type");
$fieldTypeComponent.change(function() { $fieldTypeComponent.change(function() {
var $thisComponent = $(this); var $thisComponent = $(this);
...@@ -227,6 +227,11 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { ...@@ -227,6 +227,11 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) {
var prop = allProp[pIdx]; var prop = allProp[pIdx];
model.push({ value : "PROP." + prop.code, label : prop.label }); model.push({ value : "PROP." + prop.code, label : prop.label });
} }
model.sort(function(propertyA, propertyB) {
return propertyA.label.localeCompare(propertyB.label);
});
return model; return model;
} }
...@@ -265,8 +270,6 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { ...@@ -265,8 +270,6 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) {
{ value : "ATTR.SAMPLE_TYPE", label: "Sample Type" }, { value : "ATTR.SAMPLE_TYPE", label: "Sample Type" },
{ value : "ATTR.PERM_ID", label: "Perm Id" }, { value : "ATTR.PERM_ID", label: "Perm Id" },
{ value : "ATTR.SPACE", label: "Space" }, { value : "ATTR.SPACE", label: "Space" },
{ value : "ATTR.PROJECT", label: "Project" },
{ value : "ATTR.PROJECT_PERM_ID", label: "Project Perm Id" },
{ value : "ATTR.METAPROJECT", label: "Metaproject" }, { value : "ATTR.METAPROJECT", label: "Metaproject" },
{ value : "ATTR.REGISTRATION_DATE", label: "Registration Date" }, { value : "ATTR.REGISTRATION_DATE", label: "Registration Date" },
{ value : "ATTR.MODIFICATION_DATE", label: "Modification Date" }]; { value : "ATTR.MODIFICATION_DATE", label: "Modification Date" }];
...@@ -278,8 +281,6 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { ...@@ -278,8 +281,6 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) {
{ value : "ATTR.REGISTRATION_DATE", label : "Registration Date" }, { value : "ATTR.REGISTRATION_DATE", label : "Registration Date" },
{ value : "ATTR.MODIFICATION_DATE", label : "Modification Date" }]; { value : "ATTR.MODIFICATION_DATE", label : "Modification Date" }];
break; break;
default:
//Do Nothing
} }
return model; return model;
} }
...@@ -289,6 +290,7 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { ...@@ -289,6 +290,7 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) {
var model = [{ value : 'EXPERIMENT', label : "Experiment" }, var model = [{ value : 'EXPERIMENT', label : "Experiment" },
{ value : 'SAMPLE', label : "Sample", selected : true }, { value : 'SAMPLE', label : "Sample", selected : true },
{ value : 'DATASET', label : "Dataset" }]; { value : 'DATASET', label : "Dataset" }];
this._advancedSearchModel.resetModel('SAMPLE');
var $dropdown = FormUtil.getDropdown(model, 'Select Entity Type to search for'); var $dropdown = FormUtil.getDropdown(model, 'Select Entity Type to search for');
$dropdown.change(function() { $dropdown.change(function() {
......
...@@ -386,6 +386,9 @@ function SideMenuWidgetController(mainController) { ...@@ -386,6 +386,9 @@ function SideMenuWidgetController(mainController) {
new SideMenuWidgetComponent(true, false, "STORAGE MANAGER", "STORAGE_MANAGER", utilities, null, "showStorageManager", null, "") new SideMenuWidgetComponent(true, false, "STORAGE MANAGER", "STORAGE_MANAGER", utilities, null, "showStorageManager", null, "")
); );
} }
utilities.newMenuIfSelected.children.push(
new SideMenuWidgetComponent(true, false, "ADVANCED SEARCH", "ADVANCED_SEARCH", utilities, null, "showAdvancedSearchPage", null, "")
);
utilities.newMenuIfSelected.children.push( utilities.newMenuIfSelected.children.push(
new SideMenuWidgetComponent(true, false, "TRASHCAN", "TRASHCAN", utilities, null, "showTrashcanPage", null, "") new SideMenuWidgetComponent(true, false, "TRASHCAN", "TRASHCAN", utilities, null, "showTrashcanPage", null, "")
); );
......
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