Search in sources :

Example 16 with WorkflowProcess

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

the class NewConsumptionProcessDetailHandler method handle.

@Override
public ProcessDetailResponse handle(ProcessDetailResponse workflowResponse) {
    WorkflowProcess process = processDefinitionService.getByName(workflowResponse.getWorkflow().getName());
    NewConsumptionProcessForm processForm = WorkflowFormParserUtils.parseProcessForm(workflowResponse.getProcessInfo().getFormData().toString(), process);
    if (processForm == null) {
        return workflowResponse;
    }
    workflowResponse.getProcessInfo().setFormData(processForm);
    return workflowResponse;
}
Also used : NewConsumptionProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.NewConsumptionProcessForm) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 17 with WorkflowProcess

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

the class NewConsumptionWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Define process information
    WorkflowProcess process = new WorkflowProcess();
    process.setType("Data Consumption Resource Creation");
    process.setName(getProcessName().name());
    process.setDisplayName(getProcessName().getDisplayName());
    process.setFormClass(NewConsumptionProcessForm.class);
    process.setVersion(1);
    process.setProcessDetailHandler(newConsumptionProcessDetailHandler);
    // Start node
    StartEvent startEvent = new StartEvent();
    process.setStartEvent(startEvent);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    // Group approval tasks
    UserTask groupOwnerUserTask = new UserTask();
    groupOwnerUserTask.setName(UT_GROUP_OWNER_NAME);
    groupOwnerUserTask.setDisplayName("Group Approval");
    groupOwnerUserTask.setApproverAssign(this::bizOwnerUserTaskApprover);
    process.addTask(groupOwnerUserTask);
    // System administrator approval
    UserTask adminUserTask = new UserTask();
    adminUserTask.setName(UT_ADMINT_NAME);
    adminUserTask.setDisplayName("System Administrator");
    adminUserTask.setFormClass(ConsumptionApproveForm.class);
    adminUserTask.setApproverAssign(this::adminUserTaskApprover);
    adminUserTask.addListener(consumptionPassTaskListener);
    process.addTask(adminUserTask);
    // Set order relationship
    startEvent.addNext(groupOwnerUserTask);
    groupOwnerUserTask.addNext(adminUserTask);
    adminUserTask.addNext(endEvent);
    // Set up the listener
    process.addListener(consumptionCompleteProcessListener);
    process.addListener(consumptionRejectProcessListener);
    process.addListener(consumptionCancelProcessListener);
    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 18 with WorkflowProcess

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

the class WorkflowServiceImplTest method testStopProcess.

@Test
public void testStopProcess() {
    InlongGroupInfo groupInfo = initGroupForm(Constant.MIDDLEWARE_PULSAR);
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.SUSPENDED.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    UpdateGroupProcessForm form = new UpdateGroupProcessForm();
    form.setGroupInfo(groupInfo);
    form.setOperateType(OperateType.DELETE);
    taskListenerFactory.acceptPlugin(new MockPlugin());
    WorkflowContext context = workflowEngine.processService().start(ProcessName.DELETE_GROUP_PROCESS.name(), applicant, form);
    WorkflowResult result = WorkflowBeanUtils.result(context);
    ProcessResponse view = result.getProcessInfo();
    Assert.assertSame(view.getStatus(), ProcessStatus.COMPLETED);
    WorkflowProcess process = context.getProcess();
    WorkflowTask deleteSort = process.getTaskByName("deleteSort");
    Assert.assertTrue(deleteSort instanceof ServiceTask);
    List<TaskEventListener> listeners = Lists.newArrayList(deleteSort.getNameToListenerMap().values());
    Assert.assertEquals(1, listeners.size());
    Assert.assertTrue(listeners.get(0) instanceof MockDeleteSortListener);
    WorkflowTask deleteSourceTask = process.getTaskByName("deleteSource");
    Assert.assertTrue(deleteSourceTask instanceof ServiceTask);
    listeners = Lists.newArrayList(deleteSourceTask.getNameToListenerMap().values());
    Assert.assertEquals(2, listeners.size());
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) MockDeleteSortListener(org.apache.inlong.manager.service.mocks.MockDeleteSortListener) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 19 with WorkflowProcess

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

the class WorkflowServiceImplTest method testStartCreateTubeWorkflow.

@Test
public void testStartCreateTubeWorkflow() {
    initGroupForm(Constant.MIDDLEWARE_TUBE);
    mockTaskListenerFactory();
    WorkflowContext context = workflowEngine.processService().start(processName.name(), applicant, form);
    WorkflowResult result = WorkflowBeanUtils.result(context);
    ProcessResponse response = result.getProcessInfo();
    Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
    WorkflowProcess process = context.getProcess();
    WorkflowTask task = process.getTaskByName("initMQ");
    Assert.assertTrue(task instanceof ServiceTask);
    Assert.assertEquals(2, task.getNameToListenerMap().size());
    List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
    Assert.assertTrue(listeners.get(0) instanceof CreateTubeTopicTaskListener);
    Assert.assertTrue(listeners.get(1) instanceof CreateTubeGroupTaskListener);
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) CreateTubeTopicTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreateTubeTopicTaskListener) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) CreateTubeGroupTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreateTubeGroupTaskListener) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 20 with WorkflowProcess

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

the class CreateGroupWorkflowDefinitionTest method testDefineProcess.

@Test
public void testDefineProcess() {
    WorkflowProcess process = createGroupWorkflowDefinition.defineProcess();
    Assert.assertEquals("Group Resource Creation", process.getType());
    Assert.assertNotNull(process.getTaskByName("initSource"));
    Assert.assertNotNull(process.getTaskByName("initMQ"));
    Assert.assertNotNull(process.getTaskByName("initSort"));
    Assert.assertNotNull(process.getTaskByName("initSink"));
    Assert.assertEquals(4, process.getNameToTaskMap().size());
}
Also used : WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest) Test(org.junit.Test)

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