From c082a34640e961dae6b30efa9a99d33a2828ba32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Mon, 20 Sep 2010 18:42:31 +0200 Subject: [PATCH] [Bug #645] Provide IResourceSearchModel instead of IResourceDAO so the correct thing is done GenericAllocationRow was not taking into account the resource type. Now it uses IResourceSearchModel so it takes it into account. FEA: ItEr60S04ValidacionEProbasFuncionaisItEr59S04 --- .../web/planner/allocation/AllocationRow.java | 9 +++++---- .../planner/allocation/GenericAllocationRow.java | 16 +++++++++++----- .../allocation/ResourceAllocationModel.java | 4 ++-- 3 files changed, 18 insertions(+), 11 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 6dea85071..7cef84711 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 @@ -34,11 +34,11 @@ 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.business.workingday.ResourcesPerDay; import org.navalplanner.web.common.Util; import org.navalplanner.web.planner.allocation.ResourceAllocationController.DerivedAllocationColumn; +import org.navalplanner.web.resources.search.IResourceSearchModel; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; @@ -153,10 +153,11 @@ public abstract class AllocationRow { } public static List toRows( - Collection> resourceAllocations, IResourceDAO resourceDAO) { + Collection> resourceAllocations, + IResourceSearchModel searchModel) { List result = new ArrayList(); - result.addAll(GenericAllocationRow - .toGenericAllocations(resourceAllocations, resourceDAO)); + result.addAll(GenericAllocationRow.toGenericAllocations( + resourceAllocations, searchModel)); 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 ca57540b1..a3a55d764 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,11 +34,11 @@ import org.navalplanner.business.planner.entities.ResourceAllocation; 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.business.resources.entities.ResourceEnum; import org.navalplanner.business.workingday.ResourcesPerDay; +import org.navalplanner.web.resources.search.IResourceSearchModel; /** * The information required for creating a {@link GenericResourceAllocation} @@ -68,7 +68,8 @@ public class GenericAllocationRow extends AllocationRow { } public static GenericAllocationRow from( - GenericResourceAllocation resourceAllocation, IResourceDAO resourceDAO) { + GenericResourceAllocation resourceAllocation, + IResourceSearchModel searchModel) { GenericAllocationRow result = createDefault(resourceAllocation .getResourceType()); result.setOrigin(resourceAllocation); @@ -77,7 +78,10 @@ public class GenericAllocationRow extends AllocationRow { .getNonConsolidatedResourcePerDay()); result.criterions = resourceAllocation.getCriterions(); - result.resources = resourceDAO.findSatisfyingAllCriterionsAtSomePoint(result.criterions); + result.resources = new ArrayList(searchModel + .searchBy(resourceAllocation.getResourceType()) + .byCriteria(resourceAllocation.getCriterions()) + .byLimiting(resourceAllocation.isLimiting()).execute()); result.setName(Criterion .getCaptionForCriterionsFrom(resourceAllocation)); return result; @@ -93,11 +97,13 @@ public class GenericAllocationRow extends AllocationRow { } public static Collection toGenericAllocations( - Collection> resourceAllocations, IResourceDAO resourceDAO) { + Collection> resourceAllocations, + IResourceSearchModel searchModel) { ArrayList result = new ArrayList(); for (ResourceAllocation resourceAllocation : resourceAllocations) { if (resourceAllocation instanceof GenericResourceAllocation) { - result.add(from((GenericResourceAllocation) resourceAllocation, resourceDAO)); + result.add(from((GenericResourceAllocation) resourceAllocation, + searchModel)); } } 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 079907d2b..4c8ad874f 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 @@ -251,8 +251,8 @@ public class ResourceAllocationModel implements IResourceAllocationModel { reattachCriterions(this.task.getHoursGroup().getValidCriterions()); loadResources(this.task.getSatisfiedResourceAllocations()); loadDerivedAllocations(this.task.getSatisfiedResourceAllocations()); - List initialRows = AllocationRow.toRows(task - .getNonLimitingResourceAllocations(), resourceDAO); + List initialRows = AllocationRow.toRows( + task.getNonLimitingResourceAllocations(), searchModel); allocationRowsHandler = AllocationRowsHandler.create(task, initialRows, createWorkerFinder()); return allocationRowsHandler;