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); } }
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); } }