Search in sources :

Example 1 with HistoricActivityStatisticsDto

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;
}
Also used : HistoricActivityStatisticsQuery(org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery) DateConverter(org.camunda.bpm.engine.rest.dto.converter.DateConverter) HistoricActivityStatisticsDto(org.camunda.bpm.engine.rest.dto.history.HistoricActivityStatisticsDto) ArrayList(java.util.ArrayList) HistoryService(org.camunda.bpm.engine.HistoryService) HistoricActivityStatistics(org.camunda.bpm.engine.history.HistoricActivityStatistics) Date(java.util.Date)

Aggregations

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HistoryService (org.camunda.bpm.engine.HistoryService)1 HistoricActivityStatistics (org.camunda.bpm.engine.history.HistoricActivityStatistics)1 HistoricActivityStatisticsQuery (org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery)1 DateConverter (org.camunda.bpm.engine.rest.dto.converter.DateConverter)1 HistoricActivityStatisticsDto (org.camunda.bpm.engine.rest.dto.history.HistoricActivityStatisticsDto)1