Search in sources :

Example 11 with WorkflowProcessEntity

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

the class AbstractTaskProcessor method skip.

@Override
public void skip(T task, WorkflowContext context) {
    WorkflowProcessEntity workflowProcessEntity = context.getProcessEntity();
    Date now = new Date();
    String operators = Joiner.on(WorkflowTaskEntity.APPROVERS_DELIMITER).join(ApproverAssign.DEFAULT_SKIP_APPROVER.assign(context));
    WorkflowTaskEntity taskEntity = new WorkflowTaskEntity();
    taskEntity.setType(task.getClass().getSimpleName());
    taskEntity.setProcessId(workflowProcessEntity.getId());
    taskEntity.setProcessName(workflowProcessEntity.getName());
    taskEntity.setProcessDisplayName(workflowProcessEntity.getDisplayName());
    taskEntity.setApplicant(workflowProcessEntity.getApplicant());
    taskEntity.setApprovers(operators);
    taskEntity.setOperator(operators);
    taskEntity.setName(task.getName());
    taskEntity.setDisplayName(task.getDisplayName());
    taskEntity.setStatus(TaskStatus.SKIPPED.name());
    taskEntity.setRemark("auto skipped");
    taskEntity.setStartTime(now);
    taskEntity.setEndTime(now);
    taskEntityMapper.insert(taskEntity);
    Preconditions.checkNotNull(taskEntity.getId(), "task saved failed");
}
Also used : WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) Date(java.util.Date)

Example 12 with WorkflowProcessEntity

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

the class ServiceTaskProcessor method saveTaskEntity.

private WorkflowTaskEntity saveTaskEntity(ServiceTask serviceTask, WorkflowContext context) {
    WorkflowProcessEntity workflowProcessEntity = context.getProcessEntity();
    List<String> approvers = ApproverAssign.DEFAULT_SYSTEM_APPROVER.assign(context);
    WorkflowTaskEntity taskEntity = new WorkflowTaskEntity();
    taskEntity.setType(ServiceTask.class.getSimpleName());
    taskEntity.setProcessId(workflowProcessEntity.getId());
    taskEntity.setProcessName(context.getProcess().getName());
    taskEntity.setProcessDisplayName(context.getProcess().getDisplayName());
    taskEntity.setName(serviceTask.getName());
    taskEntity.setDisplayName(serviceTask.getDisplayName());
    taskEntity.setApplicant(workflowProcessEntity.getApplicant());
    taskEntity.setApprovers(StringUtils.join(approvers, WorkflowTaskEntity.APPROVERS_DELIMITER));
    taskEntity.setStatus(TaskStatus.PENDING.name());
    taskEntity.setStartTime(new Date());
    taskEntityMapper.insert(taskEntity);
    Preconditions.checkNotNull(taskEntity.getId(), "task saved failed");
    return taskEntity;
}
Also used : ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) Date(java.util.Date)

Example 13 with WorkflowProcessEntity

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

the class StartEventProcessor method create.

@Override
public void create(StartEvent startEvent, WorkflowContext context) {
    String applicant = context.getApplicant();
    WorkflowProcess process = context.getProcess();
    ProcessForm form = context.getProcessForm();
    if (process.getFormClass() != null) {
        Preconditions.checkNotNull(form, "form cannot be null");
        Preconditions.checkTrue(form.getClass().isAssignableFrom(process.getFormClass()), "form type not match, should be class " + process.getFormClass());
        form.validate();
    } else {
        Preconditions.checkNull(form, "no form required");
    }
    WorkflowProcessEntity processEntity = saveProcessEntity(applicant, process, form);
    context.setProcessEntity(processEntity);
    context.setActionContext(new WorkflowContext.ActionContext().setAction(WorkflowAction.START));
}
Also used : ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 14 with WorkflowProcessEntity

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

the class LogableEventListener method buildEventLog.

protected WorkflowEventLogEntity buildEventLog(WorkflowContext context) {
    WorkflowProcessEntity workflowProcessEntity = context.getProcessEntity();
    Element currentElement = context.getCurrentElement();
    WorkflowEventLogEntity logEntity = new WorkflowEventLogEntity();
    logEntity.setProcessId(workflowProcessEntity.getId());
    logEntity.setProcessName(workflowProcessEntity.getName());
    logEntity.setProcessDisplayName(workflowProcessEntity.getDisplayName());
    logEntity.setInlongGroupId(context.getProcessForm().getInlongGroupId());
    logEntity.setElementName(currentElement.getName());
    logEntity.setElementDisplayName(currentElement.getDisplayName());
    logEntity.setEventType(event().getClass().getSimpleName());
    logEntity.setEvent(event().name());
    logEntity.setListener(eventListener.name());
    logEntity.setStatus(EventStatus.EXECUTING.getStatus());
    logEntity.setAsync(async() ? 1 : 0);
    logEntity.setIp(NetworkUtils.getLocalIp());
    logEntity.setStartTime(new Date());
    return logEntity;
}
Also used : Element(org.apache.inlong.manager.workflow.definition.Element) WorkflowEventLogEntity(org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) Date(java.util.Date)

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