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 = engine.getManagementService();
ActivityStatisticsQuery query = mgmtService.createActivityStatisticsQuery(processDefinitionId);
if (includeFailedJobs != null && includeFailedJobs) {
query.includeFailedJobs();
}
if (includeIncidents != null && includeIncidents) {
query.includeIncidents();
} else if (includeIncidentsForType != null) {
query.includeIncidentsForType(includeIncidentsForType);
}
List<ActivityStatistics> queryResults = query.list();
List<StatisticsResultDto> results = new ArrayList<StatisticsResultDto>();
for (ActivityStatistics queryResult : queryResults) {
StatisticsResultDto dto = ActivityStatisticsResultDto.fromActivityStatistics(queryResult);
results.add(dto);