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

The following examples show how to use org.activiti.engine.impl.persistence.entity.TaskEntity#getExecution() . 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: DeleteTaskWithCommentCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public Object execute(CommandContext commandContext) {
    TaskEntity taskEntity = commandContext.getTaskEntityManager()
            .findTaskById(taskId);

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

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

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

        // execution.signal(null, null);
    }

    return null;
}
 
Example 2
Source File: DefaultHistoryManager.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskAssignment(TaskEntity task) {
  ExecutionEntity executionEntity = task.getExecution();
  if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
    if (executionEntity != null) {
      HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(executionEntity, false, true);
      if (historicActivityInstance != null) {
        historicActivityInstance.setAssignee(task.getAssignee());
      }
    }
  }
}
 
Example 3
Source File: DefaultHistoryManager.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskId(TaskEntity task) {
  if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
    ExecutionEntity execution = task.getExecution();
    if (execution != null) {
      HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(execution, false, true);
      if (historicActivityInstance != null) {
        historicActivityInstance.setTaskId(task.getId());
      }
    }
  }
}
 
Example 4
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskAssignment(TaskEntity task) {
    ExecutionEntity executionEntity = task.getExecution();
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
        if (executionEntity != null) {
            HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(executionEntity);
            if (historicActivityInstance != null) {
                historicActivityInstance.setAssignee(task.getAssignee());
            }
        }
    }
}
 
Example 5
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskId(TaskEntity task) {
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
        ExecutionEntity execution = task.getExecution();
        if (execution != null) {
            HistoricActivityInstanceEntity historicActivityInstance = findActivityInstance(execution);
            if (historicActivityInstance != null) {
                historicActivityInstance.setTaskId(task.getId());
            }
        }
    }
}
 
Example 6
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;
}