Skip to content
Snippets Groups Projects
Commit 2079bff6 authored by felmer's avatar felmer
Browse files

SSDM-1621: fixing bugs

SVN: 33708
parent 6b3c53d1
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant; ...@@ -40,6 +40,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewSample;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePropertyTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePropertyTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
...@@ -457,14 +458,17 @@ abstract class AbstractSampleBusinessObject extends AbstractSampleIdentifierBusi ...@@ -457,14 +458,17 @@ abstract class AbstractSampleBusinessObject extends AbstractSampleIdentifierBusi
protected void checkExperimentBusinessRules(SamplePE sample) protected void checkExperimentBusinessRules(SamplePE sample)
{ {
// checkSampleWithoutDatasets(sample); ExperimentPE experiment = sample.getExperiment();
if (experiment == null)
{
checkSampleWithoutDatasets(sample);
}
if (hasDatasets(sample) && sample.getSpace() == null) if (hasDatasets(sample) && sample.getSpace() == null)
{ {
throw UserFailureException.fromTemplate("Cannot detach the sample '%s' from the space " throw UserFailureException.fromTemplate("Cannot detach the sample '%s' from the space "
+ "because there are already datasets attached to the sample.", + "because there are already datasets attached to the sample.",
sample.getIdentifier()); sample.getIdentifier());
} }
ExperimentPE experiment = sample.getExperiment();
if (experiment != null if (experiment != null
&& (sample.getSpace() == null || experiment.getProject().getSpace() && (sample.getSpace() == null || experiment.getProject().getSpace()
.equals(sample.getSpace()) == false)) .equals(sample.getSpace()) == false))
...@@ -558,14 +562,14 @@ abstract class AbstractSampleBusinessObject extends AbstractSampleIdentifierBusi ...@@ -558,14 +562,14 @@ abstract class AbstractSampleBusinessObject extends AbstractSampleIdentifierBusi
return; return;
} }
ensureExperimentIsValid(identifierOrNull, newExperiment, sample); ensureExperimentIsValid(identifierOrNull, newExperiment, sample);
ensureSampleAttachableToExperiment(sample); ensureSampleAttachableToExperiment(sample, newExperiment);
assignSampleAndRelatedDataSetsToExperiment(sample, newExperiment); assignSampleAndRelatedDataSetsToExperiment(sample, newExperiment);
} }
private void ensureSampleAttachableToExperiment(SamplePE sample) private void ensureSampleAttachableToExperiment(SamplePE sample, ExperimentPE newExperiment)
{ {
if (sample.getSpace() == null) if (sample.getSpace() == null && newExperiment != null)
{ {
throw UserFailureException.fromTemplate( throw UserFailureException.fromTemplate(
"It is not allowed to connect a shared sample '%s' to the experiment.", "It is not allowed to connect a shared sample '%s' to the experiment.",
......
...@@ -44,7 +44,7 @@ public class SampleUtils ...@@ -44,7 +44,7 @@ public class SampleUtils
{ {
return UserFailureException.fromTemplate( return UserFailureException.fromTemplate(
"The dataset '%s' cannot be connected to the sample '%s' because %s.", "The dataset '%s' cannot be connected to the sample '%s' because %s.",
data.getCode(), sample.getIdentifier(), reason); data.getCode(), sample == null ? "?" : sample.getIdentifier(), reason);
} }
} }
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