Search in sources :

Example 1 with TaskResponse

use of org.apache.inlong.manager.common.pojo.workflow.TaskResponse in project incubator-inlong by apache.

the class InlongGroupImpl method init.

@Override
public InlongGroupContext init() throws Exception {
    InlongGroupInfo groupInfo = this.groupContext.getGroupInfo();
    WorkflowResult initWorkflowResult = managerClient.initInlongGroup(groupInfo.genRequest());
    List<TaskResponse> taskViews = initWorkflowResult.getNewTasks();
    AssertUtil.notEmpty(taskViews, "Init business info failed");
    TaskResponse taskView = taskViews.get(0);
    final int taskId = taskView.getId();
    ProcessResponse processView = initWorkflowResult.getProcessInfo();
    AssertUtil.isTrue(ProcessStatus.PROCESSING == processView.getStatus(), String.format("Business info state : %s is not corrected , should be PROCESSING", processView.getStatus()));
    String formData = GsonUtil.toJson(processView.getFormData());
    Pair<InlongGroupApproveRequest, List<InlongStreamApproveRequest>> initMsg = InlongParser.parseGroupForm(formData);
    groupContext.setInitMsg(initMsg);
    WorkflowResult startWorkflowResult = managerClient.startInlongGroup(taskId, initMsg);
    processView = startWorkflowResult.getProcessInfo();
    AssertUtil.isTrue(ProcessStatus.COMPLETED == processView.getStatus(), String.format("Business info state : %s is not corrected , should be COMPLETED", processView.getStatus()));
    return generateSnapshot();
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) List(java.util.List) TaskResponse(org.apache.inlong.manager.common.pojo.workflow.TaskResponse) InlongGroupApproveRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)

Example 2 with TaskResponse

use of org.apache.inlong.manager.common.pojo.workflow.TaskResponse 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 3 with TaskResponse

use of org.apache.inlong.manager.common.pojo.workflow.TaskResponse in project incubator-inlong by apache.

the class WorkflowServiceImpl method addShowInListForEachTask.

private void addShowInListForEachTask(List<TaskResponse> taskList) {
    if (CollectionUtils.isEmpty(taskList)) {
        return;
    }
    PageHelper.clearPage();
    List<Integer> list = taskList.stream().map(TaskResponse::getProcessId).distinct().collect(Collectors.toList());
    ProcessQuery query = new ProcessQuery();
    query.setIdList(list);
    List<WorkflowProcessEntity> processEntities = queryService.listProcessEntity(query);
    Map<Integer, Map<String, Object>> processShowInListMap = Maps.newHashMap();
    processEntities.forEach(entity -> processShowInListMap.put(entity.getId(), getShowInList(entity)));
    taskList.forEach(task -> task.setShowInList(processShowInListMap.get(task.getProcessId())));
}
Also used : WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) TaskResponse(org.apache.inlong.manager.common.pojo.workflow.TaskResponse) Map(java.util.Map) ProcessQuery(org.apache.inlong.manager.common.pojo.workflow.ProcessQuery)

Example 4 with TaskResponse

use of org.apache.inlong.manager.common.pojo.workflow.TaskResponse in project incubator-inlong by apache.

the class WorkflowBeanUtils method result.

/**
 * Get the workflow result from the given workflow context
 */
public static WorkflowResult result(WorkflowContext context) {
    if (context == null) {
        return null;
    }
    WorkflowResult workflowResult = new WorkflowResult();
    workflowResult.setProcessInfo(WorkflowBeanUtils.fromProcessEntity(context.getProcessEntity()));
    List<TaskResponse> taskList = context.getNewTaskList().stream().map(WorkflowBeanUtils::fromTaskEntity).collect(Collectors.toList());
    workflowResult.setNewTasks(taskList);
    return workflowResult;
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) TaskResponse(org.apache.inlong.manager.common.pojo.workflow.TaskResponse)

Example 5 with TaskResponse

use of org.apache.inlong.manager.common.pojo.workflow.TaskResponse in project incubator-inlong by apache.

the class WorkflowQueryServiceImpl method detail.

@Override
public ProcessDetailResponse detail(Integer processId, Integer taskId, String operator) {
    WorkflowProcessEntity processEntity = this.getProcessEntity(processId);
    if (processEntity == null) {
        return null;
    }
    WorkflowTaskEntity taskEntity = null;
    if (taskId == null) {
        if (!operator.equals(processEntity.getApplicant())) {
            throw new WorkflowException("current user is not the applicant of the process");
        }
    } else {
        taskEntity = this.getTaskEntity(taskId);
        List<String> taskApprovers = Arrays.asList(taskEntity.getApprovers().split(","));
        if (!taskApprovers.contains(operator)) {
            WorkflowApproverQuery query = new WorkflowApproverQuery();
            query.setProcessName(processEntity.getName());
            List<WorkflowApproverEntity> approverList = approverMapper.selectByQuery(query);
            boolean match = approverList.stream().anyMatch(approverEntity -> {
                String[] approverArr = approverEntity.getApprovers().split(",");
                for (String approver : approverArr) {
                    if (Objects.equals(approver, operator)) {
                        return true;
                    }
                }
                return false;
            });
            if (!match) {
                throw new WorkflowException("current user is not the approver of the process");
            }
        }
    }
    WorkflowProcess process = definitionRepository.get(processEntity.getName());
    TaskResponse currentTask = null;
    if (taskEntity != null) {
        currentTask = WorkflowBeanUtils.fromTaskEntity(taskEntity);
        if (process != null && TaskStatus.PENDING.equals(currentTask.getStatus())) {
            WorkflowTask task = process.getTaskByName(currentTask.getName());
            currentTask.setFormData(this.getEmptyTaskForm(task));
        }
        if (!processId.equals(currentTask.getProcessId())) {
            throw new WorkflowException("task [" + taskId + "] not belongs to process [" + processId + "]");
        }
    }
    ProcessDetailResponse detailResponse = this.getProcessDetail(processId, processEntity);
    detailResponse.setCurrentTask(currentTask);
    if (process == null || process.getProcessDetailHandler() == null) {
        return detailResponse;
    }
    return process.getProcessDetailHandler().handle(detailResponse);
}
Also used : WorkflowException(org.apache.inlong.manager.common.exceptions.WorkflowException) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) WorkflowApproverEntity(org.apache.inlong.manager.dao.entity.WorkflowApproverEntity) WorkflowApproverQuery(org.apache.inlong.manager.common.pojo.workflow.WorkflowApproverQuery) ProcessDetailResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessDetailResponse) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) TaskResponse(org.apache.inlong.manager.common.pojo.workflow.TaskResponse)

Aggregations

TaskResponse (org.apache.inlong.manager.common.pojo.workflow.TaskResponse)5 ProcessDetailResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessDetailResponse)2 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)2 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)2 WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)2 List (java.util.List)1 Map (java.util.Map)1 WorkflowException (org.apache.inlong.manager.common.exceptions.WorkflowException)1 InlongGroupApproveRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)1 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)1 ProcessQuery (org.apache.inlong.manager.common.pojo.workflow.ProcessQuery)1 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)1 WorkflowApproverQuery (org.apache.inlong.manager.common.pojo.workflow.WorkflowApproverQuery)1 WorkflowBriefDTO (org.apache.inlong.manager.common.pojo.workflow.WorkflowBriefDTO)1 WorkflowApproverEntity (org.apache.inlong.manager.dao.entity.WorkflowApproverEntity)1 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)1 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)1