diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationRowsHandler.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationRowsHandler.java index bf45be85f..dd6fc39a4 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationRowsHandler.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AllocationRowsHandler.java @@ -34,29 +34,14 @@ import org.navalplanner.business.planner.entities.Task; import org.navalplanner.business.planner.entities.DerivedAllocationGenerator.IWorkerFinder; 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.Worker; public class AllocationRowsHandler { public static AllocationRowsHandler create(Task task, - List initialAllocations, IResourceDAO resourceDAO) { - return new AllocationRowsHandler(task, initialAllocations, - workersFinderOn(resourceDAO)); - } - - private static IWorkerFinder workersFinderOn(final IResourceDAO resourceDAO) { - return new IWorkerFinder() { - - @Override - public Collection findWorkersMatching( - Collection requiredCriterions) { - return Resource.workers(resourceDAO - .findAllSatisfyingCriterions(requiredCriterions)); - } - }; + List initialAllocations, IWorkerFinder workerFinder) { + return new AllocationRowsHandler(task, initialAllocations, workerFinder); } private final List currentRows; 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 87ca61a12..52d223686 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 @@ -39,12 +39,14 @@ import org.navalplanner.business.planner.entities.DayAssignment; import org.navalplanner.business.planner.entities.GenericResourceAllocation; import org.navalplanner.business.planner.entities.ResourceAllocation; import org.navalplanner.business.planner.entities.Task; +import org.navalplanner.business.planner.entities.DerivedAllocationGenerator.IWorkerFinder; import org.navalplanner.business.resources.daos.ICriterionDAO; import org.navalplanner.business.resources.daos.IResourceDAO; import org.navalplanner.business.resources.entities.Criterion; import org.navalplanner.business.resources.entities.CriterionSatisfaction; import org.navalplanner.business.resources.entities.CriterionType; import org.navalplanner.business.resources.entities.Resource; +import org.navalplanner.business.resources.entities.Worker; import org.navalplanner.web.planner.order.PlanningState; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanDefinition; @@ -216,11 +218,26 @@ public class ResourceAllocationModel implements IResourceAllocationModel { loadResources(this.task.getResourceAllocations()); List initialRows = AllocationRow.toRows(this.task .getResourceAllocations()); - allocationRowsHandler = AllocationRowsHandler.create( - task, initialRows, resourceDAO); + allocationRowsHandler = AllocationRowsHandler.create(task, initialRows, + createWorkerFinder()); return allocationRowsHandler; } + private IWorkerFinder createWorkerFinder() { + return new IWorkerFinder() { + + @Override + public Collection findWorkersMatching( + Collection requiredCriterions) { + reassociateResourcesWithSession(); + List findAllSatisfyingCriterions = resourceDAO + .findAllSatisfyingCriterions(requiredCriterions); + return Resource.workers(reloadResources(Resource + .workers(findAllSatisfyingCriterions))); + } + }; + } + private void loadCriterionsOfGenericAllocations() { Set> resourceAllocations = this.task .getResourceAllocations();