use of org.activiti.engine.history.HistoricActivityInstance in project Activiti by Activiti.
the class MultiInstanceTest method testSequentialSubProcessHistory.
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialSubProcess.bpmn20.xml" })
public void testSequentialSubProcessHistory() {
runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
for (int i = 0; i < 4; i++) {
List<Task> tasks = taskService.createTaskQuery().list();
taskService.complete(tasks.get(0).getId());
taskService.complete(tasks.get(1).getId());
}
// Validate history
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
List<HistoricActivityInstance> onlySubProcessInstances = historyService.createHistoricActivityInstanceQuery().activityType("subProcess").list();
assertEquals(4, onlySubProcessInstances.size());
List<HistoricActivityInstance> historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("subProcess").list();
assertEquals(4, historicInstances.size());
for (HistoricActivityInstance hai : historicInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
historicInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list();
assertEquals(8, historicInstances.size());
for (HistoricActivityInstance hai : historicInstances) {
assertNotNull(hai.getStartTime());
assertNotNull(hai.getEndTime());
}
}
}
use of org.activiti.engine.history.HistoricActivityInstance in project daijie-example by daijiejay.
the class BaseService method getProcesses.
@Override
public ModelResult<PageResult<Map<String, Object>>> getProcesses() {
List<Map<String, Object>> rows = new ArrayList<>();
PageResult<Map<String, Object>> datas = new PageResult<>();
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery();
List<ProcessInstance> processInstances = query.list();
processInstances.forEach(processInstance -> {
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).unfinished().list();
if (!historicActivityInstances.isEmpty()) {
historicActivityInstances.forEach(historicActivityInstance -> {
Map<String, Object> row = new HashMap<>();
row.put("processInstanceId", processInstance.getId());
Task task = taskService.createTaskQuery().taskId(historicActivityInstance.getTaskId()).singleResult();
row.put("activityName", historicActivityInstance.getActivityName());
row.put("taskId", historicActivityInstance.getTaskId());
row.put("createTime", task.getCreateTime());
row.put("assignee", task.getAssignee());
rows.add(row);
});
} else {
Map<String, Object> row = new HashMap<>();
row.put("processInstanceId", processInstance.getId());
row.put("activityName", "流程结束");
rows.add(row);
}
});
datas.setTotal(query.count());
datas.setRows(rows);
return Result.build(datas);
}
use of org.activiti.engine.history.HistoricActivityInstance in project herd by FINRAOS.
the class ActivitiServiceTest method testGetHistoricActivityInstancesByProcessInstanceId.
@Test
public void testGetHistoricActivityInstancesByProcessInstanceId() {
String processInstanceId = "processInstanceId";
HistoricActivityInstanceQuery historicActivityInstanceQuery = mock(HistoricActivityInstanceQuery.class);
when(activitiHistoryService.createHistoricActivityInstanceQuery()).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.processInstanceId(processInstanceId)).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.orderByHistoricActivityInstanceStartTime()).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.asc()).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.orderByHistoricActivityInstanceEndTime()).thenReturn(historicActivityInstanceQuery);
when(historicActivityInstanceQuery.asc()).thenReturn(historicActivityInstanceQuery);
List<HistoricActivityInstance> expectedHistoricActivityInstances = new ArrayList<>();
when(historicActivityInstanceQuery.list()).thenReturn(expectedHistoricActivityInstances);
List<HistoricActivityInstance> actualHistoricActivityInstances = activitiService.getHistoricActivityInstancesByProcessInstanceId(processInstanceId);
assertSame(expectedHistoricActivityInstances, actualHistoricActivityInstances);
InOrder inOrder = inOrder(historicActivityInstanceQuery);
inOrder.verify(historicActivityInstanceQuery).processInstanceId(processInstanceId);
inOrder.verify(historicActivityInstanceQuery).orderByHistoricActivityInstanceStartTime();
inOrder.verify(historicActivityInstanceQuery).asc();
inOrder.verify(historicActivityInstanceQuery).orderByHistoricActivityInstanceEndTime();
inOrder.verify(historicActivityInstanceQuery).asc();
inOrder.verify(historicActivityInstanceQuery).list();
inOrder.verifyNoMoreInteractions();
}
use of org.activiti.engine.history.HistoricActivityInstance in project alfresco-remote-api by Alfresco.
the class ActivitiesImpl method getActivities.
@Override
public CollectionWithPagingInfo<Activity> getActivities(String processId, Parameters parameters) {
Paging paging = parameters.getPaging();
String status = parameters.getParameter("status");
validateIfUserAllowedToWorkWithProcess(processId);
HistoricActivityInstanceQuery query = activitiProcessEngine.getHistoryService().createHistoricActivityInstanceQuery();
if (STATUS_ACTIVE.equals(status))
query.unfinished();
else if (STATUS_COMPLETED.equals(status))
query.finished();
query.processInstanceId(processId);
query.orderByExecutionId().asc();
List<HistoricActivityInstance> activities = query.listPage(paging.getSkipCount(), paging.getMaxItems());
List<Activity> page = new ArrayList<Activity>(activities.size());
for (HistoricActivityInstance activityInstance : activities) {
Activity activity = new Activity(activityInstance);
page.add(activity);
}
return CollectionWithPagingInfo.asPaged(paging, page, false, page.size());
}
use of org.activiti.engine.history.HistoricActivityInstance in project modesti by jlsalmon.
the class HistoryService method getHistoryForRequest.
/**
* Retrieve the workflow history for a particular request.
*
* @param requestId the id of the request
* @return the list of historic events
*/
public List<HistoricEvent> getHistoryForRequest(String requestId) {
log.info("querying history for request id " + requestId + "...");
Request request = requestRepository.findOneByRequestId(requestId);
if (request == null) {
throw new IllegalArgumentException("No request with id " + requestId + " was found");
}
List<HistoricEvent> history = new ArrayList<>();
// Find the process instance for this request
HistoricProcessInstance process = historyService.createHistoricProcessInstanceQuery().processInstanceBusinessKey(requestId).singleResult();
// Find all the activities that happened so far for this process
List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().processInstanceId(process.getId()).orderByTaskCreateTime().asc().list();
// Find all the activities that happened so far for this process
List<HistoricActivityInstance> activities = historyService.createHistoricActivityInstanceQuery().processInstanceId(process.getId()).orderByHistoricActivityInstanceStartTime().asc().list();
for (HistoricActivityInstance activity : activities) {
// Only interested in user tasks
if (activity.getActivityType().equals("userTask")) {
String description = "";
for (HistoricTaskInstance task : tasks) {
if (task.getId().equals(activity.getTaskId())) {
description = task.getDescription();
}
}
HistoricEvent event = new HistoricEvent(activity.getStartTime(), activity.getEndTime(), activity.getDurationInMillis(), activity.getActivityName(), activity.getActivityType(), description, activity.getAssignee());
history.add(event);
}
}
return history;
}
Aggregations