List<TaskElement> result = new ArrayList<TaskElement>();
List<Order> list = getOrders(predicate);
for (Order order : list) {
order.useSchedulingDataFor(currentScenario, false);
TaskGroup associatedTaskElement = order.getAssociatedTaskElement();
if (associatedTaskElement != null) {
if (predicate != null) {
// If predicate includeChildren then we check if it accepts
// the element
if (!predicate.accepts(associatedTaskElement)) {
// If it doesn't accept the element we move on to the
// next order
continue;
}
}
// If predicate doesn't includeChildren then the orders where
// already filtered in the DB query.
// Otherwise they've been filtered with the predicate above, and
// if they didn't pass the filter the execution doesn't reach
// this point.
associatedTaskElement.setSimplifiedAssignedStatusCalculationEnabled(true);
result.add(associatedTaskElement);
}
}
Collections.sort(result,new Comparator<TaskElement>(){
@Override