Search in sources :

Example 1 with WorkflowProcessEntity

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

the class StartEventProcessor method saveProcessEntity.

private WorkflowProcessEntity saveProcessEntity(String applicant, WorkflowProcess process, ProcessForm form) {
    WorkflowProcessEntity processEntity = new WorkflowProcessEntity();
    processEntity.setName(process.getName());
    processEntity.setDisplayName(process.getDisplayName());
    processEntity.setType(process.getType());
    processEntity.setTitle(form.getTitle());
    processEntity.setInlongGroupId(form.getInlongGroupId());
    processEntity.setApplicant(applicant);
    processEntity.setStatus(ProcessStatus.PROCESSING.name());
    processEntity.setFormData(JsonUtils.toJson(form));
    processEntity.setStartTime(new Date());
    processEntity.setHidden(process.getHidden());
    processEntityMapper.insert(processEntity);
    Preconditions.checkNotNull(processEntity.getId(), "process saved failed");
    return processEntity;
}
Also used : WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) Date(java.util.Date)

Example 2 with WorkflowProcessEntity

use of org.apache.inlong.manager.dao.entity.WorkflowProcessEntity 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 3 with WorkflowProcessEntity

use of org.apache.inlong.manager.dao.entity.WorkflowProcessEntity 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 WorkflowProcessEntity

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

the class WorkflowServiceImpl method listProcess.

@Override
public PageInfo<ProcessResponse> listProcess(ProcessQuery query) {
    PageHelper.startPage(query.getPageNum(), query.getPageSize());
    Page<WorkflowProcessEntity> result = (Page<WorkflowProcessEntity>) queryService.listProcessEntity(query);
    PageInfo<ProcessResponse> pageInfo = result.toPageInfo(entity -> {
        ProcessResponse response = WorkflowBeanUtils.fromProcessEntity(entity);
        if (query.getIncludeShowInList()) {
            response.setShowInList(getShowInList(entity));
        }
        return response;
    });
    pageInfo.setTotal(result.getTotal());
    if (query.getIncludeCurrentTask()) {
        TaskQuery taskQuery = TaskQuery.builder().type(UserTask.class.getSimpleName()).statusSet(Collections.singleton(TaskStatus.PENDING)).build();
        PageHelper.startPage(0, 100);
        pageInfo.getList().forEach(this.addCurrentTask(taskQuery));
    }
    return pageInfo;
}
Also used : TaskQuery(org.apache.inlong.manager.common.pojo.workflow.TaskQuery) UserTask(org.apache.inlong.manager.workflow.definition.UserTask) Page(com.github.pagehelper.Page) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)

Example 5 with WorkflowProcessEntity

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

the class WorkflowServiceImpl method listTaskExecuteLogs.

@Override
public PageInfo<WorkflowExecuteLog> listTaskExecuteLogs(TaskExecuteLogQuery query) {
    Preconditions.checkNotNull(query, "task execute log query params cannot be null");
    String groupId = query.getInlongGroupId();
    List<String> processNameList = query.getProcessNames();
    Preconditions.checkNotEmpty(groupId, "inlong group id cannot be null");
    Preconditions.checkNotEmpty(processNameList, "process name list cannot be null");
    ProcessQuery processRequest = new ProcessQuery();
    processRequest.setInlongGroupId(groupId);
    processRequest.setNameList(processNameList);
    processRequest.setHidden(1);
    // Paging query process instance, construct process execution log
    PageHelper.startPage(query.getPageNum(), query.getPageSize());
    Page<WorkflowProcessEntity> entityPage = (Page<WorkflowProcessEntity>) queryService.listProcessEntity(processRequest);
    PageInfo<WorkflowExecuteLog> pageInfo = entityPage.toPageInfo(inst -> WorkflowExecuteLog.builder().processId(inst.getId()).processDisplayName(inst.getDisplayName()).status(inst.getStatus()).startTime(inst.getStartTime()).endTime(inst.getEndTime()).build());
    // According to the process execution log, query the execution log of each task in the process
    for (WorkflowExecuteLog executeLog : pageInfo.getList()) {
        TaskQuery taskQuery = new TaskQuery();
        taskQuery.setProcessId(executeLog.getProcessId());
        taskQuery.setType(taskQuery.getType());
        List<TaskExecutorLog> executorLogs = queryService.listTaskEntity(taskQuery).stream().map(TaskExecutorLog::buildFromTaskInst).collect(Collectors.toList());
        // Set the execution log of the task's listener
        for (TaskExecutorLog taskExecutorLog : executorLogs) {
            EventLogQuery eventLogQuery = new EventLogQuery();
            eventLogQuery.setTaskId(taskExecutorLog.getTaskId());
            List<ListenerExecutorLog> logs = queryService.listEventLog(eventLogQuery).stream().map(ListenerExecutorLog::fromEventLog).collect(Collectors.toList());
            taskExecutorLog.setListenerExecutorLogs(logs);
        }
        executeLog.setTaskExecutorLogs(executorLogs);
    }
    LOGGER.info("success to page list task execute logs for " + query);
    pageInfo.setTotal(entityPage.getTotal());
    return pageInfo;
}
Also used : ListenerExecutorLog(org.apache.inlong.manager.service.workflow.WorkflowExecuteLog.ListenerExecutorLog) EventLogQuery(org.apache.inlong.manager.common.pojo.workflow.EventLogQuery) Page(com.github.pagehelper.Page) TaskExecutorLog(org.apache.inlong.manager.service.workflow.WorkflowExecuteLog.TaskExecutorLog) ProcessQuery(org.apache.inlong.manager.common.pojo.workflow.ProcessQuery) TaskQuery(org.apache.inlong.manager.common.pojo.workflow.TaskQuery) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)

Aggregations

WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)14 WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)7 Date (java.util.Date)6 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)4 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)4 Page (com.github.pagehelper.Page)2 Map (java.util.Map)2 SneakyThrows (lombok.SneakyThrows)2 WorkflowException (org.apache.inlong.manager.common.exceptions.WorkflowException)2 ProcessQuery (org.apache.inlong.manager.common.pojo.workflow.ProcessQuery)2 TaskQuery (org.apache.inlong.manager.common.pojo.workflow.TaskQuery)2 TaskResponse (org.apache.inlong.manager.common.pojo.workflow.TaskResponse)2 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)2 Element (org.apache.inlong.manager.workflow.definition.Element)2 UserTask (org.apache.inlong.manager.workflow.definition.UserTask)2 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Collections (java.util.Collections)1