[Bug #943] Fix bug
When an allocation can not be satisfied keep the old resources per day and not update them from data. Thus when moving a task back to a place where it's satisfied the resources per day of the last satisfied allocation are used.
This commit is contained in:
parent
ee2af5828f
commit
27aabfa7bb
1 changed files with 12 additions and 1 deletions
|
|
@ -322,6 +322,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
IntraDayDate resultDate,
|
||||
ResourcesPerDay resourcesPerDay, List<T> dayAssignments) {
|
||||
Task task = AllocationsSpecified.this.task;
|
||||
allocation.setIntendedResourcesPerDay(resourcesPerDay);
|
||||
if (isForwardScheduling()) {
|
||||
allocation.resetAllAllocationAssignmentsTo(
|
||||
dayAssignments,
|
||||
|
|
@ -528,6 +529,9 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
}
|
||||
|
||||
protected void updateResourcesPerDay() {
|
||||
if (!isSatisfied()) {
|
||||
return;
|
||||
}
|
||||
ResourcesPerDay resourcesPerDay = calculateResourcesPerDayFromAssignments(getAssignments());
|
||||
if (resourcesPerDay == null) {
|
||||
this.resourcesPerDay = ResourcesPerDay.amount(0);
|
||||
|
|
@ -540,6 +544,12 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
this.resourcesPerDay = ResourcesPerDay.amount(amount);
|
||||
}
|
||||
|
||||
private void setIntendedResourcesPerDay(ResourcesPerDay resourcesPerDay) {
|
||||
Validate.notNull(resourcesPerDay);
|
||||
Validate.isTrue(!resourcesPerDay.isZero());
|
||||
this.resourcesPerDay = resourcesPerDay;
|
||||
}
|
||||
|
||||
public ResourceAllocation(Task task) {
|
||||
this(task, null);
|
||||
}
|
||||
|
|
@ -629,6 +639,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
@Override
|
||||
public final void allocate(ResourcesPerDay resourcesPerDay) {
|
||||
Task currentTask = getTask();
|
||||
setIntendedResourcesPerDay(resourcesPerDay);
|
||||
List<T> assignmentsCreated = createAssignments(resourcesPerDay,
|
||||
currentTask.getIntraDayStartDate(),
|
||||
currentTask.getIntraDayEndDate());
|
||||
|
|
@ -645,7 +656,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
assignmentsCreated.addAll(distributeForDay(day.getDate(),
|
||||
durationForDay));
|
||||
}
|
||||
return assignmentsCreated;
|
||||
return onlyNonZeroHours(assignmentsCreated);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue