org.activiti.engine.task.DelegationState Java Examples
The following examples show how to use
org.activiti.engine.task.DelegationState.
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: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti5/engine/test/api/twoTasksProcess.bpmn20.xml" }) public void testResolveWithParametersTask() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("twoTasksProcess"); // Fetch first task Task task = taskService.createTaskQuery().singleResult(); assertEquals("First task", task.getName()); taskService.delegateTask(task.getId(), "johndoe"); // Resolve first task Map<String, Object> taskParams = new HashMap<String, Object>(); taskParams.put("myParam", "myValue"); taskService.resolveTask(task.getId(), taskParams); // Verify that task is resolved task = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED).singleResult(); assertEquals("First task", task.getName()); // Verify task parameters set on execution Map<String, Object> variables = runtimeService.getVariables(processInstance.getId()); assertEquals(1, variables.size()); assertEquals("myValue", variables.get("myParam")); }
Example #2
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testTaskDelegationThroughServiceCall() { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); String taskId = task.getId(); // Fetch the task again and update task = taskService.createTaskQuery().taskId(taskId).singleResult(); taskService.delegateTask(task.getId(), "joesmoe"); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("joesmoe", task.getAssignee()); assertEquals(DelegationState.PENDING, task.getDelegationState()); taskService.resolveTask(taskId); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("johndoe", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); // Finally, delete task taskService.deleteTask(taskId, true); }
Example #3
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * @see <a href="https://activiti.atlassian.net/browse/ACT-1059">https://activiti.atlassian.net/browse/ACT-1059</a> */ public void testSetDelegationState() { Task task = taskService.newTask(); task.setOwner("wuzh"); taskService.saveTask(task); taskService.delegateTask(task.getId(), "other"); String taskId = task.getId(); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("wuzh", task.getOwner()); assertEquals("other", task.getAssignee()); assertEquals(DelegationState.PENDING, task.getDelegationState()); task.setDelegationState(DelegationState.RESOLVED); taskService.saveTask(task); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("wuzh", task.getOwner()); assertEquals("other", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); taskService.deleteTask(taskId, true); }
Example #4
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testResolveTaskWithParametersNullParameters() { Task task = taskService.newTask(); task.setDelegationState(DelegationState.PENDING); taskService.saveTask(task); String taskId = task.getId(); taskService.resolveTask(taskId, null); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(taskId); } // Fetch the task again task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); taskService.deleteTask(taskId, true); }
Example #5
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/engine/test/api/twoTasksProcess.bpmn20.xml" }) public void testResolveWithParametersTask() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("twoTasksProcess"); // Fetch first task Task task = taskService.createTaskQuery().singleResult(); assertEquals("First task", task.getName()); taskService.delegateTask(task.getId(), "johndoe"); // Resolve first task Map<String, Object> taskParams = new HashMap<String, Object>(); taskParams.put("myParam", "myValue"); taskService.resolveTask(task.getId(), taskParams); // Verify that task is resolved task = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED).singleResult(); assertEquals("First task", task.getName()); // Verify task parameters set on execution Map<String, Object> variables = runtimeService.getVariables(processInstance.getId()); assertEquals(1, variables.size()); assertEquals("myValue", variables.get("myParam")); }
Example #6
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void testResolveTaskWithParametersEmptyParameters() { Task task = taskService.newTask(); task.setDelegationState(DelegationState.PENDING); taskService.saveTask(task); String taskId = task.getId(); taskService.resolveTask(taskId, Collections.EMPTY_MAP); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(taskId); } // Fetch the task again task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); taskService.deleteTask(taskId, true); }
Example #7
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testResolveTaskWithParametersNullParameters() { Task task = taskService.newTask(); task.setDelegationState(DelegationState.PENDING); taskService.saveTask(task); String taskId = task.getId(); taskService.resolveTask(taskId, null); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(taskId); } // Fetch the task again task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); taskService.deleteTask(taskId, true); }
Example #8
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * @see <a href="https://activiti.atlassian.net/browse/ACT-1059">https://activiti.atlassian.net/browse/ACT-1059</a> */ public void testSetDelegationState() { Task task = taskService.newTask(); task.setOwner("wuzh"); taskService.saveTask(task); taskService.delegateTask(task.getId(), "other"); String taskId = task.getId(); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("wuzh", task.getOwner()); assertEquals("other", task.getAssignee()); assertEquals(DelegationState.PENDING, task.getDelegationState()); task.setDelegationState(DelegationState.RESOLVED); taskService.saveTask(task); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("wuzh", task.getOwner()); assertEquals("other", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); taskService.deleteTask(taskId, true); }
Example #9
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testTaskDelegationThroughServiceCall() { Task task = taskService.newTask(); task.setOwner("johndoe"); taskService.saveTask(task); String taskId = task.getId(); // Fetch the task again and update task = taskService.createTaskQuery().taskId(taskId).singleResult(); taskService.delegateTask(task.getId(), "joesmoe"); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("joesmoe", task.getAssignee()); assertEquals(DelegationState.PENDING, task.getDelegationState()); taskService.resolveTask(taskId); task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals("johndoe", task.getOwner()); assertEquals("johndoe", task.getAssignee()); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); // Finally, delete task taskService.deleteTask(taskId, true); }
Example #10
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void testResolveTaskWithParametersEmptyParameters() { Task task = taskService.newTask(); task.setDelegationState(DelegationState.PENDING); taskService.saveTask(task); String taskId = task.getId(); taskService.resolveTask(taskId, Collections.EMPTY_MAP); if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { historyService.deleteHistoricTaskInstance(taskId); } // Fetch the task again task = taskService.createTaskQuery().taskId(taskId).singleResult(); assertEquals(DelegationState.RESOLVED, task.getDelegationState()); taskService.deleteTask(taskId, true); }
Example #11
Source File: TaskQueryImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public TaskQuery taskDelegationState(DelegationState delegationState) { if (orActive) { if (delegationState == null) { currentOrQueryObject.noDelegationState = true; } else { currentOrQueryObject.delegationState = delegationState; } } else { if (delegationState == null) { this.noDelegationState = true; } else { this.delegationState = delegationState; } } return this; }
Example #12
Source File: TaskQueryImpl.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public TaskQuery taskDelegationState(DelegationState delegationState) { if (orActive) { if (delegationState == null) { currentOrQueryObject.noDelegationState = true; } else { currentOrQueryObject.delegationState = delegationState; } } else { if (delegationState == null) { this.noDelegationState = true; } else { this.delegationState = delegationState; } } return this; }
Example #13
Source File: TaskQueryImpl.java From lemon with Apache License 2.0 | 6 votes |
public TaskQuery taskDelegationState(DelegationState delegationState) { if (orActive) { if (delegationState == null) { currentOrQueryObject.noDelegationState = true; } else { currentOrQueryObject.delegationState = delegationState; } } else { if (delegationState == null) { this.noDelegationState = true; } else { this.delegationState = delegationState; } } return this; }
Example #14
Source File: TaskDelegateTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 学习任务委派的过程,任务分配给bill,然后bill把任务委派给henryyan,henryyan处理完成后任务回归到bill */ @Deployment(resources = "diagrams/chapter12/taskDelegate.bpmn") public void testTaskDelegate() throws Exception { Map<String, Object> variables = new HashMap<String, Object>(); String userId = "bill"; variables.put("userId", userId); runtimeService.startProcessInstanceByKey("taskDelegateProcess", variables); Task task = taskService.createTaskQuery().taskAssignee(userId).singleResult(); assertNotNull(task); assertNull(task.getOwner()); // 委派任务给其他人 String delegatedUserId = "henryyan"; taskService.delegateTask(task.getId(), delegatedUserId); // 查看数据状态 task = taskService.createTaskQuery().taskAssignee(delegatedUserId).taskDelegationState(DelegationState.PENDING).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), delegatedUserId); // 被委派人处理完成任务 taskService.resolveTask(task.getId()); // 任务回归到委派人 task = taskService.createTaskQuery().taskAssignee(userId).taskDelegationState(DelegationState.RESOLVED).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), userId); // 委派人完成任务 taskService.complete(task.getId()); long count = historyService.createHistoricProcessInstanceQuery().finished().count(); assertEquals(1, count); }
Example #15
Source File: TaskEntity.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") public void complete(Map variablesMap, boolean localScope) { if (getDelegationState() != null && getDelegationState().equals(DelegationState.PENDING)) { throw new ActivitiException("A delegated task cannot be completed, but should be resolved instead."); } fireEvent(TaskListener.EVENTNAME_COMPLETE); if (Authentication.getAuthenticatedUserId() != null && processInstanceId != null) { getProcessInstance().involveUser(Authentication.getAuthenticatedUserId(), IdentityLinkType.PARTICIPANT); } if(Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityWithVariablesEvent(ActivitiEventType.TASK_COMPLETED, this, variablesMap, localScope)); } Context .getCommandContext() .getTaskEntityManager() .deleteTask(this, TaskEntity.DELETE_REASON_COMPLETED, false); if (executionId!=null) { ExecutionEntity execution = getExecution(); execution.removeTask(this); execution.signal(null, null); } }
Example #16
Source File: TaskEntity.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void delegate(String userId) { setDelegationState(DelegationState.PENDING); if (getOwner() == null) { setOwner(getAssignee()); } setAssignee(userId, true, true); }
Example #17
Source File: TaskResponse.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected String getDelegationStateString(DelegationState state) { String result = null; if (state != null) { result = state.toString().toLowerCase(); } return result; }
Example #18
Source File: TaskBaseResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Populate the task based on the values that are present in the given {@link TaskRequest}. */ protected void populateTaskFromRequest(Task task, TaskRequest taskRequest) { if (taskRequest.isNameSet()) { task.setName(taskRequest.getName()); } if (taskRequest.isAssigneeSet()) { task.setAssignee(taskRequest.getAssignee()); } if (taskRequest.isDescriptionSet()) { task.setDescription(taskRequest.getDescription()); } if (taskRequest.isDuedateSet()) { task.setDueDate(taskRequest.getDueDate()); } if (taskRequest.isOwnerSet()) { task.setOwner(taskRequest.getOwner()); } if (taskRequest.isParentTaskIdSet()) { task.setParentTaskId(taskRequest.getParentTaskId()); } if (taskRequest.isPrioritySet()) { task.setPriority(taskRequest.getPriority()); } if (taskRequest.isCategorySet()) { task.setCategory(taskRequest.getCategory()); } if (taskRequest.isTenantIdSet()) { task.setTenantId(taskRequest.getTenantId()); } if (taskRequest.isFormKeySet()) { task.setFormKey(taskRequest.getFormKey()); } if (taskRequest.isDelegationStateSet()) { DelegationState delegationState = getDelegationState(taskRequest.getDelegationState()); task.setDelegationState(delegationState); } }
Example #19
Source File: TaskBaseResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected DelegationState getDelegationState(String delegationState) { DelegationState state = null; if (delegationState != null) { if (DelegationState.RESOLVED.name().toLowerCase().equals(delegationState)) { return DelegationState.RESOLVED; } else if (DelegationState.PENDING.name().toLowerCase().equals(delegationState)) { return DelegationState.PENDING; } else { throw new ActivitiIllegalArgumentException("Illegal value for delegationState: " + delegationState); } } return state; }
Example #20
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testQueryByDelegationState() { TaskQuery query = taskService.createTaskQuery().taskDelegationState(null); assertEquals(12, query.count()); assertEquals(12, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.PENDING); assertEquals(0, query.count()); assertEquals(0, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED); assertEquals(0, query.count()); assertEquals(0, query.list().size()); String taskId = taskService.createTaskQuery().taskAssignee("gonzo").singleResult().getId(); taskService.delegateTask(taskId, "kermit"); query = taskService.createTaskQuery().taskDelegationState(null); assertEquals(11, query.count()); assertEquals(11, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.PENDING); assertEquals(1, query.count()); assertEquals(1, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED); assertEquals(0, query.count()); assertEquals(0, query.list().size()); taskService.resolveTask(taskId); query = taskService.createTaskQuery().taskDelegationState(null); assertEquals(11, query.count()); assertEquals(11, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.PENDING); assertEquals(0, query.count()); assertEquals(0, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED); assertEquals(1, query.count()); assertEquals(1, query.list().size()); }
Example #21
Source File: ProcessConnectorImpl.java From lemon with Apache License 2.0 | 5 votes |
/** * 代理中的任务(代理人还未完成该任务). */ public Page findDelegatedTasks(String userId, String tenantId, Page page) { TaskService taskService = processEngine.getTaskService(); long count = taskService.createTaskQuery().taskTenantId(tenantId) .taskOwner(userId).taskDelegationState(DelegationState.PENDING) .count(); List<Task> tasks = taskService.createTaskQuery().taskTenantId(tenantId) .taskOwner(userId).taskDelegationState(DelegationState.PENDING) .listPage((int) page.getStart(), page.getPageSize()); page.setResult(tasks); page.setTotalCount(count); return page; }
Example #22
Source File: TaskDelegateTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 学习任务委派的过程,任务分配给bill,然后bill把任务委派给henryyan,henryyan处理完成后任务回归到bill */ @Deployment(resources = "diagrams/chapter12/taskDelegate.bpmn") public void testTaskDelegate() throws Exception { Map<String, Object> variables = new HashMap<String, Object>(); String userId = "bill"; variables.put("userId", userId); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("taskDelegateProcess", variables); Task task = taskService.createTaskQuery().taskAssignee(userId).singleResult(); assertNotNull(task); assertNull(task.getOwner()); // 委派任务给其他人 String delegatedUserId = "henryyan"; taskService.delegateTask(task.getId(), delegatedUserId); // 查看数据状态 task = taskService.createTaskQuery().taskAssignee(delegatedUserId).taskDelegationState(DelegationState.PENDING).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), delegatedUserId); // 被委派人处理完成任务 taskService.resolveTask(task.getId()); // 任务回归到委派人 task = taskService.createTaskQuery().taskAssignee(userId).taskDelegationState(DelegationState.RESOLVED).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), userId); // 委派人完成任务 taskService.complete(task.getId()); long count = historyService.createHistoricProcessInstanceQuery().finished().count(); assertEquals(1, count); }
Example #23
Source File: TaskDelegateTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 学习任务委派的过程,任务分配给bill,然后bill把任务委派给henryyan,henryyan处理完成后任务回归到bill */ @Deployment(resources = "diagrams/chapter12/taskDelegate.bpmn") public void testTaskDelegate() throws Exception { Map<String, Object> variables = new HashMap<String, Object>(); String userId = "bill"; variables.put("userId", userId); runtimeService.startProcessInstanceByKey("taskDelegateProcess", variables); Task task = taskService.createTaskQuery().taskAssignee(userId).singleResult(); assertNotNull(task); assertNull(task.getOwner()); // 委派任务给其他人 String delegatedUserId = "henryyan"; taskService.delegateTask(task.getId(), delegatedUserId); // 查看数据状态 task = taskService.createTaskQuery().taskAssignee(delegatedUserId).taskDelegationState(DelegationState.PENDING).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), delegatedUserId); // 被委派人处理完成任务 taskService.resolveTask(task.getId()); // 任务回归到委派人 task = taskService.createTaskQuery().taskAssignee(userId).taskDelegationState(DelegationState.RESOLVED).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), userId); // 委派人完成任务 taskService.complete(task.getId()); long count = historyService.createHistoricProcessInstanceQuery().finished().count(); assertEquals(1, count); }
Example #24
Source File: TaskDelegateTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 学习任务委派的过程,任务分配给bill,然后bill把任务委派给henryyan,henryyan处理完成后任务回归到bill */ @Deployment(resources = "diagrams/chapter12/taskDelegate.bpmn") public void testTaskDelegate() throws Exception { Map<String, Object> variables = new HashMap<String, Object>(); String userId = "bill"; variables.put("userId", userId); runtimeService.startProcessInstanceByKey("taskDelegateProcess", variables); Task task = taskService.createTaskQuery().taskAssignee(userId).singleResult(); assertNotNull(task); assertNull(task.getOwner()); // 委派任务给其他人 String delegatedUserId = "henryyan"; taskService.delegateTask(task.getId(), delegatedUserId); // 查看数据状态 task = taskService.createTaskQuery().taskAssignee(delegatedUserId).taskDelegationState(DelegationState.PENDING).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), delegatedUserId); // 被委派人处理完成任务 taskService.resolveTask(task.getId()); // 任务回归到委派人 task = taskService.createTaskQuery().taskAssignee(userId).taskDelegationState(DelegationState.RESOLVED).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), userId); // 委派人完成任务 taskService.complete(task.getId()); long count = historyService.createHistoricProcessInstanceQuery().finished().count(); assertEquals(1, count); }
Example #25
Source File: ResolveTaskCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected Void execute(CommandContext commandContext, TaskEntity task) { if (variables != null) { task.setVariables(variables); } if (transientVariables != null) { task.setTransientVariables(transientVariables); } task.setDelegationState(DelegationState.RESOLVED); commandContext.getTaskEntityManager().changeTaskAssignee(task, task.getOwner()); return null; }
Example #26
Source File: DelegateTaskCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected Object execute(CommandContext commandContext, TaskEntity task) { task.setDelegationState(DelegationState.PENDING); if (task.getOwner() == null) { task.setOwner(task.getAssignee()); } commandContext.getTaskEntityManager().changeTaskAssignee(task, userId); return null; }
Example #27
Source File: AbstractCompleteTaskCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void executeTaskComplete(CommandContext commandContext, TaskEntity taskEntity, Map<String, Object> variables, boolean localScope) { // Task complete logic if (taskEntity.getDelegationState() != null && taskEntity.getDelegationState().equals(DelegationState.PENDING)) { throw new ActivitiException("A delegated task cannot be completed, but should be resolved instead."); } commandContext.getProcessEngineConfiguration().getListenerNotificationHelper().executeTaskListeners(taskEntity, TaskListener.EVENTNAME_COMPLETE); if (Authentication.getAuthenticatedUserId() != null && taskEntity.getProcessInstanceId() != null) { ExecutionEntity processInstanceEntity = commandContext.getExecutionEntityManager().findById(taskEntity.getProcessInstanceId()); commandContext.getIdentityLinkEntityManager().involveUser(processInstanceEntity, Authentication.getAuthenticatedUserId(),IdentityLinkType.PARTICIPANT); } ActivitiEventDispatcher eventDispatcher = Context.getProcessEngineConfiguration().getEventDispatcher(); if (eventDispatcher.isEnabled()) { if (variables != null) { eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityWithVariablesEvent(ActivitiEventType.TASK_COMPLETED, taskEntity, variables, localScope)); } else { eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TASK_COMPLETED, taskEntity)); } } commandContext.getTaskEntityManager().deleteTask(taskEntity, null, false, false); // Continue process (if not a standalone task) if (taskEntity.getExecutionId() != null) { ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findById(taskEntity.getExecutionId()); Context.getAgenda().planTriggerExecutionOperation(executionEntity); } }
Example #28
Source File: TaskQueryTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testQueryByDelegationState() { TaskQuery query = taskService.createTaskQuery().taskDelegationState(null); assertEquals(12, query.count()); assertEquals(12, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.PENDING); assertEquals(0, query.count()); assertEquals(0, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED); assertEquals(0, query.count()); assertEquals(0, query.list().size()); String taskId= taskService.createTaskQuery().taskAssignee("gonzo").singleResult().getId(); taskService.delegateTask(taskId, "kermit"); query = taskService.createTaskQuery().taskDelegationState(null); assertEquals(11, query.count()); assertEquals(11, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.PENDING); assertEquals(1, query.count()); assertEquals(1, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED); assertEquals(0, query.count()); assertEquals(0, query.list().size()); taskService.resolveTask(taskId); query = taskService.createTaskQuery().taskDelegationState(null); assertEquals(11, query.count()); assertEquals(11, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.PENDING); assertEquals(0, query.count()); assertEquals(0, query.list().size()); query = taskService.createTaskQuery().taskDelegationState(DelegationState.RESOLVED); assertEquals(1, query.count()); assertEquals(1, query.list().size()); }
Example #29
Source File: Task.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public Task(org.activiti.engine.task.Task taskInstance) { this.id = taskInstance.getId(); this.processId = taskInstance.getProcessInstanceId(); this.processDefinitionId = taskInstance.getProcessDefinitionId(); this.activityDefinitionId = taskInstance.getTaskDefinitionKey(); this.name = taskInstance.getName(); this.description = taskInstance.getDescription(); this.dueAt = taskInstance.getDueDate(); this.startedAt = taskInstance.getCreateTime(); this.priority = taskInstance.getPriority(); this.owner = taskInstance.getOwner(); this.assignee = taskInstance.getAssignee(); if (taskInstance.getDelegationState() == DelegationState.PENDING) { this.state = TaskStateTransition.DELEGATED.name().toLowerCase(); } else if (taskInstance.getDelegationState() == DelegationState.RESOLVED) { this.state = TaskStateTransition.RESOLVED.name().toLowerCase(); } else if (taskInstance.getAssignee() != null) { this.state = TaskStateTransition.CLAIMED.name().toLowerCase(); } else { this.state = TaskStateTransition.UNCLAIMED.name().toLowerCase(); } }
Example #30
Source File: TaskDelegateTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * 学习任务委派的过程,任务分配给bill,然后bill把任务委派给henryyan,henryyan处理完成后任务回归到bill */ @Deployment(resources = "diagrams/chapter12/taskDelegate.bpmn") public void testTaskDelegate() throws Exception { Map<String, Object> variables = new HashMap<String, Object>(); String userId = "bill"; variables.put("userId", userId); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("taskDelegateProcess", variables); Task task = taskService.createTaskQuery().taskAssignee(userId).singleResult(); assertNotNull(task); assertNull(task.getOwner()); // 委派任务给其他人 String delegatedUserId = "henryyan"; taskService.delegateTask(task.getId(), delegatedUserId); // 查看数据状态 task = taskService.createTaskQuery().taskAssignee(delegatedUserId).taskDelegationState(DelegationState.PENDING).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), delegatedUserId); // 被委派人处理完成任务 taskService.resolveTask(task.getId()); // 任务回归到委派人 task = taskService.createTaskQuery().taskAssignee(userId).taskDelegationState(DelegationState.RESOLVED).singleResult(); assertEquals(task.getOwner(), userId); assertEquals(task.getAssignee(), userId); // 委派人完成任务 taskService.complete(task.getId()); long count = historyService.createHistoricProcessInstanceQuery().finished().count(); assertEquals(1, count); }