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:
Óscar González Fernández 2010-05-27 14:17:41 +02:00
parent aa7da76554
commit a0d7316a5a
2 changed files with 22 additions and 2 deletions

View file

@ -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());
}

View file

@ -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();