Search in sources :

Example 1 with WorkflowProcess

use of org.apache.inlong.manager.workflow.definition.WorkflowProcess in project incubator-inlong by apache.

the class NewGroupWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Configuration process
    WorkflowProcess process = new WorkflowProcess();
    process.setType(getProcessName().getDisplayName());
    process.setName(getProcessName().name());
    process.setDisplayName(getProcessName().getDisplayName());
    process.setFormClass(NewGroupProcessForm.class);
    process.setVersion(1);
    // Set up the listener
    process.addListener(groupCancelProcessListener);
    process.addListener(approveRejectProcessListener);
    // Initiate the process of creating inlong group resources, and set the inlong group status
    // to [Configuration Successful]/[Configuration Failed] according to its completion
    process.addListener(startCreateGroupProcessListener);
    // Start node
    StartEvent startEvent = new StartEvent();
    process.setStartEvent(startEvent);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    // System administrator approval
    UserTask adminUserTask = new UserTask();
    adminUserTask.setName("ut_admin");
    adminUserTask.setDisplayName("System Administrator");
    adminUserTask.setFormClass(InlongGroupApproveForm.class);
    adminUserTask.setApproverAssign(context -> getTaskApprovers(adminUserTask.getName()));
    adminUserTask.addListener(groupPassTaskListener);
    process.addTask(adminUserTask);
    // Configuration order relationship
    startEvent.addNext(adminUserTask);
    // If you need another approval process, you can add it here
    adminUserTask.addNext(endEvent);
    return process;
}
Also used : StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) UserTask(org.apache.inlong.manager.workflow.definition.UserTask) EndEvent(org.apache.inlong.manager.workflow.definition.EndEvent) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 2 with WorkflowProcess

use of org.apache.inlong.manager.workflow.definition.WorkflowProcess in project incubator-inlong by apache.

the class SuspendGroupWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Configuration process
    WorkflowProcess process = new WorkflowProcess();
    process.addListener(updateGroupListener);
    process.addListener(updateGroupCompleteListener);
    process.setType("Group Resource Suspend");
    process.setName(getProcessName().name());
    process.setDisplayName(getProcessName().getDisplayName());
    process.setFormClass(UpdateGroupProcessForm.class);
    process.setVersion(1);
    process.setHidden(1);
    // Start node
    StartEvent startEvent = new StartEvent();
    process.setStartEvent(startEvent);
    // stop datasource
    ServiceTask stopDataSourceTask = new ServiceTask();
    stopDataSourceTask.setName("stopSource");
    stopDataSourceTask.setDisplayName("Group-StopSource");
    stopDataSourceTask.addServiceTaskType(ServiceTaskType.STOP_SOURCE);
    stopDataSourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(stopDataSourceTask);
    // stop sort
    ServiceTask stopSortTask = new ServiceTask();
    stopSortTask.setName("stopSort");
    stopSortTask.setDisplayName("Group-StopSort");
    stopSortTask.addServiceTaskType(ServiceTaskType.STOP_SORT);
    stopSortTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(stopSortTask);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    startEvent.addNext(stopDataSourceTask);
    stopDataSourceTask.addNext(stopSortTask);
    stopSortTask.addNext(endEvent);
    return process;
}
Also used : ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) EndEvent(org.apache.inlong.manager.workflow.definition.EndEvent) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 3 with WorkflowProcess

use of org.apache.inlong.manager.workflow.definition.WorkflowProcess in project incubator-inlong by apache.

the class CreateGroupWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Configuration process
    WorkflowProcess process = new WorkflowProcess();
    process.addListener(initGroupListener);
    process.addListener(groupCompleteProcessListener);
    process.addListener(groupFailedProcessListener);
    process.setType("Group Resource Creation");
    process.setName(getProcessName().name());
    process.setDisplayName(getProcessName().getDisplayName());
    process.setFormClass(GroupResourceProcessForm.class);
    process.setVersion(1);
    process.setHidden(1);
    // Start node
    StartEvent startEvent = new StartEvent();
    process.setStartEvent(startEvent);
    // init DataSource
    ServiceTask initDataSourceTask = new ServiceTask();
    initDataSourceTask.setName("initSource");
    initDataSourceTask.setDisplayName("Group-InitSource");
    initDataSourceTask.addServiceTaskType(ServiceTaskType.INIT_SOURCE);
    initDataSourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(initDataSourceTask);
    // init MQ resource
    ServiceTask initMQResourceTask = new ServiceTask();
    initMQResourceTask.setName("initMQ");
    initMQResourceTask.setDisplayName("Group-InitMQ");
    initMQResourceTask.addServiceTaskType(ServiceTaskType.INIT_MQ);
    initMQResourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(initMQResourceTask);
    // init Sort resource
    ServiceTask initSortResourceTask = new ServiceTask();
    initSortResourceTask.setName("initSort");
    initSortResourceTask.setDisplayName("Group-InitSort");
    initSortResourceTask.addServiceTaskType(ServiceTaskType.INIT_SORT);
    initSortResourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(initSortResourceTask);
    // init sink
    ServiceTask initSinkTask = new ServiceTask();
    initSinkTask.setName("initSink");
    initSinkTask.setDisplayName("Group-InitSink");
    initSinkTask.addServiceTaskType(ServiceTaskType.INIT_SINK);
    initSinkTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(initSinkTask);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    startEvent.addNext(initDataSourceTask);
    initDataSourceTask.addNext(initMQResourceTask);
    initMQResourceTask.addNext(initSortResourceTask);
    initSortResourceTask.addNext(initSinkTask);
    initSinkTask.addNext(endEvent);
    return process;
}
Also used : ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) EndEvent(org.apache.inlong.manager.workflow.definition.EndEvent) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 4 with WorkflowProcess

use of org.apache.inlong.manager.workflow.definition.WorkflowProcess in project incubator-inlong by apache.

the class DeleteGroupWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Configuration process
    WorkflowProcess process = new WorkflowProcess();
    process.addListener(updateGroupListener);
    process.addListener(updateGroupCompleteListener);
    process.setType("Group Resource Delete");
    process.setName(getProcessName().name());
    process.setDisplayName(getProcessName().getDisplayName());
    process.setFormClass(UpdateGroupProcessForm.class);
    process.setVersion(1);
    process.setHidden(1);
    // Start node
    StartEvent startEvent = new StartEvent();
    process.setStartEvent(startEvent);
    // delete datasource
    ServiceTask deleteDataSourceTask = new ServiceTask();
    deleteDataSourceTask.setName("deleteSource");
    deleteDataSourceTask.setDisplayName("Group-DeleteSource");
    deleteDataSourceTask.addServiceTaskType(ServiceTaskType.DELETE_SOURCE);
    deleteDataSourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(deleteDataSourceTask);
    // delete sort
    ServiceTask deleteSortTask = new ServiceTask();
    deleteSortTask.setName("deleteSort");
    deleteSortTask.setDisplayName("Group-DeleteSort");
    deleteSortTask.addServiceTaskType(ServiceTaskType.DELETE_SORT);
    deleteSortTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(deleteSortTask);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    startEvent.addNext(deleteDataSourceTask);
    deleteDataSourceTask.addNext(deleteSortTask);
    deleteSortTask.addNext(endEvent);
    return process;
}
Also used : ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) EndEvent(org.apache.inlong.manager.workflow.definition.EndEvent) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 5 with WorkflowProcess

use of org.apache.inlong.manager.workflow.definition.WorkflowProcess in project incubator-inlong by apache.

the class WorkflowApproverServiceImpl method list.

@Override
public List<WorkflowApprover> list(WorkflowApproverQuery query) {
    List<WorkflowApproverEntity> entityList = workflowApproverMapper.selectByQuery(query);
    List<WorkflowApprover> approverList = CommonBeanUtils.copyListProperties(entityList, WorkflowApprover::new);
    approverList.forEach(config -> {
        WorkflowProcess process = workflowEngine.processDefinitionService().getByName(config.getProcessName());
        if (process != null) {
            config.setProcessDisplayName(process.getDisplayName());
            config.setTaskDisplayName(Optional.ofNullable(process.getTaskByName(config.getTaskName())).map(WorkflowTask::getDisplayName).orElse(null));
        }
    });
    return approverList;
}
Also used : WorkflowApprover(org.apache.inlong.manager.common.pojo.workflow.WorkflowApprover) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowApproverEntity(org.apache.inlong.manager.dao.entity.WorkflowApproverEntity) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Aggregations

WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)29 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)15 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)14 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)13 Test (org.junit.Test)10 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)9 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)9 StartEvent (org.apache.inlong.manager.workflow.definition.StartEvent)8 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)7 EndEvent (org.apache.inlong.manager.workflow.definition.EndEvent)7 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)7 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)6 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)5 SneakyThrows (lombok.SneakyThrows)4 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)4 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)4 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)4 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)3 WorkflowApproverEntity (org.apache.inlong.manager.dao.entity.WorkflowApproverEntity)3