ItEr46S12CUVisualizacionResponsabilidadesTRaballoNaPlanificacion: Fixing infinite loop problem when calculating end date.
Using IWorkHours#thereAreAvailableHoursFrom is checked if there are enough hours to complete the task. This avoids infinite loop problem. The ResourceAllocation is marked as invalid.
This commit is contained in:
parent
4c3c072d4f
commit
16b2104ca6
2 changed files with 32 additions and 0 deletions
|
|
@ -200,6 +200,24 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
allocation.setResourcesPerDay(resourcesPerDay);
|
||||
allocation.resetGenericAssignmentsTo(dayAssignments);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean thereAreAvailableHoursFrom(
|
||||
LocalDate start,
|
||||
ResourcesPerDayModification resourcesPerDayModification,
|
||||
int hoursToAllocate) {
|
||||
IWorkHours workHoursPerDay = resourcesPerDayModification
|
||||
.getBeingModified().getWorkHoursPerDay();
|
||||
ResourcesPerDay resourcesPerDay = resourcesPerDayModification
|
||||
.getGoal();
|
||||
return workHoursPerDay.thereAreAvailableHoursFrom(start,
|
||||
resourcesPerDay, hoursToAllocate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void markUnsatisfied(ResourceAllocation<?> allocation) {
|
||||
allocation.markAsUnsatisfied();
|
||||
}
|
||||
};
|
||||
return allocator.untilAllocating(hoursToAllocate);
|
||||
}
|
||||
|
|
@ -530,6 +548,9 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
@Override
|
||||
public boolean thereAreAvailableHoursFrom(LocalDate date,
|
||||
ResourcesPerDay resourcesPerDay, int hours) {
|
||||
if (getTaskCalendar() == null) {
|
||||
return true;
|
||||
}
|
||||
return getTaskCalendar().thereAreAvailableHoursFrom(date,
|
||||
resourcesPerDay, hours);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,11 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
|
|||
Integer hoursToAllocate) {
|
||||
int hoursRemaining = hoursToAllocate;
|
||||
LocalDate start = new LocalDate(task.getStartDate().getTime());
|
||||
if (!thereAreAvailableHoursFrom(start, resourcesPerDayModification,
|
||||
hoursToAllocate)) {
|
||||
markUnsatisfied(resourcesPerDayModification.getBeingModified());
|
||||
return 0;
|
||||
}
|
||||
int day = 0;
|
||||
while (hoursRemaining > 0) {
|
||||
LocalDate current = start.plusDays(day);
|
||||
|
|
@ -105,6 +110,12 @@ public abstract class AllocatorForSpecifiedResourcesPerDayAndHours {
|
|||
protected abstract List<DayAssignment> createAssignmentsAtDay(
|
||||
ResourcesPerDayModification allocation, LocalDate day, Integer limit);
|
||||
|
||||
protected abstract boolean thereAreAvailableHoursFrom(LocalDate start,
|
||||
ResourcesPerDayModification resourcesPerDayModification,
|
||||
int hoursToAllocate);
|
||||
|
||||
protected abstract void markUnsatisfied(ResourceAllocation<?> beingModified);
|
||||
|
||||
private int assignForDay(
|
||||
ResourcesPerDayModification resourcesPerDayModification,
|
||||
LocalDate day, int remaining) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue