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;
}
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;
}
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());
}
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);
}
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());
}
Aggregations