diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSample.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSample.java index 12dadda841177abd0b804f310e99d7b1ada02469..3ca2619cefa76ccf7ba56797da080387928349b4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSample.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSample.java @@ -30,7 +30,7 @@ public class NewSample extends Identifier<NewSample> implements Comparable<NewSa private static final long serialVersionUID = ServiceVersionHolder.VERSION; public static final String SAMPLE_REGISTRATION_TEMPLATE_COMMENT = - "# The \"container\" and \"parents\" columns are optional, only one should be specified. " + "# The \"container\" and \"parents\" columns are optional, only one should be specified.\n" + "# \"container\" should contain a sample identifier, e.g. /SPACE/SAMPLE_1, while \"parents\" should contain comma separated list of sample identifiers. \n" + "# If \"container\" sample is provided, the registered sample will become a \"component\" of it.\n" + "# If \"parents\" are provided, the registered sample will become a \"child\" of all specified samples.\n" @@ -156,7 +156,10 @@ public class NewSample extends Identifier<NewSample> implements Comparable<NewSa : getParentsOrNull()[0]; } - /** @deprecated convenience method for tests - use {@link #setParents(String)} instead */ + /** + * @deprecated kept for backward compatibility and used as a convenience method for tests - use + * {@link #setParents(String)} instead + */ @Deprecated @BeanProperty(label = PARENT, optional = true) public final void setParentIdentifier(final String parent) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactory.java index e1f17b0034fc6fe3c714c0413fbfcb9bb2a01254..f997cebd8e2db3261970b621e3d21cd88b407590 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/parser/NewSampleParserObjectFactory.java @@ -93,7 +93,6 @@ class NewSampleParserObjectFactory extends AbstractParserObjectFactory<NewSample return true; } - @SuppressWarnings("deprecation") @Override public NewSample createObject(final String[] lineTokens) throws ParserException { @@ -117,9 +116,24 @@ class NewSampleParserObjectFactory extends AbstractParserObjectFactory<NewSample setProperties(newSample, lineTokens); newSample .setContainerIdentifier(StringUtils.trimToNull(newSample.getContainerIdentifier())); - if (newSample.getParentIdentifier() != null) + if (newSample.getParentsOrNull() != null) { - newSample.setParentIdentifier(StringUtils.trimToNull(newSample.getParentIdentifier())); + List<String> parents = new ArrayList<String>(); + for (String parent : newSample.getParentsOrNull()) + { + String trimmedOrNull = StringUtils.trimToNull(parent); + if (trimmedOrNull != null) + { + parents.add(trimmedOrNull); + } + } + if (parents.size() == 0) + { + newSample.setParentsOrNull(null); + } else + { + newSample.setParentsOrNull(parents.toArray(new String[0])); + } } newSample.setExperimentIdentifier(StringUtils.trimToNull(newSample .getExperimentIdentifier()));