use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class TestWarDeploymentWithProcessEnginePlugin method testPAGroovyProcessEnginePlugin.
@Test
public void testPAGroovyProcessEnginePlugin() {
ProcessEngine groovyEngine = processEngineService.getProcessEngine("groovy");
Assert.assertNotNull(groovyEngine);
ProcessInstance pi = groovyEngine.getRuntimeService().startProcessInstanceByKey("groovy");
HistoricProcessInstance hpi = groovyEngine.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionKey("groovy").finished().singleResult();
assertEquals(pi.getId(), hpi.getId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class TestWarDeploymentWithProcessEnginePlugin method testPAGroovyAsyncProcessEnginePlugin.
@Test
public void testPAGroovyAsyncProcessEnginePlugin() {
ProcessEngine groovyEngine = processEngineService.getProcessEngine("groovy");
Assert.assertNotNull(groovyEngine);
ProcessInstance pi = groovyEngine.getRuntimeService().startProcessInstanceByKey("groovyAsync");
waitForJobExecutorToProcessAllJobs();
HistoricProcessInstance hpi = groovyEngine.getHistoryService().createHistoricProcessInstanceQuery().processDefinitionKey("groovyAsync").finished().singleResult();
assertEquals(pi.getId(), hpi.getId());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class CompleteProcessWithParallelGatewayTest method testQueryHistoricProcessWithParallelGateway.
@Test
@ScenarioUnderTest("init.complete.two.1")
public void testQueryHistoricProcessWithParallelGateway() {
// given an already finished process instance with parallel gateway and two user tasks
HistoricProcessInstance historicProcessInstance = rule.historicProcessInstance();
// when query history
HistoricTaskInstanceQuery historicTaskQuery = rule.getHistoryService().createHistoricTaskInstanceQuery().processInstanceId(historicProcessInstance.getId());
// then two historic user tasks are returned
Assert.assertEquals(2, historicTaskQuery.count());
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class DeleteHistoricProcessInstancesCmd method execute.
@Override
public Void execute(CommandContext commandContext) {
ensureNotEmpty(BadUserRequestException.class, "processInstanceIds", processInstanceIds);
ensureNotContainsNull(BadUserRequestException.class, "processInstanceId is null", "processInstanceIds", processInstanceIds);
// Check if process instance is still running
List<HistoricProcessInstance> instances = commandContext.runWithoutAuthorization(new Callable<List<HistoricProcessInstance>>() {
@Override
public List<HistoricProcessInstance> call() throws Exception {
return new HistoricProcessInstanceQueryImpl().processInstanceIds(new HashSet<String>(processInstanceIds)).list();
}
});
if (processInstanceIds.size() == 1) {
ensureNotEmpty(BadUserRequestException.class, "No historic process instance found with id: " + processInstanceIds.get(0), "historicProcessInstanceIds", instances);
} else {
ensureNotEmpty(BadUserRequestException.class, "No historic process instances found", "historicProcessInstanceIds", instances);
}
// check if all historicProcessInstances were found
List<String> existingIds = new ArrayList<String>();
for (HistoricProcessInstance historicProcessInstance : instances) {
existingIds.add(historicProcessInstance.getId());
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkDeleteHistoricProcessInstance(historicProcessInstance);
}
ensureNotNull(BadUserRequestException.class, "Process instance is still running, cannot delete historic process instance: " + historicProcessInstance, "instance.getEndTime()", historicProcessInstance.getEndTime());
}
ArrayList<String> nonExistingIds = new ArrayList<String>(processInstanceIds);
nonExistingIds.removeAll(existingIds);
ensureNumberOfElements(BadUserRequestException.class, "No historic process instances found with ids " + nonExistingIds, "nonExistingIds", nonExistingIds, 0);
commandContext.getHistoricProcessInstanceManager().deleteHistoricProcessInstanceByIds(processInstanceIds);
return null;
}
use of org.camunda.bpm.engine.history.HistoricProcessInstance in project camunda-bpm-platform by camunda.
the class BulkHistoryDeleteCmmnDisabledTest method clearDatabase.
@After
public void clearDatabase() {
engineRule.getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
List<Job> jobs = engineRule.getManagementService().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);
}
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());
}
}
Aggregations