Java Code Examples for org.activiti.engine.task.TaskQuery#list()
The following examples show how to use
org.activiti.engine.task.TaskQuery#list() .
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: ComplaintUserInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 6 votes |
/** * 自动提交第一步 */ private void autoFinishFirstTask(ComplaintDto complaintDto) { Task task = null; TaskQuery query = taskService.createTaskQuery().taskCandidateOrAssigned(complaintDto.getCurrentUserId()).active(); List<Task> todoList = query.list();//获取申请人的待办任务列表 for (Task tmp : todoList) { if (tmp.getProcessInstanceId().equals(complaintDto.getProcessInstanceId())) { task = tmp;//获取当前流程实例,当前申请人的待办任务 break; } } Assert.notNull(task, "未找到当前用户任务userId = " + complaintDto.getCurrentUserId()); complaintDto.setTaskId(task.getId()); complaintDto.setAuditCode("10000"); complaintDto.setAuditMessage("提交"); completeTask(complaintDto); }
Example 2
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private List<WorkflowTask> queryRuntimeTasks(WorkflowTaskQuery query) { // Runtime-tasks only exist on process-instances that are active // so no use in querying runtime tasks if not active if (!Boolean.FALSE.equals(query.isActive())) { TaskQuery taskQuery = createRuntimeTaskQuery(query); List<Task> results; int limit = query.getLimit(); if (limit > 0) { results = taskQuery.listPage(0, limit); } else { results = taskQuery.list(); } return getValidWorkflowTasks(results); } return new ArrayList<WorkflowTask>(); }
Example 3
Source File: MultiInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testSequentialSubProcessEndEvent() { // ACT-1185: end-event in subprocess causes inactivated execution String procId = runtimeService.startProcessInstanceByKey("miSequentialSubprocess").getId(); TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc(); for (int i=0; i<4; i++) { List<Task> tasks = query.list(); assertEquals(1, tasks.size()); assertEquals("task one", tasks.get(0).getName()); taskService.complete(tasks.get(0).getId()); // Last run, the execution no longer exists if(i != 3) { List<String> activities = runtimeService.getActiveActivityIds(procId); assertNotNull(activities); assertEquals(1, activities.size()); } } assertProcessEnded(procId); }
Example 4
Source File: MultiInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testSequentialSubProcess() { String procId = runtimeService.startProcessInstanceByKey("miSequentialSubprocess").getId(); TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc(); for (int i = 0; i < 4; i++) { List<Task> tasks = query.list(); assertEquals(2, tasks.size()); assertEquals("task one", tasks.get(0).getName()); assertEquals("task two", tasks.get(1).getName()); taskService.complete(tasks.get(0).getId()); taskService.complete(tasks.get(1).getId()); if (i != 3) { List<String> activities = runtimeService.getActiveActivityIds(procId); assertNotNull(activities); assertEquals(3, activities.size()); } } assertProcessEnded(procId); }
Example 5
Source File: MultiInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testSequentialSubProcessEndEvent() { // ACT-1185: end-event in subprocess causes inactivated execution String procId = runtimeService.startProcessInstanceByKey("miSequentialSubprocess").getId(); TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc(); for (int i = 0; i < 4; i++) { List<Task> tasks = query.list(); assertEquals(1, tasks.size()); assertEquals("task one", tasks.get(0).getName()); taskService.complete(tasks.get(0).getId()); // Last run, the execution no longer exists if (i != 3) { List<String> activities = runtimeService.getActiveActivityIds(procId); assertNotNull(activities); assertEquals(2, activities.size()); } } assertProcessEnded(procId); }
Example 6
Source File: MultiInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testSequentialSubProcessCompletionCondition() { String procId = runtimeService.startProcessInstanceByKey("miSequentialSubprocessCompletionCondition").getId(); TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc(); for (int i = 0; i < 3; i++) { List<Task> tasks = query.list(); assertEquals(2, tasks.size()); assertEquals("task one", tasks.get(0).getName()); assertEquals("task two", tasks.get(1).getName()); taskService.complete(tasks.get(0).getId()); taskService.complete(tasks.get(1).getId()); } assertProcessEnded(procId); }
Example 7
Source File: ParallelGatewayTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testForkJoin() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("forkJoin"); TaskQuery query = taskService .createTaskQuery() .processInstanceId(pi.getId()) .orderByTaskName() .asc(); List<Task> tasks = query.list(); assertEquals(2, tasks.size()); // the tasks are ordered by name (see above) Task task1 = tasks.get(0); assertEquals("Receive Payment", task1.getName()); Task task2 = tasks.get(1); assertEquals("Ship Order", task2.getName()); // Completing both tasks will join the concurrent executions taskService.complete(tasks.get(0).getId()); taskService.complete(tasks.get(1).getId()); tasks = query.list(); assertEquals(1, tasks.size()); assertEquals("Archive Order", tasks.get(0).getName()); }
Example 8
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void addTasksForCandidateGroups(List<String> groupNames, Map<String, Task> resultingTasks) { if(groupNames != null && groupNames.size() > 0) { TaskQuery query = taskService.createTaskQuery().taskCandidateGroupIn(groupNames); // Additional filtering on the tenant-property in case workflow-definitions are shared across tenants if(!activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && tenantService.isEnabled()) { query.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain()); } List<Task> tasks =query.list(); for(Task task : tasks) { resultingTasks.put(task.getId(), task); } } }
Example 9
Source File: CallActivityAdvancedTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/engine/test/bpmn/callactivity/CallActivity.testCallParallelSubProcess.bpmn20.xml", "org/activiti/engine/test/bpmn/callactivity/simpleParallelSubProcess.bpmn20.xml" }) public void testCallParallelSubProcess() { runtimeService.startProcessInstanceByKey("callParallelSubProcess"); // The two tasks in the parallel subprocess should be active TaskQuery taskQuery = taskService.createTaskQuery().orderByTaskName().asc(); List<Task> tasks = taskQuery.list(); assertEquals(2, tasks.size()); Task taskA = tasks.get(0); Task taskB = tasks.get(1); assertEquals("Task A", taskA.getName()); assertEquals("Task B", taskB.getName()); // Completing the first task should not end the subprocess taskService.complete(taskA.getId()); assertEquals(1, taskQuery.list().size()); // Completing the second task should end the subprocess and end the // whole process instance taskService.complete(taskB.getId()); assertEquals(0, runtimeService.createExecutionQuery().count()); }
Example 10
Source File: SubProcessTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * A test case that has a timer attached to the subprocess, where 2 concurrent paths are defined when the timer fires. */ @Deployment public void IGNORE_testSimpleSubProcessWithConcurrentTimer() { // After staring the process, the task in the subprocess should be active ProcessInstance pi = runtimeService.startProcessInstanceByKey("simpleSubProcessWithConcurrentTimer"); TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(pi.getId()).orderByTaskName().asc(); Task subProcessTask = taskQuery.singleResult(); assertEquals("Task in subprocess", subProcessTask.getName()); // When the timer is fired (after 2 hours), two concurrent paths should be created Job job = managementService.createJobQuery().singleResult(); managementService.executeJob(job.getId()); List<Task> tasksAfterTimer = taskQuery.list(); assertEquals(2, tasksAfterTimer.size()); Task taskAfterTimer1 = tasksAfterTimer.get(0); Task taskAfterTimer2 = tasksAfterTimer.get(1); assertEquals("Task after timer 1", taskAfterTimer1.getName()); assertEquals("Task after timer 2", taskAfterTimer2.getName()); // Completing the two tasks should end the process instance taskService.complete(taskAfterTimer1.getId()); taskService.complete(taskAfterTimer2.getId()); assertProcessEnded(pi.getId()); }
Example 11
Source File: SubProcessTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testTwoNestedSubProcessesInParallelWithTimer() { // Date startTime = new Date(); ProcessInstance pi = runtimeService.startProcessInstanceByKey("nestedParallelSubProcessesWithTimer"); TaskQuery taskQuery = taskService .createTaskQuery() .processInstanceId(pi.getId()) .orderByTaskName() .asc(); List<Task> tasks = taskQuery.list(); // After process start, both tasks in the subprocesses should be active Task taskA = tasks.get(0); Task taskB = tasks.get(1); assertEquals("Task in subprocess A", taskA.getName()); assertEquals("Task in subprocess B", taskB.getName()); // Firing the timer should destroy all three subprocesses and activate the task after the timer // processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + (2 * 60 * 60 * 1000 ) + 1000)); // waitForJobExecutorToProcessAllJobs(5000L, 50L); Job job = managementService.createTimerJobQuery().singleResult(); managementService.moveTimerToExecutableJob(job.getId()); managementService.executeJob(job.getId()); Task taskAfterTimer = taskQuery.singleResult(); assertEquals("Task after timer", taskAfterTimer.getName()); // Completing the task should end the process instance taskService.complete(taskAfterTimer.getId()); assertProcessEnded(pi.getId()); }
Example 12
Source File: ParallelGatewayTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testUnbalancedForkJoin() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnbalancedForkJoin"); TaskQuery query = taskService.createTaskQuery() .processInstanceId(pi.getId()) .orderByTaskName() .asc(); List<Task> tasks = query.list(); assertEquals(3, tasks.size()); // the tasks are ordered by name (see above) Task task1 = tasks.get(0); assertEquals("Task 1", task1.getName()); Task task2 = tasks.get(1); assertEquals("Task 2", task2.getName()); // Completing the first task should *not* trigger the join taskService.complete(task1.getId()); // Completing the second task should trigger the first join taskService.complete(task2.getId()); tasks = query.list(); Task task3 = tasks.get(0); assertEquals(2, tasks.size()); assertEquals("Task 3", task3.getName()); Task task4 = tasks.get(1); assertEquals("Task 4", task4.getName()); // Completing the remaing tasks should trigger the second join and end the process taskService.complete(task3.getId()); taskService.complete(task4.getId()); assertProcessEnded(pi.getId()); }
Example 13
Source File: BoundaryTimerNonInterruptingEventTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment /** * see https://activiti.atlassian.net/browse/ACT-1173 */ public void testTimerOnEmbeddedSubprocess() { String id = runtimeService.startProcessInstanceByKey("nonInterruptingTimerOnEmbeddedSubprocess").getId(); TaskQuery tq = taskService.createTaskQuery().taskAssignee("kermit"); assertEquals(1, tq.count()); // Simulate timer Job timer = managementService.createTimerJobQuery().singleResult(); managementService.moveTimerToExecutableJob(timer.getId()); managementService.executeJob(timer.getId()); tq = taskService.createTaskQuery().taskAssignee("kermit"); assertEquals(2, tq.count()); List<Task> tasks = tq.list(); taskService.complete(tasks.get(0).getId()); taskService.complete(tasks.get(1).getId()); assertProcessEnded(id); }
Example 14
Source File: BoundaryTimerNonInterruptingEventTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment /** * see https://activiti.atlassian.net/browse/ACT-1173 */ public void testTimerOnEmbeddedSubprocess() { String id = runtimeService.startProcessInstanceByKey("nonInterruptingTimerOnEmbeddedSubprocess").getId(); TaskQuery tq = taskService.createTaskQuery().taskAssignee("kermit"); assertEquals(1, tq.count()); // Simulate timer Job timer = managementService.createTimerJobQuery().singleResult(); managementService.moveTimerToExecutableJob(timer.getId()); managementService.executeJob(timer.getId()); tq = taskService.createTaskQuery().taskAssignee("kermit"); assertEquals(2, tq.count()); List<Task> tasks = tq.list(); taskService.complete(tasks.get(0).getId()); taskService.complete(tasks.get(1).getId()); assertProcessEnded(id); }
Example 15
Source File: SubProcessTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testTwoSubProcessInParallel() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("twoSubProcessInParallel"); TaskQuery taskQuery = taskService .createTaskQuery() .processInstanceId(pi.getId()) .orderByTaskName() .asc(); List<Task> tasks = taskQuery.list(); // After process start, both tasks in the subprocesses should be active assertEquals("Task in subprocess A", tasks.get(0).getName()); assertEquals("Task in subprocess B", tasks.get(1).getName()); // Completing both tasks should active the tasks outside the subprocesses taskService.complete(tasks.get(0).getId()); tasks = taskQuery.list(); assertEquals("Task after subprocess A", tasks.get(0).getName()); assertEquals("Task in subprocess B", tasks.get(1).getName()); taskService.complete(tasks.get(1).getId()); tasks = taskQuery.list(); assertEquals("Task after subprocess A", tasks.get(0).getName()); assertEquals("Task after subprocess B", tasks.get(1).getName()); // Completing these tasks should end the process taskService.complete(tasks.get(0).getId()); taskService.complete(tasks.get(1).getId()); assertProcessEnded(pi.getId()); }
Example 16
Source File: SubProcessTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * A test case that has a timer attached to the subprocess, * where 2 concurrent paths are defined when the timer fires. */ @Deployment public void IGNORE_testSimpleSubProcessWithConcurrentTimer() { // After staring the process, the task in the subprocess should be active ProcessInstance pi = runtimeService.startProcessInstanceByKey("simpleSubProcessWithConcurrentTimer"); TaskQuery taskQuery = taskService .createTaskQuery() .processInstanceId(pi.getId()) .orderByTaskName() .asc(); Task subProcessTask = taskQuery.singleResult(); assertEquals("Task in subprocess", subProcessTask.getName()); // When the timer is fired (after 2 hours), two concurrent paths should be created Job job = managementService.createJobQuery().singleResult(); managementService.executeJob(job.getId()); List<Task> tasksAfterTimer = taskQuery.list(); assertEquals(2, tasksAfterTimer.size()); Task taskAfterTimer1 = tasksAfterTimer.get(0); Task taskAfterTimer2 = tasksAfterTimer.get(1); assertEquals("Task after timer 1", taskAfterTimer1.getName()); assertEquals("Task after timer 2", taskAfterTimer2.getName()); // Completing the two tasks should end the process instance taskService.complete(taskAfterTimer1.getId()); taskService.complete(taskAfterTimer2.getId()); assertProcessEnded(pi.getId()); }
Example 17
Source File: CallActivityAdvancedTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment(resources = { "org/activiti5/engine/test/bpmn/callactivity/CallActivity.testCallParallelSubProcess.bpmn20.xml", "org/activiti5/engine/test/bpmn/callactivity/simpleParallelSubProcess.bpmn20.xml"}) public void testCallParallelSubProcess() { runtimeService.startProcessInstanceByKey("callParallelSubProcess"); // The two tasks in the parallel subprocess should be active TaskQuery taskQuery = taskService .createTaskQuery() .orderByTaskName() .asc(); List<Task> tasks = taskQuery.list(); assertEquals(2, tasks.size()); Task taskA = tasks.get(0); Task taskB = tasks.get(1); assertEquals("Task A", taskA.getName()); assertEquals("Task B", taskB.getName()); // Completing the first task should not end the subprocess taskService.complete(taskA.getId()); assertEquals(1, taskQuery.list().size()); // Completing the second task should end the subprocess and end the whole process instance taskService.complete(taskB.getId()); assertEquals(0, runtimeService.createExecutionQuery().count()); }
Example 18
Source File: ParallelGatewayTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testNestedForkJoin() { runtimeService.startProcessInstanceByKey("nestedForkJoin"); // After process startm, only task 0 should be active TaskQuery query = taskService.createTaskQuery().orderByTaskName().asc(); List<Task> tasks = query.list(); assertEquals(1, tasks.size()); assertEquals("Task 0", tasks.get(0).getName()); // Completing task 0 will create Task A and B taskService.complete(tasks.get(0).getId()); tasks = query.list(); assertEquals(2, tasks.size()); assertEquals("Task A", tasks.get(0).getName()); assertEquals("Task B", tasks.get(1).getName()); // Completing task A should not trigger any new tasks taskService.complete(tasks.get(0).getId()); tasks = query.list(); assertEquals(1, tasks.size()); assertEquals("Task B", tasks.get(0).getName()); // Completing task B creates tasks B1 and B2 taskService.complete(tasks.get(0).getId()); tasks = query.list(); assertEquals(2, tasks.size()); assertEquals("Task B1", tasks.get(0).getName()); assertEquals("Task B2", tasks.get(1).getName()); // Completing B1 and B2 will activate both joins, and process reaches // task C taskService.complete(tasks.get(0).getId()); taskService.complete(tasks.get(1).getId()); tasks = query.list(); assertEquals(1, tasks.size()); assertEquals("Task C", tasks.get(0).getName()); }
Example 19
Source File: SubProcessTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testTwoSubProcessInParallelWithinSubProcess() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("twoSubProcessInParallelWithinSubProcess"); TaskQuery taskQuery = taskService .createTaskQuery() .processInstanceId(pi.getId()) .orderByTaskName() .asc(); List<Task> tasks = taskQuery.list(); // After process start, both tasks in the subprocesses should be active Task taskA = tasks.get(0); Task taskB = tasks.get(1); assertEquals("Task in subprocess A", taskA.getName()); assertEquals("Task in subprocess B", taskB.getName()); // Completing both tasks should active the tasks outside the subprocesses taskService.complete(taskA.getId()); taskService.complete(taskB.getId()); Task taskAfterSubProcess = taskQuery.singleResult(); assertEquals("Task after subprocess", taskAfterSubProcess.getName()); // Completing this task should end the process taskService.complete(taskAfterSubProcess.getId()); assertProcessEnded(pi.getId()); }
Example 20
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testQueryByCandidateOrAssignedOr() { TaskQuery query = taskService.createTaskQuery() .or() .taskId("invalid") .taskCandidateOrAssigned("kermit"); assertEquals(11, query.count()); List<Task> tasks = query.list(); assertEquals(11, tasks.size()); // if dbIdentityUsed set false in process engine configuration of using custom session factory of GroupIdentityManager ArrayList<String> candidateGroups = new ArrayList<String>(); candidateGroups.add("management"); candidateGroups.add("accountancy"); candidateGroups.add("noexist"); query = taskService.createTaskQuery() .or() .taskId("invalid") .taskCandidateGroupIn(candidateGroups) .taskCandidateOrAssigned("kermit"); assertEquals(11, query.count()); tasks = query.list(); assertEquals(11, tasks.size()); query = taskService.createTaskQuery() .or() .taskId("invalid") .taskCandidateOrAssigned("fozzie"); assertEquals(3, query.count()); assertEquals(3, query.list().size()); // create a new task that no identity link and assignee to kermit Task task = taskService.newTask(); task.setName("assigneeToKermit"); task.setDescription("testTask description"); task.setPriority(3); task.setAssignee("kermit"); taskService.saveTask(task); query = taskService.createTaskQuery() .or() .taskId("invalid") .taskCandidateOrAssigned("kermit"); assertEquals(12, query.count()); tasks = query.list(); assertEquals(12, tasks.size()); Task assigneeToKermit = taskService.createTaskQuery() .or() .taskId("invalid") .taskName("assigneeToKermit").singleResult(); taskService.deleteTask(assigneeToKermit.getId()); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(assigneeToKermit.getId()); } }