From 7a48d664bb701cf234a2172891b5940646596be6 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Wed, 25 Jun 2014 14:29:11 +0000 Subject: [PATCH] SSDM-516: Add Sample Children to Storage during creation SVN: 31789 --- .../newbrowser/html/js/util/FormUtil.js | 12 ++++++++++ .../newbrowser/html/js/views/SampleForm.js | 23 ++++++++++++++++--- .../reporting-plugins/newbrowserapi/script.py | 6 +++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/util/FormUtil.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/util/FormUtil.js index 6e09ccbebbe..0846dfa2294 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/util/FormUtil.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/util/FormUtil.js @@ -17,6 +17,18 @@ var FormUtil = new function() { // // Standard Form Fields // + this.getDefaultStoragesDropDown = function(id, isRequired) { + if(!this.profile.storagesConfiguration["isEnabled"]) { + return null; + } + var storageVocabularyProp = this.profile.getPropertyType(this.profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["NAME_PROPERTY"]); + var $storageDropDown = this.getFieldForPropertyType(storageVocabularyProp); + $storageDropDown.attr('id', id); + if (isRequired) { + $storageDropDown.attr('required', ''); + } + return $storageDropDown; + } this.getSampleTypeDropdown = function(id, isRequired) { var sampleTypes = this.profile.getAllSampleTypes(); diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js index 51ab3f8ca7b..764a1c4dc08 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js @@ -340,6 +340,14 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod }); } + this.childrenAdded = function() { + var $childrenStorageDropdown = FormUtil.getDefaultStoragesDropDown('childrenStorageSelector', true); + if($childrenStorageDropdown && !$("#childrenStorageSelector").length) { + var $childrenStorageDropdownWithLabel = FormUtil.getFieldForComponentWithLabel($childrenStorageDropdown, 'Storage'); + $("#newChildrenOnBenchDropDown").append($childrenStorageDropdownWithLabel); + } + } + this.repaint = function() { $("#"+this.containerId).empty(); var sampleType = profile.getSampleTypeForSampleTypeCode(this.sampleTypeCode); @@ -481,6 +489,7 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod component += "<a class='btn btn-default' style='margin-left:25px;' id='generate_children'>Generate Children</a>"; component += "</div>"; component += "</div>"; + component += "<div id='newChildrenOnBenchDropDown'></div>"; } @@ -650,6 +659,7 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod this.createSample = function(isCopyWithNewCode) { Util.blockUI(); + var localReference = this; //Other properties var properties = {}; @@ -744,6 +754,14 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod var samplesToCreate = []; this.sampleLinksChildren.getSamples().forEach(function(child) { if(child.newSample) { + if(this.profile.storagesConfiguration["isEnabled"]) { + child.properties = {}; + child.properties[localReference.profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["NAME_PROPERTY"]] = $("#childrenStorageSelector").val(); + child.properties[localReference.profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["ROW_PROPERTY"]] = 1; + child.properties[localReference.profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["COLUMN_PROPERTY"]] = 1; + child.properties[localReference.profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["BOX_PROPERTY"]] = $("#sampleSpaceProject").val().replace(/\//g,'\/') + "_" + $("#sampleCode").val() + "_EXP_RESULTS"; + child.properties[localReference.profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["USER_PROPERTY"]] = localReference.serverFacade.openbisServer.getSession().split("-")[0]; + } samplesToCreate.push(child); } }); @@ -784,8 +802,6 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod parameters["sampleChildrenRemoved"] = []; } - var localReference = this; - if(this.profile.allDataStores.length > 0) { this.serverFacade.createReportFromAggregationService(this.profile.allDataStores[0].code, parameters, function(response) { localReference.createSampleCallback(response, localReference, isCopyWithNewCode); @@ -969,7 +985,8 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod virtualSample.sampleTypeCode = generatedChildrenType; _this.sampleLinksChildren.addSample(virtualSample); } - + + _this.childrenAdded(); Util.unblockUI(); } diff --git a/plasmid/source/core-plugins/newbrowser/1/dss/reporting-plugins/newbrowserapi/script.py b/plasmid/source/core-plugins/newbrowser/1/dss/reporting-plugins/newbrowserapi/script.py index 485c4f107c1..5b49fd381ce 100644 --- a/plasmid/source/core-plugins/newbrowser/1/dss/reporting-plugins/newbrowserapi/script.py +++ b/plasmid/source/core-plugins/newbrowser/1/dss/reporting-plugins/newbrowserapi/script.py @@ -183,6 +183,12 @@ def insertUpdateSample(tr, parameters, tableBuilder): for newSampleChild in sampleChildrenNew: child = tr.createNewSample(newSampleChild["identifier"], newSampleChild["sampleTypeCode"]); #Create Sample given his id child.setParentSampleIdentifiers([sampleIdentifier]); + for key in newSampleChild["properties"].keySet(): + propertyValue = unicode(newSampleChild["properties"][key]); + if propertyValue == "": + propertyValue = None; + + child.setPropertyValue(key,propertyValue); #Add sample children for sampleChildIdentifier in sampleChildren: -- GitLab