ItEr31S12ValidacionEProbasFuncionaisItEr30S17: Adding support for modifying existent allocations
This commit is contained in:
parent
89673f001b
commit
77459d43ed
1 changed files with 18 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue