From 448d04c7cfccac8940a00ca03813d9b206cd13b3 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Thu, 12 Nov 2015 10:22:27 +0000 Subject: [PATCH] SSDM-2601: FullSampleIndetifier normalizes the codes SVN: 35046 --- .../api/v3/executor/sample/FullSampleIdentifier.java | 6 ++++-- .../api/v3/executor/sample/FullSampleIdentifierTest.java | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/FullSampleIdentifier.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/FullSampleIdentifier.java index 441695289f1..f33472edcf1 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/FullSampleIdentifier.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/FullSampleIdentifier.java @@ -23,6 +23,7 @@ import java.util.StringTokenizer; import org.apache.commons.lang.StringUtils; import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.sample.SampleIdentifier; +import ch.systemsx.cisd.openbis.generic.shared.basic.CodeConverter; /** * Helper class which parses a sample identifier string. @@ -80,8 +81,9 @@ public class FullSampleIdentifier verifyCodePattern(containerCode, "Container sample code"); verifyCodePattern(plainSampleCode, containerCode == null ? "Sample code" : "Sample subcode"); - sampleCode = plainSampleCode; - sampleIdentifierParts = new SampleIdentifierParts(spaceCode, projectCode, containerCode); + sampleCode = CodeConverter.tryToDatabase(plainSampleCode); + sampleIdentifierParts = new SampleIdentifierParts(CodeConverter.tryToDatabase(spaceCode), + CodeConverter.tryToDatabase(projectCode), CodeConverter.tryToDatabase(containerCode)); } diff --git a/openbis/sourceTest/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/FullSampleIdentifierTest.java b/openbis/sourceTest/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/FullSampleIdentifierTest.java index f74dfa8e1e1..6dd19ca330a 100644 --- a/openbis/sourceTest/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/FullSampleIdentifierTest.java +++ b/openbis/sourceTest/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/sample/FullSampleIdentifierTest.java @@ -38,10 +38,11 @@ public class FullSampleIdentifierTest assertSampId("/SPACE1/S2:A02"); assertSampId("/SPACE1/PROJECT1/S1"); assertSampId("/SPACE1/PROJECT1/S1:A02"); - assertSampIdWithHomeSpace("/HS/S1", "//S1", "HS"); - assertSampIdWithHomeSpace("/HS/C1:S1", "//C1:S1", "HS"); - assertSampIdWithHomeSpace("/HS/PROJECT1/S1", "//PROJECT1/S1", "HS"); - assertSampIdWithHomeSpace("/HS/PROJECT1/C1:S1", "//PROJECT1/C1:S1", "HS"); + assertSampIdWithHomeSpace("/HS/S1", "//s1", "HS"); + assertSampIdWithHomeSpace("/HS/C1:S1", "//c1:s1", "HS"); + assertSampIdWithHomeSpace("/HS/PROJECT1/S1", "//Project1/s1", "HS"); + assertSampIdWithHomeSpace("/HS/PROJECT1/C1:S1", "//project1/c1:s1", "HS"); + assertSampIdWithHomeSpace("/SP1/PROJECT1/C1:S1", "/sp1/project1/c1:s1", "HS"); } @Test -- GitLab