[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
This commit is contained in:
parent
79c0bcd546
commit
c082a34640
3 changed files with 18 additions and 11 deletions
|
|
@ -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<AllocationRow> toRows(
|
||||
Collection<? extends ResourceAllocation<?>> resourceAllocations, IResourceDAO resourceDAO) {
|
||||
Collection<? extends ResourceAllocation<?>> resourceAllocations,
|
||||
IResourceSearchModel searchModel) {
|
||||
List<AllocationRow> result = new ArrayList<AllocationRow>();
|
||||
result.addAll(GenericAllocationRow
|
||||
.toGenericAllocations(resourceAllocations, resourceDAO));
|
||||
result.addAll(GenericAllocationRow.toGenericAllocations(
|
||||
resourceAllocations, searchModel));
|
||||
result.addAll(SpecificAllocationRow
|
||||
.toSpecificAllocations(resourceAllocations));
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -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<Resource>(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<GenericAllocationRow> toGenericAllocations(
|
||||
Collection<? extends ResourceAllocation<?>> resourceAllocations, IResourceDAO resourceDAO) {
|
||||
Collection<? extends ResourceAllocation<?>> resourceAllocations,
|
||||
IResourceSearchModel searchModel) {
|
||||
ArrayList<GenericAllocationRow> result = new ArrayList<GenericAllocationRow>();
|
||||
for (ResourceAllocation<?> resourceAllocation : resourceAllocations) {
|
||||
if (resourceAllocation instanceof GenericResourceAllocation) {
|
||||
result.add(from((GenericResourceAllocation) resourceAllocation, resourceDAO));
|
||||
result.add(from((GenericResourceAllocation) resourceAllocation,
|
||||
searchModel));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -251,8 +251,8 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
reattachCriterions(this.task.getHoursGroup().getValidCriterions());
|
||||
loadResources(this.task.getSatisfiedResourceAllocations());
|
||||
loadDerivedAllocations(this.task.getSatisfiedResourceAllocations());
|
||||
List<AllocationRow> initialRows = AllocationRow.toRows(task
|
||||
.getNonLimitingResourceAllocations(), resourceDAO);
|
||||
List<AllocationRow> initialRows = AllocationRow.toRows(
|
||||
task.getNonLimitingResourceAllocations(), searchModel);
|
||||
allocationRowsHandler = AllocationRowsHandler.create(task, initialRows,
|
||||
createWorkerFinder());
|
||||
return allocationRowsHandler;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue