diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/TrashBO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/TrashBO.java index 9bb99870c7536984f372ad3601c8219aa49270f1..fc74d40faea5af8282aceb19c1128b412cb77a53 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/TrashBO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/TrashBO.java @@ -44,7 +44,6 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFetchOption; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.IIdentifierHolder; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Code; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetArchivingStatus; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; @@ -52,7 +51,9 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListOrSearchSampleCrite import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.DeletionPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.managed_property.IManagedPropertyEvaluatorFactory; @@ -429,18 +430,18 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO } Set<Long> allRelatedDataSets = new LinkedHashSet<Long>(); addIds(allRelatedDataSets, containerIds); - List<AbstractExternalData> relatedDataSets - = datasetLister.listByDatasetIds(allRelatedDataSets, DATA_SET_FETCH_OPTIONS); + IDataSetTable dataSetTable = boFactory.createDataSetTable(session); + dataSetTable.loadByIds(TechId.createList(new ArrayList<Long>(allRelatedDataSets))); StringBuilder builder = new StringBuilder(); int numberOfForeignDataSets = 0; - for (AbstractExternalData relatedDataSet : relatedDataSets) + for (DataPE relatedDataSet : dataSetTable.getDataSets()) { if (numberOfForeignDataSets >= 10) { break; } - Sample sample = relatedDataSet.getSample(); - Experiment experiment = relatedDataSet.getExperiment(); + SamplePE sample = relatedDataSet.tryGetSample(); + ExperimentPE experiment = relatedDataSet.getExperiment(); if (sample != null) { if (sIds.contains(sample.getId()) == false) @@ -463,7 +464,7 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO } } - private void addTo(StringBuilder builder, String entityDescription, AbstractExternalData dataSet, + private void addTo(StringBuilder builder, String entityDescription, DataPE dataSet, Map<Long, Set<Long>> containerIds) { String findOriginalDataSet = findOriginalDataSet(containerIds, dataSet); @@ -471,7 +472,7 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO + dataSet.getCode() + " which belongs to " + entityDescription + " outside the deletion set.\n"); } - private String findOriginalDataSet(Map<Long, Set<Long>> relations, AbstractExternalData dataSet) + private String findOriginalDataSet(Map<Long, Set<Long>> relations, DataPE dataSet) { Set<Entry<Long, Set<Long>>> entrySet = relations.entrySet(); for (Entry<Long, Set<Long>> entry : entrySet) diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/TrashBOTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/TrashBOTest.java index 243f66551695a1cf22f9d51a2df9fcec98672c25..45dee2414180e0c81483a66864dbb56db4f7ebd4 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/TrashBOTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/TrashBOTest.java @@ -680,7 +680,7 @@ public final class TrashBOTest extends AbstractBOTest } catch (UserFailureException ex) { String outsiderType = outsiderNode instanceof ExperimentNode ? "experiment" : "sample"; - assertEquals("The sample " + relatedSample.getCode() + " belongs to " + outsiderType + " " + assertEquals("The sample " + relatedSample.getIdentifier() + " belongs to " + outsiderType + " " + outsiderNode.getCode() + " is outside the deletion set.", ex.getMessage()); } } @@ -698,12 +698,13 @@ public final class TrashBOTest extends AbstractBOTest } } - private void assertExceptionMessage(DataSetNode originalDataSet, DataSetNode relatedDataSet, EntityNode outsiderNode, UserFailureException ex) + private void assertExceptionMessage(DataSetNode originalDataSet, DataSetNode relatedDataSet, + EntityNode outsiderNode, UserFailureException ex) { String outsiderType = outsiderNode instanceof ExperimentNode ? "experiment" : "sample"; assertEquals("The data set " + originalDataSet.getCode() + " is a component of the data set " + relatedDataSet.getCode() + " which belongs to " + outsiderType + " " - + outsiderNode.getCode() + " outside the deletion set.", ex.getMessage()); + + outsiderNode.getIdentifier() + " outside the deletion set.", ex.getMessage()); } private void prepareEntityGraph(EntityGraphGenerator g) diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/EntityNode.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/EntityNode.java index b2489d1bc3fd459d65b7f5b92791d6ca2e34798f..a90b4922dc50a23e378e5f6e4d1f9e5cbeac3757 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/EntityNode.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/EntityNode.java @@ -42,6 +42,11 @@ public class EntityNode implements IIdHolder, Comparable<EntityNode> { return code; } + + public String getIdentifier() + { + return getCode(); + } public String getType() { diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/ExperimentNode.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/ExperimentNode.java index aa0e91a9148e091d1979e2c66f85483f38034d67..573e3d096c1374a35c2def59dc9a6dbb44240b8a 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/ExperimentNode.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/ExperimentNode.java @@ -82,6 +82,12 @@ public final class ExperimentNode extends EntityNode } } + @Override + public String getIdentifier() + { + return "/" + (space == null ? "" : space) + "/" + (project == null ? "" : project) + "/" + getCode(); + } + @Override public String getIdentifierAndType() { diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/SampleNode.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/SampleNode.java index 9fcd46f5c91161bc3f8ae1e62c64fdac36fae528..d08074b82b770b33450a846641667c1edf1c8f37 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/SampleNode.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/SampleNode.java @@ -138,6 +138,16 @@ public final class SampleNode extends EntityNode } } + @Override + public String getIdentifier() + { + if (shared) + { + return "/" + getCode(); + } + return "/" + (space == null ? "" : space) + "/" + getCode(); + } + @Override public String getIdentifierAndType() { diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/Utils.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/Utils.java index c0663379ef6e2ab88fd1e93439f46261e45c0162..96ffb40d88f7c45bdd4c637f9bc3b735af702612 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/Utils.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/entitygraph/Utils.java @@ -25,7 +25,9 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PhysicalDataSet; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE; +import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE; /** * @@ -43,7 +45,7 @@ public class Utils Sample sample = new Sample(); sample.setId(sampleNode.getId()); sample.setCode(sampleNode.getCode()); - sample.setIdentifier(sampleNode.getCode()); + sample.setIdentifier(sampleNode.getIdentifier()); sample.setExperiment(createExperiment(sampleNode.getExperiment())); sample.setContainer(createSample(sampleNode.getContainer())); return sample; @@ -66,6 +68,12 @@ public class Utils SamplePE samplePE = new SamplePE(); samplePE.setId(sample.getId()); samplePE.setCode(sample.getCode()); + if (sample.isShared() == false) + { + SpacePE space = new SpacePE(); + space.setCode(sample.getSpace() == null ? "" : sample.getSpace()); + samplePE.setSpace(space); + } data.setSample(samplePE); experiment = sample.getExperiment(); } else @@ -77,6 +85,12 @@ public class Utils ExperimentPE experimentPE = new ExperimentPE(); experimentPE.setId(experiment.getId()); experimentPE.setCode(experiment.getCode()); + ProjectPE projectPE = new ProjectPE(); + projectPE.setCode(experiment.getProject() == null ? "" : experiment.getProject()); + SpacePE spacePE = new SpacePE(); + spacePE.setCode(experiment.getSpace() == null ? "" : experiment.getSpace()); + projectPE.setSpace(spacePE); + experimentPE.setProject(projectPE); data.setExperiment(experimentPE); } return data;