use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class ArchivedPage method createDetailComponent.
@Override
protected Component createDetailComponent(String id) {
HistoryService historyService = ProcessEngines.getDefaultProcessEngine().getHistoryService();
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult();
taskEventPanel.setTaskId(historicTaskInstance.getId());
return new HistoricTaskDetailPanel(historicTaskInstance, this);
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoricTaskDetailPanel method initSubTasks.
protected void initSubTasks() {
subTasksLayout = new VerticalLayout();
subTasksLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
addComponent(subTasksLayout);
initSubTaskTitle();
List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(historicTask.getId()).list();
if (!subTasks.isEmpty()) {
initSubTaskGrid();
populateSubTasks(subTasks);
} else {
initNoSubTasksLabel();
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class UserTaskTest method testTaskCategory.
@Deployment
public void testTaskCategory() {
runtimeService.startProcessInstanceByKey("testTaskCategory");
Task task = taskService.createTaskQuery().singleResult();
// Test if the property set in the model is shown in the task
String testCategory = "My Category";
assertEquals(testCategory, task.getCategory());
// Test if can be queried by query API
assertEquals("Task with category", taskService.createTaskQuery().taskCategory(testCategory).singleResult().getName());
assertTrue(taskService.createTaskQuery().taskCategory("Does not exist").count() == 0);
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
// Check historic task
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals(testCategory, historicTaskInstance.getCategory());
assertEquals("Task with category", historyService.createHistoricTaskInstanceQuery().taskCategory(testCategory).singleResult().getName());
assertTrue(historyService.createHistoricTaskInstanceQuery().taskCategory("Does not exist").count() == 0);
// Update category
String newCategory = "New Test Category";
task.setCategory(newCategory);
taskService.saveTask(task);
task = taskService.createTaskQuery().singleResult();
assertEquals(newCategory, task.getCategory());
assertEquals("Task with category", taskService.createTaskQuery().taskCategory(newCategory).singleResult().getName());
assertTrue(taskService.createTaskQuery().taskCategory(testCategory).count() == 0);
// Complete task and verify history
taskService.complete(task.getId());
historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals(newCategory, historicTaskInstance.getCategory());
assertEquals("Task with category", historyService.createHistoricTaskInstanceQuery().taskCategory(newCategory).singleResult().getName());
assertTrue(historyService.createHistoricTaskInstanceQuery().taskCategory(testCategory).count() == 0);
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class SubProcessTest method testSimpleSubProcessWithTimer.
@Deployment
public void testSimpleSubProcessWithTimer() {
Date startTime = new Date();
// After staring the process, the task in the subprocess should be active
ProcessInstance pi = runtimeService.startProcessInstanceByKey("simpleSubProcess");
Task subProcessTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("Task in subprocess", subProcessTask.getName());
// Setting the clock forward 2 hours 1 second (timer fires in 2 hours) and fire up the job executor
processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + (2 * 60 * 60 * 1000) + 1000));
waitForJobExecutorToProcessAllJobs(5000L, 50L);
// The subprocess should be left, and the escalated task should be active
Task escalationTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("Fix escalated problem", escalationTask.getName());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
// Verify history for task that was killed
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskName("Task in subprocess").singleResult();
assertNotNull(historicTaskInstance.getEndTime());
HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("subProcessTask").singleResult();
assertNotNull(historicActivityInstance.getEndTime());
}
}
use of org.activiti.engine.history.HistoricTaskInstance 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());
}
}
}
Aggregations