From a77306b1da83c69a3736d0e6e5343ed219f65876 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Fri, 18 Sep 2015 09:30:06 +0000 Subject: [PATCH] SSDM-2495 : Refactoring, removing/merging sample search calls SVN: 34666 --- .../eln-lims/html/js/server/ServerFacade.js | 42 ++++--------------- .../views/SampleForm/SampleFormController.js | 19 +-------- .../SampleForm/widgets/DilutionTableView.js | 2 +- .../js/views/SampleTable/SampleTableView.js | 2 +- .../html/js/views/legacy/SampleLinksWidget.js | 2 +- 5 files changed, 13 insertions(+), 54 deletions(-) diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js index c7b302c21f9..50f7f946148 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js @@ -598,7 +598,7 @@ function ServerFacade(openbisServer) { }); } - this.searchWithTypeAndLinks = function(sampleType, sampleCode, callbackFunction) + this.searchWithType = function(sampleType, sampleCode, includeAncestorsAndDescendants, callbackFunction) { var matchClauses = [ {"@type":"AttributeMatchClause", fieldType : "ATTRIBUTE", @@ -624,8 +624,14 @@ function ServerFacade(openbisServer) { operator : "MATCH_ALL_CLAUSES" }; + var options = ["PROPERTIES"]; + if(includeAncestorsAndDescendants) { + options.push("ANCESTORS"); + options.push("DESCENDANTS"); + } + var localReference = this; - this.openbisServer.searchForSamplesWithFetchOptions(sampleCriteria, ["PROPERTIES", "ANCESTORS", "DESCENDANTS"], function(data) { + this.openbisServer.searchForSamplesWithFetchOptions(sampleCriteria, options, function(data) { callbackFunction(localReference.getInitializedSamples(data.result)); }); } @@ -634,38 +640,6 @@ function ServerFacade(openbisServer) { this.openbisServer.getDataSetMetaDataWithFetchOptions(dataSetCodes, [ 'SAMPLE' ], callback); } - this.searchWithType = function(sampleType, sampleCode, callbackFunction) - { - var matchClauses = [ {"@type":"AttributeMatchClause", - fieldType : "ATTRIBUTE", - attribute : "TYPE", - desiredValue : sampleType - } - ] - - if(sampleCode){ - matchClauses.push( - { - "@type":"AttributeMatchClause", - fieldType : "ATTRIBUTE", - attribute : "CODE", - desiredValue : sampleCode - } - ); - } - - var sampleCriteria = - { - matchClauses : matchClauses, - operator : "MATCH_ALL_CLAUSES" - }; - - var localReference = this; - this.openbisServer.searchForSamplesWithFetchOptions(sampleCriteria, ["PROPERTIES"], function(data) { - callbackFunction(localReference.getInitializedSamples(data.result)); - }); - } - this.searchWithExperiment = function(experimentIdentifier, callbackFunction) { var matchClauses = [ {"@type":"AttributeMatchClause", diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js index 459b3a9e98f..69dfd4982ae 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js @@ -64,27 +64,12 @@ function SampleFormController(mainController, mode, sample) { return this._storageControllers[this._storageControllers.length-1]; } -// this.addStorageController = function(storagePropertyGroupName) { -// var storageController = new StorageController({ -// title : null, -// storagePropertyGroupSelector : "off", -// storageSelector : "on", -// userSelector : "off", -// boxSelector: "on", -// boxSizeSelector: "on", -// rackSelector: "on", -// contentsSelector: "off", -// positionSelector: "on" -// }); -// storageController.getModel().storagePropertyGroup = profile.getStoragePropertyGroup(storagePropertyGroupName); -// this._storageControllers.push(storageController); -// } - this.getNextCopyCode = function(callback) { var _this = this; mainController.serverFacade.searchWithType( this._sampleFormModel.sample.sampleTypeCode, this._sampleFormModel.sample.code + "_*", + false, function(results) { callback(_this._sampleFormModel.sample.code + "_" + (results.length + 1)); }); @@ -317,7 +302,7 @@ function SampleFormController(mainController, mode, sample) { var searchUntilFound = null; searchUntilFound = function() { - mainController.serverFacade.searchWithType(_this._sampleFormModel.sample.sampleTypeCode, sampleCodeToOpen, function(data) { + mainController.serverFacade.searchWithType(_this._sampleFormModel.sample.sampleTypeCode, sampleCodeToOpen, false, function(data) { if(data && data.length === 1) { mainController.changeView('showViewSamplePageFromPermId',data[0].permId); } else { //Recursive call diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/DilutionTableView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/DilutionTableView.js index c895aa3127d..bb20f1013a2 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/DilutionTableView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/DilutionTableView.js @@ -23,7 +23,7 @@ function DilutionTableView(dilutionTableController, dilutionTableModel) { $container.append("Loading data for Dilution Widget."); var _this = this; //Load all proteins - mainController.serverFacade.searchWithTypeAndLinks("PROTEIN", null, function(data) { + mainController.serverFacade.searchWithType("PROTEIN", null, true, function(data) { _this._dilutionTableModel.allProteins = data; //First repaint after all initializations diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js index 1865636aa46..bcdef2e941d 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js @@ -137,7 +137,7 @@ function SampleTableView(sampleTableController, sampleTableModel) { var $sampleTypesSelector = FormUtil.getSampleTypeDropdown(null, false); $sampleTypesSelector.change(function() { var sampleTypeToShow = $(this).val(); - mainController.serverFacade.searchWithType(sampleTypeToShow, null, function(samples) { + mainController.serverFacade.searchWithType(sampleTypeToShow, null, false, function(samples) { _this._sampleTableModel.allSamples = samples; _this._sampleTableController._reloadTableWithSampleType(sampleTypeToShow); }); diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleLinksWidget.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleLinksWidget.js index 4055b322542..4d0ba952a00 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleLinksWidget.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleLinksWidget.js @@ -227,7 +227,7 @@ function SampleLinksWidget(containerId, profile, serverFacade, title, sampleType if(sampleType !== null) { - mainController.serverFacade.searchWithType(sampleTypeCode, null, function(samples) { + mainController.serverFacade.searchWithType(sampleTypeCode, null, false, function(samples) { //Clear last state if(_this._lastUsedId) { $('#'+_this._lastUsedId + "-table").empty(); -- GitLab