@Override
public List<HistoricActivityStatisticsDto> getHistoricActivityStatistics(String processDefinitionId, Boolean includeCanceled, Boolean includeFinished,
Boolean includeCompleteScope, String sortBy, String sortOrder) {
HistoryService historyService = processEngine.getHistoryService();
HistoricActivityStatisticsQuery query = historyService.createHistoricActivityStatisticsQuery(processDefinitionId);
if (includeCanceled != null && includeCanceled) {
query.includeCanceled();
}
if (includeFinished != null && includeFinished) {
query.includeFinished();
}
if (includeCompleteScope != null && includeCompleteScope) {
query.includeCompleteScope();
}
setSortOptions(query, sortOrder, sortBy);
List<HistoricActivityStatisticsDto> result = new ArrayList<HistoricActivityStatisticsDto>();
List<HistoricActivityStatistics> statistics = query.list();
for (HistoricActivityStatistics currentStatistics : statistics) {
result.add(HistoricActivityStatisticsDto.fromHistoricActivityStatistics(currentStatistics));
}