Search in sources :

Example 1 with BatchStatisticsQuery

use of org.camunda.bpm.engine.batch.BatchStatisticsQuery in project camunda-bpm-platform by camunda.

the class BatchRestServiceImpl method getStatistics.

public List<BatchStatisticsDto> getStatistics(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
    BatchStatisticsQueryDto queryDto = new BatchStatisticsQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    BatchStatisticsQuery query = queryDto.toQuery(getProcessEngine());
    List<BatchStatistics> batchStatisticsList;
    if (firstResult != null || maxResults != null) {
        batchStatisticsList = executePaginatedStatisticsQuery(query, firstResult, maxResults);
    } else {
        batchStatisticsList = query.list();
    }
    List<BatchStatisticsDto> statisticsResults = new ArrayList<BatchStatisticsDto>();
    for (BatchStatistics batchStatistics : batchStatisticsList) {
        statisticsResults.add(BatchStatisticsDto.fromBatchStatistics(batchStatistics));
    }
    return statisticsResults;
}
Also used : BatchStatisticsQuery(org.camunda.bpm.engine.batch.BatchStatisticsQuery) BatchStatisticsQueryDto(org.camunda.bpm.engine.rest.dto.batch.BatchStatisticsQueryDto) ArrayList(java.util.ArrayList) BatchStatisticsDto(org.camunda.bpm.engine.rest.dto.batch.BatchStatisticsDto) BatchStatistics(org.camunda.bpm.engine.batch.BatchStatistics)

Example 2 with BatchStatisticsQuery

use of org.camunda.bpm.engine.batch.BatchStatisticsQuery in project camunda-bpm-platform by camunda.

the class BatchRestServiceImpl method getStatisticsCount.

public CountResultDto getStatisticsCount(UriInfo uriInfo) {
    BatchStatisticsQueryDto queryDto = new BatchStatisticsQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
    BatchStatisticsQuery query = queryDto.toQuery(getProcessEngine());
    long count = query.count();
    return new CountResultDto(count);
}
Also used : BatchStatisticsQuery(org.camunda.bpm.engine.batch.BatchStatisticsQuery) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) BatchStatisticsQueryDto(org.camunda.bpm.engine.rest.dto.batch.BatchStatisticsQueryDto)

Example 3 with BatchStatisticsQuery

use of org.camunda.bpm.engine.batch.BatchStatisticsQuery in project camunda-bpm-platform by camunda.

the class BatchStatisticsQueryTest method testStatisticsQueryBySuspendedBatches.

@Test
public void testStatisticsQueryBySuspendedBatches() {
    // given
    Batch batch1 = helper.migrateProcessInstancesAsync(1);
    Batch batch2 = helper.migrateProcessInstancesAsync(1);
    helper.migrateProcessInstancesAsync(1);
    // when
    managementService.suspendBatchById(batch1.getId());
    managementService.suspendBatchById(batch2.getId());
    managementService.activateBatchById(batch1.getId());
    // then
    BatchStatisticsQuery query = managementService.createBatchStatisticsQuery().suspended();
    Assert.assertEquals(1, query.count());
    Assert.assertEquals(1, query.list().size());
    Assert.assertEquals(batch2.getId(), query.singleResult().getId());
}
Also used : BatchStatisticsQuery(org.camunda.bpm.engine.batch.BatchStatisticsQuery) Batch(org.camunda.bpm.engine.batch.Batch) Test(org.junit.Test)

Example 4 with BatchStatisticsQuery

use of org.camunda.bpm.engine.batch.BatchStatisticsQuery in project camunda-bpm-platform by camunda.

the class BatchStatisticsQueryTest method testStatisticsQueryByActiveBatches.

@Test
public void testStatisticsQueryByActiveBatches() {
    // given
    Batch batch1 = helper.migrateProcessInstancesAsync(1);
    Batch batch2 = helper.migrateProcessInstancesAsync(1);
    Batch batch3 = helper.migrateProcessInstancesAsync(1);
    // when
    managementService.suspendBatchById(batch1.getId());
    managementService.suspendBatchById(batch2.getId());
    managementService.activateBatchById(batch1.getId());
    // then
    BatchStatisticsQuery query = managementService.createBatchStatisticsQuery().active();
    Assert.assertEquals(2, query.count());
    Assert.assertEquals(2, query.list().size());
    List<String> foundIds = new ArrayList<String>();
    for (Batch batch : query.list()) {
        foundIds.add(batch.getId());
    }
    assertThat(foundIds, hasItems(batch1.getId(), batch3.getId()));
}
Also used : BatchStatisticsQuery(org.camunda.bpm.engine.batch.BatchStatisticsQuery) Batch(org.camunda.bpm.engine.batch.Batch) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

BatchStatisticsQuery (org.camunda.bpm.engine.batch.BatchStatisticsQuery)4 ArrayList (java.util.ArrayList)2 Batch (org.camunda.bpm.engine.batch.Batch)2 BatchStatisticsQueryDto (org.camunda.bpm.engine.rest.dto.batch.BatchStatisticsQueryDto)2 Test (org.junit.Test)2 BatchStatistics (org.camunda.bpm.engine.batch.BatchStatistics)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 BatchStatisticsDto (org.camunda.bpm.engine.rest.dto.batch.BatchStatisticsDto)1