Skip to content
Snippets Groups Projects
Commit 311c6ceb authored by brinn's avatar brinn
Browse files

add: support for providing the parent data set code as column 'parent' in the index.tsv file

SVN: 12316
parent 4cfb7df9
No related branches found
No related tags found
No related merge requests found
......@@ -58,6 +58,7 @@ public class BatchDataSetInfoExtractor implements IDataSetInfoExtractor
info.setGroupCode(plainInfo.getGroupCode());
MLConversionType conversion = getConversion(plainInfo.getConversion());
info.setConversion(conversion);
info.setParentDataSetCode(plainInfo.getParentDataSetCode());
fileNameDecorator.enrich(info, incomingDataSetPath);
return info;
} else
......
......@@ -42,6 +42,8 @@ public class DataSetMappingInformation
private String groupCode;
private String conversion;
private String parentDataSetCode;
private List<NewProperty> properties;
......@@ -67,6 +69,20 @@ public class DataSetMappingInformation
this.sampleCodeOrLabel = StringUtils.trimToNull(sampleCodeOrLabel);
}
/**
* Returns the code of the parent data set, if any.
*/
public final String getParentDataSetCode()
{
return parentDataSetCode;
}
@BeanProperty(label="parent", optional = true)
public final void setParentDataSetCode(String parentCode)
{
this.parentDataSetCode = parentCode;
}
public String getExperimentName()
{
return experimentName;
......
......@@ -36,9 +36,11 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.NewProperty;
*/
public class DataSetInformationParserTest extends AbstractFileSystemTestCase
{
private static final String MANDATORY_HEADER = "file_name sample group\n";
private static final String HEADER =
// "# user@gmail.com\n+"+
"file_name sample group experiment conversion dataset_property_1 dataset_property_2\n";
"file_name sample parent group experiment project conversion dataset_property_1 dataset_property_2\n";
private static final String TAB = "\t";
......@@ -46,23 +48,42 @@ public class DataSetInformationParserTest extends AbstractFileSystemTestCase
public void testLoadIndexFile()
{
File indexFile =
writeMappingFile(HEADER + "data.txt sample1 group1 experiment1 fiaML v1 v2");
writeMappingFile(HEADER
+ "data.txt sample1 parentCode group1 experiment1 project1 fiaML v1 v2");
List<DataSetMappingInformation> list = tryParse(indexFile);
AssertJUnit.assertEquals(1, list.size());
DataSetMappingInformation elem = list.get(0);
AssertJUnit.assertEquals("group1", elem.getGroupCode());
AssertJUnit.assertEquals("parentCode", elem.getParentDataSetCode());
AssertJUnit.assertEquals("sample1", elem.getSampleCodeOrLabel());
AssertJUnit.assertEquals("data.txt", elem.getFileName());
AssertJUnit.assertEquals("experiment1", elem.getExperimentName());
AssertJUnit.assertEquals("project1", elem.getProjectCode());
AssertJUnit.assertEquals(2, elem.getProperties().size());
NewProperty prop1 = elem.getProperties().get(0);
AssertJUnit.assertEquals("v1", prop1.getValue());
AssertJUnit.assertEquals("dataset_property_1", prop1.getPropertyCode());
}
@Test
public void testLoadIndexFileMandatoryColumnsOnly()
{
File indexFile =
writeMappingFile(MANDATORY_HEADER
+ "data2.txt sample2 group2");
List<DataSetMappingInformation> list = tryParse(indexFile);
AssertJUnit.assertEquals(1, list.size());
DataSetMappingInformation elem = list.get(0);
AssertJUnit.assertEquals("group2", elem.getGroupCode());
AssertJUnit.assertEquals("sample2", elem.getSampleCodeOrLabel());
AssertJUnit.assertEquals("data2.txt", elem.getFileName());
}
@Test
public void testLoadIndexFileWithMissingFieldValueFails() throws FileNotFoundException,
IOException
{
File indexFile = writeMappingFile(HEADER + TAB + TAB + TAB + TAB + TAB + TAB);
File indexFile = writeMappingFile(HEADER + TAB + TAB + TAB + TAB + TAB + TAB + TAB + TAB);
List<DataSetMappingInformation> result = tryParse(indexFile);
AssertJUnit.assertNull("error during parsing expected", result);
List<String> logLines = readLogFile();
......
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