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

SSDM-623: Copy parents and children when duplicating subexperiments/samples (set default bench).

SVN: 32134
parent e7dc7bf9
No related branches found
No related tags found
No related merge requests found
......@@ -817,6 +817,33 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod
}
if(!copyChildrenOnCopy) {
parameters["sampleChildren"] = [];
} else if(this.profile.storagesConfiguration["isEnabled"]) {
//1. All properties belonging to benches, to not to copy
parameters["notCopyProperties"] = [];
parameters["defaultBenchPropertyList"] = [];
for(var i = 0; i < this.profile.storagesConfiguration["STORAGE_PROPERTIES"].length; i++) {
var storagePropertyGroup = this.profile.storagesConfiguration["STORAGE_PROPERTIES"][i];
var listToUse = "notCopyProperties";
if(i === 0) {
listToUse = "defaultBenchPropertyList";
}
parameters[listToUse].push(storagePropertyGroup["NAME_PROPERTY"]);
parameters[listToUse].push(storagePropertyGroup["ROW_PROPERTY"]);
parameters[listToUse].push(storagePropertyGroup["COLUMN_PROPERTY"]);
parameters[listToUse].push(storagePropertyGroup["BOX_PROPERTY"]);
parameters[listToUse].push(storagePropertyGroup["USER_PROPERTY"]);
}
//2. Default Bench properties
var defaultStoragePropertyGroup = this.profile.storagesConfiguration["STORAGE_PROPERTIES"][0];
parameters["defaultBenchProperties"] = {};
var $benchDropdown = FormUtil.getDefaultBenchDropDown();
var defaultBench = $benchDropdown.children()[1].value;
parameters["defaultBenchProperties"][defaultStoragePropertyGroup["NAME_PROPERTY"]] = defaultBench;
parameters["defaultBenchProperties"][defaultStoragePropertyGroup["ROW_PROPERTY"]] = 1;
parameters["defaultBenchProperties"][defaultStoragePropertyGroup["COLUMN_PROPERTY"]] = 1;
parameters["defaultBenchProperties"][defaultStoragePropertyGroup["BOX_PROPERTY"]] = $("#sampleSpaceProject").val().replace(/\//g,'\/') + "_" + isCopyWithNewCode + "_EXP_RESULTS";
parameters["defaultBenchProperties"][defaultStoragePropertyGroup["USER_PROPERTY"]] = this.serverFacade.openbisServer.getSession().split("-")[0];
}
parameters["sampleChildrenNew"] = [];
parameters["sampleChildrenRemoved"] = [];
......
......@@ -167,7 +167,7 @@ def copySample(tr, parameters, tableBuilder):
if sampleChildren != None:
for sampleChildIdentifier in sampleChildren:
child = tr.getSample(sampleChildIdentifier); #Retrieve Sample child to copy
copyChildCode = parameters.get("sampleCode") + "_" + child.getCode();
copyChildCode = parameters.get("sampleCode") + child.getCode()[child.getCode().index('_'):];
copyChildIdentifier = "/" + parameters.get("sampleSpace") + "/" + copyChildCode;
# Create new sample children
......@@ -179,11 +179,29 @@ def copySample(tr, parameters, tableBuilder):
propertiesDefinitions = searchService.listPropertiesDefinitionsForSampleType(child.getSampleType());
for propertyDefinition in propertiesDefinitions:
propCode = propertyDefinition.getPropertyTypeCode();
propValue = child.getPropertyValue(propCode);
propValue = getCopySampleChildrenPropertyValue(
propCode,
child.getPropertyValue(propCode),
parameters.get("notCopyProperties"),
parameters.get("defaultBenchPropertyList"),
parameters.get("defaultBenchProperties")
);
if propValue != None:
childCopy.setPropertyValue(propCode, propValue);
return True;
#This method is used to return the properties, deleting the storage ones and setting the default storage
def getCopySampleChildrenPropertyValue(propCode, propValue, notCopyProperties, defaultBenchPropertyList, defaultBenchProperties):
isPropertyToSkip = any(propCode == s for s in notCopyProperties);
isDefaultBenchProperty = any(propCode == s for s in defaultBenchPropertyList);
print propCode + " " + str(isPropertyToSkip) + " " + str(isDefaultBenchProperty);
if isPropertyToSkip:
return None;
elif isDefaultBenchProperty:
return str(defaultBenchProperties[propCode]);
else:
return propValue;
def insertUpdateSample(tr, parameters, tableBuilder):
......
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