From 815f81703160e6e542e6bbebe8f215f58c02b353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Tue, 20 Dec 2011 17:47:13 +0100 Subject: [PATCH] [Bug #1304] Don't use the cached value sumOfHoursAllocated when drawing the progress bars of tasks. This unupdated cached value is causing the bug. We will use it only in company view, where allocations can't change. FEA: ItEr75S04BugFixing --- .../libreplan/business/planner/entities/TaskElement.java | 8 ++++++++ .../org/libreplan/web/planner/TaskElementAdapter.java | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/TaskElement.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/TaskElement.java index fd9fcba50..52c31d235 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/TaskElement.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/TaskElement.java @@ -695,6 +695,14 @@ public abstract class TaskElement extends BaseEntity { return sumOfHoursAllocated; } + public Integer getSumOfHoursAllocatedCalculated() { + int result = 0; + for(ResourceAllocation allocation : getAllResourceAllocations()) { + result += allocation.getAssignedHours(); + } + return result; + } + public String toString() { return super.toString() + " :: " + getName(); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java index b22323a67..3bfd3a79f 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java @@ -597,7 +597,13 @@ public class TaskElementAdapter { private GanttDate getAdvanceEndDate(BigDecimal advancePercentage) { Integer hours = Integer.valueOf(0); if (taskElement.getOrderElement() != null) { - hours = taskElement.getSumOfHoursAllocated(); + if(taskElement.getParent() == null){ + //it's an order, we use the cached value + hours = taskElement.getSumOfHoursAllocated(); + } + else { + hours = taskElement.getSumOfHoursAllocatedCalculated(); + } } if (taskElement instanceof TaskGroup) {