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

SSDM-623: Copy parents and children when duplicating subexperiments/samples (ongoing work).

SVN: 32127
parent bc691e85
No related branches found
No related tags found
No related merge requests found
...@@ -166,15 +166,23 @@ def copySample(tr, parameters, tableBuilder): ...@@ -166,15 +166,23 @@ def copySample(tr, parameters, tableBuilder):
#Copy children and attach to Sample #Copy children and attach to Sample
if sampleChildren != None: if sampleChildren != None:
for sampleChildIdentifier in sampleChildren: for sampleChildIdentifier in sampleChildren:
child = tr.getSampleForUpdate(sampleChildIdentifier); #Retrieve Sample child to copy child = tr.getSample(sampleChildIdentifier); #Retrieve Sample child to copy
copyChildCode = parameters.get("sampleCode") + "_" + child.getCode(); copyChildCode = parameters.get("sampleCode") + "_" + child.getCode();
copyChildIdentifier = "/" + parameters.get("sampleSpace") + "/" + copyChildCode; copyChildIdentifier = "/" + parameters.get("sampleSpace") + "/" + copyChildCode;
# Create new sample children # Create new sample children
child = tr.createNewSample(copyChildIdentifier, child.getSampleType()); #Create Sample given his id childCopy = tr.createNewSample(copyChildIdentifier, child.getSampleType()); #Create Sample given his id
childParents = child.getParentSampleIdentifiers(); childParents = childCopy.getParentSampleIdentifiers();
childParents.add(sampleIdentifier); childParents.add(sampleIdentifier);
child.setParentSampleIdentifiers(childParents); childCopy.setParentSampleIdentifiers(childParents);
searchService = tr.getSearchService();
propertiesDefinitions = searchService.listPropertiesDefinitionsForSampleType(child.getSampleType());
for propertyDefinition in propertiesDefinitions:
propCode = propertyDefinition.getPropertyTypeCode();
propValue = child.getPropertyValue(propCode);
if propValue != None:
childCopy.setPropertyValue(propCode, propValue);
return True; return True;
def insertUpdateSample(tr, parameters, tableBuilder): 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