ItEr45S19CUTraspasoDeResponsabilidadesTraballoEntreUnidadesPlanificacion: Adding querySuitableResources method.

It allows to query the resources that are currently suitable for this allocation.
This commit is contained in:
Óscar González Fernández 2010-01-29 01:06:57 +01:00
parent ec8bfe7c40
commit 8bc58d30b5
3 changed files with 23 additions and 0 deletions

View file

@ -35,6 +35,7 @@ import org.navalplanner.business.calendars.entities.IWorkHours;
import org.navalplanner.business.planner.entities.HoursDistributor.ResourceWithAssignedHours;
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;
@ -257,4 +258,9 @@ public class GenericResourceAllocation extends
getAssociatedResources());
}
@Override
public List<Resource> querySuitableResources(IResourceDAO resourceDAO) {
return resourceDAO.findAllSatisfyingCriterions(getCriterions());
}
}

View file

@ -44,6 +44,7 @@ import org.navalplanner.business.planner.entities.allocationalgorithms.Allocator
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocatorForTaskDurationAndSpecifiedResourcesPerDay;
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.Machine;
import org.navalplanner.business.resources.entities.MachineWorkersConfigurationUnit;
import org.navalplanner.business.resources.entities.Resource;
@ -708,4 +709,13 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
return !getAssignments().isEmpty();
}
/**
* Do a query to recover a list of resources that are suitable for this
* allocation. For a {@link SpecificResourceAllocation} returns the current
* resource. For a {@link GenericResourceAllocation} returns the resources
* that currently match this allocation criterions
* @return a list of resources that are proper for this allocation
*/
public abstract List<Resource> querySuitableResources(IResourceDAO resourceDAO);
}

View file

@ -23,6 +23,7 @@ package org.navalplanner.business.planner.entities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -34,6 +35,7 @@ import org.navalplanner.business.calendars.entities.CombinedWorkHours;
import org.navalplanner.business.calendars.entities.IWorkHours;
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.resources.entities.Worker;
@ -223,4 +225,9 @@ public class SpecificResourceAllocation extends
return ResourcesPerDayModification.create(this, resourcesPerDay);
}
@Override
public List<Resource> querySuitableResources(IResourceDAO resourceDAO) {
return Collections.singletonList(resource);
}
}