if (includeIncidents != null && includeIncidentsForType != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeIncidentsForType can be set.");
}
ManagementService mgmtService = getProcessEngine().getManagementService();
ProcessDefinitionStatisticsQuery query = mgmtService.createProcessDefinitionStatisticsQuery();
if (includeFailedJobs != null && includeFailedJobs) {
query.includeFailedJobs();
}
if (includeIncidents != null && includeIncidents) {
query.includeIncidents();
} else if (includeIncidentsForType != null) {
query.includeIncidentsForType(includeIncidentsForType);
}
List<ProcessDefinitionStatistics> queryResults = query.list();
List<StatisticsResultDto> results = new ArrayList<StatisticsResultDto>();
for (ProcessDefinitionStatistics queryResult : queryResults) {
StatisticsResultDto dto = ProcessDefinitionStatisticsResultDto.fromProcessDefinitionStatistics(queryResult);
results.add(dto);