ItEr37S08CUCreacionUnidadesPlanificacionItEr36S11: Renaming AllocationBeingModified to ResourcesPerDayModification to reflect better the intent of the class

This commit is contained in:
Óscar González Fernández 2009-12-01 20:41:57 +01:00
parent 5f5691fc84
commit e315e6b047
13 changed files with 96 additions and 96 deletions

View file

@ -33,7 +33,7 @@ import org.apache.commons.lang.Validate;
import org.joda.time.LocalDate;
import org.navalplanner.business.calendars.entities.IWorkHours;
import org.navalplanner.business.calendars.entities.SameWorkHoursEveryDay;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification;
import org.navalplanner.business.resources.entities.Criterion;
import org.navalplanner.business.resources.entities.Resource;
@ -272,15 +272,15 @@ public class GenericResourceAllocation extends
}
@Override
public AllocationBeingModified asAllocationBeingModified() {
return AllocationBeingModified.create(this,
public ResourcesPerDayModification asResourcesPerDayModification() {
return ResourcesPerDayModification.create(this,
getResourcesPerDay(), getAssociatedResources());
}
@Override
public AllocationBeingModified withDesiredResourcesPerDay(
public ResourcesPerDayModification withDesiredResourcesPerDay(
ResourcesPerDay resourcesPerDay) {
return AllocationBeingModified.create(this, resourcesPerDay,
return ResourcesPerDayModification.create(this, resourcesPerDay,
getAssociatedResources());
}

View file

@ -37,7 +37,7 @@ 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.ResourcesPerDayModification;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocatorForSpecifiedResourcesPerDayAndHours;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocatorForTaskDurationAndSpecifiedResourcesPerDay;
import org.navalplanner.business.resources.entities.Resource;
@ -101,18 +101,18 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
}
public static AllocationsCurried allocating(
List<AllocationBeingModified> resourceAllocations) {
List<ResourcesPerDayModification> resourceAllocations) {
return new AllocationsCurried(resourceAllocations);
}
public static class AllocationsCurried {
private final List<AllocationBeingModified> allocations;
private final List<ResourcesPerDayModification> allocations;
private final Task task;
public AllocationsCurried(
List<AllocationBeingModified> resourceAllocations) {
List<ResourcesPerDayModification> resourceAllocations) {
Validate.notNull(resourceAllocations);
Validate.notEmpty(resourceAllocations);
Validate.noNullElements(resourceAllocations);
@ -125,8 +125,8 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
}
private static void checkNoAllocationWithZeroResourcesPerDay(
List<AllocationBeingModified> allocations) {
for (AllocationBeingModified r : allocations) {
List<ResourcesPerDayModification> allocations) {
for (ResourcesPerDayModification r : allocations) {
if (isZero(r.getGoal().getAmount())) {
throw new IllegalArgumentException(
"all resources per day must be no zero");
@ -139,9 +139,9 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
}
private static void checkNoOneHasNullTask(
List<AllocationBeingModified> allocations) {
for (AllocationBeingModified allocationBeingModified : allocations) {
if (allocationBeingModified
List<ResourcesPerDayModification> allocations) {
for (ResourcesPerDayModification resourcesPerDayModification : allocations) {
if (resourcesPerDayModification
.getBeingModified().getTask() == null) {
throw new IllegalArgumentException(
"all allocations must have task");
@ -150,9 +150,9 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
}
private static void checkAllHaveSameTask(
List<AllocationBeingModified> resourceAllocations) {
List<ResourcesPerDayModification> resourceAllocations) {
Task task = null;
for (AllocationBeingModified r : resourceAllocations) {
for (ResourcesPerDayModification r : resourceAllocations) {
if (task == null) {
task = r.getBeingModified().getTask();
}
@ -169,7 +169,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
@Override
protected List<DayAssignment> createAssignmentsAtDay(
AllocationBeingModified allocation, LocalDate day,
ResourcesPerDayModification allocation, LocalDate day,
Integer limit) {
return allocation.createAssignmentsAtDay(day, limit);
}
@ -241,10 +241,10 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
return task;
}
public abstract AllocationBeingModified withDesiredResourcesPerDay(
public abstract ResourcesPerDayModification withDesiredResourcesPerDay(
ResourcesPerDay resourcesPerDay);
public abstract AllocationBeingModified asAllocationBeingModified();
public abstract ResourcesPerDayModification asResourcesPerDayModification();
public abstract IAllocatable withPreviousAssociatedResources();

View file

@ -32,7 +32,7 @@ import org.hibernate.validator.NotNull;
import org.joda.time.LocalDate;
import org.navalplanner.business.calendars.entities.CombinedWorkHours;
import org.navalplanner.business.calendars.entities.IWorkHours;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.business.resources.entities.Worker;
@ -202,14 +202,14 @@ public class SpecificResourceAllocation extends
}
@Override
public AllocationBeingModified asAllocationBeingModified() {
return AllocationBeingModified.create(this, getResourcesPerDay());
public ResourcesPerDayModification asResourcesPerDayModification() {
return ResourcesPerDayModification.create(this, getResourcesPerDay());
}
@Override
public AllocationBeingModified withDesiredResourcesPerDay(
public ResourcesPerDayModification withDesiredResourcesPerDay(
ResourcesPerDay resourcesPerDay) {
return AllocationBeingModified.create(this, resourcesPerDay);
return ResourcesPerDayModification.create(this, resourcesPerDay);
}
}

View file

@ -37,7 +37,7 @@ import org.navalplanner.business.orders.entities.AggregatedHoursGroup;
import org.navalplanner.business.orders.entities.HoursGroup;
import org.navalplanner.business.orders.entities.OrderElement;
import org.navalplanner.business.orders.entities.TaskSource;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification;
import org.navalplanner.business.resources.entities.Criterion;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.business.resources.entities.Worker;
@ -289,7 +289,7 @@ public class Task extends TaskElement {
protected void moveAllocations() {
List<ModifiedAllocation> copied = ModifiedAllocation
.copy(resourceAllocations);
List<AllocationBeingModified> allocations = AllocationBeingModified
List<ResourcesPerDayModification> allocations = ResourcesPerDayModification
.fromExistent(ModifiedAllocation.modified(copied));
if (allocations.isEmpty()) {
return;

View file

@ -39,19 +39,19 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
private final Task task;
private List<AllocationBeingModified> allocations;
private List<ResourcesPerDayModification> allocations;
private Map<AllocationBeingModified, List<DayAssignment>> resultAssignments = new HashMap<AllocationBeingModified, List<DayAssignment>>();
private Map<ResourcesPerDayModification, List<DayAssignment>> resultAssignments = new HashMap<ResourcesPerDayModification, List<DayAssignment>>();
public AllocatorForSpecifiedResourcesPerDayAndHours(Task task,
List<AllocationBeingModified> allocations) {
List<ResourcesPerDayModification> allocations) {
this.task = task;
this.allocations = allocations;
initializeResultsMap();
}
private void initializeResultsMap() {
for (AllocationBeingModified r : allocations) {
for (ResourcesPerDayModification r : allocations) {
resultAssignments.put(r, new ArrayList<DayAssignment>());
}
}
@ -71,7 +71,7 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
}
private void setAssignmentsForEachAllocation() {
for (Entry<AllocationBeingModified, List<DayAssignment>> entry : resultAssignments
for (Entry<ResourcesPerDayModification, List<DayAssignment>> entry : resultAssignments
.entrySet()) {
ResourceAllocation<?> allocation = entry.getKey()
.getBeingModified();
@ -87,13 +87,13 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
List<DayAssignment> dayAssignments);
protected abstract List<DayAssignment> createAssignmentsAtDay(
AllocationBeingModified allocation, LocalDate day, Integer limit);
ResourcesPerDayModification allocation, LocalDate day, Integer limit);
private int assignForDay(LocalDate day, int toBeAssigned) {
int i = 0;
int total = 0;
List<Integer> maxPerAllocations = calculateLimits(toBeAssigned);
for (AllocationBeingModified each : allocations) {
for (ResourcesPerDayModification each : allocations) {
List<DayAssignment> assignments = createAssignmentsAtDay(each, day,
maxPerAllocations.get(i));
resultAssignments.get(each).addAll(assignments);
@ -158,7 +158,7 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
private BigDecimal sumAll() {
BigDecimal result = new BigDecimal(0);
for (AllocationBeingModified r : allocations) {
for (ResourcesPerDayModification r : allocations) {
result = result.add(r.getGoal().getAmount());
}
return result;

View file

@ -26,21 +26,21 @@ import org.joda.time.LocalDate;
public class AllocatorForTaskDurationAndSpecifiedResourcesPerDay {
private List<AllocationBeingModified> allocations;
private List<ResourcesPerDayModification> allocations;
public AllocatorForTaskDurationAndSpecifiedResourcesPerDay(
List<AllocationBeingModified> allocations) {
List<ResourcesPerDayModification> allocations) {
this.allocations = allocations;
}
public void allocateOnTaskLength() {
for (AllocationBeingModified allocation : allocations) {
for (ResourcesPerDayModification allocation : allocations) {
allocation.applyAllocationOnAllTaskLength();
}
}
public void allocateUntil(LocalDate endExclusive) {
for (AllocationBeingModified allocation : allocations) {
for (ResourcesPerDayModification allocation : allocations) {
allocation.applyAllocationUntil(endExclusive);
}
}

View file

@ -34,13 +34,13 @@ import org.navalplanner.business.planner.entities.ResourcesPerDay;
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
import org.navalplanner.business.resources.entities.Resource;
public abstract class AllocationBeingModified {
public abstract class ResourcesPerDayModification {
private static class GenericAllocationBeingModified extends
AllocationBeingModified {
private static class OnGenericAllocation extends
ResourcesPerDayModification {
private final GenericResourceAllocation genericAllocation;
GenericAllocationBeingModified(
OnGenericAllocation(
GenericResourceAllocation resourceAllocation,
ResourcesPerDay resourcesPerDay,
Collection<? extends Resource> resources) {
@ -68,12 +68,12 @@ public abstract class AllocationBeingModified {
}
}
private static class SpecificAllocationBeingModified extends
AllocationBeingModified {
private static class OnSpecificAllocation extends
ResourcesPerDayModification {
private final SpecificResourceAllocation resourceAllocation;
SpecificAllocationBeingModified(
OnSpecificAllocation(
SpecificResourceAllocation resourceAllocation,
ResourcesPerDay resourcesPerDay,
Collection<? extends Resource> resources) {
@ -99,29 +99,29 @@ public abstract class AllocationBeingModified {
}
}
public static AllocationBeingModified create(
public static ResourcesPerDayModification create(
GenericResourceAllocation resourceAllocation,
ResourcesPerDay resourcesPerDay, List<Resource> resources) {
return new GenericAllocationBeingModified(resourceAllocation,
return new OnGenericAllocation(resourceAllocation,
resourcesPerDay, resources);
}
public static AllocationBeingModified create(
public static ResourcesPerDayModification create(
SpecificResourceAllocation resourceAllocation,
ResourcesPerDay resourcesPerDay) {
return new SpecificAllocationBeingModified(resourceAllocation,
return new OnSpecificAllocation(resourceAllocation,
resourcesPerDay, Collections.singletonList(resourceAllocation
.getResource()));
}
public static List<AllocationBeingModified> fromExistent(
public static List<ResourcesPerDayModification> fromExistent(
Collection<? extends ResourceAllocation<?>> allocations) {
List<AllocationBeingModified> result = new ArrayList<AllocationBeingModified>();
List<ResourcesPerDayModification> result = new ArrayList<ResourcesPerDayModification>();
for (ResourceAllocation<?> resourceAllocation : allocations) {
ResourcesPerDay perDay = resourceAllocation
.getResourcesPerDay();
Validate.notNull(perDay);
result.add(resourceAllocation.asAllocationBeingModified());
result.add(resourceAllocation.asResourcesPerDayModification());
}
return result;
}
@ -132,7 +132,7 @@ public abstract class AllocationBeingModified {
private final List<Resource> resourcesOnWhichApplyAllocation;
private AllocationBeingModified(
private ResourcesPerDayModification(
ResourceAllocation<?> resourceAllocation,
ResourcesPerDay resourcesPerDay,
Collection<? extends Resource> resources) {
@ -152,9 +152,9 @@ public abstract class AllocationBeingModified {
}
public static List<ResourceAllocation<?>> stripResourcesPerDay(
Collection<AllocationBeingModified> withResourcesPerDay) {
Collection<ResourcesPerDayModification> withResourcesPerDay) {
List<ResourceAllocation<?>> result = new ArrayList<ResourceAllocation<?>>();
for (AllocationBeingModified r : withResourcesPerDay) {
for (ResourcesPerDayModification r : withResourcesPerDay) {
result.add(r.getBeingModified());
}
return result;

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.AllocationBeingModified;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.business.resources.entities.Worker;
public class AllocationUntilFillingHoursTest {
private List<AllocationBeingModified> allocations = new ArrayList<AllocationBeingModified>();
private List<ResourcesPerDayModification> allocations = new ArrayList<ResourcesPerDayModification>();
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<AllocationBeingModified>());
.allocating(new ArrayList<ResourcesPerDayModification>());
}
@Test
@ -167,7 +167,7 @@ public class AllocationUntilFillingHoursTest {
private void givenGenericAllocation(ResourcesPerDay resourcesPerDay) {
createTaskIfNotCreatedYet();
allocations.add(AllocationBeingModified.create(GenericResourceAllocation
allocations.add(ResourcesPerDayModification.create(GenericResourceAllocation
.create(task), resourcesPerDay, resources));
}
@ -178,7 +178,7 @@ public class AllocationUntilFillingHoursTest {
for (ResourcesPerDay resourcesPerDay : specifiedResourcesPerDay) {
SpecificResourceAllocation allocation = createSpecificResourceAllocationFor(
task, worker);
allocations.add(AllocationBeingModified.create(allocation,
allocations.add(ResourcesPerDayModification.create(allocation,
resourcesPerDay));
}
}
@ -203,26 +203,26 @@ public class AllocationUntilFillingHoursTest {
}
private void givenAllocationsWithoutTask() {
allocations.add(AllocationBeingModified.create(
allocations.add(ResourcesPerDayModification.create(
(SpecificResourceAllocation)
createStubAllocationReturning(
SpecificResourceAllocation.class, null),
ResourcesPerDay.amount(2)));
allocations.add(AllocationBeingModified.create(
allocations.add(ResourcesPerDayModification.create(
createStubAllocationReturning(SpecificResourceAllocation.class,
null), ResourcesPerDay.amount(2)));
}
private void givenAllocationsBelongingToDifferentTasks() {
Task task = createStubTask();
allocations.add(AllocationBeingModified.create(
allocations.add(ResourcesPerDayModification.create(
createStubAllocationReturning(SpecificResourceAllocation.class,
task), ResourcesPerDay.amount(2)));
allocations.add(AllocationBeingModified.create(
allocations.add(ResourcesPerDayModification.create(
createStubAllocationReturning(SpecificResourceAllocation.class,
task), ResourcesPerDay.amount(2)));
Task other = createStubTask();
allocations.add(AllocationBeingModified.create(
allocations.add(ResourcesPerDayModification.create(
createStubAllocationReturning(SpecificResourceAllocation.class,
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.AllocationBeingModified;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification;
/**
* @author Óscar González Fernández <ogonzalez@igalia.com>
@ -45,9 +45,9 @@ import org.navalplanner.business.planner.entities.allocationalgorithms.Allocatio
public class AllocationResult {
private static Map<ResourceAllocation<?>, ResourceAllocation<?>> translation(
Map<AllocationBeingModified, ResourceAllocation<?>> fromDetachedToAttached) {
Map<ResourcesPerDayModification, ResourceAllocation<?>> fromDetachedToAttached) {
Map<ResourceAllocation<?>, ResourceAllocation<?>> result = new HashMap<ResourceAllocation<?>, ResourceAllocation<?>>();
for (Entry<AllocationBeingModified, ResourceAllocation<?>> entry : fromDetachedToAttached
for (Entry<ResourcesPerDayModification, ResourceAllocation<?>> entry : fromDetachedToAttached
.entrySet()) {
result
.put(entry.getKey().getBeingModified(), entry
@ -70,7 +70,7 @@ public class AllocationResult {
Task task,
CalculatedValue calculatedValue,
AggregateOfResourceAllocations aggregate,
Map<AllocationBeingModified, ResourceAllocation<?>> fromDetachedAllocationToAttached) {
Map<ResourcesPerDayModification, ResourceAllocation<?>> fromDetachedAllocationToAttached) {
Validate.notNull(aggregate);
Validate.notNull(calculatedValue);
Validate.notNull(task);

View file

@ -30,7 +30,7 @@ import org.navalplanner.business.planner.entities.CalculatedValue;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.ResourcesPerDay;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.web.common.Util;
import org.zkoss.zk.ui.event.EventListener;
@ -107,7 +107,7 @@ public abstract class AllocationRow {
SimpleConstraint.NO_NEGATIVE));
}
public abstract AllocationBeingModified toAllocationBeingModified(
public abstract ResourcesPerDayModification toResourcesPerDayModification(
Task task);
public boolean isCreating() {

View file

@ -32,7 +32,7 @@ import org.navalplanner.business.planner.entities.GenericResourceAllocation;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.ResourcesPerDay;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification;
import org.navalplanner.business.resources.entities.Criterion;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.web.resourceload.ResourceLoadModel;
@ -92,10 +92,10 @@ public class GenericAllocationRow extends AllocationRow {
}
@Override
public AllocationBeingModified toAllocationBeingModified(Task task) {
public ResourcesPerDayModification toResourcesPerDayModification(Task task) {
GenericResourceAllocation genericResourceAllocation = GenericResourceAllocation
.create(task, criterions);
return AllocationBeingModified.create(genericResourceAllocation,
return ResourcesPerDayModification.create(genericResourceAllocation,
getResourcesPerDay(), this.resources);
}

View file

@ -35,7 +35,7 @@ import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations
import org.navalplanner.business.planner.entities.CalculatedValue;
import org.navalplanner.business.planner.entities.ResourceAllocation;
import org.navalplanner.business.planner.entities.Task;
import org.navalplanner.business.planner.entities.allocationalgorithms.AllocationBeingModified;
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;
@ -45,19 +45,19 @@ public class ResourceAllocationsBeingEdited {
public static AllocationResult createInitialAllocation(Task task) {
Set<ResourceAllocation<?>> resourceAllocations = task
.getResourceAllocations();
Map<AllocationBeingModified, ResourceAllocation<?>> forModification = forModification(resourceAllocations);
Map<ResourcesPerDayModification, ResourceAllocation<?>> forModification = forModification(resourceAllocations);
AggregateOfResourceAllocations aggregate = new AggregateOfResourceAllocations(
AllocationBeingModified.stripResourcesPerDay(forModification
ResourcesPerDayModification.stripResourcesPerDay(forModification
.keySet()));
return new AllocationResult(task, task.getCalculatedValue(), aggregate,
forModification);
}
private static Map<AllocationBeingModified, ResourceAllocation<?>> forModification(
private static Map<ResourcesPerDayModification, ResourceAllocation<?>> forModification(
Collection<ResourceAllocation<?>> resourceAllocations) {
Map<AllocationBeingModified, ResourceAllocation<?>> result = new HashMap<AllocationBeingModified, ResourceAllocation<?>>();
Map<ResourcesPerDayModification, ResourceAllocation<?>> result = new HashMap<ResourcesPerDayModification, ResourceAllocation<?>>();
for (ResourceAllocation<?> resourceAllocation : resourceAllocations) {
result.put(resourceAllocation.copy().asAllocationBeingModified(),
result.put(resourceAllocation.copy().asResourcesPerDayModification(),
resourceAllocation);
}
return result;
@ -188,8 +188,8 @@ public class ResourceAllocationsBeingEdited {
public AllocationResult doAllocation() {
checkInvalidValues();
Map<AllocationBeingModified, ResourceAllocation<?>> fromDetachedToAttached = getAllocationsWithRelationshipsToOriginal();
List<AllocationBeingModified> allocations = asList(fromDetachedToAttached);
Map<ResourcesPerDayModification, ResourceAllocation<?>> fromDetachedToAttached = getAllocationsWithRelationshipsToOriginal();
List<ResourcesPerDayModification> allocations = asList(fromDetachedToAttached);
if (!allocations.isEmpty()) {
switch (calculatedValue) {
case NUMBER_OF_HOURS:
@ -205,40 +205,40 @@ public class ResourceAllocationsBeingEdited {
}
}
AllocationResult result = new AllocationResult(task, calculatedValue,
new AggregateOfResourceAllocations(AllocationBeingModified
new AggregateOfResourceAllocations(ResourcesPerDayModification
.stripResourcesPerDay(allocations)),
fromDetachedToAttached);
daysDuration = result.getDaysDuration();
return result;
}
private Map<AllocationBeingModified, ResourceAllocation<?>> getAllocationsWithRelationshipsToOriginal() {
private Map<ResourcesPerDayModification, ResourceAllocation<?>> getAllocationsWithRelationshipsToOriginal() {
Map<AllocationRow, ResourceAllocation<?>> allocationsWithTheirRelatedAllocationsOnTask = allocationsWithTheirRelatedAllocationsOnTask();
Map<AllocationBeingModified, ResourceAllocation<?>> fromDetachedToAttached = instantiate(allocationsWithTheirRelatedAllocationsOnTask);
Map<ResourcesPerDayModification, ResourceAllocation<?>> fromDetachedToAttached = instantiate(allocationsWithTheirRelatedAllocationsOnTask);
return fromDetachedToAttached;
}
private List<AllocationBeingModified> asList(
Map<AllocationBeingModified, ResourceAllocation<?>> map) {
return new ArrayList<AllocationBeingModified>(
private List<ResourcesPerDayModification> asList(
Map<ResourcesPerDayModification, ResourceAllocation<?>> map) {
return new ArrayList<ResourcesPerDayModification>(
map.keySet());
}
private Map<AllocationBeingModified, ResourceAllocation<?>> instantiate(
private Map<ResourcesPerDayModification, ResourceAllocation<?>> instantiate(
Map<AllocationRow, ResourceAllocation<?>> allocationsWithTheirRelatedAllocationsOnTask) {
Map<AllocationBeingModified, ResourceAllocation<?>> result = new HashMap<AllocationBeingModified, ResourceAllocation<?>>();
Map<ResourcesPerDayModification, ResourceAllocation<?>> result = new HashMap<ResourcesPerDayModification, ResourceAllocation<?>>();
for (Entry<AllocationRow, ResourceAllocation<?>> entry : allocationsWithTheirRelatedAllocationsOnTask
.entrySet()) {
AllocationRow key = entry.getKey();
AllocationBeingModified instantiated = instantiate(key);
ResourcesPerDayModification instantiated = instantiate(key);
result.put(instantiated, entry.getValue());
key.setLast(instantiated.getBeingModified());
}
return result;
}
private AllocationBeingModified instantiate(AllocationRow row) {
return row.toAllocationBeingModified(task);
private ResourcesPerDayModification instantiate(AllocationRow row) {
return row.toResourcesPerDayModification(task);
}
public FormBinder createFormBinder(

View file

@ -29,7 +29,7 @@ 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.AllocationBeingModified;
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification;
import org.navalplanner.business.resources.entities.Resource;
/**
@ -100,11 +100,11 @@ public class SpecificAllocationRow extends AllocationRow {
private Resource resource;
@Override
public AllocationBeingModified toAllocationBeingModified(Task task) {
public ResourcesPerDayModification toResourcesPerDayModification(Task task) {
SpecificResourceAllocation specific = SpecificResourceAllocation
.create(task);
specific.setResource(resource);
return AllocationBeingModified.create(specific, getResourcesPerDay());
return ResourcesPerDayModification.create(specific, getResourcesPerDay());
}
public Resource getResource() {