use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceImpl method deleteAsync.
public BatchDto deleteAsync(DeleteHistoricDecisionInstancesDto dto) {
HistoricDecisionInstanceQuery decisionInstanceQuery = null;
if (dto.getHistoricDecisionInstanceQuery() != null) {
decisionInstanceQuery = dto.getHistoricDecisionInstanceQuery().toQuery(processEngine);
}
try {
List<String> historicDecisionInstanceIds = dto.getHistoricDecisionInstanceIds();
String deleteReason = dto.getDeleteReason();
Batch batch = processEngine.getHistoryService().deleteHistoricDecisionInstancesAsync(historicDecisionInstanceIds, decisionInstanceQuery, deleteReason);
return BatchDto.fromBatch(batch);
} catch (BadUserRequestException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceImpl method queryHistoricDecisionInstancesCount.
public CountResultDto queryHistoricDecisionInstancesCount(HistoricDecisionInstanceQueryDto queryDto) {
HistoricDecisionInstanceQuery query = queryDto.toQuery(processEngine);
long count = query.count();
return new CountResultDto(count);
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceInteractionTest method testDeleteAsyncWithBadRequestQuery.
@Test
public void testDeleteAsyncWithBadRequestQuery() {
doThrow(new BadUserRequestException("process instance ids are empty")).when(historyServiceMock).deleteHistoricDecisionInstancesAsync(eq((List<String>) null), eq((HistoricDecisionInstanceQuery) null), anyString());
given().contentType(ContentType.JSON).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.BAD_REQUEST.getStatusCode()).when().post(HISTORIC_DECISION_INSTANCES_DELETE_ASYNC_URL);
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceRestServiceInteractionTest method testDeleteAsyncWithIdsAndQuery.
@Test
public void testDeleteAsyncWithIdsAndQuery() {
Batch batchEntity = MockProvider.createMockBatch();
when(historyServiceMock.deleteHistoricDecisionInstancesAsync(anyListOf(String.class), any(HistoricDecisionInstanceQuery.class), anyString())).thenReturn(batchEntity);
Map<String, Object> messageBodyJson = new HashMap<String, Object>();
HistoricDecisionInstanceQueryDto query = new HistoricDecisionInstanceQueryDto();
query.setDecisionDefinitionKey("decision");
messageBodyJson.put("historicDecisionInstanceQuery", query);
List<String> ids = Arrays.asList(MockProvider.EXAMPLE_DECISION_INSTANCE_ID);
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), any(HistoricDecisionInstanceQuery.class), eq("a-delete-reason"));
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery in project camunda-bpm-platform by camunda.
the class BatchHistoricDecisionInstanceDeletionUserOperationTest method testCreationByQuery.
@Test
public void testCreationByQuery() {
// given
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery().decisionDefinitionKey(DECISION);
// when
identityService.setAuthenticatedUserId(USER_ID);
historyService.deleteHistoricDecisionInstancesAsync(query, "a-delete-reason");
identityService.clearAuthentication();
// then
List<UserOperationLogEntry> opLogEntries = engineRule.getHistoryService().createUserOperationLogQuery().list();
Assert.assertEquals(4, opLogEntries.size());
Map<String, UserOperationLogEntry> entries = asMap(opLogEntries);
UserOperationLogEntry typeEntry = entries.get("type");
assertNotNull(typeEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("history", typeEntry.getNewValue());
UserOperationLogEntry asyncEntry = entries.get("async");
assertNotNull(asyncEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("true", asyncEntry.getNewValue());
UserOperationLogEntry numInstancesEntry = entries.get("nrOfInstances");
assertNotNull(numInstancesEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("10", numInstancesEntry.getNewValue());
UserOperationLogEntry deleteReasonEntry = entries.get("deleteReason");
assertNotNull(deleteReasonEntry);
assertEquals(EntityTypes.DECISION_INSTANCE, typeEntry.getEntityType());
assertEquals(UserOperationLogEntry.OPERATION_TYPE_DELETE, typeEntry.getOperationType());
assertNull(typeEntry.getProcessDefinitionId());
assertNull(typeEntry.getProcessDefinitionKey());
assertNull(typeEntry.getProcessInstanceId());
assertNull(typeEntry.getOrgValue());
assertEquals("a-delete-reason", deleteReasonEntry.getNewValue());
assertEquals(typeEntry.getOperationId(), asyncEntry.getOperationId());
assertEquals(asyncEntry.getOperationId(), numInstancesEntry.getOperationId());
assertEquals(numInstancesEntry.getOperationId(), deleteReasonEntry.getOperationId());
}
Aggregations