From b7d612b6555af1faed14caa35fc5979b35600f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Mon, 1 Oct 2012 13:46:53 +0200 Subject: [PATCH] Bug #1538: Detect inconsistent states on unsaved scheduling points. FEA: ItEr77S04BugFixing --- .../business/orders/entities/OrderElement.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 fea3430a3..cb0a17c0d 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 @@ -316,7 +316,7 @@ public abstract class OrderElement extends IntegrationEntity implements } else if (isSuperElementPartialOrCompletelyScheduled()) { removeUnscheduled(result); if (wasASchedulingPoint()) { - result.add(taskSourceRemoval()); + removeTaskSource(result); } else { if (hadATaskSource() && currentTaskSourceIsNotTheSame()) { //all the children of this element were unscheduled and then scheduled again, @@ -350,6 +350,14 @@ public abstract class OrderElement extends IntegrationEntity implements } private boolean wasASchedulingPoint() { + TaskSource currentTaskSource = getTaskSource(); + // check if the existing TaskSource is inconsistent with the current + // scheduling state + if (currentTaskSource != null && currentTaskSource.getTask().isLeaf() + && getSchedulingStateType() != Type.SCHEDULING_POINT) { + return true; + } + // check if the scheduling state has changed WRT the DB SchedulingDataForVersion currentVersionOnDB = getCurrentVersionOnDB(); return SchedulingState.Type.SCHEDULING_POINT == currentVersionOnDB .getSchedulingStateType();