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 297f8a4de..a8e3cb3d2 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 @@ -297,10 +297,10 @@ public abstract class OrderElement extends IntegrationEntity implements //we have to remove the TaskSource which contains a TaskGroup instead of TaskElement removeTaskSource(result); } - if(getOnDBTaskSource() != getTaskSource()) { + if(currentTaskSourceIsNotTheSame()) { //this element was unscheduled and then scheduled again. Its TaskSource has //been recreated but we have to remove the old one. - if(getParent().getTaskSource() == getParent().getOnDBTaskSource()) { + if(!getParent().currentTaskSourceIsNotTheSame()) { //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. @@ -314,7 +314,7 @@ public abstract class OrderElement extends IntegrationEntity implements if (wasASchedulingPoint()) { result.add(taskSourceRemoval()); } - if(getOnDBTaskSource() != getTaskSource()) { + if(currentTaskSourceIsNotTheSame()) { //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()); @@ -346,6 +346,10 @@ public abstract class OrderElement extends IntegrationEntity implements .getSchedulingStateType(); } + protected boolean currentTaskSourceIsNotTheSame() { + return getOnDBTaskSource() != getTaskSource(); + } + private List childrenSynchronizations() { List childrenOfGroup = new ArrayList(); for (OrderElement orderElement : getSomewhatScheduledOrderElements()) { @@ -427,7 +431,7 @@ public abstract class OrderElement extends IntegrationEntity implements } } - protected TaskSource getOnDBTaskSource() { + private TaskSource getOnDBTaskSource() { SchedulingDataForVersion schedulingDataForVersion = getCurrentVersionOnDB(); return schedulingDataForVersion.getTaskSource(); }