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;
}
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);
}
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());
}
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()));
}
Aggregations