use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class AbstractActivitiTestCase method assertProcessEnded.
public void assertProcessEnded(final String processInstanceId) {
ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (processInstance != null) {
throw new AssertionFailedError("Expected finished process instance '" + processInstanceId + "' but it was still in the db");
}
// Verify historical data if end times are correctly set
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
// process instance
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
assertEquals(processInstanceId, historicProcessInstance.getId());
assertNotNull("Historic process instance has no start time", historicProcessInstance.getStartTime());
assertNotNull("Historic process instance has no end time", historicProcessInstance.getEndTime());
// tasks
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).list();
if (historicTaskInstances != null && historicTaskInstances.size() > 0) {
for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId());
assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime());
assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
}
}
// activities
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();
if (historicActivityInstances != null && historicActivityInstances.size() > 0) {
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
assertEquals(processInstanceId, historicActivityInstance.getProcessInstanceId());
assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no start time", historicActivityInstance.getStartTime());
assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no end time", historicActivityInstance.getEndTime());
}
}
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class RuntimeServiceTest method testDeleteProcessInstance.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testDeleteProcessInstance() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
String deleteReason = "testing instance deletion";
runtimeService.deleteProcessInstance(processInstance.getId(), deleteReason);
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
// ACT-848
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals(deleteReason, historicTaskInstance.getDeleteReason());
HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(historicInstance);
assertEquals(deleteReason, historicInstance.getDeleteReason());
assertNotNull(historicInstance.getEndTime());
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class SavedReportsListQuery method loadItems.
public List<Item> loadItems(int start, int count) {
List<HistoricProcessInstance> processInstances = createQuery().listPage(start, count);
List<Item> reportItems = new ArrayList<Item>();
for (HistoricProcessInstance instance : processInstances) {
reportItems.add(new SavedReportListItem(instance));
}
return reportItems;
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class MultiInstanceTest method testParallelCallActivityHistory.
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelCallActivity.bpmn20.xml", "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" })
public void testParallelCallActivityHistory() {
runtimeService.startProcessInstanceByKey("miParallelCallActivity");
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(12, tasks.size());
for (int i = 0; i < tasks.size(); i++) {
taskService.complete(tasks.get(i).getId());
}
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
// Validate historic processes
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
// 6 subprocesses + main process
assertEquals(7, historicProcessInstances.size());
for (HistoricProcessInstance hpi : historicProcessInstances) {
assertNotNull(hpi.getStartTime());
assertNotNull(hpi.getEndTime());
}
// Validate historic tasks
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list();
assertEquals(12, historicTaskInstances.size());
for (HistoricTaskInstance hti : historicTaskInstances) {
assertNotNull(hti.getStartTime());
assertNotNull(hti.getEndTime());
assertNotNull(hti.getAssignee());
assertEquals("completed", hti.getDeleteReason());
}
// Validate historic activities
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("callActivity").list();
assertEquals(6, historicActivityInstances.size());
for (HistoricActivityInstance hai : historicActivityInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class EventOverviewPanel method fillInstanceValues.
protected void fillInstanceValues() {
for (HistoricProcessInstance processInstance : instanceList) {
ProcessDefinition definition = definitionMap.get(processInstance.getProcessDefinitionId());
String definitionName = "";
if (definition != null) {
if (definition.getName() != null) {
definitionName = definition.getName();
} else {
definitionName = definition.getId();
}
definitionName += " (v" + definition.getVersion() + ")";
}
instanceTable.addItem(new String[] { processInstance.getId(), definitionName, processInstance.getStartTime().toString(), processInstance.getEndTime() != null ? processInstance.getEndTime().toString() : "" }, processInstance.getId());
}
}
Aggregations