Search in sources :

Example 1 with TaskStatus

use of org.apache.inlong.manager.common.enums.TaskStatus in project incubator-inlong by apache.

the class WorkflowQueryServiceImpl method getBriefFromProcessEntity.

private WorkflowBriefDTO getBriefFromProcessEntity(WorkflowProcessEntity processEntity) {
    WorkflowProcess process = definitionRepository.get(processEntity.getName());
    if (process == null) {
        return null;
    }
    Map<String, TaskStatus> nameStatusMap = this.getTaskNameStatusMap(processEntity);
    ElementDTO elementDTO = new ElementDTO();
    StartEvent startEvent = process.getStartEvent();
    elementDTO.setName(startEvent.getName());
    elementDTO.setDisplayName(startEvent.getDisplayName());
    WorkflowContext context = WorkflowBeanUtils.buildContext(process, processEntity);
    addNext(startEvent, elementDTO, context, nameStatusMap);
    WorkflowBriefDTO briefDTO = new WorkflowBriefDTO();
    briefDTO.setName(process.getName());
    briefDTO.setDisplayName(process.getDisplayName());
    briefDTO.setType(process.getType());
    briefDTO.setStartEvent(elementDTO);
    return briefDTO;
}
Also used : WorkflowBriefDTO(org.apache.inlong.manager.common.pojo.workflow.WorkflowBriefDTO) ElementDTO(org.apache.inlong.manager.common.pojo.workflow.ElementDTO) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) TaskStatus(org.apache.inlong.manager.common.enums.TaskStatus) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 2 with TaskStatus

use of org.apache.inlong.manager.common.enums.TaskStatus in project incubator-inlong by apache.

the class UserTaskProcessor method completeTaskInstance.

private void completeTaskInstance(WorkflowContext.ActionContext actionContext) {
    WorkflowTaskEntity taskEntity = actionContext.getTaskEntity();
    TaskStatus taskStatus = toTaskState(actionContext.getAction());
    taskEntity.setStatus(taskStatus.name());
    taskEntity.setOperator(actionContext.getOperator());
    taskEntity.setRemark(actionContext.getRemark());
    UserTask userTask = (UserTask) actionContext.getTask();
    if (needForm(userTask, actionContext.getAction())) {
        Preconditions.checkNotNull(actionContext.getForm(), "form cannot be null");
        Preconditions.checkTrue(actionContext.getForm().getClass().isAssignableFrom(userTask.getFormClass()), "form type not match, should be class " + userTask.getFormClass());
        actionContext.getForm().validate();
        taskEntity.setFormData(JsonUtils.toJson(actionContext.getForm()));
    } else {
        Preconditions.checkNull(actionContext.getForm(), "no form required");
    }
    taskEntity.setEndTime(new Date());
    taskEntity.setExtParams(handlerExt(actionContext, taskEntity.getExtParams()));
    taskEntityMapper.update(taskEntity);
}
Also used : UserTask(org.apache.inlong.manager.workflow.definition.UserTask) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) TaskStatus(org.apache.inlong.manager.common.enums.TaskStatus) Date(java.util.Date)

Example 3 with TaskStatus

use of org.apache.inlong.manager.common.enums.TaskStatus in project incubator-inlong by apache.

the class WorkflowQueryServiceImpl method getTaskNameStatusMap.

private Map<String, TaskStatus> getTaskNameStatusMap(WorkflowProcessEntity processEntity) {
    TaskQuery request = TaskQuery.builder().processId(processEntity.getId()).build();
    List<WorkflowTaskEntity> allTasks = taskEntityMapper.selectByQuery(request).stream().sorted(Comparator.comparing(WorkflowTaskEntity::getId).thenComparing(Comparator.nullsLast(Comparator.comparing(WorkflowTaskEntity::getEndTime)))).collect(Collectors.toList());
    Map<String, TaskStatus> nameStatusMap = Maps.newHashMap();
    allTasks.forEach(task -> nameStatusMap.put(task.getName(), TaskStatus.valueOf(task.getStatus())));
    return nameStatusMap;
}
Also used : TaskQuery(org.apache.inlong.manager.common.pojo.workflow.TaskQuery) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) TaskStatus(org.apache.inlong.manager.common.enums.TaskStatus)

Aggregations

TaskStatus (org.apache.inlong.manager.common.enums.TaskStatus)3 WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)2 Date (java.util.Date)1 ElementDTO (org.apache.inlong.manager.common.pojo.workflow.ElementDTO)1 TaskQuery (org.apache.inlong.manager.common.pojo.workflow.TaskQuery)1 WorkflowBriefDTO (org.apache.inlong.manager.common.pojo.workflow.WorkflowBriefDTO)1 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)1 StartEvent (org.apache.inlong.manager.workflow.definition.StartEvent)1 UserTask (org.apache.inlong.manager.workflow.definition.UserTask)1 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)1