From 516369b843de6dcd2d0ecd00870619490ba2629b Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Thu, 11 Nov 2010 17:18:46 +0000 Subject: [PATCH] [LMS-1772] fixed multi-parent operations and comment in template SVN: 18643 --- .../generic/shared/basic/dto/NewSample.java | 7 +++++-- .../parser/NewSampleParserObjectFactory.java | 20 ++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) 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 12dadda8411..3ca2619cefa 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 e1f17b0034f..f997cebd8e2 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())); -- GitLab