use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceManager method findHistoricDecisionInstancesByQueryCriteria.
public List<HistoricDecisionInstance> findHistoricDecisionInstancesByQueryCriteria(HistoricDecisionInstanceQueryImpl query, Page page) {
if (isHistoryEnabled()) {
configureQuery(query);
@SuppressWarnings("unchecked") List<HistoricDecisionInstance> decisionInstances = getDbEntityManager().selectList("selectHistoricDecisionInstancesByQueryCriteria", query, page);
Map<String, HistoricDecisionInstanceEntity> decisionInstancesById = new HashMap<String, HistoricDecisionInstanceEntity>();
for (HistoricDecisionInstance decisionInstance : decisionInstances) {
decisionInstancesById.put(decisionInstance.getId(), (HistoricDecisionInstanceEntity) decisionInstance);
}
if (!decisionInstances.isEmpty() && query.isIncludeInput()) {
appendHistoricDecisionInputInstances(decisionInstancesById, query);
}
if (!decisionInstances.isEmpty() && query.isIncludeOutputs()) {
appendHistoricDecisionOutputInstances(decisionInstancesById, query);
}
return decisionInstances;
} else {
return Collections.emptyList();
}
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceAuthorizationTest method testDeleteHistoricDecisionInstanceByInstanceIdWithDeleteHistoryPermissionOnDecisionDefinition.
public void testDeleteHistoricDecisionInstanceByInstanceIdWithDeleteHistoryPermissionOnDecisionDefinition() {
// given
createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, DELETE_HISTORY, READ_HISTORY);
startProcessInstanceAndEvaluateDecision();
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
verifyQueryResults(query, 1);
HistoricDecisionInstance historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();
// when
historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
// then
verifyQueryResults(query, 0);
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoricDecisionInstanceAuthorizationTest method testDeleteHistoricDecisionInstanceByInstanceIdWithoutAuthorization.
public void testDeleteHistoricDecisionInstanceByInstanceIdWithoutAuthorization() {
// given
createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ_HISTORY);
startProcessInstanceAndEvaluateDecision();
HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
HistoricDecisionInstance historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();
try {
// when
historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
fail("expect authorization exception");
} catch (AuthorizationException e) {
// then
assertThat(e.getMessage(), is("The user with id 'test' does not have 'DELETE_HISTORY' permission on resource 'testDecision' of type 'DecisionDefinition'."));
}
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class HistoryCleanupAuthorizationTest method clearDatabase.
protected void clearDatabase() {
// reset configuration changes
String defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime();
String defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime();
int defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize();
processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(defaultStartTime);
processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(defaultEndTime);
processEngineConfiguration.setHistoryCleanupBatchSize(defaultBatchSize);
processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
List<Job> jobs = managementService.createJobQuery().list();
if (jobs.size() > 0) {
assertEquals(1, jobs.size());
String jobId = jobs.get(0).getId();
commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
}
List<HistoricIncident> historicIncidents = historyService.createHistoricIncidentQuery().list();
for (HistoricIncident historicIncident : historicIncidents) {
commandContext.getDbEntityManager().delete((HistoricIncidentEntity) historicIncident);
}
commandContext.getMeterLogManager().deleteAll();
return null;
}
});
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
}
List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
}
List<HistoricCaseInstance> historicCaseInstances = historyService.createHistoricCaseInstanceQuery().list();
for (HistoricCaseInstance historicCaseInstance : historicCaseInstances) {
historyService.deleteHistoricCaseInstance(historicCaseInstance.getId());
}
}
use of org.camunda.bpm.engine.history.HistoricDecisionInstance in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteDecisionInstancesAuthorizationTest method prepareHistoricDecisions.
private List<String> prepareHistoricDecisions() {
for (int i = 0; i < 5; i++) {
decisionService.evaluateDecisionByKey(DECISION).variables(createVariables()).evaluate();
}
final List<HistoricDecisionInstance> decisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
final List<String> decisionInstanceIds = new ArrayList<String>();
for (HistoricDecisionInstance decisionInstance : decisionInstances) {
decisionInstanceIds.add(decisionInstance.getId());
}
return decisionInstanceIds;
}
Aggregations