ItEr39S16CUConfiguracionMaquinasItEr35S09: Avoiding LazyInitializationExceptions when calculating derived allocations.
This commit is contained in:
parent
16c96c7480
commit
286acc73f0
2 changed files with 21 additions and 19 deletions
|
|
@ -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<AllocationRow> initialAllocations, IResourceDAO resourceDAO) {
|
||||
return new AllocationRowsHandler(task, initialAllocations,
|
||||
workersFinderOn(resourceDAO));
|
||||
}
|
||||
|
||||
private static IWorkerFinder workersFinderOn(final IResourceDAO resourceDAO) {
|
||||
return new IWorkerFinder() {
|
||||
|
||||
@Override
|
||||
public Collection<Worker> findWorkersMatching(
|
||||
Collection<? extends Criterion> requiredCriterions) {
|
||||
return Resource.workers(resourceDAO
|
||||
.findAllSatisfyingCriterions(requiredCriterions));
|
||||
}
|
||||
};
|
||||
List<AllocationRow> initialAllocations, IWorkerFinder workerFinder) {
|
||||
return new AllocationRowsHandler(task, initialAllocations, workerFinder);
|
||||
}
|
||||
|
||||
private final List<AllocationRow> currentRows;
|
||||
|
|
|
|||
|
|
@ -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<AllocationRow> 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<Worker> findWorkersMatching(
|
||||
Collection<? extends Criterion> requiredCriterions) {
|
||||
reassociateResourcesWithSession();
|
||||
List<Resource> findAllSatisfyingCriterions = resourceDAO
|
||||
.findAllSatisfyingCriterions(requiredCriterions);
|
||||
return Resource.workers(reloadResources(Resource
|
||||
.workers(findAllSatisfyingCriterions)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void loadCriterionsOfGenericAllocations() {
|
||||
Set<ResourceAllocation<?>> resourceAllocations = this.task
|
||||
.getResourceAllocations();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue