diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/FormBinder.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/FormBinder.java index 4e1ddb15b..53de982fd 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/FormBinder.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/FormBinder.java @@ -162,7 +162,8 @@ class FormBinder { } private void doApply() { - aggregate = resourceAllocationsBeingEdited.doAllocation(); + aggregate = resourceAllocationsBeingEdited.doAllocation() + .getAggregate(); reloadValues(); } 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 6ccab7da7..0f04866c6 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,8 +119,8 @@ public class ResourceAllocationModel implements IResourceAllocationModel { private void doTheAllocation() { ResourceAllocationsBeingEdited allocator = resourceAllocationsBeingEdited .taskModifying(); - allocator.doAllocation(); - Integer newDaysDuration = allocator.getDaysDuration(); + AllocationResult allocationResult = allocator.doAllocation(); + Integer newDaysDuration = allocationResult.getDaysDuration(); if (task.getDaysDuration() != newDaysDuration) { task.setDaysDuration(newDaysDuration); 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 e431edab4..8ba7dc019 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 @@ -28,6 +28,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import org.apache.commons.lang.Validate; import org.joda.time.Days; import org.joda.time.LocalDate; import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations; @@ -185,7 +186,7 @@ public class ResourceAllocationsBeingEdited { && getGenericAllocation().isEmptyResourcesPerDay(); } - public AggregateOfResourceAllocations doAllocation() { + public AllocationResult doAllocation() { checkInvalidValues(); List allocations = asResourceAllocations(); switch (calculatedValue) { @@ -203,7 +204,8 @@ public class ResourceAllocationsBeingEdited { default: throw new RuntimeException("cant handle: " + calculatedValue); } - return new AggregateOfResourceAllocations(stripResourcesPerDay(allocations)); + return new AllocationResult(new AggregateOfResourceAllocations( + stripResourcesPerDay(allocations)), daysDuration); } private Integer from(Date startDate, LocalDate end) { @@ -301,3 +303,27 @@ public class ResourceAllocationsBeingEdited { } } + +class AllocationResult { + + private final AggregateOfResourceAllocations aggregate; + + private final Integer daysDuration; + + AllocationResult(AggregateOfResourceAllocations aggregate, + Integer daysDuration) { + Validate.notNull(daysDuration); + Validate.notNull(daysDuration); + this.aggregate = aggregate; + this.daysDuration = daysDuration; + } + + public AggregateOfResourceAllocations getAggregate() { + return aggregate; + } + + public Integer getDaysDuration() { + return daysDuration; + } + +}