From 9c9b54de2266d3a7cb6a3fe1c07ac782dae921fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Tue, 6 Oct 2009 23:18:31 +0200 Subject: [PATCH] ItEr29S06CUAsignacionGrupoRecursosAPlanificacionItEr28S06: Extracting method and moving it to AllocationResult --- .../ResourceAllocationController.java | 2 ++ .../allocation/ResourceAllocationModel.java | 4 +--- .../ResourceAllocationsBeingEdited.java | 21 +++++++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java index e1c658771..3b787d3a5 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationController.java @@ -312,6 +312,8 @@ public class ResourceAllocationController extends GenericForwardComposer { } public void advanceAllocation() { + AllocationResult allocationResult = allocationsBeingEdited + .doAllocation(); switcher.goToAdvancedAllocation(); window.setVisible(false); } diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java index e7725ab57..f2b0c47b7 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationModel.java @@ -119,9 +119,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel { private void doTheAllocation() { AllocationResult allocationResult = resourceAllocationsBeingEdited .doAllocation(); - task.mergeAllocation(resourceAllocationsBeingEdited - .getCalculatedValue(), allocationResult.getDaysDuration(), - allocationResult.getNew(), allocationResult.getModified()); + allocationResult.applyTo(task); ganttTask.setEndDate(task.getEndDate()); } diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationsBeingEdited.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationsBeingEdited.java index 602e3b002..65af56731 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationsBeingEdited.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/ResourceAllocationsBeingEdited.java @@ -201,7 +201,8 @@ public class ResourceAllocationsBeingEdited { default: throw new RuntimeException("cant handle: " + calculatedValue); } - return new AllocationResult(new AggregateOfResourceAllocations( + return new AllocationResult(calculatedValue, + new AggregateOfResourceAllocations( stripResourcesPerDay(allocations)), daysDuration, fromDetachedToAttached); } @@ -318,11 +319,17 @@ class AllocationResult { private final Map, ResourceAllocation> fromDetachedAllocationToAttached; - AllocationResult(AggregateOfResourceAllocations aggregate, + private final CalculatedValue calculatedValue; + + AllocationResult( + CalculatedValue calculatedValue, + AggregateOfResourceAllocations aggregate, Integer daysDuration, Map> fromDetachedAllocationToAttached) { Validate.notNull(daysDuration); Validate.notNull(aggregate); + Validate.notNull(calculatedValue); + this.calculatedValue = calculatedValue; this.aggregate = aggregate; this.daysDuration = daysDuration; this.fromDetachedAllocationToAttached = translation(fromDetachedAllocationToAttached); @@ -358,4 +365,14 @@ class AllocationResult { } return result; } + + public CalculatedValue getCalculatedValue() { + return calculatedValue; + } + + public void applyTo(Task task) { + task.mergeAllocation(getCalculatedValue(), + getDaysDuration(), + getNew(), getModified()); + } }