Search in sources :

Example 1 with HistoricBatchQuery

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

the class HistoricBatchRestServiceImpl method getHistoricBatchesCount.

@Override
public CountResultDto getHistoricBatchesCount(UriInfo uriInfo) {
    HistoricBatchQueryDto queryDto = new HistoricBatchQueryDto(objectMapper, uriInfo.getQueryParameters());
    HistoricBatchQuery query = queryDto.toQuery(processEngine);
    long count = query.count();
    return new CountResultDto(count);
}
Also used : HistoricBatchQueryDto(org.camunda.bpm.engine.rest.dto.history.batch.HistoricBatchQueryDto) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) HistoricBatchQuery(org.camunda.bpm.engine.batch.history.HistoricBatchQuery)

Example 2 with HistoricBatchQuery

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

the class HistoricBatchRestServiceInteractionTest method testGetNonExistingHistoricBatch.

@Test
public void testGetNonExistingHistoricBatch() {
    String nonExistingId = MockProvider.NON_EXISTING_ID;
    HistoricBatchQuery historicBatchQuery = mock(HistoricBatchQuery.class);
    when(historicBatchQuery.batchId(nonExistingId)).thenReturn(historicBatchQuery);
    when(historicBatchQuery.singleResult()).thenReturn(null);
    when(historyServiceMock.createHistoricBatchQuery()).thenReturn(historicBatchQuery);
    given().pathParam("id", nonExistingId).then().expect().statusCode(Status.NOT_FOUND.getStatusCode()).body("type", equalTo(InvalidRequestException.class.getSimpleName())).body("message", equalTo("Historic batch with id '" + nonExistingId + "' does not exist")).when().get(HISTORIC_SINGLE_BATCH_RESOURCE_URL);
}
Also used : HistoricBatchQuery(org.camunda.bpm.engine.batch.history.HistoricBatchQuery) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 3 with HistoricBatchQuery

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

the class HistoricBatchRestServiceImpl method getHistoricBatches.

@SuppressWarnings("unchecked")
@Override
public List<HistoricBatchDto> getHistoricBatches(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
    HistoricBatchQueryDto queryDto = new HistoricBatchQueryDto(objectMapper, uriInfo.getQueryParameters());
    HistoricBatchQuery query = queryDto.toQuery(processEngine);
    List<HistoricBatch> matchingBatches;
    if (firstResult != null || maxResults != null) {
        matchingBatches = (List<HistoricBatch>) executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingBatches = query.list();
    }
    List<HistoricBatchDto> batchResults = new ArrayList<HistoricBatchDto>();
    for (HistoricBatch matchingBatch : matchingBatches) {
        batchResults.add(HistoricBatchDto.fromBatch(matchingBatch));
    }
    return batchResults;
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) HistoricBatchQueryDto(org.camunda.bpm.engine.rest.dto.history.batch.HistoricBatchQueryDto) HistoricBatchQuery(org.camunda.bpm.engine.batch.history.HistoricBatchQuery) ArrayList(java.util.ArrayList) HistoricBatchDto(org.camunda.bpm.engine.rest.dto.history.batch.HistoricBatchDto)

Aggregations

HistoricBatchQuery (org.camunda.bpm.engine.batch.history.HistoricBatchQuery)3 HistoricBatchQueryDto (org.camunda.bpm.engine.rest.dto.history.batch.HistoricBatchQueryDto)2 ArrayList (java.util.ArrayList)1 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)1 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricBatchDto (org.camunda.bpm.engine.rest.dto.history.batch.HistoricBatchDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 Test (org.junit.Test)1