ItEr32S12CUAsignacionGrupoRecursosAPlanificacionItEr31S15: Renaming class and properties in order to convey the meaning better

This commit is contained in:
Óscar González Fernández 2009-11-01 23:02:56 +01:00
parent 8ce5f94e96
commit a08c3b998f
8 changed files with 158 additions and 88 deletions

View file

@ -39,9 +39,9 @@ import org.navalplanner.business.calendars.entities.BaseCalendar;
import org.navalplanner.business.calendars.entities.IWorkHours;
import org.navalplanner.business.calendars.entities.SameWorkHoursEveryDay;
import org.navalplanner.business.common.BaseEntity;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocatorForSpecifiedResourcesPerDayAndHours;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocatorForTaskDurationAndSpecifiedResourcesPerDay;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourceAllocationWithDesiredResourcesPerDay;
import org.navalplanner.business.resources.entities.Resource;
/**
@ -103,18 +103,18 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
}
public static AllocationsCurried allocating(
List<ResourceAllocationWithDesiredResourcesPerDay> resourceAllocations) {
List<AllocationBeingModified> resourceAllocations) {
return new AllocationsCurried(resourceAllocations);
}
public static class AllocationsCurried {
private final List<ResourceAllocationWithDesiredResourcesPerDay> resourceAllocations;
private final List<AllocationBeingModified> resourceAllocations;
private final Task task;
public AllocationsCurried(
List<ResourceAllocationWithDesiredResourcesPerDay> resourceAllocations) {
List<AllocationBeingModified> resourceAllocations) {
Validate.notNull(resourceAllocations);
Validate.notEmpty(resourceAllocations);
Validate.noNullElements(resourceAllocations);
@ -122,14 +122,14 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
checkAllHaveSameTask(resourceAllocations);
checkNoAllocationWithZeroResourcesPerDay(resourceAllocations);
this.resourceAllocations = resourceAllocations;
this.task = resourceAllocations.get(0).getResourceAllocation()
this.task = resourceAllocations.get(0).getBeingModified()
.getTask();
}
private static void checkNoAllocationWithZeroResourcesPerDay(
List<ResourceAllocationWithDesiredResourcesPerDay> allocations) {
for (ResourceAllocationWithDesiredResourcesPerDay r : allocations) {
if (isZero(r.getResourcesPerDay().getAmount())) {
List<AllocationBeingModified> allocations) {
for (AllocationBeingModified r : allocations) {
if (isZero(r.getGoal().getAmount())) {
throw new IllegalArgumentException(
"all resources per day must be no zero");
}
@ -141,23 +141,23 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
}
private static void checkNoOneHasNullTask(
List<ResourceAllocationWithDesiredResourcesPerDay> allocations) {
for (ResourceAllocationWithDesiredResourcesPerDay resourceAllocationWithDesiredResourcesPerDay : allocations) {
if (resourceAllocationWithDesiredResourcesPerDay
.getResourceAllocation().getTask() == null)
List<AllocationBeingModified> allocations) {
for (AllocationBeingModified allocationBeingModified : allocations) {
if (allocationBeingModified
.getBeingModified().getTask() == null)
throw new IllegalArgumentException(
"all allocations must have task");
}
}
private static void checkAllHaveSameTask(
List<ResourceAllocationWithDesiredResourcesPerDay> resourceAllocations) {
List<AllocationBeingModified> resourceAllocations) {
Task task = null;
for (ResourceAllocationWithDesiredResourcesPerDay r : resourceAllocations) {
for (AllocationBeingModified r : resourceAllocations) {
if (task == null) {
task = r.getResourceAllocation().getTask();
task = r.getBeingModified().getTask();
}
if (!task.equals(r.getResourceAllocation().getTask())) {
if (!task.equals(r.getBeingModified().getTask())) {
throw new IllegalArgumentException(
"all allocations must belong to the same task");
}
@ -173,7 +173,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
public AllocationsAndResourcesCurried withExistentResources() {
return new AllocationsAndResourcesCurried(task,
getResourcesFrom(ResourceAllocationWithDesiredResourcesPerDay
getResourcesFrom(AllocationBeingModified
.stripResourcesPerDay(resourceAllocations)),
resourceAllocations);
}
@ -191,13 +191,13 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
public static class AllocationsAndResourcesCurried {
private List<Resource> resources;
private List<ResourceAllocationWithDesiredResourcesPerDay> allocations;
private List<AllocationBeingModified> allocations;
private final Task task;
public AllocationsAndResourcesCurried(Task task,
List<Resource> resources,
List<ResourceAllocationWithDesiredResourcesPerDay> allocations) {
List<AllocationBeingModified> allocations) {
this.task = task;
this.resources = resources;
this.allocations = allocations;
@ -232,8 +232,8 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
}
private boolean thereIsGenericAllocation() {
for (ResourceAllocationWithDesiredResourcesPerDay r : allocations) {
if (r.getResourceAllocation() instanceof GenericResourceAllocation) {
for (AllocationBeingModified r : allocations) {
if (r.getBeingModified() instanceof GenericResourceAllocation) {
return true;
}
}
@ -293,10 +293,9 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
return task;
}
public ResourceAllocationWithDesiredResourcesPerDay withDesiredResourcesPerDay(
public AllocationBeingModified withDesiredResourcesPerDay(
ResourcesPerDay resourcesPerDay) {
return new ResourceAllocationWithDesiredResourcesPerDay(this,
resourcesPerDay);
return new AllocationBeingModified(this, resourcesPerDay);
}
public abstract IAllocatable withPreviousAssociatedResources();

View file

@ -34,7 +34,7 @@ import org.joda.time.DateTime;
import org.joda.time.Days;
import org.joda.time.LocalDate;
import org.navalplanner.business.orders.entities.HoursGroup;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourceAllocationWithDesiredResourcesPerDay;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
import org.navalplanner.business.resources.entities.Criterion;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.business.resources.entities.Worker;
@ -315,7 +315,7 @@ public class Task extends TaskElement {
protected void moveAllocations() {
List<ModifiedAllocation> copied = ModifiedAllocation
.copy(resourceAllocations);
List<ResourceAllocationWithDesiredResourcesPerDay> allocations = ResourceAllocationWithDesiredResourcesPerDay
List<AllocationBeingModified> allocations = AllocationBeingModified
.fromExistent(ModifiedAllocation
.modified(copied));
if (allocations.isEmpty()) {

View file

@ -0,0 +1,73 @@
/*
* This file is part of ###PROJECT_NAME###
*
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.navalplanner.business.planner.entities.allocationalgorithms;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang.Validate;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.ResourcesPerDay;
public class AllocationBeingModified {
public static List<AllocationBeingModified> fromExistent(
Collection<? extends ResourceAllocation<?>> allocations) {
List<AllocationBeingModified> result = new ArrayList<AllocationBeingModified>();
for (ResourceAllocation<?> resourceAllocation : allocations) {
ResourcesPerDay perDay = resourceAllocation
.getResourcesPerDay();
Validate.notNull(perDay);
result.add(new AllocationBeingModified(
resourceAllocation, perDay));
}
return result;
}
private final ResourceAllocation<?> beingModified;
private final ResourcesPerDay goal;
public AllocationBeingModified(
ResourceAllocation<?> resourceAllocation,
ResourcesPerDay resourcesPerDay) {
this.beingModified = resourceAllocation;
this.goal = resourcesPerDay;
}
public ResourceAllocation<?> getBeingModified() {
return beingModified;
}
public ResourcesPerDay getGoal() {
return goal;
}
public static List<ResourceAllocation<?>> stripResourcesPerDay(
List<AllocationBeingModified> withResourcesPerDay) {
List<ResourceAllocation<?>> result = new ArrayList<ResourceAllocation<?>>();
for (AllocationBeingModified r : withResourcesPerDay) {
result.add(r.getBeingModified());
}
return result;
}
}

View file

@ -42,13 +42,13 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
private List<Resource> resources;
private List<ResourceAllocationWithDesiredResourcesPerDay> allocations;
private List<AllocationBeingModified> allocations;
private Map<ResourceAllocationWithDesiredResourcesPerDay, List<DayAssignment>> resultAssignments = new HashMap<ResourceAllocationWithDesiredResourcesPerDay, List<DayAssignment>>();
private Map<AllocationBeingModified, List<DayAssignment>> resultAssignments = new HashMap<AllocationBeingModified, List<DayAssignment>>();
public AllocatorForSpecifiedResourcesPerDayAndHours(Task task,
List<Resource> resources,
List<ResourceAllocationWithDesiredResourcesPerDay> allocations) {
List<AllocationBeingModified> allocations) {
this.task = task;
this.resources = resources;
this.allocations = allocations;
@ -56,7 +56,7 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
}
private void initializeResultsMap() {
for (ResourceAllocationWithDesiredResourcesPerDay r : allocations) {
for (AllocationBeingModified r : allocations) {
resultAssignments.put(r, new ArrayList<DayAssignment>());
}
}
@ -76,12 +76,12 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
}
private void setAssignmentsForEachAllocation() {
for (Entry<ResourceAllocationWithDesiredResourcesPerDay, List<DayAssignment>> entry : resultAssignments
for (Entry<AllocationBeingModified, List<DayAssignment>> entry : resultAssignments
.entrySet()) {
ResourceAllocation<?> allocation = entry.getKey()
.getResourceAllocation();
.getBeingModified();
ResourcesPerDay resourcesPerDay = entry.getKey()
.getResourcesPerDay();
.getGoal();
List<DayAssignment> value = entry.getValue();
setNewDataForAllocation(allocation, resourcesPerDay, value);
}
@ -99,11 +99,11 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
int i = 0;
int total = 0;
List<Integer> maxPerAllocations = calculateLimits(toBeAssigned);
for (ResourceAllocationWithDesiredResourcesPerDay withResourcesPerDay : allocations) {
for (AllocationBeingModified withResourcesPerDay : allocations) {
ResourceAllocation<?> resourceAllocation = withResourcesPerDay
.getResourceAllocation();
.getBeingModified();
ResourcesPerDay resourcesPerDay = withResourcesPerDay
.getResourcesPerDay();
.getGoal();
List<DayAssignment> assignments = createAssignmentsAtDay(
resourceAllocation, resources, day,
resourcesPerDay, maxPerAllocations.get(i));
@ -118,7 +118,7 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
BigDecimal[] limits = new BigDecimal[allocations.size()];
BigDecimal sumAll = sumAll();
for (int i = 0; i < limits.length; i++) {
BigDecimal amount = allocations.get(i).getResourcesPerDay()
BigDecimal amount = allocations.get(i).getGoal()
.getAmount();
limits[i] = amount.divide(sumAll, RoundingMode.DOWN).multiply(
new BigDecimal(toBeAssigned));
@ -169,8 +169,8 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
private BigDecimal sumAll() {
BigDecimal result = new BigDecimal(0);
for (ResourceAllocationWithDesiredResourcesPerDay r : allocations) {
result = result.add(r.getResourcesPerDay().getAmount());
for (AllocationBeingModified r : allocations) {
result = result.add(r.getGoal().getAmount());
}
return result;
}

View file

@ -30,21 +30,21 @@ import org.navalplanner.business.resources.entities.Resource;
public class AllocatorForTaskDurationAndSpecifiedResourcesPerDay {
private List<ResourceAllocationWithDesiredResourcesPerDay> allocations;
private List<AllocationBeingModified> allocations;
private List<Resource> resources;
public AllocatorForTaskDurationAndSpecifiedResourcesPerDay(
List<ResourceAllocationWithDesiredResourcesPerDay> allocations,
List<AllocationBeingModified> allocations,
List<Resource> resources) {
this.allocations = allocations;
this.resources = resources;
}
public void allocateOnTaskLength() {
for (ResourceAllocationWithDesiredResourcesPerDay allocation : allocations) {
doAllocationForFixedTask(allocation.getResourceAllocation(),
allocation.getResourcesPerDay());
for (AllocationBeingModified allocation : allocations) {
doAllocationForFixedTask(allocation.getBeingModified(),
allocation.getGoal());
}
}

View file

@ -38,13 +38,13 @@ import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.ResourcesPerDay;
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourceAllocationWithDesiredResourcesPerDay;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.business.resources.entities.Worker;
public class AllocationUntilFillingHoursTest {
private List<ResourceAllocationWithDesiredResourcesPerDay> allocations = new ArrayList<ResourceAllocationWithDesiredResourcesPerDay>();
private List<AllocationBeingModified> allocations = new ArrayList<AllocationBeingModified>();
private List<Resource> resources = new ArrayList<Resource>();
@ -67,7 +67,7 @@ public class AllocationUntilFillingHoursTest {
@Test(expected = IllegalArgumentException.class)
public void mustReceiveAtLeastOneAllocation() {
ResourceAllocation
.allocating(new ArrayList<ResourceAllocationWithDesiredResourcesPerDay>());
.allocating(new ArrayList<AllocationBeingModified>());
}
@Test
@ -84,7 +84,7 @@ public class AllocationUntilFillingHoursTest {
ResourceAllocation.allocating(allocations).withResources(resources)
.untilAllocating(32);
ResourceAllocation<?> allocation = allocations.get(0)
.getResourceAllocation();
.getBeingModified();
assertThat(allocation.getAssignments(), haveHours(16, 16));
}
@ -95,9 +95,9 @@ public class AllocationUntilFillingHoursTest {
ResourceAllocation.allocating(allocations).withResources(resources)
.untilAllocating(32);
ResourceAllocation<?> first = allocations.get(0)
.getResourceAllocation();
.getBeingModified();
ResourceAllocation<?> second = allocations.get(1)
.getResourceAllocation();
.getBeingModified();
assertThat(first.getAssignments(), haveHours(8, 8));
assertThat(second.getAssignments(), haveHours(8, 8));
}
@ -109,9 +109,9 @@ public class AllocationUntilFillingHoursTest {
ResourceAllocation.allocating(allocations).withResources(resources)
.untilAllocating(60);
ResourceAllocation<?> first = allocations.get(0)
.getResourceAllocation();
.getBeingModified();
ResourceAllocation<?> second = allocations.get(1)
.getResourceAllocation();
.getBeingModified();
assertThat(first.getAssignments(), haveHours(16, 16, 8));
assertThat(second.getAssignments(), haveHours(8, 8, 4));
}
@ -123,9 +123,9 @@ public class AllocationUntilFillingHoursTest {
ResourceAllocation.allocating(allocations).withResources(resources)
.untilAllocating(36);
ResourceAllocation<?> first = allocations.get(0)
.getResourceAllocation();
.getBeingModified();
ResourceAllocation<?> second = allocations.get(1)
.getResourceAllocation();
.getBeingModified();
assertThat(first.getAssignments(), haveHours(8, 8, 8));
assertThat(second.getAssignments(), haveHours(4, 4, 4));
}
@ -139,11 +139,11 @@ public class AllocationUntilFillingHoursTest {
ResourceAllocation.allocating(allocations).withResources(resources)
.untilAllocating(64);
ResourceAllocation<?> generic = allocations.get(0)
.getResourceAllocation();
.getBeingModified();
ResourceAllocation<?> firstSpecific = allocations.get(1)
.getResourceAllocation();
.getBeingModified();
ResourceAllocation<?> secondSpecific = allocations.get(2)
.getResourceAllocation();
.getBeingModified();
assertThat(generic.getAssignments(), haveHours(16, 16));
assertThat(firstSpecific.getAssignments(), haveHours(8, 8));
assertThat(secondSpecific.getAssignments(), haveHours(8, 8));
@ -177,7 +177,7 @@ public class AllocationUntilFillingHoursTest {
private void givenGenericAllocation(ResourcesPerDay resourcesPerDay) {
createTaskIfNotCreatedYet();
allocations.add(new ResourceAllocationWithDesiredResourcesPerDay(
allocations.add(new AllocationBeingModified(
GenericResourceAllocation.create(task), resourcesPerDay));
}
@ -188,7 +188,7 @@ public class AllocationUntilFillingHoursTest {
for (ResourcesPerDay resourcesPerDay : specifiedResourcesPerDay) {
SpecificResourceAllocation allocation = createSpecificResourceAllocationFor(
task, worker);
allocations.add(new ResourceAllocationWithDesiredResourcesPerDay(
allocations.add(new AllocationBeingModified(
allocation, resourcesPerDay));
}
}
@ -214,11 +214,11 @@ public class AllocationUntilFillingHoursTest {
private void givenAllocationsWithoutTask() {
allocations
.add(new ResourceAllocationWithDesiredResourcesPerDay(
.add(new AllocationBeingModified(
createStubAllocationReturning(null), ResourcesPerDay
.amount(2)));
allocations
.add(new ResourceAllocationWithDesiredResourcesPerDay(
.add(new AllocationBeingModified(
createStubAllocationReturning(null), ResourcesPerDay
.amount(2)));
}
@ -226,16 +226,16 @@ public class AllocationUntilFillingHoursTest {
private void givenAllocationsBelongingToDifferentTasks() {
Task task = createStubTask();
allocations
.add(new ResourceAllocationWithDesiredResourcesPerDay(
.add(new AllocationBeingModified(
createStubAllocationReturning(task), ResourcesPerDay
.amount(2)));
allocations
.add(new ResourceAllocationWithDesiredResourcesPerDay(
.add(new AllocationBeingModified(
createStubAllocationReturning(task), ResourcesPerDay
.amount(2)));
Task other = createStubTask();
allocations
.add(new ResourceAllocationWithDesiredResourcesPerDay(
.add(new AllocationBeingModified(
createStubAllocationReturning(other), ResourcesPerDay
.amount(2)));
}

View file

@ -36,7 +36,7 @@ import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.Task.ModifiedAllocation;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourceAllocationWithDesiredResourcesPerDay;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
/**
* @author Óscar González Fernández <ogonzalez@igalia.com>
@ -45,12 +45,12 @@ import org.navalplanner.business.planner.entities.allocationalgorithms.ResourceA
public class AllocationResult {
private static Map<ResourceAllocation<?>, ResourceAllocation<?>> translation(
Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> fromDetachedToAttached) {
Map<AllocationBeingModified, ResourceAllocation<?>> fromDetachedToAttached) {
Map<ResourceAllocation<?>, ResourceAllocation<?>> result = new HashMap<ResourceAllocation<?>, ResourceAllocation<?>>();
for (Entry<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> entry : fromDetachedToAttached
for (Entry<AllocationBeingModified, ResourceAllocation<?>> entry : fromDetachedToAttached
.entrySet()) {
result
.put(entry.getKey().getResourceAllocation(), entry
.put(entry.getKey().getBeingModified(), entry
.getValue());
}
return result;
@ -71,7 +71,7 @@ public class AllocationResult {
CalculatedValue calculatedValue,
AggregateOfResourceAllocations aggregate,
Integer daysDuration,
Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> fromDetachedAllocationToAttached) {
Map<AllocationBeingModified, ResourceAllocation<?>> fromDetachedAllocationToAttached) {
Validate.notNull(daysDuration);
Validate.notNull(aggregate);
Validate.notNull(calculatedValue);

View file

@ -40,7 +40,7 @@ import org.navalplanner.business.planner.entities.GenericResourceAllocation;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourceAllocationWithDesiredResourcesPerDay;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
import org.navalplanner.business.resources.daos.IResourceDAO;
import org.navalplanner.business.resources.entities.Resource;
@ -182,8 +182,8 @@ public class ResourceAllocationsBeingEdited {
public AllocationResult doAllocation() {
checkInvalidValues();
Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> fromDetachedToAttached = getAllocationsWithRelationshipsToOriginal();
List<ResourceAllocationWithDesiredResourcesPerDay> allocations = asList(fromDetachedToAttached);
Map<AllocationBeingModified, ResourceAllocation<?>> fromDetachedToAttached = getAllocationsWithRelationshipsToOriginal();
List<AllocationBeingModified> allocations = asList(fromDetachedToAttached);
switch (calculatedValue) {
case NUMBER_OF_HOURS:
ResourceAllocation.allocating(allocations)
@ -202,25 +202,25 @@ public class ResourceAllocationsBeingEdited {
}
return new AllocationResult(task, calculatedValue,
new AggregateOfResourceAllocations(
ResourceAllocationWithDesiredResourcesPerDay.stripResourcesPerDay(allocations)), daysDuration,
AllocationBeingModified.stripResourcesPerDay(allocations)), daysDuration,
fromDetachedToAttached);
}
private Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> getAllocationsWithRelationshipsToOriginal() {
private Map<AllocationBeingModified, ResourceAllocation<?>> getAllocationsWithRelationshipsToOriginal() {
Map<AllocationDTO, ResourceAllocation<?>> allocationsWithTheirRelatedAllocationsOnTask = allocationsWithTheirRelatedAllocationsOnTask();
Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> fromDetachedToAttached = instantiate(allocationsWithTheirRelatedAllocationsOnTask);
Map<AllocationBeingModified, ResourceAllocation<?>> fromDetachedToAttached = instantiate(allocationsWithTheirRelatedAllocationsOnTask);
return fromDetachedToAttached;
}
private List<ResourceAllocationWithDesiredResourcesPerDay> asList(
Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> map) {
return new ArrayList<ResourceAllocationWithDesiredResourcesPerDay>(
private List<AllocationBeingModified> asList(
Map<AllocationBeingModified, ResourceAllocation<?>> map) {
return new ArrayList<AllocationBeingModified>(
map.keySet());
}
private Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> instantiate(
private Map<AllocationBeingModified, ResourceAllocation<?>> instantiate(
Map<AllocationDTO, ResourceAllocation<?>> allocationsWithTheirRelatedAllocationsOnTask) {
Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> result = new HashMap<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>>();
Map<AllocationBeingModified, ResourceAllocation<?>> result = new HashMap<AllocationBeingModified, ResourceAllocation<?>>();
for (Entry<AllocationDTO, ResourceAllocation<?>> entry : allocationsWithTheirRelatedAllocationsOnTask
.entrySet()) {
AllocationDTO key = entry.getKey();
@ -229,9 +229,9 @@ public class ResourceAllocationsBeingEdited {
return result;
}
private ResourceAllocationWithDesiredResourcesPerDay instantiate(
private AllocationBeingModified instantiate(
AllocationDTO key) {
return new ResourceAllocationWithDesiredResourcesPerDay(
return new AllocationBeingModified(
createAllocation(key), key
.getResourcesPerDay());
}
@ -284,14 +284,12 @@ public class ResourceAllocationsBeingEdited {
buildMap(resourceAllocations));
}
private Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> buildMap(
private Map<AllocationBeingModified, ResourceAllocation<?>> buildMap(
Collection<ResourceAllocation<?>> resourceAllocations) {
Map<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>> result = new HashMap<ResourceAllocationWithDesiredResourcesPerDay, ResourceAllocation<?>>();
Map<AllocationBeingModified, ResourceAllocation<?>> result = new HashMap<AllocationBeingModified, ResourceAllocation<?>>();
for (ResourceAllocation<?> resourceAllocation : resourceAllocations) {
result.put(
new ResourceAllocationWithDesiredResourcesPerDay(
resourceAllocation, resourceAllocation
.getResourcesPerDay()), resourceAllocation);
result.put(new AllocationBeingModified(resourceAllocation,
resourceAllocation.getResourcesPerDay()),resourceAllocation);
}
return result;
}