Skip to content
Snippets Groups Projects
Commit 10e83eff authored by cramakri's avatar cramakri
Browse files

LMS-1988 Fixed some small bugs in the entity registration code. Removed...

LMS-1988 Fixed some small bugs in the entity registration code. Removed not-yet-implemented method from interface.

SVN: 19990
parent 7764a8cd
No related branches found
No related tags found
No related merge requests found
...@@ -39,12 +39,17 @@ public interface IDataSetRegistrationTransaction ...@@ -39,12 +39,17 @@ public interface IDataSetRegistrationTransaction
IDataSet createNewDataSet(); IDataSet createNewDataSet();
/** /**
* Get a sample from the openBIS AS. * Get a sample from the openBIS AS. Returns null if the sample does not exist.
*
* @return A sample or null
*/ */
ISampleImmutable getSample(String sampleIdentifierString); ISampleImmutable getSample(String sampleIdentifierString);
/** /**
* Get a sample from the openBIS AS for the purpose of modifying it. * Get a sample from the openBIS AS for the purpose of modifying it. Returns null if the sample
* does not exist.
*
* @return A sample or null
*/ */
ISample getSampleForUpdate(String sampleIdentifierString); ISample getSampleForUpdate(String sampleIdentifierString);
...@@ -114,8 +119,4 @@ public interface IDataSetRegistrationTransaction ...@@ -114,8 +119,4 @@ public interface IDataSetRegistrationTransaction
*/ */
String createNewFile(IDataSet dst, String dstInDataset, String fileName); String createNewFile(IDataSet dst, String dstInDataset, String fileName);
/**
* Delete a file a the given path.
*/
void deleteFile(String src);
} }
...@@ -26,6 +26,7 @@ import ch.systemsx.cisd.etlserver.registrator.api.v1.ISampleImmutable; ...@@ -26,6 +26,7 @@ import ch.systemsx.cisd.etlserver.registrator.api.v1.ISampleImmutable;
import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation; import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation;
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.FileFormatType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.FileFormatType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space;
import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier;
import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifierFactory; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifierFactory;
...@@ -103,15 +104,22 @@ public class DataSet<T extends DataSetInformation> implements IDataSet ...@@ -103,15 +104,22 @@ public class DataSet<T extends DataSetInformation> implements IDataSet
{ {
this.sampleOrNull = sampleOrNull; this.sampleOrNull = sampleOrNull;
DataSetInformation dataSetInformation = registrationDetails.getDataSetInformation();
if (sampleOrNull == null) if (sampleOrNull == null)
{ {
registrationDetails.getDataSetInformation().setSample(null); dataSetInformation.setSample(null);
registrationDetails.getDataSetInformation().setSampleCode(null); dataSetInformation.setSampleCode(null);
} else } else
{ {
Sample sample = (Sample) sampleOrNull; Sample sample = (Sample) sampleOrNull;
registrationDetails.getDataSetInformation().setSample(sample.getSample());
registrationDetails.getDataSetInformation().setSampleCode(sample.getSample().getCode()); dataSetInformation.setSample(sample.getSample());
dataSetInformation.setSampleCode(sample.getSample().getCode());
Space space = sample.getSample().getSpace();
if (null != space)
{
dataSetInformation.setSpaceCode(space.getCode());
}
setExperiment(sample.getSample().getExperiment()); setExperiment(sample.getSample().getExperiment());
} }
} }
......
...@@ -179,7 +179,9 @@ public class DataSetRegistrationTransaction<T extends DataSetInformation> implem ...@@ -179,7 +179,9 @@ public class DataSetRegistrationTransaction<T extends DataSetInformation> implem
{ {
SampleIdentifier sampleIdentifier = SampleIdentifier sampleIdentifier =
new SampleIdentifierFactory(sampleIdentifierString).createIdentifier(); new SampleIdentifierFactory(sampleIdentifierString).createIdentifier();
return new SampleImmutable(openBisService.tryGetSampleWithExperiment(sampleIdentifier)); ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sampleOrNull =
openBisService.tryGetSampleWithExperiment(sampleIdentifier);
return (null == sampleOrNull) ? null : new SampleImmutable(sampleOrNull);
} }
public ISample getSampleForUpdate(String sampleIdentifierString) public ISample getSampleForUpdate(String sampleIdentifierString)
...@@ -196,9 +198,9 @@ public class DataSetRegistrationTransaction<T extends DataSetInformation> implem ...@@ -196,9 +198,9 @@ public class DataSetRegistrationTransaction<T extends DataSetInformation> implem
{ {
ExperimentIdentifier experimentIdentifier = ExperimentIdentifier experimentIdentifier =
new ExperimentIdentifierFactory(experimentIdentifierString).createIdentifier(); new ExperimentIdentifierFactory(experimentIdentifierString).createIdentifier();
ExperimentImmutable experiment = ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment experimentOrNull =
new ExperimentImmutable(openBisService.tryToGetExperiment(experimentIdentifier)); openBisService.tryToGetExperiment(experimentIdentifier);
return experiment; return (null == experimentOrNull) ? null : new ExperimentImmutable(experimentOrNull);
} }
public IExperiment createNewExperiment(String experimentIdentifierString) public IExperiment createNewExperiment(String experimentIdentifierString)
......
...@@ -40,7 +40,7 @@ class ExperimentImmutable implements IExperimentImmutable ...@@ -40,7 +40,7 @@ class ExperimentImmutable implements IExperimentImmutable
public boolean isExistingExperiment() public boolean isExistingExperiment()
{ {
return null != experiment; return true;
} }
/** /**
......
...@@ -16,13 +16,10 @@ ...@@ -16,13 +16,10 @@
package ch.systemsx.cisd.etlserver.registrator.api.v1.impl; package ch.systemsx.cisd.etlserver.registrator.api.v1.impl;
import java.util.ArrayList;
import java.util.List;
import ch.systemsx.cisd.etlserver.registrator.api.v1.IExperimentImmutable; import ch.systemsx.cisd.etlserver.registrator.api.v1.IExperimentImmutable;
import ch.systemsx.cisd.etlserver.registrator.api.v1.ISample; import ch.systemsx.cisd.etlserver.registrator.api.v1.ISample;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty;
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.basic.dto.builders.SampleBuilder;
import ch.systemsx.cisd.openbis.generic.shared.util.EntityHelper; import ch.systemsx.cisd.openbis.generic.shared.util.EntityHelper;
/** /**
...@@ -31,6 +28,13 @@ import ch.systemsx.cisd.openbis.generic.shared.util.EntityHelper; ...@@ -31,6 +28,13 @@ import ch.systemsx.cisd.openbis.generic.shared.util.EntityHelper;
public class Sample extends SampleImmutable implements ISample public class Sample extends SampleImmutable implements ISample
{ {
private static ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample buildSampleWithIdentifier(
String identifier)
{
SampleBuilder builder = new SampleBuilder(identifier);
return builder.getSample();
}
public Sample(ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample) public Sample(ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample)
{ {
super(sample); super(sample);
...@@ -38,15 +42,10 @@ public class Sample extends SampleImmutable implements ISample ...@@ -38,15 +42,10 @@ public class Sample extends SampleImmutable implements ISample
public Sample(String sampleIdentifier, String permId) public Sample(String sampleIdentifier, String permId)
{ {
super(new ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample()); super(buildSampleWithIdentifier(sampleIdentifier), false);
getSample().setIdentifier(sampleIdentifier);
getSample().setPermId(permId); getSample().setPermId(permId);
List<IEntityProperty> properties = new ArrayList<IEntityProperty>();
getSample().setProperties(properties);
} }
public void setExperiment(IExperimentImmutable experiment) public void setExperiment(IExperimentImmutable experiment)
{ {
ExperimentImmutable exp = (ExperimentImmutable) experiment; ExperimentImmutable exp = (ExperimentImmutable) experiment;
......
...@@ -28,9 +28,18 @@ public class SampleImmutable implements ISampleImmutable ...@@ -28,9 +28,18 @@ public class SampleImmutable implements ISampleImmutable
{ {
private final ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample; private final ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample;
private final boolean existingSample;
public SampleImmutable(ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample) public SampleImmutable(ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample)
{
this(sample, true);
}
public SampleImmutable(ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample sample,
boolean existingSample)
{ {
this.sample = sample; this.sample = sample;
this.existingSample = existingSample;
} }
public IExperimentImmutable getExperiment() public IExperimentImmutable getExperiment()
...@@ -52,7 +61,7 @@ public class SampleImmutable implements ISampleImmutable ...@@ -52,7 +61,7 @@ public class SampleImmutable implements ISampleImmutable
public boolean isExistingSample() public boolean isExistingSample()
{ {
return null != sample; return existingSample;
} }
/** /**
......
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