Revert "Bug #1428: Possible fix"

This reverts commit 0a51bbdca0.
This commit is contained in:
Óscar González Fernández 2012-05-11 11:29:25 +02:00 committed by Manuel Rego Casasnovas
parent 91ea28a56c
commit 6a8b0ba9c8
2 changed files with 15 additions and 19 deletions

View file

@ -2160,7 +2160,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
getDayAssignmentsState().detachAssignments();
}
public void associateAssignmentsToResource() {
void associateAssignmentsToResource() {
for (DayAssignment dayAssignment : getAssignments()) {
dayAssignment.associateToResource();
}

View file

@ -29,6 +29,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.Validate;
import org.joda.time.LocalDate;
@ -88,19 +89,8 @@ public abstract class UntilFillingHoursAllocator {
IntraDayDate candidate = untilAllocating(dateFromWhichToAllocate,
each.allocation, each.duration);
currentResult = pickCurrentOrCandidate(currentResult, candidate);
setNewDataForAllocation(each.allocation, currentResult);
// This is done in order that new assignments are taken into account
// for the next allocations in the same task
each.allocation.getResourceAllocation()
.associateAssignmentsToResource();
}
// Then we detach the day assignments as they are going to be associated
// again later
for (EffortPerAllocation each : effortPerAllocation) {
each.allocation.getResourceAllocation().detach();
}
setAssignmentsForEachAllocation(currentResult);
return currentResult;
}
@ -238,16 +228,22 @@ public abstract class UntilFillingHoursAllocator {
}
}
private void setAssignmentsForEachAllocation(IntraDayDate resultDate) {
for (Entry<ResourcesPerDayModification, List<DayAssignment>> entry : resultAssignments
.entrySet()) {
setNewDataForAllocation(entry, resultDate);
}
}
private <T extends DayAssignment> void setNewDataForAllocation(
ResourcesPerDayModification resourcesPerDayModification,
Entry<ResourcesPerDayModification, List<DayAssignment>> entry,
IntraDayDate resultDate) {
@SuppressWarnings("unchecked")
ResourceAllocation<T> allocation = (ResourceAllocation<T>) resourcesPerDayModification
.getBeingModified();
ResourcesPerDay resourcesPerDay = resourcesPerDayModification.getGoal();
ResourceAllocation<T> allocation = (ResourceAllocation<T>) entry
.getKey().getBeingModified();
ResourcesPerDay resourcesPerDay = entry.getKey().getGoal();
@SuppressWarnings("unchecked")
List<T> value = (List<T>) resultAssignments
.get(resourcesPerDayModification);
List<T> value = (List<T>) entry.getValue();
setNewDataForAllocation(allocation, resultDate, resourcesPerDay,
value);
}