diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/IResourceAllocationModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/IResourceAllocationModel.java index 88d4a40ce..9eab72005 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/IResourceAllocationModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/IResourceAllocationModel.java @@ -1,6 +1,5 @@ package org.navalplanner.web.planner.allocation; -import java.util.List; import java.util.Set; import org.navalplanner.business.planner.entities.GenericResourceAllocation; @@ -37,13 +36,6 @@ public interface IResourceAllocationModel { */ Set getCriterions(); - /** - * Returns the {@link List} of {@link AllocationDTO} in the current state of - * the conversation. - * @return a {@link List} of {@link AllocationDTO} - */ - List getAllocations(); - /** * Gets the current {@link Task} object. * @@ -51,12 +43,6 @@ public interface IResourceAllocationModel { */ Task getTask(); - /** - * Removes {@link SpecificResourceAllocation} from current allocations list - * @param data - */ - void removeSpecificResourceAllocation(SpecificAllocationDTO data); - /** * Cancel operation */ @@ -73,7 +59,8 @@ public interface IResourceAllocationModel { * @param ganttTask * @param planningState */ - void initAllocationsFor(Task task, org.zkoss.ganttz.data.Task ganttTask, + ResourceAllocationsBeingEdited initAllocationsFor(Task task, + org.zkoss.ganttz.data.Task ganttTask, PlanningState planningState); } 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 d59596562..4d7defe7e 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 @@ -4,6 +4,7 @@ import static org.navalplanner.web.I18nHelper._; import java.math.BigDecimal; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -63,6 +64,8 @@ public class ResourceAllocationController extends GenericForwardComposer { private ResourceAllocationFormBinder formBinder; + private ResourceAllocationsBeingEdited allocationsBeingEdited; + @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); @@ -78,7 +81,8 @@ public class ResourceAllocationController extends GenericForwardComposer { */ public void showWindow(Task task, org.zkoss.ganttz.data.Task ganttTask, PlanningState planningState) { - resourceAllocationModel.initAllocationsFor(task, ganttTask, + allocationsBeingEdited = resourceAllocationModel.initAllocationsFor( + task, ganttTask, planningState); formBinder = new ResourceAllocationFormBinder( getCurrentCalculatedValue(task), resourceAllocationModel); @@ -208,7 +212,8 @@ public class ResourceAllocationController extends GenericForwardComposer { } public List getResourceAllocations() { - return resourceAllocationModel.getAllocations(); + return allocationsBeingEdited != null ? allocationsBeingEdited + .getCurrentAllocations() : Collections.emptyList(); } public ResourceAllocationRenderer getResourceAllocationRenderer() { @@ -285,7 +290,7 @@ public class ResourceAllocationController extends GenericForwardComposer { } private void removeSpecificResourceAllocation(SpecificAllocationDTO data) { - resourceAllocationModel.removeSpecificResourceAllocation(data); + allocationsBeingEdited.remove(data); Util.reloadBindings(resourcesList); } 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 664fbbb0d..cafe59190 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 @@ -1,7 +1,6 @@ package org.navalplanner.web.planner.allocation; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -74,20 +73,6 @@ public class ResourceAllocationModel implements IResourceAllocationModel { : new HashSet(); } - @Override - public List getAllocations() { - if (resourceAllocationsBeingEdited == null) { - return Collections.emptyList(); - } - return resourceAllocationsBeingEdited.getCurrentAllocations(); - } - - @Override - public void removeSpecificResourceAllocation( - SpecificAllocationDTO allocation) { - resourceAllocationsBeingEdited.remove(allocation); - } - @Override public void cancel() { resourceAllocationsBeingEdited = null; @@ -129,7 +114,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel { @Override @Transactional(readOnly = true) - public void initAllocationsFor(Task task, + public ResourceAllocationsBeingEdited initAllocationsFor(Task task, org.zkoss.ganttz.data.Task ganttTask, PlanningState planningState) { this.ganttTask = ganttTask; this.task = task; @@ -144,6 +129,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel { .getResourceAllocations())); resourceAllocationsBeingEdited = new ResourceAllocationsBeingEdited( currentAllocations, resourceDAO); + return resourceAllocationsBeingEdited; } private void reattachResourceAllocations(