From 73b4f99e33d64997bbe0f333fd3f6037a9987aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Mon, 7 May 2012 14:25:44 +0200 Subject: [PATCH] Bug #1433: Make sure that old TaskSources are deleted also in the case of parent tasks. It fixes the other part of the bug, when a task is the only child of a container and it is unscheduled, so the TaskSource of the parent is deleted too. FEA: ItEr76S04BugFixing --- .../business/orders/entities/OrderElement.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderElement.java b/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderElement.java index 3d3683a35..297f8a4de 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderElement.java +++ b/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderElement.java @@ -300,7 +300,12 @@ public abstract class OrderElement extends IntegrationEntity implements if(getOnDBTaskSource() != getTaskSource()) { //this element was unscheduled and then scheduled again. Its TaskSource has //been recreated but we have to remove the old one. - removeTaskSource(result); + if(getParent().getTaskSource() == getParent().getOnDBTaskSource()) { + //we only remove the TaskSource if the parent is not in the same situation. + //In case the parent is in the same situation, it will remove the related + //TaskSources in children tasks. + removeTaskSource(result); + } } result .addAll(synchronizationForSchedulingPoint(schedulingDataForVersion)); @@ -309,6 +314,11 @@ public abstract class OrderElement extends IntegrationEntity implements if (wasASchedulingPoint()) { result.add(taskSourceRemoval()); } + if(getOnDBTaskSource() != getTaskSource()) { + //all the children of this element were unscheduled and then scheduled again, + //its TaskSource has been recreated but we have to remove the old one. + result.add(taskSourceRemoval()); + } result .add(synchronizationForSuperelement(schedulingDataForVersion)); } else if (schedulingState.isNoScheduled()) { @@ -417,7 +427,7 @@ public abstract class OrderElement extends IntegrationEntity implements } } - private TaskSource getOnDBTaskSource() { + protected TaskSource getOnDBTaskSource() { SchedulingDataForVersion schedulingDataForVersion = getCurrentVersionOnDB(); return schedulingDataForVersion.getTaskSource(); }