[Bug #942] Logging a warning when it's not calendar capacity in 5 years to calculate end date for a task.
FEA: ItEr73S04BugFixing
This commit is contained in:
parent
cce6cfbfb0
commit
d26f47c960
1 changed files with 21 additions and 1 deletions
|
|
@ -33,6 +33,8 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.validator.AssertTrue;
|
||||
import org.hibernate.validator.Valid;
|
||||
import org.joda.time.Days;
|
||||
|
|
@ -64,6 +66,14 @@ import org.navalplanner.business.workingday.IntraDayDate.PartialDay;
|
|||
*/
|
||||
public class Task extends TaskElement implements ITaskPositionConstrained {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(Task.class);
|
||||
|
||||
/**
|
||||
* Maximum number of days in order to looking for calendar capacity (defined
|
||||
* to 5 years)
|
||||
*/
|
||||
private static int MAX_DAYS_LOOKING_CAPACITY = 360 * 5;
|
||||
|
||||
public static Task createTask(TaskSource taskSource) {
|
||||
Task task = new Task();
|
||||
OrderElement orderElement = taskSource.getOrderElement();
|
||||
|
|
@ -615,13 +625,23 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
|
|||
EffortDuration remaining) {
|
||||
IntraDayDate result = IntraDayDate.startOfDay(start.getDate());
|
||||
remaining = remaining.plus(start.getEffortDuration());
|
||||
LocalDate current = start.getDate();
|
||||
EffortDuration originalRemaining = remaining;
|
||||
LocalDate startDate = start.getDate();
|
||||
LocalDate current = startDate;
|
||||
while (!remaining.isZero()) {
|
||||
EffortDuration capacity = calendar.getCapacityOn(PartialDay
|
||||
.wholeDay(current));
|
||||
result = IntraDayDate.create(current, remaining);
|
||||
remaining = remaining.minus(min(capacity, remaining));
|
||||
current = current.plusDays(1);
|
||||
if (Days.daysBetween(startDate, current).getDays() > MAX_DAYS_LOOKING_CAPACITY) {
|
||||
LOG
|
||||
.warn("Calendar doesn't have enough capacity in 5 years, "
|
||||
+ "using 8h per day to calculate end date for the task");
|
||||
return IntraDayDate.create(startDate
|
||||
.plusDays(originalRemaining.getHours() / 8),
|
||||
EffortDuration.zero());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue