From d6468ddd1ceeb7b746d1cfcc1aed49c993e38752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Mon, 26 Mar 2012 18:46:32 +0200 Subject: [PATCH] Bug #1387: Fix bug Possible fix of the first problem. It looks into the SchedulingDataForVersion instead of the data to see the status in the database instead of in memory so the synchronizations sent to the database are ok. --- .../business/orders/entities/OrderElement.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 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 c028a683d..8f558ae5a 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 @@ -57,7 +57,6 @@ import org.libreplan.business.orders.entities.SchedulingState.Type; import org.libreplan.business.orders.entities.TaskSource.TaskSourceSynchronization; import org.libreplan.business.planner.entities.Task; import org.libreplan.business.planner.entities.TaskElement; -import org.libreplan.business.planner.entities.TaskGroup; import org.libreplan.business.planner.entities.TaskPositionConstraint; import org.libreplan.business.qualityforms.entities.QualityForm; import org.libreplan.business.qualityforms.entities.TaskQualityForm; @@ -291,7 +290,7 @@ public abstract class OrderElement extends IntegrationEntity implements SchedulingDataForVersion schedulingDataForVersion) { List result = new ArrayList(); if (isSchedulingPoint()) { - if(isSchedulingPointButItWasNot()) { + if (itWasntSchedulingPoint()) { //this element was a container but now it's a scheduling point //we have to remove the TaskSource which contains a TaskGroup instead of TaskElement removeTaskSource(result); @@ -329,9 +328,10 @@ public abstract class OrderElement extends IntegrationEntity implements && getTaskSource().getTask() instanceof Task; } - private boolean isSchedulingPointButItWasNot() { - return getTaskSource() != null - && getTaskSource().getTask() instanceof TaskGroup; + private boolean itWasntSchedulingPoint() { + SchedulingDataForVersion currentVersionOnDB = getCurrentVersionOnDB(); + return SchedulingState.Type.SCHEDULING_POINT != currentVersionOnDB + .getSchedulingStateType(); } private List childrenSynchronizations() { @@ -416,11 +416,16 @@ public abstract class OrderElement extends IntegrationEntity implements } private TaskSource getOnDBTaskSource() { + SchedulingDataForVersion schedulingDataForVersion = getCurrentVersionOnDB(); + return schedulingDataForVersion.getTaskSource(); + } + + SchedulingDataForVersion getCurrentVersionOnDB() { OrderVersion version = getCurrentSchedulingData() .getOriginOrderVersion(); SchedulingDataForVersion schedulingDataForVersion = schedulingDatasForVersion .get(version); - return schedulingDataForVersion.getTaskSource(); + return schedulingDataForVersion; } private TaskSourceSynchronization taskSourceRemoval() {