use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class MyProcessInstancesListQuery method loadItems.
public List<Item> loadItems(int start, int count) {
List<HistoricProcessInstance> processInstances = historyService.createHistoricProcessInstanceQuery().startedBy(ExplorerApp.get().getLoggedInUser().getId()).unfinished().list();
List<Item> items = new ArrayList<Item>();
for (HistoricProcessInstance processInstance : processInstances) {
items.add(createItem(processInstance));
}
return items;
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class DeleteHistoricProcessInstanceCmd method execute.
public Object execute(CommandContext commandContext) {
if (processInstanceId == null) {
throw new ActivitiIllegalArgumentException("processInstanceId is null");
}
// Check if process instance is still running
HistoricProcessInstance instance = commandContext.getHistoricProcessInstanceEntityManager().findHistoricProcessInstance(processInstanceId);
if (instance == null) {
throw new ActivitiObjectNotFoundException("No historic process instance found with id: " + processInstanceId, HistoricProcessInstance.class);
}
if (instance.getEndTime() == null) {
throw new ActivitiException("Process instance is still running, cannot delete historic process instance: " + processInstanceId);
}
commandContext.getHistoricProcessInstanceEntityManager().deleteHistoricProcessInstanceById(processInstanceId);
return null;
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class ProcessInstanceUpdateBusinessKeyTest method testUpdateExistingBusinessKey.
@Deployment
public void testUpdateExistingBusinessKey() {
runtimeService.startProcessInstanceByKey("businessKeyProcess", "testKey");
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertEquals("testKey", processInstance.getBusinessKey());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertEquals("testKey", historicProcessInstance.getBusinessKey());
}
runtimeService.updateBusinessKey(processInstance.getId(), "newKey");
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertEquals("newKey", processInstance.getBusinessKey());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertEquals("newKey", historicProcessInstance.getBusinessKey());
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class ProcessInstanceUpdateBusinessKeyTest method testProcessInstanceUpdateBusinessKey.
@Deployment
public void testProcessInstanceUpdateBusinessKey() {
runtimeService.startProcessInstanceByKey("businessKeyProcess");
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertEquals("bzKey", processInstance.getBusinessKey());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().singleResult();
assertEquals("bzKey", historicProcessInstance.getBusinessKey());
}
}
use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.
the class RuntimeServiceTest method testDeleteProcessInstanceNullReason.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testDeleteProcessInstanceNullReason() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
assertEquals(1, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
// Deleting without a reason should be possible
runtimeService.deleteProcessInstance(processInstance.getId(), null);
assertEquals(0, runtimeService.createProcessInstanceQuery().processDefinitionKey("oneTaskProcess").count());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(historicInstance);
assertEquals("ACTIVITY_DELETED", historicInstance.getDeleteReason());
}
}
Aggregations