use of org.camunda.bpm.engine.rest.dto.history.HistoricActivityStatisticsDto in project camunda-bpm-platform by camunda.
the class HistoricProcessDefinitionRestServiceImpl method getHistoricActivityStatistics.
@Override
public List<HistoricActivityStatisticsDto> getHistoricActivityStatistics(UriInfo uriInfo, 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();
}
final MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
DateConverter dateConverter = new DateConverter();
dateConverter.setObjectMapper(objectMapper);
if (queryParameters.getFirst(QUERY_PARAM_STARTED_AFTER) != null) {
Date startedAfter = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_STARTED_AFTER));
query.startedAfter(startedAfter);
}
if (queryParameters.getFirst(QUERY_PARAM_STARTED_BEFORE) != null) {
Date startedBefore = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_STARTED_BEFORE));
query.startedBefore(startedBefore);
}
if (queryParameters.getFirst(QUERY_PARAM_FINISHED_AFTER) != null) {
Date finishedAfter = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_FINISHED_AFTER));
query.finishedAfter(finishedAfter);
}
if (queryParameters.getFirst(QUERY_PARAM_FINISHED_BEFORE) != null) {
Date finishedBefore = dateConverter.convertQueryParameterToType(queryParameters.getFirst(QUERY_PARAM_FINISHED_BEFORE));
query.finishedBefore(finishedBefore);
}
setSortOptions(query, sortOrder, sortBy);
List<HistoricActivityStatisticsDto> result = new ArrayList<HistoricActivityStatisticsDto>();
List<HistoricActivityStatistics> statistics = query.list();
for (HistoricActivityStatistics currentStatistics : statistics) {
result.add(HistoricActivityStatisticsDto.fromHistoricActivityStatistics(currentStatistics));
}
return result;
}
Aggregations