Skip to content
Snippets Groups Projects
Commit 2aa8d543 authored by cramakri's avatar cramakri
Browse files

LMS-1909 Fixed minor inconsistencies in the Sample/Data Set registration processes. Fixed tests.

SVN: 19140
parent 8eab33f0
No related branches found
No related tags found
No related merge requests found
Showing
with 48 additions and 57 deletions
...@@ -37,8 +37,6 @@ import ch.systemsx.cisd.common.utilities.UnicodeUtils; ...@@ -37,8 +37,6 @@ import ch.systemsx.cisd.common.utilities.UnicodeUtils;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType;
import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.DatabaseInstanceIdentifier;
import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SpaceIdentifier;
import ch.systemsx.cisd.openbis.generic.shared.parser.BisTabFileLoader; import ch.systemsx.cisd.openbis.generic.shared.parser.BisTabFileLoader;
import ch.systemsx.cisd.openbis.generic.shared.parser.GlobalProperties; import ch.systemsx.cisd.openbis.generic.shared.parser.GlobalProperties;
import ch.systemsx.cisd.openbis.generic.shared.parser.GlobalPropertiesLoader; import ch.systemsx.cisd.openbis.generic.shared.parser.GlobalPropertiesLoader;
...@@ -74,21 +72,6 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce ...@@ -74,21 +72,6 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce
properties = GlobalPropertiesLoader.load(controlFile); properties = GlobalPropertiesLoader.load(controlFile);
} }
public String trySpaceCode()
{
return properties.get(SampleAndDataSetRegistrationHandler.DATA_SPACE_CONTROL_FILE_KEY);
}
public SpaceIdentifier trySpaceIdentifier()
{
String spaceCode = trySpaceCode();
if (null == spaceCode)
{
return null;
}
return new SpaceIdentifier(DatabaseInstanceIdentifier.createHome(), spaceCode);
}
public SampleType trySampleType() public SampleType trySampleType()
{ {
String sampleTypeCode = String sampleTypeCode =
...@@ -168,19 +151,6 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce ...@@ -168,19 +151,6 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce
return globalProperties; return globalProperties;
} }
/**
* Returns a space identifier. Call checkValidity first.
*/
public SpaceIdentifier getSpaceIdentifier()
{
SpaceIdentifier spaceIdentifier = overrideProperties.trySpaceIdentifier();
if (null == spaceIdentifier)
{
spaceIdentifier = globalProperties.trySpaceIdentifier();
}
return spaceIdentifier;
}
public SampleType getSampleType() public SampleType getSampleType()
{ {
SampleType sampleType = overrideProperties.trySampleType(); SampleType sampleType = overrideProperties.trySampleType();
...@@ -208,18 +178,12 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce ...@@ -208,18 +178,12 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce
public void checkValidity() public void checkValidity()
{ {
SpaceIdentifier spaceIdentifier = getSpaceIdentifier();
SampleType sampleType = getSampleType(); SampleType sampleType = getSampleType();
DataSetType dataSetType = getDataSetType(); DataSetType dataSetType = getDataSetType();
Person theUser = getUser(); Person theUser = getUser();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
boolean hasError = false; boolean hasError = false;
if (null == spaceIdentifier)
{
hasError = true;
sb.append("\tNo default space identifier has been specified, and no space identifier was specified in the control file.");
}
if (null == sampleType) if (null == sampleType)
{ {
hasError = true; hasError = true;
...@@ -340,10 +304,9 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce ...@@ -340,10 +304,9 @@ class SampleAndDataSetControlFileProcessor extends AbstractSampleAndDataSetProce
{ {
String message = String message =
String.format( String.format(
"Global properties extracted from file '%s': SAMPLE_TYPE(%s) DATA_SET_TYPE(%s) DEFAULT_SPACE(%s) USER(%s)", "Global properties extracted from file '%s': SAMPLE_TYPE(%s) DATA_SET_TYPE(%s) USER(%s)",
controlFile.getName(), properties.trySampleType(), controlFile.getName(), properties.trySampleType(),
properties.tryDataSetType(), properties.trySpaceCode(), properties.tryDataSetType(), properties.tryUserString());
properties.tryUserString());
logInfo(message); logInfo(message);
} }
......
...@@ -18,10 +18,12 @@ package ch.systemsx.cisd.etlserver.entityregistration; ...@@ -18,10 +18,12 @@ package ch.systemsx.cisd.etlserver.entityregistration;
import java.io.File; import java.io.File;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.etlserver.IExtensibleDataSetHandler; import ch.systemsx.cisd.etlserver.IExtensibleDataSetHandler;
import ch.systemsx.cisd.etlserver.TransferredDataSetHandler; import ch.systemsx.cisd.etlserver.TransferredDataSetHandler;
import ch.systemsx.cisd.etlserver.entityregistration.SampleAndDataSetControlFileProcessor.ControlFileRegistrationProperties; import ch.systemsx.cisd.etlserver.entityregistration.SampleAndDataSetControlFileProcessor.ControlFileRegistrationProperties;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.FileFormatType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
import ch.systemsx.cisd.openbis.generic.shared.dto.NewExternalData; import ch.systemsx.cisd.openbis.generic.shared.dto.NewExternalData;
...@@ -58,6 +60,12 @@ class SampleAndDataSetRegistrator extends AbstractSampleAndDataSetProcessor impl ...@@ -58,6 +60,12 @@ class SampleAndDataSetRegistrator extends AbstractSampleAndDataSetProcessor impl
public Exception register() public Exception register()
{ {
File dataSetFile = new File(folder, sampleDataSetPair.getFolderName()); File dataSetFile = new File(folder, sampleDataSetPair.getFolderName());
Exception isEmptyException = checkDataSetFileNotEmpty(dataSetFile);
if (null != isEmptyException)
{
return isEmptyException;
}
if (globalState.getDelegator() instanceof IExtensibleDataSetHandler) if (globalState.getDelegator() instanceof IExtensibleDataSetHandler)
{ {
IExtensibleDataSetHandler handler = IExtensibleDataSetHandler handler =
...@@ -71,6 +79,15 @@ class SampleAndDataSetRegistrator extends AbstractSampleAndDataSetProcessor impl ...@@ -71,6 +79,15 @@ class SampleAndDataSetRegistrator extends AbstractSampleAndDataSetProcessor impl
return failureException; return failureException;
} }
private Exception checkDataSetFileNotEmpty(File dataSetFile)
{
if (0 == dataSetFile.list().length)
{
return new UserFailureException("The data set folder cannot be empty");
}
return null;
}
private void logDataRegistered() private void logDataRegistered()
{ {
String message = String.format("Registered sample/data set pair %s", sampleDataSetPair); String message = String.format("Registered sample/data set pair %s", sampleDataSetPair);
...@@ -79,6 +96,14 @@ class SampleAndDataSetRegistrator extends AbstractSampleAndDataSetProcessor impl ...@@ -79,6 +96,14 @@ class SampleAndDataSetRegistrator extends AbstractSampleAndDataSetProcessor impl
public void registerDataSetInApplicationServer(NewExternalData data) public void registerDataSetInApplicationServer(NewExternalData data)
{ {
data.setDataSetType(properties.getDataSetType());
if (null != sampleDataSetPair.getFileFormatTypeCode())
{
FileFormatType fileFormatType =
new FileFormatType(sampleDataSetPair.getFileFormatTypeCode());
data.setFileFormatType(fileFormatType);
}
try try
{ {
Sample sample = Sample sample =
...@@ -93,6 +118,11 @@ class SampleAndDataSetRegistrator extends AbstractSampleAndDataSetProcessor impl ...@@ -93,6 +118,11 @@ class SampleAndDataSetRegistrator extends AbstractSampleAndDataSetProcessor impl
didSucceed = false; didSucceed = false;
failureException = e; failureException = e;
throw e; throw e;
} catch (Exception e)
{
didSucceed = false;
failureException = e;
throw new CheckedExceptionTunnel(e);
} }
} }
......
...@@ -44,8 +44,6 @@ public class SampleDataSetPair ...@@ -44,8 +44,6 @@ public class SampleDataSetPair
private final static String DATA_SET_CODE = "D_code"; private final static String DATA_SET_CODE = "D_code";
private final static String DATA_SET_TYPE = "D_data_set_type";
private final static String DATA_SET_FILE_TYPE = "D_file_type"; private final static String DATA_SET_FILE_TYPE = "D_file_type";
private final static String FOLDER = "FOLDER"; private final static String FOLDER = "FOLDER";
...@@ -58,6 +56,8 @@ public class SampleDataSetPair ...@@ -58,6 +56,8 @@ public class SampleDataSetPair
private String folderName; private String folderName;
private String fileFormatTypeCode;
public SampleDataSetPair() public SampleDataSetPair()
{ {
newSample = new NewSample(); newSample = new NewSample();
...@@ -84,7 +84,7 @@ public class SampleDataSetPair ...@@ -84,7 +84,7 @@ public class SampleDataSetPair
return dataSetInformation; return dataSetInformation;
} }
@BeanProperty(label = SAMPLE_IDENTIFIER, optional = true) @BeanProperty(label = SAMPLE_IDENTIFIER, optional = false)
public void setSampleIdentifier(String sampleIdentifier) public void setSampleIdentifier(String sampleIdentifier)
{ {
this.newSample.setIdentifier(sampleIdentifier); this.newSample.setIdentifier(sampleIdentifier);
...@@ -114,14 +114,15 @@ public class SampleDataSetPair ...@@ -114,14 +114,15 @@ public class SampleDataSetPair
dataSetInformation.setDataSetCode(code); dataSetInformation.setDataSetCode(code);
} }
@BeanProperty(label = DATA_SET_TYPE, optional = true) public String getFileFormatTypeCode()
public void setDataSetType(String parent)
{ {
return fileFormatTypeCode;
} }
@BeanProperty(label = DATA_SET_FILE_TYPE, optional = true) @BeanProperty(label = DATA_SET_FILE_TYPE, optional = true)
public void setDataSetFileType(String experimentIdentifier) public void setFileFormatTypeCode(String fileFormatType)
{ {
this.fileFormatTypeCode = fileFormatType;
} }
public String getFolderName() public String getFolderName()
...@@ -129,7 +130,7 @@ public class SampleDataSetPair ...@@ -129,7 +130,7 @@ public class SampleDataSetPair
return folderName; return folderName;
} }
@BeanProperty(label = FOLDER, optional = true) @BeanProperty(label = FOLDER, optional = false)
public void setFolderName(String folderName) public void setFolderName(String folderName)
{ {
this.folderName = folderName; this.folderName = folderName;
......
...@@ -95,8 +95,6 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT ...@@ -95,8 +95,6 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT
setupOpenBisExpectations(); setupOpenBisExpectations();
setupDataSetHandlerExpectations(dataSetInfoMatcher, newSampleMatcher); setupDataSetHandlerExpectations(dataSetInfoMatcher, newSampleMatcher);
// setupSessionContextExpectations();
// setupCallerDataSetInfoExpectations();
File workingCopy = createWorkingCopyOfTestFolder("basic-example"); File workingCopy = createWorkingCopyOfTestFolder("basic-example");
...@@ -104,10 +102,10 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT ...@@ -104,10 +102,10 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT
handler.handleDataSet(workingCopy); handler.handleDataSet(workingCopy);
String logText = String logText =
"Global properties extracted from file 'control.tsv': SAMPLE_TYPE(MY_SAMPLE_TYPE) DATA_SET_TYPE(MY_DATA_SET_TYPE) DEFAULT_SPACE(MYSPACE) USER(test@test.test)\n" "Global properties extracted from file 'control.tsv': SAMPLE_TYPE(MY_SAMPLE_TYPE) DATA_SET_TYPE(MY_DATA_SET_TYPE) USER(test@test.test)\n"
+ "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=<null>,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=<null>,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n" + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=<null>,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+ "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=<null>,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=<null>,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n" + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S2,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=<null>,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+ "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=<null>,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=<null>,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]"; + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=<null>,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]";
checkAppenderContent(logText, "basic-example"); checkAppenderContent(logText, "basic-example");
context.assertIsSatisfied(); context.assertIsSatisfied();
......
# Control Parameters # Control Parameters
#! GLOBAL_PROPERTIES_START #! GLOBAL_PROPERTIES_START
#! DEFAULT_SPACE = MYSPACE
#! SAMPLE_TYPE = MY_SAMPLE_TYPE #! SAMPLE_TYPE = MY_SAMPLE_TYPE
#! DATA_SET_TYPE = MY_DATA_SET_TYPE #! DATA_SET_TYPE = MY_DATA_SET_TYPE
#! USERID = test@test.test #! USERID = test@test.test
#! GLOBAL_PROPERTIES_END #! GLOBAL_PROPERTIES_END
# Data # Data
S_experiment S_PROP1 S_PROP2 S_PROP3 D_file_type D_PROP1 D_PROP2 FOLDER S_identifier S_experiment S_PROP1 S_PROP2 S_PROP3 D_file_type D_PROP1 D_PROP2 FOLDER
/MYSPACE/MYPROJ/EXP1 VAL10 VAL20 VAL30 FILE_TYPE VAL40 VAL50 ds1/ /MYSPACE/S1 /MYSPACE/MYPROJ/EXP1 VAL10 VAL20 VAL30 FILE_TYPE VAL40 VAL50 ds1/
/MYSPACE/MYPROJ/EXP2 VAL11 VAL21 VAL31 FILE_TYPE VAL41 VAL51 ds2/ /MYSPACE/S2 /MYSPACE/MYPROJ/EXP2 VAL11 VAL21 VAL31 FILE_TYPE VAL41 VAL51 ds2/
/MYSPACE/MYPROJ/EXP3 VAL12 VAL22 VAL32 FILE_TYPE VAL42 VAL52 ds3/ /MYSPACE/S3 /MYSPACE/MYPROJ/EXP3 VAL12 VAL22 VAL32 FILE_TYPE VAL42 VAL52 ds3/
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