org.activiti.engine.task.TaskQuery Java Examples
The following examples show how to use
org.activiti.engine.task.TaskQuery.
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: HistoricVariableInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testSimple() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProc"); TaskQuery taskQuery = taskService.createTaskQuery(); Task userTask = taskQuery.singleResult(); assertEquals("userTask1", userTask.getName()); taskService.complete(userTask.getId(), CollectionUtil.singletonMap("myVar", "test789")); assertProcessEnded(processInstance.getId()); List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().list(); assertEquals(1, variables.size()); HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0); assertEquals("test456", historicVariable.getTextValue()); assertEquals(5, historyService.createHistoricActivityInstanceQuery().count()); assertEquals(3, historyService.createHistoricDetailQuery().count()); } }
Example #2
Source File: HistoricVariableInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/examples/bpmn/callactivity/orderProcess.bpmn20.xml", "org/activiti/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml" }) public void testOrderProcessWithCallActivity() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) { // After the process has started, the 'verify credit history' task should be active ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess"); TaskQuery taskQuery = taskService.createTaskQuery(); Task verifyCreditTask = taskQuery.singleResult(); assertEquals("Verify credit history", verifyCreditTask.getName()); // Verify with Query API ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult(); assertNotNull(subProcessInstance); assertEquals(pi.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(subProcessInstance.getId()).singleResult().getId()); // Completing the task with approval, will end the subprocess and continue the original process taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true)); Task prepareAndShipTask = taskQuery.singleResult(); assertEquals("Prepare and Ship", prepareAndShipTask.getName()); } }
Example #3
Source File: TaskQueryImpl.java From lemon with Apache License 2.0 | 6 votes |
public TaskQuery taskDescriptionLikeIgnoreCase( String descriptionLikeIgnoreCase) { if (descriptionLikeIgnoreCase == null) { throw new ActivitiIllegalArgumentException( "Task descriptionLikeIgnoreCase is null"); } if (orActive) { currentOrQueryObject.descriptionLikeIgnoreCase = descriptionLikeIgnoreCase .toLowerCase(); } else { this.descriptionLikeIgnoreCase = descriptionLikeIgnoreCase .toLowerCase(); } return this; }
Example #4
Source File: SubTaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * test for task inclusion/exclusion when additional filter is specified (like assignee), no order. */ public void testQueryByAssigneeExcludeSubtasksPaginated() throws Exception { // gonzo has 2 root tasks and 3+2 subtasks assigned // include subtasks TaskQuery query = taskService.createTaskQuery().taskAssignee("gonzo"); assertEquals(7, query.count()); assertEquals(2, query.listPage(0, 2).size()); // exclude subtasks query = taskService.createTaskQuery().taskAssignee("gonzo").excludeSubtasks(); assertEquals(2, query.count()); assertEquals(1, query.listPage(0, 1).size()); // kermit has no root tasks and no subtasks assigned // include subtasks query = taskService.createTaskQuery().taskAssignee("kermit"); assertEquals(0, query.count()); assertEquals(0, query.listPage(0, 2).size()); assertNull(query.singleResult()); // exclude subtasks query = taskService.createTaskQuery().taskAssignee("kermit").excludeSubtasks(); assertEquals(0, query.count()); assertEquals(0, query.listPage(0, 2).size()); assertNull(query.singleResult()); }
Example #5
Source File: ActivitiWorkflowEngine.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private void addProcessPropertiesToQuery( Map<QName, Object> processCustomProps, TaskQuery taskQuery) { for(Entry<QName, Object> customProperty : processCustomProps.entrySet()) { String name =factory.mapQNameToName(customProperty.getKey()); // Exclude the special "VAR_TENANT_DOMAIN" variable, this cannot be queried by users if(name != ActivitiConstants.VAR_TENANT_DOMAIN) { // Perform minimal property conversions Object converted = propertyConverter.convertPropertyToValue(customProperty.getValue()); taskQuery.processVariableValueEquals(name, converted); } } }
Example #6
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testQueryByNameIn() { final List<String> taskNameList = new ArrayList<String>(2); taskNameList.add("testTask"); taskNameList.add("gonzoTask"); TaskQuery query = taskService.createTaskQuery().taskNameIn(taskNameList); assertEquals(7, query.list().size()); assertEquals(7, query.count()); try { query.singleResult(); fail("expected exception"); } catch (ActivitiException e) { // OK } }
Example #7
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testQueryByInvalidNameLikeOr() { TaskQuery query = taskService.createTaskQuery() .or() .taskId("invalid") .taskNameLike("1"); assertNull(query.singleResult()); assertEquals(0, query.list().size()); assertEquals(0, query.count()); try { taskService.createTaskQuery() .or() .taskId("invalid") .taskNameLike(null).singleResult(); fail(); } catch (ActivitiIllegalArgumentException e) { } }
Example #8
Source File: TaskQueryImpl.java From lemon with Apache License 2.0 | 6 votes |
public TaskQuery taskCandidateGroupIn(List<String> candidateGroups) { if (candidateGroups == null) { throw new ActivitiIllegalArgumentException( "Candidate group list is null"); } if (candidateGroups.isEmpty()) { throw new ActivitiIllegalArgumentException( "Candidate group list is empty"); } if (candidateGroup != null) { throw new ActivitiIllegalArgumentException( "Invalid query usage: cannot set both candidateGroupIn and candidateGroup"); } if (orActive) { currentOrQueryObject.candidateGroups = candidateGroups; } else { this.candidateGroups = candidateGroups; } return this; }
Example #9
Source File: HistoricVariableInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testRestrictByExecutionId() { if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProc"); TaskQuery taskQuery = taskService.createTaskQuery(); Task userTask = taskQuery.singleResult(); assertEquals("userTask1", userTask.getName()); taskService.complete(userTask.getId(), CollectionUtil.singletonMap("myVar", "test789")); assertProcessEnded(processInstance.getId()); List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().executionId(processInstance.getId()).list(); assertEquals(1, variables.size()); HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0); assertEquals("test456", historicVariable.getTextValue()); assertEquals(5, historyService.createHistoricActivityInstanceQuery().count()); assertEquals(3, historyService.createHistoricDetailQuery().count()); } }
Example #10
Source File: HistoricVariableInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources={ "org/activiti5/examples/bpmn/callactivity/orderProcess.bpmn20.xml", "org/activiti5/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml" }) public void testOrderProcessWithCallActivity() { if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) { // After the process has started, the 'verify credit history' task should be active ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess"); TaskQuery taskQuery = taskService.createTaskQuery(); Task verifyCreditTask = taskQuery.singleResult(); assertEquals("Verify credit history", verifyCreditTask.getName()); // Verify with Query API ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult(); assertNotNull(subProcessInstance); assertEquals(pi.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(subProcessInstance.getId()).singleResult().getId()); // Completing the task with approval, will end the subprocess and continue the original process taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true)); Task prepareAndShipTask = taskQuery.singleResult(); assertEquals("Prepare and Ship", prepareAndShipTask.getName()); } }
Example #11
Source File: CallActivityAdvancedTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * Test case for a possible tricky case: reaching the end event * of the subprocess leads to an end event in the super process instance. */ @Deployment(resources = { "org/activiti5/engine/test/bpmn/callactivity/CallActivity.testSubProcessEndsSuperProcess.bpmn20.xml", "org/activiti5/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml" }) public void testSubProcessEndsSuperProcess() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subProcessEndsSuperProcess"); // one task in the subprocess should be active after starting the process instance TaskQuery taskQuery = taskService.createTaskQuery(); Task taskBeforeSubProcess = taskQuery.singleResult(); assertEquals("Task in subprocess", taskBeforeSubProcess.getName()); // Completing this task ends the subprocess which leads to the end of the whole process instance taskService.complete(taskBeforeSubProcess.getId()); assertProcessEnded(processInstance.getId()); assertEquals(0, runtimeService.createExecutionQuery().list().size()); }
Example #12
Source File: CallActivityTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources={ "org/activiti5/examples/bpmn/callactivity/orderProcess.bpmn20.xml", "org/activiti5/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml" }) public void testOrderProcessWithCallActivity() { // After the process has started, the 'verify credit history' task should be active ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess"); TaskQuery taskQuery = taskService.createTaskQuery(); Task verifyCreditTask = taskQuery.singleResult(); assertEquals("Verify credit history", verifyCreditTask.getName()); // Verify with Query API ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult(); assertNotNull(subProcessInstance); assertEquals(pi.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(subProcessInstance.getId()).singleResult().getId()); // Completing the task with approval, will end the subprocess and continue the original process taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true)); Task prepareAndShipTask = taskQuery.singleResult(); assertEquals("Prepare and Ship", prepareAndShipTask.getName()); }
Example #13
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testQueryPaging() { TaskQuery query = taskService.createTaskQuery().taskCandidateUser("kermit"); assertEquals(11, query.listPage(0, Integer.MAX_VALUE).size()); // Verifying the un-paged results assertEquals(11, query.count()); assertEquals(11, query.list().size()); // Verifying paged results assertEquals(2, query.listPage(0, 2).size()); assertEquals(2, query.listPage(2, 2).size()); assertEquals(3, query.listPage(4, 3).size()); assertEquals(1, query.listPage(10, 3).size()); assertEquals(1, query.listPage(10, 1).size()); // Verifying odd usages assertEquals(0, query.listPage(-1, -1).size()); assertEquals(0, query.listPage(11, 2).size()); // 10 is the last index with a result assertEquals(11, query.listPage(0, 15).size()); // there are only 11 tasks }
Example #14
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testQueryByAssigneeOr() { TaskQuery query = taskService.createTaskQuery() .or() .taskId("invalid") .taskAssignee("gonzo"); assertEquals(1, query.count()); assertEquals(1, query.list().size()); assertNotNull(query.singleResult()); query = taskService.createTaskQuery() .or() .taskId("invalid") .taskAssignee("kermit"); assertEquals(0, query.count()); assertEquals(0, query.list().size()); assertNull(query.singleResult()); }
Example #15
Source File: CallActivityAdvancedTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti5/engine/test/bpmn/callactivity/CallActivity.testTimerOnCallActivity.bpmn20.xml", "org/activiti5/engine/test/bpmn/callactivity/simpleSubProcess.bpmn20.xml"}) public void testTimerOnCallActivity() { Date startTime = processEngineConfiguration.getClock().getCurrentTime(); // After process start, the task in the subprocess should be active runtimeService.startProcessInstanceByKey("timerOnCallActivity"); TaskQuery taskQuery = taskService.createTaskQuery(); Task taskInSubProcess = taskQuery.singleResult(); assertEquals("Task in subprocess", taskInSubProcess.getName()); // When the timer on the subprocess is fired, the complete subprocess is destroyed processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + (6 * 60 * 1000))); // + 6 minutes, timer fires on 5 minutes waitForJobExecutorToProcessAllJobs(10000, 5000L); Task escalatedTask = taskQuery.singleResult(); assertEquals("Escalated Task", escalatedTask.getName()); // Completing the task ends the complete process taskService.complete(escalatedTask.getId()); assertEquals(0, runtimeService.createExecutionQuery().list().size()); }
Example #16
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testQueryByInvalidNameInIgnoreCaseOr() { final List<String> taskNameList = new ArrayList<String>(2); taskNameList.add("invalid"); TaskQuery query = taskService.createTaskQuery() .or() .taskNameInIgnoreCase(taskNameList) .taskId("invalid"); assertEquals(0, query.list().size()); assertEquals(0, query.count()); try { taskService.createTaskQuery() .or() .taskId("invalid") .taskNameIn(null).singleResult(); fail("expected exception"); } catch (ActivitiException e) { // OK } }
Example #17
Source File: SubTaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * test for task inclusion/exclusion when additional filter is specified (like assignee), no order. */ public void testQueryByAssigneeExcludeSubtasks() throws Exception { // gonzo has 2 root tasks and 3+2 subtasks assigned // include subtasks TaskQuery query = taskService.createTaskQuery().taskAssignee("gonzo"); assertEquals(7, query.count()); assertEquals(7, query.list().size()); // exclude subtasks query = taskService.createTaskQuery().taskAssignee("gonzo").excludeSubtasks(); assertEquals(2, query.count()); assertEquals(2, query.list().size()); // kermit has no root tasks and no subtasks assigned // include subtasks query = taskService.createTaskQuery().taskAssignee("kermit"); assertEquals(0, query.count()); assertEquals(0, query.list().size()); assertNull(query.singleResult()); // exclude subtasks query = taskService.createTaskQuery().taskAssignee("kermit").excludeSubtasks(); assertEquals(0, query.count()); assertEquals(0, query.list().size()); assertNull(query.singleResult()); }
Example #18
Source File: CallActivityTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/examples/bpmn/callactivity/orderProcess.bpmn20.xml", "org/activiti/examples/bpmn/callactivity/checkCreditProcess.bpmn20.xml" }) public void testOrderProcessWithCallActivity() { // After the process has started, the 'verify credit history' task // should be active ProcessInstance pi = runtimeService.startProcessInstanceByKey("orderProcess"); TaskQuery taskQuery = taskService.createTaskQuery(); Task verifyCreditTask = taskQuery.singleResult(); assertEquals("Verify credit history", verifyCreditTask.getName()); // Verify with Query API ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId(pi.getId()).singleResult(); assertNotNull(subProcessInstance); assertEquals(pi.getId(), runtimeService.createProcessInstanceQuery().subProcessInstanceId(subProcessInstance.getId()).singleResult().getId()); // Completing the task with approval, will end the subprocess and // continue the original process taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true)); Task prepareAndShipTask = taskQuery.singleResult(); assertEquals("Prepare and Ship", prepareAndShipTask.getName()); }
Example #19
Source File: HistoricVariableInstanceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment public void testSimple() { if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.FULL)) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProc"); TaskQuery taskQuery = taskService.createTaskQuery(); Task userTask = taskQuery.singleResult(); assertEquals("userTask1", userTask.getName()); taskService.complete(userTask.getId(), CollectionUtil.singletonMap("myVar", "test789")); assertProcessEnded(processInstance.getId()); List<HistoricVariableInstance> variables = historyService.createHistoricVariableInstanceQuery().list(); assertEquals(1, variables.size()); HistoricVariableInstanceEntity historicVariable = (HistoricVariableInstanceEntity) variables.get(0); assertEquals("test456", historicVariable.getTextValue()); assertEquals(5, historyService.createHistoricActivityInstanceQuery().count()); assertEquals(3, historyService.createHistoricDetailQuery().count()); } }
Example #20
Source File: TaskQueryImpl.java From lemon with Apache License 2.0 | 5 votes |
public TaskQuery taskPriority(Integer priority) { if (priority == null) { throw new ActivitiIllegalArgumentException("Priority is null"); } if (orActive) { currentOrQueryObject.priority = priority; } else { this.priority = priority; } return this; }
Example #21
Source File: TaskQueryImpl.java From lemon with Apache License 2.0 | 5 votes |
public TaskQuery processVariableValueEquals(Object variableValue) { if (orActive) { currentOrQueryObject.variableValueEquals(variableValue, false); } else { this.variableValueEquals(variableValue, false); } return this; }
Example #22
Source File: TaskQueryImpl.java From lemon with Apache License 2.0 | 5 votes |
public TaskQuery taskVariableValueLessThan(String name, Object value) { if (orActive) { currentOrQueryObject.variableValueLessThan(name, value); } else { this.variableValueLessThan(name, value); } return this; }
Example #23
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testQueryCreatedBeforeOr() throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss.SSS"); // Should result in 7 tasks Date before = sdf.parse("03/02/2002 02:02:02.000"); TaskQuery query = taskService.createTaskQuery().or().taskId("invalid").taskCreatedBefore(before); assertEquals(7, query.count()); assertEquals(7, query.list().size()); before = sdf.parse("01/01/2001 01:01:01.000"); query = taskService.createTaskQuery().or().taskId("invalid").taskCreatedBefore(before); assertEquals(0, query.count()); assertEquals(0, query.list().size()); }
Example #24
Source File: TaskQueryImpl.java From lemon with Apache License 2.0 | 5 votes |
public TaskQuery suspended() { if (orActive) { currentOrQueryObject.suspensionState = SuspensionState.SUSPENDED; } else { this.suspensionState = SuspensionState.SUSPENDED; } return this; }
Example #25
Source File: TaskQueryImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public TaskQuery taskVariableValueNotEquals(String variableName, Object variableValue) { if (orActive) { currentOrQueryObject.variableValueNotEquals(variableName, variableValue); } else { this.variableValueNotEquals(variableName, variableValue); } return this; }
Example #26
Source File: TaskQueryImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public TaskQuery taskAssigneeLikeIgnoreCase(String assigneeLikeIgnoreCase) { if (assigneeLikeIgnoreCase == null) { throw new ActivitiIllegalArgumentException("assigneeLikeIgnoreCase is null"); } if (orActive) { currentOrQueryObject.assigneeLikeIgnoreCase = assigneeLikeIgnoreCase.toLowerCase(); } else { this.assigneeLikeIgnoreCase = assigneeLikeIgnoreCase.toLowerCase(); } return this; }
Example #27
Source File: TaskQueryImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public TaskQuery processVariableValueLessThan(String name, Object value) { if(orActive) { currentOrQueryObject.variableValueLessThan(name, value, false); } else { this.variableValueLessThan(name, value, false); } return this; }
Example #28
Source File: TaskQueryImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public TaskQuery processVariableValueGreaterThanOrEqual(String name, Object value) { if(orActive) { currentOrQueryObject.variableValueGreaterThanOrEqual(name, value, false); } else { this.variableValueGreaterThanOrEqual(name, value, false); } return this; }
Example #29
Source File: TaskQueryImpl.java From lemon with Apache License 2.0 | 5 votes |
public TaskQuery processVariableValueEqualsIgnoreCase(String name, String value) { if (orActive) { currentOrQueryObject.variableValueEqualsIgnoreCase(name, value, false); } else { this.variableValueEqualsIgnoreCase(name, value, false); } return this; }
Example #30
Source File: TaskQueryImpl.java From lemon with Apache License 2.0 | 5 votes |
public TaskQuery taskOwnerLikeIgnoreCase(String ownerLikeIgnoreCase) { if (ownerLikeIgnoreCase == null) { throw new ActivitiIllegalArgumentException("OwnerLikeIgnoreCase"); } if (orActive) { currentOrQueryObject.ownerLikeIgnoreCase = ownerLikeIgnoreCase .toLowerCase(); } else { this.ownerLikeIgnoreCase = ownerLikeIgnoreCase.toLowerCase(); } return this; }