From 5edf9998ff91ff43674c61c7d7ed09ec94795f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Mon, 7 May 2012 16:08:47 +0200 Subject: [PATCH] Bug #1433: Small code refactor of this bug fix. FEA: ItEr76S04BugFixing --- .../business/orders/entities/OrderElement.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 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(); }