The start and end date are always set when reseting all allocations
By default, if they are not specified, the start and end are taken from the task. This allows to calculate resources per day correctly when doing backwards scheduling. The external behavior is the same for resource allocations' start date. For the end date now instead of returning the date of the last day assignment, the date set at the reset method would be returned. FEA: ItEr62OTS04PlanificacionHaciaAtras
This commit is contained in:
parent
8596aeef8a
commit
3c9f569099
2 changed files with 27 additions and 13 deletions
|
|
@ -258,7 +258,9 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
protected <T extends DayAssignment> void setNewDataForAllocation(
|
||||
ResourceAllocation<T> allocation, IntraDayDate end,
|
||||
ResourcesPerDay resourcesPerDay, List<T> dayAssignments) {
|
||||
allocation.resetAssignmentsTo(dayAssignments, end);
|
||||
Task task = AllocationsSpecified.this.task;
|
||||
allocation.resetAssignmentsTo(dayAssignments,
|
||||
task.getIntraDayStartDate(), end);
|
||||
allocation.updateResourcesPerDay();
|
||||
}
|
||||
|
||||
|
|
@ -538,10 +540,12 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
@Override
|
||||
public void allocate(ResourcesPerDay resourcesPerDay) {
|
||||
IntraDayDate startInclusive = getStartAfterConsolidated();
|
||||
IntraDayDate allocationEnd = IntraDayDate
|
||||
.startOfDay(endExclusive);
|
||||
List<T> assignmentsCreated = createAssignments(
|
||||
resourcesPerDay, startInclusive,
|
||||
IntraDayDate.startOfDay(endExclusive));
|
||||
resetAssignmentsTo(assignmentsCreated);
|
||||
resourcesPerDay, startInclusive, allocationEnd);
|
||||
resetAssignmentsTo(assignmentsCreated, startInclusive,
|
||||
allocationEnd);
|
||||
updateResourcesPerDay();
|
||||
}
|
||||
|
||||
|
|
@ -587,7 +591,8 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
|
||||
@Override
|
||||
public void allocateHours(int hours) {
|
||||
allocate(end, hours(hours));
|
||||
allocate(getStartAfterConsolidated(),
|
||||
IntraDayDate.startOfDay(end), hours(hours));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -604,17 +609,11 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
};
|
||||
}
|
||||
|
||||
private void allocate(LocalDate end, EffortDuration durationToAssign) {
|
||||
IntraDayDate startInclusive = getStartAfterConsolidated();
|
||||
IntraDayDate endExclusive = IntraDayDate.startOfDay(end);
|
||||
allocate(startInclusive, endExclusive, durationToAssign);
|
||||
}
|
||||
|
||||
private void allocate(IntraDayDate startInclusive,
|
||||
IntraDayDate endExclusive, EffortDuration durationToAssign) {
|
||||
List<T> assignmentsCreated = createAssignments(startInclusive,
|
||||
endExclusive, durationToAssign);
|
||||
resetAssignmentsTo(assignmentsCreated);
|
||||
resetAssignmentsTo(assignmentsCreated, startInclusive, endExclusive);
|
||||
updateResourcesPerDay();
|
||||
}
|
||||
|
||||
|
|
@ -743,14 +742,17 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
protected abstract void copyAssignments(Scenario from, Scenario to);
|
||||
|
||||
protected void resetAssignmentsTo(List<T> assignments) {
|
||||
resetAssignmentsTo(assignments, null);
|
||||
resetAssignmentsTo(assignments, task.getIntraDayStartDate(),
|
||||
task.getIntraDayEndDate());
|
||||
}
|
||||
|
||||
protected void resetAssignmentsTo(List<T> assignments,
|
||||
IntraDayDate intraDayStart,
|
||||
IntraDayDate intraDayEnd) {
|
||||
removingAssignments(withoutConsolidated(getAssignments()));
|
||||
addingAssignments(assignments);
|
||||
updateOriginalTotalAssigment();
|
||||
getDayAssignmentsState().setIntraDayStart(intraDayStart);
|
||||
getDayAssignmentsState().setIntraDayEnd(intraDayEnd);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -316,6 +316,18 @@ public class SpecificResourceAllocationTest {
|
|||
equalTo(ResourcesPerDay.amount(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ifEndIsInTheMiddleOfADayFromEndUntilStartCalculatesResourcesPerDayCorrectly() {
|
||||
LocalDate start = new LocalDate(2000, 2, 4);
|
||||
IntraDayDate end = IntraDayDate.create(start.plusDays(3), hours(4));
|
||||
givenSpecificResourceAllocation(IntraDayDate.startOfDay(start), end);
|
||||
specificResourceAllocation.fromEndUntil(start).allocateHours(28);
|
||||
assertThat(specificResourceAllocation.getAssignments(),
|
||||
haveHours(8, 8, 8, 4));
|
||||
assertThat(specificResourceAllocation.getResourcesPerDay(),
|
||||
equalTo(ResourcesPerDay.amount(1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canBeNotifiedWhenADayAssignmentIsRemoved() {
|
||||
LocalDate start = new LocalDate(2000, 2, 4);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue