ItEr50S04ValidacionEProbasFuncionaisItEr49S04: [Bug #376] On assigning a generic allocation, fetch all possible resources matching task criteria

This commit is contained in:
Diego Pino Garcia 2010-03-10 09:11:12 +01:00 committed by Óscar González Fernández
parent 49d374d914
commit e4ffb40df9
3 changed files with 10 additions and 7 deletions

View file

@ -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<AllocationRow> toRows(
Collection<? extends ResourceAllocation<?>> resourceAllocations) {
Collection<? extends ResourceAllocation<?>> resourceAllocations, IResourceDAO resourceDAO) {
List<AllocationRow> result = new ArrayList<AllocationRow>();
result.addAll(GenericAllocationRow
.toGenericAllocations(resourceAllocations));
.toGenericAllocations(resourceAllocations, resourceDAO));
result.addAll(SpecificAllocationRow
.toSpecificAllocations(resourceAllocations));
return result;

View file

@ -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<GenericAllocationRow> toGenericAllocations(
Collection<? extends ResourceAllocation<?>> resourceAllocations) {
Collection<? extends ResourceAllocation<?>> resourceAllocations, IResourceDAO resourceDAO) {
ArrayList<GenericAllocationRow> result = new ArrayList<GenericAllocationRow>();
for (ResourceAllocation<?> resourceAllocation : resourceAllocations) {
if (resourceAllocation instanceof GenericResourceAllocation) {
result.add(from((GenericResourceAllocation) resourceAllocation));
result.add(from((GenericResourceAllocation) resourceAllocation, resourceDAO));
}
}
return result;

View file

@ -239,7 +239,7 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
loadResources(this.task.getSatisfiedResourceAllocations());
loadDerivedAllocations(this.task.getSatisfiedResourceAllocations());
List<AllocationRow> initialRows = AllocationRow.toRows(this.task
.getAllResourceAllocations());
.getAllResourceAllocations(), resourceDAO);
allocationRowsHandler = AllocationRowsHandler.create(task, initialRows,
createWorkerFinder());
return allocationRowsHandler;