Java Code Examples for org.activiti.engine.impl.persistence.entity.TaskEntity#getDelegationState()

The following examples show how to use org.activiti.engine.impl.persistence.entity.TaskEntity#getDelegationState() . 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: AbstractCompleteTaskCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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 2
Source File: CompleteTaskWithCommentCmd.java    From lemon with Apache License 2.0 4 votes vote down vote up
public Object execute(CommandContext commandContext) {
    TaskEntity taskEntity = commandContext.getTaskEntityManager()
            .findTaskById(taskId);

    if (variables != null) {
        taskEntity.setExecutionVariables(variables);
    }

    boolean localScope = false;

    if ((taskEntity.getDelegationState() != null)
            && taskEntity.getDelegationState().equals(
                    DelegationState.PENDING)) {
        throw new ActivitiException(
                "A delegated task cannot be completed, but should be resolved instead.");
    }

    taskEntity.fireEvent(TaskListener.EVENTNAME_COMPLETE);

    if ((Authentication.getAuthenticatedUserId() != null)
            && (taskEntity.getProcessInstanceId() != null)) {
        taskEntity.getProcessInstance().involveUser(
                Authentication.getAuthenticatedUserId(),
                IdentityLinkType.PARTICIPANT);
    }

    if (Context.getProcessEngineConfiguration().getEventDispatcher()
            .isEnabled()) {
        Context.getProcessEngineConfiguration()
                .getEventDispatcher()
                .dispatchEvent(
                        ActivitiEventBuilder
                                .createEntityWithVariablesEvent(
                                        ActivitiEventType.TASK_COMPLETED,
                                        taskEntity, variables, localScope));
    }

    Context.getCommandContext().getTaskEntityManager()
            .deleteTask(taskEntity, comment, false);

    if (taskEntity.getExecutionId() != null) {
        ExecutionEntity execution = taskEntity.getExecution();
        execution.removeTask(taskEntity);

        try {
            Context.setExecutionContext(execution);
            execution.signal(null, null);
        } finally {
            Context.removeExecutionContext();
        }
    }

    return null;
}