} else if (task.getTimesheetBookingStatus() == TimesheetBookingStatus.TREE_CLOSED) {
errorMessage = "timesheet.error.taskNotBookable.treeClosedForBooking";
}
if (errorMessage != null) {
if (throwException == true) {
throw new AccessException(errorMessage, task.getTitle() + " (#" + task.getId() + ")");
}
return false;
}
node = node.getParent();
} while (node != null);
// 2. Has the task the booking status NO_BOOKING?
TimesheetBookingStatus bookingStatus = taskNode.getTask().getTimesheetBookingStatus();
node = taskNode;
while (bookingStatus == TimesheetBookingStatus.INHERIT && node.getParent() != null) {
node = node.getParent();
bookingStatus = node.getTask().getTimesheetBookingStatus();
}
if (bookingStatus == TimesheetBookingStatus.NO_BOOKING) {
if (throwException == true) {
throw new AccessException("timesheet.error.taskNotBookable.taskClosedForBooking", taskNode.getTask().getTitle()
+ " (#"
+ taskNode.getId()
+ ")");
}
return false;
}
if (taskNode.hasChilds() == true) {
// 3. Is the task not a leaf node and has this task or ancestor task the booking status ONLY_LEAFS?
node = taskNode;
do {
final TaskDO task = node.getTask();
if (task.getTimesheetBookingStatus() == TimesheetBookingStatus.ONLY_LEAFS) {
if (throwException == true) {
throw new AccessException("timesheet.error.taskNotBookable.onlyLeafsAllowedForBooking", taskNode.getTask().getTitle()
+ " (#"
+ taskNode.getId()
+ ")");
}
return false;
}
node = node.getParent();
} while (node != null);
// 4. Does any of the descendant task node has an assigned order position?
for (final TaskNode child : taskNode.getChilds()) {
if (taskTree.hasOrderPositions(child.getId(), true) == true) {
if (throwException == true) {
throw new AccessException("timesheet.error.taskNotBookable.orderPositionsFoundInSubTasks", taskNode.getTask().getTitle()
+ " (#"
+ taskNode.getId()
+ ")");
}
return false;