Skip to content
Snippets Groups Projects
Commit f3912e55 authored by buczekp's avatar buczekp
Browse files

[LMS-2441] improved speed of logical deletion of containers (we don't need to...

[LMS-2441] improved speed of logical deletion of containers (we don't need to list components of components)

SVN: 22401
parent 0d5a0b4e
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,11 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind; ...@@ -39,6 +39,11 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind;
*/ */
public class TrashBO extends AbstractBusinessObject implements ITrashBO public class TrashBO extends AbstractBusinessObject implements ITrashBO
{ {
private enum CascadeSampleDependentComponents
{
TRUE, FALSE
}
private DeletionPE deletion; private DeletionPE deletion;
public TrashBO(IDAOFactory daoFactory, Session session) public TrashBO(IDAOFactory daoFactory, Session session)
...@@ -61,6 +66,13 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO ...@@ -61,6 +66,13 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO
} }
public void trashSamples(final List<TechId> sampleIds) public void trashSamples(final List<TechId> sampleIds)
{
assert deletion != null;
trashSamples(sampleIds, CascadeSampleDependentComponents.TRUE);
}
void trashSamples(final List<TechId> sampleIds,
final CascadeSampleDependentComponents cascadeType)
{ {
assert deletion != null; assert deletion != null;
...@@ -70,7 +82,11 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO ...@@ -70,7 +82,11 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO
if (batchOperation.counter > 0) if (batchOperation.counter > 0)
{ {
trashSampleDependentChildrenAndComponents(sampleIds); trashSampleDependentChildren(sampleIds);
if (cascadeType == CascadeSampleDependentComponents.TRUE)
{
trashSampleDependentComponents(sampleIds);
}
trashSampleDependentDataSets(sampleIds); trashSampleDependentDataSets(sampleIds);
} }
} }
...@@ -101,7 +117,7 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO ...@@ -101,7 +117,7 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO
// NOTE: data set children are not cascade trashed - a conscious decision made by Tomek // NOTE: data set children are not cascade trashed - a conscious decision made by Tomek
} }
private void trashSampleDependentChildrenAndComponents(List<TechId> sampleIds) private void trashSampleDependentChildren(List<TechId> sampleIds)
{ {
final ISampleDAO sampleDAO = getSampleDAO(); final ISampleDAO sampleDAO = getSampleDAO();
...@@ -117,8 +133,13 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO ...@@ -117,8 +133,13 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO
}; };
BatchOperationExecutor.executeInBatches(batchOperation); BatchOperationExecutor.executeInBatches(batchOperation);
trashSamples(batchOperation.getResults()); trashSamples(batchOperation.getResults());
}
private void trashSampleDependentComponents(List<TechId> sampleIds)
{
final ISampleDAO sampleDAO = getSampleDAO();
batchOperation = AbstractQueryBatchOperation batchOperation =
new AbstractQueryBatchOperation(EntityKind.SAMPLE, sampleIds, new AbstractQueryBatchOperation(EntityKind.SAMPLE, sampleIds,
"listSampleIdsByContainerIds") "listSampleIdsByContainerIds")
{ {
...@@ -129,7 +150,9 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO ...@@ -129,7 +150,9 @@ public class TrashBO extends AbstractBusinessObject implements ITrashBO
} }
}; };
BatchOperationExecutor.executeInBatches(batchOperation); BatchOperationExecutor.executeInBatches(batchOperation);
trashSamples(batchOperation.getResults()); // We have a business rule that there is just 1 level of components and using this here
// improves performance.
trashSamples(batchOperation.getResults(), CascadeSampleDependentComponents.FALSE);
} }
private void trashSampleDependentDataSets(List<TechId> sampleIds) private void trashSampleDependentDataSets(List<TechId> sampleIds)
......
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