ItEr31S12ValidacionEProbasFuncionaisItEr30S17: Adding support for modifying existent allocations

This commit is contained in:
Óscar González Fernández 2009-10-20 00:11:57 +02:00
parent 89673f001b
commit 77459d43ed

View file

@ -26,8 +26,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.apache.commons.lang.Validate;
@ -156,6 +158,22 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
return new AllocationsAndResourcesCurried(task, resources,
resourceAllocations);
}
public AllocationsAndResourcesCurried withExistentResources() {
return new AllocationsAndResourcesCurried(task,
getResourcesFrom(ResourceAllocationWithDesiredResourcesPerDay
.stripResourcesPerDay(resourceAllocations)),
resourceAllocations);
}
private List<Resource> getResourcesFrom(
List<ResourceAllocation<?>> allocations) {
Set<Resource> resources = new HashSet<Resource>();
for (ResourceAllocation<?> resourceAllocation : allocations) {
resources.addAll(resourceAllocation.getAssociatedResources());
}
return new ArrayList<Resource>(resources);
}
}
public static class AllocationsAndResourcesCurried {