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;