From e4ffb40df973977a20b315f2e3f5549890bdfd37 Mon Sep 17 00:00:00 2001 From: Diego Pino Garcia Date: Wed, 10 Mar 2010 09:11:12 +0100 Subject: [PATCH] ItEr50S04ValidacionEProbasFuncionaisItEr49S04: [Bug #376] On assigning a generic allocation, fetch all possible resources matching task criteria --- .../web/planner/allocation/AllocationRow.java | 5 +++-- .../web/planner/allocation/GenericAllocationRow.java | 10 ++++++---- .../planner/allocation/ResourceAllocationModel.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationRow.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationRow.java index b4ccbc299..efa5aff8d 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationRow.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationRow.java @@ -35,6 +35,7 @@ import org.navalplanner.business.planner.entities.Task; import org.navalplanner.business.planner.entities.Task.ModifiedAllocation; import org.navalplanner.business.planner.entities.allocationalgorithms.HoursModification; import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification; +import org.navalplanner.business.resources.daos.IResourceDAO; import org.navalplanner.business.resources.entities.Resource; import org.navalplanner.web.common.Util; import org.navalplanner.web.planner.allocation.ResourceAllocationController.DerivedAllocationColumn; @@ -153,10 +154,10 @@ public abstract class AllocationRow { } public static List toRows( - Collection> resourceAllocations) { + Collection> resourceAllocations, IResourceDAO resourceDAO) { List result = new ArrayList(); result.addAll(GenericAllocationRow - .toGenericAllocations(resourceAllocations)); + .toGenericAllocations(resourceAllocations, resourceDAO)); result.addAll(SpecificAllocationRow .toSpecificAllocations(resourceAllocations)); return result; diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/GenericAllocationRow.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/GenericAllocationRow.java index ba8cce721..965d6d05e 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/GenericAllocationRow.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/GenericAllocationRow.java @@ -34,9 +34,11 @@ import org.navalplanner.business.planner.entities.ResourcesPerDay; import org.navalplanner.business.planner.entities.Task; import org.navalplanner.business.planner.entities.allocationalgorithms.HoursModification; import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification; +import org.navalplanner.business.resources.daos.IResourceDAO; import org.navalplanner.business.resources.entities.Criterion; import org.navalplanner.business.resources.entities.Resource; import org.navalplanner.web.resourceload.ResourceLoadModel; +import org.springframework.beans.factory.annotation.Autowired; /** * The information required for creating a {@link GenericResourceAllocation} @@ -63,12 +65,12 @@ public class GenericAllocationRow extends AllocationRow { } public static GenericAllocationRow from( - GenericResourceAllocation resourceAllocation) { + GenericResourceAllocation resourceAllocation, IResourceDAO resourceDAO) { GenericAllocationRow result = createDefault(); result.setResourcesPerDay(resourceAllocation.getResourcesPerDay()); result.setOrigin(resourceAllocation); result.criterions = resourceAllocation.getCriterions(); - result.resources = resourceAllocation.getAssociatedResources(); + result.resources = resourceDAO.findSatisfyingCriterionsAtSomePoint(result.criterions); result.setName(ResourceLoadModel.getName(result.criterions)); return result; } @@ -82,11 +84,11 @@ public class GenericAllocationRow extends AllocationRow { } public static Collection toGenericAllocations( - Collection> resourceAllocations) { + Collection> resourceAllocations, IResourceDAO resourceDAO) { ArrayList result = new ArrayList(); for (ResourceAllocation resourceAllocation : resourceAllocations) { if (resourceAllocation instanceof GenericResourceAllocation) { - result.add(from((GenericResourceAllocation) resourceAllocation)); + result.add(from((GenericResourceAllocation) resourceAllocation, resourceDAO)); } } return result; 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 68273d3aa..3337e7e82 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 @@ -239,7 +239,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel { loadResources(this.task.getSatisfiedResourceAllocations()); loadDerivedAllocations(this.task.getSatisfiedResourceAllocations()); List initialRows = AllocationRow.toRows(this.task - .getAllResourceAllocations()); + .getAllResourceAllocations(), resourceDAO); allocationRowsHandler = AllocationRowsHandler.create(task, initialRows, createWorkerFinder()); return allocationRowsHandler;