ItEr27S06CUAsignacionGrupoRecursosAPlanificacionItEr26S07: Controller now works with ResouceAllocationsBeingEdited instead of accessing the model to list allocations

This commit is contained in:
Óscar González Fernández 2009-09-22 18:38:29 +02:00
parent 768f92e8f3
commit d60e5e731b
3 changed files with 12 additions and 34 deletions

View file

@ -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<Criterion> getCriterions();
/**
* Returns the {@link List} of {@link AllocationDTO} in the current state of
* the conversation.
* @return a {@link List} of {@link AllocationDTO}
*/
List<AllocationDTO> 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);
}

View file

@ -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<AllocationDTO> getResourceAllocations() {
return resourceAllocationModel.getAllocations();
return allocationsBeingEdited != null ? allocationsBeingEdited
.getCurrentAllocations() : Collections.<AllocationDTO>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);
}

View file

@ -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<Criterion>();
}
@Override
public List<AllocationDTO> 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(