[Bug #732] NullPointerException in allocation of limiting resource
FEA: ItEr64S03BugFixing
This commit is contained in:
parent
837a12437c
commit
41517ca7e0
2 changed files with 21 additions and 2 deletions
|
|
@ -49,6 +49,12 @@ public class DateAndHour implements Comparable<DateAndHour> {
|
|||
this.hour = hour;
|
||||
}
|
||||
|
||||
public DateAndHour(DateAndHour dateAndHour) {
|
||||
Validate.notNull(dateAndHour.getDate());
|
||||
this.date = dateAndHour.getDate();
|
||||
this.hour = dateAndHour.getHour();
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
|
@ -147,4 +153,8 @@ public class DateAndHour implements Comparable<DateAndHour> {
|
|||
};
|
||||
}
|
||||
|
||||
public void plusYears(int years) {
|
||||
date = date.plusYears(years);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,13 +150,22 @@ public class Gap implements Comparable<Gap> {
|
|||
public List<Integer> getHoursInGapUntilAllocatingAndGoingToTheEnd(
|
||||
BaseCalendar calendar,
|
||||
DateAndHour realStart, DateAndHour allocationEnd, int total) {
|
||||
Validate.isTrue(getEndTime() == null || allocationEnd.compareTo(getEndTime()) <= 0);
|
||||
|
||||
Validate.isTrue(endTime == null || allocationEnd.compareTo(endTime) <= 0);
|
||||
Validate.isTrue(startTime == null
|
||||
|| realStart.compareTo(startTime) >= 0);
|
||||
Validate.isTrue(total >= 0);
|
||||
List<Integer> result = new ArrayList<Integer>();
|
||||
|
||||
// If endTime is null (last tasks) assume the end is in 10 years from now
|
||||
DateAndHour endDate = getEndTime();
|
||||
if (endDate == null) {
|
||||
endDate = new DateAndHour(realStart);
|
||||
endDate.plusYears(10);
|
||||
}
|
||||
|
||||
Iterator<PartialDay> daysUntilEnd = realStart.toIntraDayDate()
|
||||
.daysUntil(getEndTime().toIntraDayDate()).iterator();
|
||||
.daysUntil(endDate.toIntraDayDate()).iterator();
|
||||
while (daysUntilEnd.hasNext()) {
|
||||
PartialDay each = daysUntilEnd.next();
|
||||
int hoursAtDay = calendar.getCapacityOn(each).roundToHours();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue