diff --git a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/etlserver/proteomics/DataSetInfoExtractorForProteinResults.java b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/etlserver/proteomics/DataSetInfoExtractorForProteinResults.java index 004b41002211ec9c5ce4abc6761d820b33aca68d..660a145f794da47f2c4d74a4eeef5747be4f1a56 100644 --- a/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/etlserver/proteomics/DataSetInfoExtractorForProteinResults.java +++ b/rtd_phosphonetx/source/java/ch/systemsx/cisd/openbis/etlserver/proteomics/DataSetInfoExtractorForProteinResults.java @@ -47,7 +47,10 @@ public class DataSetInfoExtractorForProteinResults extends AbstractDataSetInfoEx { @Private static final String EXPERIMENT_TYPE_CODE_KEY = "experiment-type-code"; - + + @Private + static final String EXPERIMENT_CODE_KEY = "experiment-code"; + @Private static final String EXPERIMENT_PROPERTIES_FILE_NAME_KEY = "experiment-properties-file-name"; @@ -103,15 +106,19 @@ public class DataSetInfoExtractorForProteinResults extends AbstractDataSetInfoEx + separator + "': " + name); } ProjectIdentifier projectIdentifier = new ProjectIdentifier(items[0], items[1]); - String experimentCode = service.generateCodes("E", EntityKind.EXPERIMENT, 1).get(0); + Properties properties = + loadSearchProperties(new File(incomingDataSetPath, experimentPropertiesFileName)); + String experimentCode = properties.getProperty(EXPERIMENT_CODE_KEY); + if (experimentCode == null) + { + experimentCode = service.generateCodes("E", EntityKind.EXPERIMENT, 1).get(0); + } ExperimentIdentifier experimentIdentifier = new ExperimentIdentifier(projectIdentifier, experimentCode); NewExperiment experiment = new NewExperiment(experimentIdentifier.toString(), experimentTypeCode); ExperimentType experimentType = service.getExperimentType(experimentTypeCode); - Properties properties = - loadSearchProperties(new File(incomingDataSetPath, experimentPropertiesFileName)); experiment.setProperties(Util.getAndCheckProperties(properties, experimentType)); DataSetInformation info = new DataSetInformation(); info.setExperimentIdentifier(experimentIdentifier); diff --git a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/etlserver/proteomics/DataSetInfoExtractorForProteinResultsTest.java b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/etlserver/proteomics/DataSetInfoExtractorForProteinResultsTest.java index ce688c86d2ec7673ba2ab198628afdf534f987ff..9996c181795427528a6b43b9c7a8061c644b6b71 100644 --- a/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/etlserver/proteomics/DataSetInfoExtractorForProteinResultsTest.java +++ b/rtd_phosphonetx/sourceTest/java/ch/systemsx/cisd/openbis/etlserver/proteomics/DataSetInfoExtractorForProteinResultsTest.java @@ -119,6 +119,32 @@ public class DataSetInfoExtractorForProteinResultsTest extends AbstractFileSyste assertEquals("[1, 2, 3, 4]", info.getParentDataSetCodes().toString()); context.assertIsSatisfied(); } + + @Test + public void testWithProvidedExperimentCode() + { + String propertiesFile = "my.properties"; + FileUtilities.writeToFile(new File(dataSet, propertiesFile), "answer=42\nblabla=blub\n" + + DataSetInfoExtractorForProteinResults.EXPERIMENT_CODE_KEY + "= MY_EXP1\n"); + Properties properties = new Properties(); + String experimentType = "MY_EXPERIMENT"; + properties.setProperty(EXPERIMENT_TYPE_CODE_KEY, experimentType); + properties.setProperty(EXPERIMENT_PROPERTIES_FILE_NAME_KEY, propertiesFile); + prepare(experimentType, false); + context.checking(new Expectations() + { + { + one(service).registerExperiment(with(any(NewExperiment.class))); + } + }); + + IDataSetInfoExtractor extractor = createExtractor(properties); + + DataSetInformation info = extractor.getDataSetInformation(dataSet, service); + + assertEquals("/SPACE1/PROJECT1/MY_EXP1", info.getExperimentIdentifier().toString()); + context.assertIsSatisfied(); + } @Test public void testRegistrationWithOneMandatoryProperty() @@ -351,12 +377,20 @@ public class DataSetInfoExtractorForProteinResultsTest extends AbstractFileSyste } private void prepare(final String experimentType) + { + prepare(experimentType, true); + } + + private void prepare(final String experimentType, final boolean experimentCodeGenerated) { context.checking(new Expectations() { { - one(service).generateCodes("E", EntityKind.EXPERIMENT, 1); - will(returnValue(Collections.singletonList("E4711"))); + if (experimentCodeGenerated) + { + one(service).generateCodes("E", EntityKind.EXPERIMENT, 1); + will(returnValue(Collections.singletonList("E4711"))); + } one(service).getExperimentType(experimentType); ExperimentType type = new ExperimentType();