org.activiti.engine.history.HistoricTaskInstance Java Examples
The following examples show how to use
org.activiti.engine.history.HistoricTaskInstance.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HistoricTaskInstanceQueryImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void localize(HistoricTaskInstance task) { HistoricTaskInstanceEntity taskEntity = (HistoricTaskInstanceEntity) task; taskEntity.setLocalizedName(null); taskEntity.setLocalizedDescription(null); if (locale != null) { String processDefinitionId = task.getProcessDefinitionId(); if (processDefinitionId != null) { ObjectNode languageNode = Context.getLocalizationElementProperties(locale, task.getTaskDefinitionKey(), processDefinitionId, withLocalizationFallback); if (languageNode != null) { JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME); if (languageNameNode != null && languageNameNode.isNull() == false) { taskEntity.setLocalizedName(languageNameNode.asText()); } JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION); if (languageDescriptionNode != null && languageDescriptionNode.isNull() == false) { taskEntity.setLocalizedDescription(languageDescriptionNode.asText()); } } } } }
Example #2
Source File: TerminateEndEventWithSubprocess.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
private void checkFinished(ProcessInstance processInstance) { // 验证流程已结束 HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() .processInstanceId(processInstance.getProcessInstanceId()).singleResult(); assertNotNull(historicProcessInstance.getEndTime()); // 查询历史任务 List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().list(); for (HistoricTaskInstance hti : list) { System.out.println(hti.getName() + " " + hti.getDeleteReason()); } // 流程结束后校验监听器设置的变量 HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().variableName("settedOnEnd").singleResult(); assertEquals(true, variableInstance.getValue()); }
Example #3
Source File: HistoricTaskQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testQueryByTaskDescriptionLikeIgnoreCase(){ if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // taskDescriptionLikeIgnoreCase List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskDescriptionLikeIgnoreCase("%\\%%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task3.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().taskDescriptionLikeIgnoreCase("%\\_%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task2.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); // orQuery list = historyService.createHistoricTaskInstanceQuery().or().taskDescriptionLikeIgnoreCase("%\\%%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task3.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().or().taskDescriptionLikeIgnoreCase("%\\_%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task2.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); } }
Example #4
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private List<WorkflowTask> queryHistoricTasks(WorkflowTaskQuery query) { HistoricTaskInstanceQuery historicQuery = createHistoricTaskQuery(query); List<HistoricTaskInstance> results; int limit = query.getLimit(); if (limit > 0) { results = historicQuery.listPage(0, limit); } else { results = historicQuery.list(); } return getValidHistoricTasks(results); }
Example #5
Source File: LocalTaskService.java From maven-framework-project with MIT License | 6 votes |
/** * Returns a list of <strong>completed</strong> Doc Approval Tasks. * * @param businessKey * @return */ public List<HistoricTask> getDocApprovalHistory(String businessKey) { log.debug("getting historic tasks for doc: " + businessKey); HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery(). includeProcessVariables().processInstanceBusinessKey(businessKey).singleResult(); if (pi == null) { return Collections.emptyList(); } log.debug("Duration time in millis: " + pi.getDurationInMillis()); List<HistoricTaskInstance> hTasks; hTasks = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().processInstanceBusinessKey(businessKey).list(); List<HistoricTask> historicTasks = Lists.newArrayList(); for (HistoricTaskInstance hti : hTasks) { if (StringUtils.startsWith(hti.getProcessDefinitionId(), Workflow.PROCESS_ID_DOC_APPROVAL) && hti.getEndTime() != null) { historicTasks.add(fromActiviti(hti)); } } Collections.sort(historicTasks); return historicTasks; }
Example #6
Source File: HistoricTaskQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testQueryByTaskOwnerLikeIgnoreCase(){ if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // taskOwnerLikeIgnoreCase List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskOwnerLikeIgnoreCase("%\\%%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task3.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().taskOwnerLikeIgnoreCase("%\\_%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task2.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); // orQuery list = historyService.createHistoricTaskInstanceQuery().or().taskOwnerLikeIgnoreCase("%\\%%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task3.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().or().taskOwnerLikeIgnoreCase("%\\_%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task2.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); } }
Example #7
Source File: HistoricTaskQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testQueryByTaskNameLike(){ if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // taskNameLike List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskNameLike("%\\%%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task3.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().taskNameLike("%\\_%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task2.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); // orQuery list = historyService.createHistoricTaskInstanceQuery().or().taskNameLike("%\\%%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task3.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().or().taskNameLike("%\\_%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task2.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); } }
Example #8
Source File: HistoricTaskQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testQueryByProcessDefinitionKeyLike(){ if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // processDefinitionKeyLike List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().processDefinitionKeyLike("%\\%%").list(); assertEquals(0, list.size()); list = historyService.createHistoricTaskInstanceQuery().processDefinitionKeyLike("%\\_%").list(); assertEquals(0, list.size()); // orQuery list = historyService.createHistoricTaskInstanceQuery().or().processDefinitionKeyLike("%\\%%").processDefinitionId("undefined").list(); assertEquals(0, list.size()); list = historyService.createHistoricTaskInstanceQuery().or().processDefinitionKeyLike("%\\_%").processDefinitionId("undefined").list(); assertEquals(0, list.size()); } }
Example #9
Source File: HistoricTaskQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testQueryByTenantIdLike(){ if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // tenantIdLike List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskTenantIdLike("%\\%%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task2.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().taskTenantIdLike("%\\_%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task3.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); // orQuery list = historyService.createHistoricTaskInstanceQuery().or().taskTenantIdLike("%\\%%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task2.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().or().taskTenantIdLike("%\\_%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task3.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); } }
Example #10
Source File: HistoricTaskQueryResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected List<TaskRepresentation> convertTaskInfoList(List<HistoricTaskInstance> tasks) { List<TaskRepresentation> result = new ArrayList<TaskRepresentation>(); if (CollectionUtils.isNotEmpty(tasks)) { TaskRepresentation representation = null; for (HistoricTaskInstance task : tasks) { representation = new TaskRepresentation(task); CachedUser cachedUser = userCache.getUser(task.getAssignee()); if (cachedUser != null && cachedUser.getUser() != null) { representation.setAssignee(new UserRepresentation(cachedUser.getUser())); } result.add(representation); } } return result; }
Example #11
Source File: AbstractTaskResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public TaskRepresentation getTask(String taskId, HttpServletResponse response) { User currentUser = SecurityUtils.getCurrentUserObject(); HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(currentUser, taskId); ProcessDefinition processDefinition = null; if (StringUtils.isNotEmpty(task.getProcessDefinitionId())) { try { processDefinition = repositoryService.getProcessDefinition(task.getProcessDefinitionId()); } catch (ActivitiException e) { logger.error("Error getting process definition " + task.getProcessDefinitionId(), e); } } TaskRepresentation rep = new TaskRepresentation(task, processDefinition); TaskUtil.fillPermissionInformation(rep, task, currentUser, identityService, historyService, repositoryService); // Populate the people populateAssignee(task, rep); rep.setInvolvedPeople(getInvolvedUsers(taskId)); return rep; }
Example #12
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testFormKeyExpression() { runtimeService.startProcessInstanceByKey("testFormExpression", CollectionUtil.singletonMap("var", "abc")); Task task = taskService.createTaskQuery().singleResult(); assertEquals("first-form.json", task.getFormKey()); taskService.complete(task.getId()); task = taskService.createTaskQuery().singleResult(); assertEquals("form-abc.json", task.getFormKey()); task.setFormKey("form-changed.json"); taskService.saveTask(task); task = taskService.createTaskQuery().singleResult(); assertEquals("form-changed.json", task.getFormKey()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult(); assertEquals("form-changed.json", historicTaskInstance.getFormKey()); } }
Example #13
Source File: HistoricTaskQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testQueryByProcessInstanceBusinessKeyLikeIgnoreCase(){ if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // processInstanceBusinessKeyLikeIgnoreCase List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().processInstanceBusinessKeyLikeIgnoreCase("%\\%%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task2.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().processInstanceBusinessKeyLikeIgnoreCase("%\\_%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task3.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); // orQuery list = historyService.createHistoricTaskInstanceQuery().or().processInstanceBusinessKeyLikeIgnoreCase("%\\%%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task2.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().or().processInstanceBusinessKeyLikeIgnoreCase("%\\_%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task3.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); } }
Example #14
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testDeleteTaskWithDeleteReason() { // ACT-900: deleteReason can be manually specified - can only be validated when historyLevel > ACTIVITY if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { Task task = taskService.newTask(); task.setName("test task"); taskService.saveTask(task); assertNotNull(task.getId()); taskService.deleteTask(task.getId(), "deleted for testing purposes"); HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery() .taskId(task.getId()).singleResult(); assertNotNull(historicTaskInstance); assertEquals("deleted for testing purposes", historicTaskInstance.getDeleteReason()); // Delete historic task that is left behind, will not be cleaned up because this is not part of a process taskService.deleteTask(task.getId(), true); } }
Example #15
Source File: HistoricTaskQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Test public void testQueryByTaskDescriptionLike(){ if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // taskDescriptionLike List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskDescriptionLike("%\\%%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task3.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().taskDescriptionLike("%\\_%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task2.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); // orQuery list = historyService.createHistoricTaskInstanceQuery().or().taskDescriptionLike("%\\%%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task1.getId(), list.get(0).getId()); assertEquals(task3.getId(), list.get(1).getId()); list = historyService.createHistoricTaskInstanceQuery().or().taskDescriptionLike("%\\_%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); assertEquals(task2.getId(), list.get(0).getId()); assertEquals(task4.getId(), list.get(1).getId()); } }
Example #16
Source File: ScriptTaskListenerTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/examples/bpmn/tasklistener/ScriptTaskListenerTest.bpmn20.xml" }) public void testScriptTaskListener() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("scriptTaskListenerProcess"); Task task = taskService.createTaskQuery().singleResult(); assertEquals("Name does not match", "All your base are belong to us", task.getName()); taskService.complete(task.getId()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult(); assertEquals("kermit", historicTask.getOwner()); task = taskService.createTaskQuery().singleResult(); assertEquals("Task name not set with 'bar' variable", "BAR", task.getName()); } Object bar = runtimeService.getVariable(processInstance.getId(), "bar"); assertNull("Expected 'bar' variable to be local to script", bar); Object foo = runtimeService.getVariable(processInstance.getId(), "foo"); assertEquals("Could not find the 'foo' variable in variable scope", "FOO", foo); }
Example #17
Source File: RuntimeServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@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()); // test that the delete reason of the process instance shows up as // delete reason of the task in history // 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()); } }
Example #18
Source File: DelegateTaskTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testChangeCategoryInDelegateTask() { // Start process instance Map<String, Object> variables = new HashMap<String, Object>(); variables.put("approvers", Collections.singletonList("kermit")); // , "gonzo", "mispiggy")); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("delegateTaskTest", variables); // Assert there are three tasks with the default category List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); for (Task task : tasks) { assertEquals("approval", task.getCategory()); Map<String, Object> taskVariables = new HashMap<String, Object>(); taskVariables.put("outcome", "approve"); taskService.complete(task.getId(), taskVariables, true); } // After completion, the task category should be changed in the script // listener working on the delegate task assertEquals(0, taskService.createTaskQuery().processInstanceId(processInstance.getId()).count()); for (HistoricTaskInstance historicTaskInstance : historyService.createHistoricTaskInstanceQuery().list()) { assertEquals("approved", historicTaskInstance.getCategory()); } }
Example #19
Source File: MultiInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@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(); assertEquals(7, historicProcessInstances.size()); // 6 subprocesses // + main process 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()); assertNull(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()); } } }
Example #20
Source File: MultiInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti5/engine/test/bpmn/multiinstance/MultiInstanceTest.testParallelCallActivity.bpmn20.xml", "org/activiti5/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(); assertEquals(7, historicProcessInstances.size()); // 6 subprocesses + main process 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()); } } }
Example #21
Source File: TasksImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override public CollectionWithPagingInfo<Item> getItems(String taskId, Paging paging) { HistoricTaskInstance task = getValidHistoricTask(taskId); if (task.getProcessInstanceId() == null) { throw new UnsupportedResourceOperationException("Task is not part of process, no items available."); } return getItemsFromProcess(task.getProcessInstanceId(), paging); }
Example #22
Source File: MultiInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.sequentialUserTasks.bpmn20.xml" }) public void testSequentialUserTasksHistory() { String procId = runtimeService.startProcessInstanceByKey("miSequentialUserTasks", CollectionUtil.singletonMap(NR_OF_LOOPS_KEY, 4)).getId(); for (int i = 0; i < 4; i++) { taskService.complete(taskService.createTaskQuery().singleResult().getId()); } assertProcessEnded(procId); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list(); assertEquals(4, historicTaskInstances.size()); for (HistoricTaskInstance ht : historicTaskInstances) { assertNotNull(ht.getAssignee()); assertNotNull(ht.getStartTime()); assertNotNull(ht.getEndTime()); } List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list(); assertEquals(4, historicActivityInstances.size()); for (HistoricActivityInstance hai : historicActivityInstances) { assertNotNull(hai.getActivityId()); assertNotNull(hai.getActivityName()); assertNotNull(hai.getStartTime()); assertNotNull(hai.getEndTime()); assertNotNull(hai.getAssignee()); } } }
Example #23
Source File: UserTaskTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@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); } }
Example #24
Source File: DeleteReasonTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testRegularProcessInstanceEnd() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("deleteReasonProcess"); List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); while (!tasks.isEmpty()) { for (Task task : tasks) { taskService.complete(task.getId()); } tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list(); } assertEquals(0L, runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).count()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { assertNull(historyService.createHistoricProcessInstanceQuery() .processInstanceId(processInstance.getId()).singleResult().getDeleteReason()); List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstance.getId()).list(); assertEquals(5, historicTaskInstances.size()); for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) { assertNull(historicTaskInstance.getDeleteReason()); } assertHistoricActivitiesDeleteReason(processInstance, null, "A", "B", "C", "D", "E"); } }
Example #25
Source File: SubProcessTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@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)); assertEquals(1, managementService.createTimerJobQuery().count()); waitForJobExecutorToProcessAllJobs(5000L, 500L); // 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()); // Verify history for task that was killed if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskName("Task in subprocess").singleResult(); assertNotNull(historicTaskInstance.getEndTime()); HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().activityId("subProcessTask").singleResult(); assertNotNull(historicActivityInstance.getEndTime()); } }
Example #26
Source File: ProcessInstanceMigrationTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = { TEST_PROCESS_USER_TASK_V1 }) public void testSetProcessDefinitionVersionWithWithTask() { try { // start process instance ProcessInstance pi = runtimeService.startProcessInstanceByKey("userTask"); // check that user task has been reached assertEquals(1, taskService.createTaskQuery().processInstanceId(pi.getId()).count()); // deploy new version of the process definition org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource(TEST_PROCESS_USER_TASK_V2).deploy(); assertEquals(2, repositoryService.createProcessDefinitionQuery().processDefinitionKey("userTask").count()); ProcessDefinition newProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("userTask").processDefinitionVersion(2).singleResult(); // migrate process instance to new process definition version processEngineConfiguration.getCommandExecutor().execute(new SetProcessDefinitionVersionCmd(pi.getId(), 2)); // check UserTask Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); assertEquals(newProcessDefinition.getId(), task.getProcessDefinitionId()); assertEquals("testFormKey", formService.getTaskFormData(task.getId()).getFormKey()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(pi.getId()).singleResult(); assertEquals(newProcessDefinition.getId(), historicTask.getProcessDefinitionId()); assertEquals("testFormKey", formService.getTaskFormData(historicTask.getId()).getFormKey()); } // continue taskService.complete(task.getId()); assertProcessEnded(pi.getId()); // undeploy "manually" deployed process definition repositoryService.deleteDeployment(deployment.getId(), true); } catch (Exception ex) { ex.printStackTrace(); } }
Example #27
Source File: ActivitiTypeConverter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Converts an Activiti object to an Alresco Workflow object. * Determines the exact conversion method to use by checking the class of object. * @param obj The object to be converted. * @return the converted object. */ private Object convert(Object obj) { if(obj == null) return null; if (obj instanceof Deployment) { return convert( (Deployment) obj); } if (obj instanceof ProcessDefinition) { return convert( (ProcessDefinition) obj); } if (obj instanceof ProcessInstance) { return convert( (ProcessInstance) obj); } if (obj instanceof Execution) { return convert( (Execution) obj); } if (obj instanceof ActivityImpl) { return convert( (ActivityImpl) obj); } if (obj instanceof Task) { return convert( (Task) obj); } if(obj instanceof HistoricTaskInstance) { return convert((HistoricTaskInstance) obj); } if(obj instanceof HistoricProcessInstance) { return convert((HistoricProcessInstance) obj); } throw new WorkflowException("Cannot convert object: " + obj + " of type: " + obj.getClass()); }
Example #28
Source File: HistoricTaskQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testQueryLikeIgnoreCaseByQueryVariableValue() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // variableValueLikeIgnoreCase List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskVariableValueLikeIgnoreCase("var1", "%\\%%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); List<String> taskIds = new ArrayList<String>(2); taskIds.add(list.get(0).getId()); taskIds.add(list.get(1).getId()); assertTrue(taskIds.contains(task1.getId())); assertTrue(taskIds.contains(task3.getId())); list = historyService.createHistoricTaskInstanceQuery().taskVariableValueLikeIgnoreCase("var1", "%\\_%").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); taskIds = new ArrayList<String>(2); taskIds.add(list.get(0).getId()); taskIds.add(list.get(1).getId()); assertTrue(taskIds.contains(task2.getId())); assertTrue(taskIds.contains(task4.getId())); // orQuery list = historyService.createHistoricTaskInstanceQuery().or().taskVariableValueLikeIgnoreCase("var1", "%\\%%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); taskIds = new ArrayList<String>(2); taskIds.add(list.get(0).getId()); taskIds.add(list.get(1).getId()); assertTrue(taskIds.contains(task1.getId())); assertTrue(taskIds.contains(task3.getId())); list = historyService.createHistoricTaskInstanceQuery().or().taskVariableValueLikeIgnoreCase("var1", "%\\_%").processDefinitionId("undefined").orderByHistoricTaskInstanceStartTime().asc().list(); assertEquals(2, list.size()); taskIds = new ArrayList<String>(2); taskIds.add(list.get(0).getId()); taskIds.add(list.get(1).getId()); assertTrue(taskIds.contains(task2.getId())); assertTrue(taskIds.contains(task4.getId())); } }
Example #29
Source File: MultiInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = {"org/activiti5/engine/test/bpmn/multiinstance/MultiInstanceTest.sequentialUserTasks.bpmn20.xml"}) public void testSequentialUserTasksHistory() { runtimeService.startProcessInstanceByKey("miSequentialUserTasks", CollectionUtil.singletonMap("nrOfLoops", 4)).getId(); for (int i=0; i<4; i++) { taskService.complete(taskService.createTaskQuery().singleResult().getId()); } if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().list(); assertEquals(4, historicTaskInstances.size()); for (HistoricTaskInstance ht : historicTaskInstances) { assertNotNull(ht.getAssignee()); assertNotNull(ht.getStartTime()); assertNotNull(ht.getEndTime()); } List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().activityType("userTask").list(); assertEquals(4, historicActivityInstances.size()); for (HistoricActivityInstance hai : historicActivityInstances) { assertNotNull(hai.getActivityId()); assertNotNull(hai.getActivityName()); assertNotNull(hai.getStartTime()); assertNotNull(hai.getEndTime()); assertNotNull(hai.getAssignee()); } } }
Example #30
Source File: TaskController.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 查看已结束任务 */ @RequestMapping(value = "task/archived/{taskId}") public ModelAndView viewHistoryTask(@PathVariable("taskId") String taskId) throws Exception { String viewName = "chapter6/task-form-archived"; ModelAndView mav = new ModelAndView(viewName); HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult(); if (task.getParentTaskId() != null) { HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult(); mav.addObject("parentTask", parentTask); } mav.addObject("task", task); // 读取子任务 List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list(); mav.addObject("subTasks", subTasks); // 读取附件 List<Attachment> attachments = null; if (task.getTaskDefinitionKey() != null) { attachments = taskService.getTaskAttachments(taskId); } else { attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId()); } mav.addObject("attachments", attachments); return mav; }