Search in sources :

Example 1 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity in project incubator-inlong by apache.

the class WorkflowQueryServiceImpl method getProcessDetail.

private ProcessDetailResponse getProcessDetail(Integer processId, WorkflowProcessEntity processEntity) {
    List<WorkflowTaskEntity> taskList = this.listApproveHistory(processId);
    List<TaskResponse> history = taskList.stream().map(WorkflowBeanUtils::fromTaskEntity).collect(Collectors.toList());
    WorkflowBriefDTO workflowDTO = this.getBriefFromProcessEntity(processEntity);
    ProcessDetailResponse processDetail = new ProcessDetailResponse();
    processDetail.setProcessInfo(WorkflowBeanUtils.fromProcessEntity(processEntity));
    processDetail.setTaskHistory(history);
    processDetail.setWorkflow(workflowDTO);
    return processDetail;
}
Also used : WorkflowBriefDTO(org.apache.inlong.manager.common.pojo.workflow.WorkflowBriefDTO) ProcessDetailResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessDetailResponse) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) TaskResponse(org.apache.inlong.manager.common.pojo.workflow.TaskResponse)

Example 2 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity in project incubator-inlong by apache.

the class UserTaskProcessor method saveTaskEntity.

private WorkflowTaskEntity saveTaskEntity(UserTask task, WorkflowProcessEntity processEntity, String approvers) {
    WorkflowTaskEntity taskEntity = new WorkflowTaskEntity();
    taskEntity.setType(UserTask.class.getSimpleName());
    taskEntity.setProcessId(processEntity.getId());
    taskEntity.setProcessName(processEntity.getName());
    taskEntity.setProcessDisplayName(processEntity.getDisplayName());
    taskEntity.setApplicant(processEntity.getApplicant());
    taskEntity.setName(task.getName());
    taskEntity.setDisplayName(task.getDisplayName());
    taskEntity.setApprovers(approvers);
    taskEntity.setStatus(TaskStatus.PENDING.name());
    taskEntity.setStartTime(new Date());
    taskEntityMapper.insert(taskEntity);
    Preconditions.checkNotNull(taskEntity.getId(), "task saved failed");
    return taskEntity;
}
Also used : UserTask(org.apache.inlong.manager.workflow.definition.UserTask) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) Date(java.util.Date)

Example 3 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity in project incubator-inlong by apache.

the class EndEventProcessor method complete.

@Override
public boolean complete(WorkflowContext context) {
    WorkflowProcessEntity processEntity = context.getProcessEntity();
    List<WorkflowTaskEntity> tasks = taskEntityMapper.selectByProcess(processEntity.getId(), TaskStatus.PENDING);
    // If there are unfinished tasks, the process cannot be ended
    if (!CollectionUtils.isEmpty(tasks)) {
        log.warn("have pending task, end event not execute");
        return true;
    }
    WorkflowContext.ActionContext actionContext = context.getActionContext();
    processEntity.setStatus(getProcessStatus(actionContext.getAction()).name());
    processEntity.setEndTime(new Date());
    processEntityMapper.update(processEntity);
    processEventNotifier.notify(mapToEvent(actionContext.getAction()), context);
    return true;
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) Date(java.util.Date)

Example 4 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity in project incubator-inlong by apache.

the class ServiceTaskProcessor method complete.

@Override
public boolean complete(WorkflowContext context) {
    WorkflowContext.ActionContext actionContext = context.getActionContext();
    Preconditions.checkTrue(SUPPORT_ACTIONS.contains(actionContext.getAction()), "serviceTask not support action: " + actionContext.getAction());
    WorkflowTaskEntity workflowTaskEntity = actionContext.getTaskEntity();
    Preconditions.checkTrue(ALLOW_COMPLETE_STATE.contains(TaskStatus.valueOf(workflowTaskEntity.getStatus())), "task status should allow complete");
    try {
        this.taskEventNotifier.notify(TaskEvent.COMPLETE, context);
        completeTaskEntity(actionContext, workflowTaskEntity, TaskStatus.COMPLETED);
        return true;
    } catch (Exception e) {
        completeTaskEntity(actionContext, workflowTaskEntity, TaskStatus.FAILED);
        this.taskEventNotifier.notify(TaskEvent.FAIL, context);
        this.processEventNotifier.notify(ProcessEvent.FAIL, context);
        return false;
    }
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)

Example 5 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity in project incubator-inlong by apache.

the class ServiceTaskProcessor method create.

@Override
public void create(ServiceTask serviceTask, WorkflowContext context) {
    WorkflowTaskEntity workflowTaskEntity = saveTaskEntity(serviceTask, context);
    context.getNewTaskList().add(workflowTaskEntity);
    serviceTask.initListeners(context);
    this.taskEventNotifier.notify(TaskEvent.CREATE, context);
}
Also used : WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)

Aggregations

WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)17 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)6 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)6 Date (java.util.Date)5 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)3 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)3 SneakyThrows (lombok.SneakyThrows)2 TaskStatus (org.apache.inlong.manager.common.enums.TaskStatus)2 WorkflowException (org.apache.inlong.manager.common.exceptions.WorkflowException)2 ProcessDetailResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessDetailResponse)2 TaskResponse (org.apache.inlong.manager.common.pojo.workflow.TaskResponse)2 UserTask (org.apache.inlong.manager.workflow.definition.UserTask)2 TaskExecuteLogQuery (org.apache.inlong.manager.common.pojo.workflow.TaskExecuteLogQuery)1 TaskQuery (org.apache.inlong.manager.common.pojo.workflow.TaskQuery)1 WorkflowApproverQuery (org.apache.inlong.manager.common.pojo.workflow.WorkflowApproverQuery)1 WorkflowBriefDTO (org.apache.inlong.manager.common.pojo.workflow.WorkflowBriefDTO)1 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)1 TaskForm (org.apache.inlong.manager.common.pojo.workflow.form.TaskForm)1 WorkflowApproverEntity (org.apache.inlong.manager.dao.entity.WorkflowApproverEntity)1 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)1