From e38fb82591cde707da5fbd95b45b647805856687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Thu, 22 Dec 2011 13:40:16 +0100 Subject: [PATCH] [Bug #1304] Make sumOfAssignedEffort return the cached value only for orders. In other cases, the actual value will be calculated and returned, to use more accurate data. FEA: ItEr75S04BugFixing --- .../business/planner/entities/TaskElement.java | 10 ++++++++-- .../org/libreplan/web/planner/TaskElementAdapter.java | 11 ++--------- 2 files changed, 10 insertions(+), 11 deletions(-) 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 b45941284..31125cbd5 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 @@ -688,10 +688,16 @@ public abstract class TaskElement extends BaseEntity { } public EffortDuration getSumOfAssignedEffort() { - return sumOfAssignedEffort; + if (this.getParent() == null) { + //it's an order, we use the cached value + return sumOfAssignedEffort; + } + else { + return getSumOfAssignedEffortCalculated(); + } } - public EffortDuration getSumOfAssignedEffortCalculated() { + private EffortDuration getSumOfAssignedEffortCalculated() { EffortDuration result = EffortDuration.hours(0); for(ResourceAllocation allocation : getAllResourceAllocations()) { result = result.plus(allocation.getAssignedEffort()); 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 76456815d..cdf8b2fb6 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 @@ -600,15 +600,8 @@ public class TaskElementAdapter { } if (taskElement.getOrderElement() != null) { - if(taskElement.getParent() == null){ - //it's an order, we use the cached value - hours = taskElement.getSumOfAssignedEffort() - .toHoursAsDecimalWithScale(2); - } - else { - hours = taskElement.getSumOfAssignedEffortCalculated() - .toHoursAsDecimalWithScale(2);; - } + hours = taskElement.getSumOfAssignedEffort() + .toHoursAsDecimalWithScale(2); } // Calculate date according to advanceHours or advancePercentage