use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceInteractionTest method testDeleteAsync.
@Test
public void testDeleteAsync() {
List<String> ids = Arrays.asList(MockProvider.EXAMPLE_DECISION_INSTANCE_ID);
Batch batchEntity = MockProvider.createMockBatch();
when(historyServiceMock.deleteHistoricDecisionInstancesAsync(anyListOf(String.class), any(HistoricDecisionInstanceQuery.class), anyString())).thenReturn(batchEntity);
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
messageBodyJson.put("historicDecisionInstanceIds", ids);
messageBodyJson.put("deleteReason", "a-delete-reason");
Response response = given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(HISTORIC_DECISION_INSTANCES_DELETE_ASYNC_URL);
verifyBatchJson(response.asString());
verify(historyServiceMock, times(1)).deleteHistoricDecisionInstancesAsync(eq(ids), eq((HistoricDecisionInstanceQuery) null), eq("a-delete-reason"));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceImpl method queryHistoricDecisionInstances.
public List<HistoricDecisionInstanceDto> queryHistoricDecisionInstances(HistoricDecisionInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
HistoricDecisionInstanceQuery query = queryDto.toQuery(processEngine);
List<HistoricDecisionInstance> matchingHistoricDecisionInstances;
if (firstResult != null || maxResults != null) {
matchingHistoricDecisionInstances = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingHistoricDecisionInstances = query.list();
}
List<HistoricDecisionInstanceDto> historicDecisionInstanceDtoResults = new ArrayList<HistoricDecisionInstanceDto>();
for (HistoricDecisionInstance historicDecisionInstance : matchingHistoricDecisionInstances) {
HistoricDecisionInstanceDto resultHistoricDecisionInstanceDto = HistoricDecisionInstanceDto.fromHistoricDecisionInstance(historicDecisionInstance);
historicDecisionInstanceDtoResults.add(resultHistoricDecisionInstanceDto);
}
return historicDecisionInstanceDtoResults;
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceResourceImpl method getHistoricDecisionInstance.
public HistoricDecisionInstanceDto getHistoricDecisionInstance(Boolean includeInputs, Boolean includeOutputs, Boolean disableBinaryFetching, Boolean disableCustomObjectDeserialization) {
HistoryService historyService = engine.getHistoryService();
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionInstanceId(decisionInstanceId);
if (includeInputs != null && includeInputs) {
query.includeInputs();
}
if (includeOutputs != null && includeOutputs) {
query.includeOutputs();
}
if (disableBinaryFetching != null && disableBinaryFetching) {
query.disableBinaryFetching();
}
if (disableCustomObjectDeserialization != null && disableCustomObjectDeserialization) {
query.disableCustomObjectDeserialization();
}
HistoricDecisionInstance instance = query.singleResult();
if (instance == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Historic decision instance with id '" + decisionInstanceId + "' does not exist");
}
return HistoricDecisionInstanceDto.fromHistoricDecisionInstance(instance);
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceAuthorizationTest method testQueryWithReadPermissionOnAnyDecisionDefinition.
public void testQueryWithReadPermissionOnAnyDecisionDefinition() {
// given
startProcessInstanceAndEvaluateDecision();
createGrantAuthorization(DECISION_DEFINITION, ANY, userId, READ_HISTORY);
// when
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
// then
verifyQueryResults(query, 1);
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceAuthorizationTest method testQueryWithoutAuthorization.
public void testQueryWithoutAuthorization() {
// given
startProcessInstanceAndEvaluateDecision();
// when
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
// then
verifyQueryResults(query, 0);
}
Aggregations