ItEr58S04ValidacionEProbasFuncionaisItEr57S04: [Bug #473] Avoid bug.
The data is inconsistent. The start date and end date from tasks and the ones from allocations are inconsistent. This happenend on a limiting resource. Make advance allocation resillient to incosistent data.
This commit is contained in:
parent
aa7da76554
commit
a0d7316a5a
2 changed files with 22 additions and 2 deletions
|
|
@ -836,6 +836,14 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
return Collections.unmodifiableSet(derivedAllocations);
|
||||
}
|
||||
|
||||
public LocalDate getStartConsideringAssignments() {
|
||||
List<? extends DayAssignment> assignments = getAssignments();
|
||||
if (assignments.isEmpty()) {
|
||||
return getStartDate();
|
||||
}
|
||||
return assignments.get(0).getDay();
|
||||
}
|
||||
|
||||
public LocalDate getStartDate() {
|
||||
return LocalDate.fromDateFields(task.getStartDate());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,12 +139,24 @@ public class AdvancedAllocationController extends GenericForwardComposer {
|
|||
return new Interval(task.getStartDate(), task
|
||||
.getEndDate());
|
||||
} else {
|
||||
LocalDate start = all.get(0).getStartDate();
|
||||
LocalDate end = getEnd(all);
|
||||
LocalDate start = min(all.get(0)
|
||||
.getStartConsideringAssignments(), all.get(0)
|
||||
.getStartDate());
|
||||
LocalDate taskEndDate = LocalDate.fromDateFields(task
|
||||
.getEndDate());
|
||||
LocalDate end = max(getEnd(all), taskEndDate);
|
||||
return new Interval(asDate(start), asDate(end));
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDate min(LocalDate... dates) {
|
||||
return Collections.min(Arrays.asList(dates), null);
|
||||
}
|
||||
|
||||
private LocalDate max(LocalDate... dates) {
|
||||
return Collections.max(Arrays.asList(dates), null);
|
||||
}
|
||||
|
||||
private static LocalDate getEnd(List<ResourceAllocation<?>> all) {
|
||||
ArrayList<ResourceAllocation<?>> reversed = reverse(all);
|
||||
LocalDate end = reversed.get(0).getEndDate();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue