public JRDataSource getWorkingArrangementsPerOrderReportReport(
Order order,
TaskStatusEnum taskStatus, boolean showDependencies,
List<Label> labels, List<Criterion> criterions) {
if (order == null) {
return new JREmptyDataSource();
}
reattachmentOrder(order);
order.useSchedulingDataFor(scenarioManager.getCurrent());
List<WorkingArrangementPerOrderDTO> workingArrangementPerOrderList =
new ArrayList<WorkingArrangementPerOrderDTO>();
reattachLabels();
final List<Task> tasks = commonQueries.filteredTaskElements(order,
labels, criterions);
final List<Task> sortTasks = sortTasks(order, tasks);
final Date deadLineOrder = order.getDeadline();
for (Task task : sortTasks) {
// If taskStatus is ALL, add task and calculate its real status
if (TaskStatusEnum.ALL.equals(taskStatus)) {
workingArrangementPerOrderList
.addAll(createWorkingArrangementPerOrderDTOs(
deadLineOrder, task,
calculateTaskStatus(task), showDependencies));
continue;
}
// Only add task if matches selected taskStatus
if (matchTaskStatus(task, taskStatus)) {
workingArrangementPerOrderList
.addAll(createWorkingArrangementPerOrderDTOs(
deadLineOrder, task, taskStatus,
showDependencies));
}
}
if (!workingArrangementPerOrderList.isEmpty()) {
return new JRBeanCollectionDataSource(
workingArrangementPerOrderList);
} else {
return new JREmptyDataSource();
}
}