Commit a1541784 by huangfusuper

Merge remote-tracking branch 'origin/developer' into developer

parents e5e7415e d70b4ece
package com.byit.api; package com.byit.api;
import com.byit.job.dto.plugin.PluginPackage;
import com.byit.service.ApiFlowService; import com.byit.service.ApiFlowService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -16,7 +14,7 @@ import javax.annotation.Resource; ...@@ -16,7 +14,7 @@ import javax.annotation.Resource;
* @author: gml * @author: gml
* @create: 2019-12-30 14:20 * @create: 2019-12-30 14:20
*/ */
@Api(description = "工作流api") @Api(tags = "工作流api")
@RestController @RestController
@RequestMapping("api/flow") @RequestMapping("api/flow")
public class ApiFlowController { public class ApiFlowController {
...@@ -26,8 +24,8 @@ public class ApiFlowController { ...@@ -26,8 +24,8 @@ public class ApiFlowController {
@PostMapping("publish") @PostMapping("publish")
@ApiOperation("发布工作流,并开始调度") @ApiOperation("发布工作流,并开始调度")
public String publishFlow(@RequestBody PluginPackage pluginPackage) throws Exception { public String publishFlow(String param) throws Exception {
apiFlowService.publishFlow(pluginPackage); apiFlowService.publishFlow(param);
return "SUCCESS"; return "SUCCESS";
} }
......
...@@ -14,7 +14,7 @@ import javax.annotation.Resource; ...@@ -14,7 +14,7 @@ import javax.annotation.Resource;
* @author: gml * @author: gml
* @create: 2019-12-31 11:19 * @create: 2019-12-31 11:19
*/ */
@Api(description = "工作空间api") @Api(tags = "工作空间api")
@RestController @RestController
@RequestMapping("api/workspace") @RequestMapping("api/workspace")
public class ApiWorkspaceController { public class ApiWorkspaceController {
......
...@@ -18,7 +18,7 @@ import java.util.List; ...@@ -18,7 +18,7 @@ import java.util.List;
* @author: gml * @author: gml
* @create: 2019-12-23 15:25 * @create: 2019-12-23 15:25
*/ */
@Api(description = "工作流") @Api(tags = "工作流")
@RestController @RestController
@RequestMapping("flow") @RequestMapping("flow")
public class FlowController { public class FlowController {
......
package com.byit.service; package com.byit.service;
import com.byit.job.dto.plugin.PluginFlow; import com.byit.job.dto.plugin.PluginFlow;
import com.byit.job.dto.plugin.PluginPackage;
/** /**
* @description: 工作流的api请求业务处理接口 * @description: 工作流的api请求业务处理接口
...@@ -22,7 +21,7 @@ public interface ApiFlowService { ...@@ -22,7 +21,7 @@ public interface ApiFlowService {
void reStartSchedule(String runId); void reStartSchedule(String runId);
void publishFlow(PluginPackage pluginPackage) throws Exception; void publishFlow(String param) throws Exception;
/** /**
* 判断工作流石佛存在 * 判断工作流石佛存在
......
package com.byit.service.impl; package com.byit.service.impl;
import com.alibaba.fastjson.JSON;
import com.byit.enums.DagCheckEnum; import com.byit.enums.DagCheckEnum;
import com.byit.enums.FlowPropertyEnum; import com.byit.enums.FlowPropertyEnum;
import com.byit.enums.NodePropertyEnum; import com.byit.enums.NodePropertyEnum;
...@@ -62,7 +63,10 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -62,7 +63,10 @@ public class ApiFlowServiceImpl implements ApiFlowService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void publishFlow(PluginPackage pluginPackage) throws Exception { public void publishFlow(String param) throws Exception {
PluginPackage pluginPackage = JSON.parseObject(param, PluginPackage.class);
//校验参数 //校验参数
log.info("校验参数是否符合规范"); log.info("校验参数是否符合规范");
Workspace workspace = validate(pluginPackage); Workspace workspace = validate(pluginPackage);
...@@ -115,7 +119,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -115,7 +119,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
if (pluginFlow.isRePublish()){ if (pluginFlow.isRePublish()){
Flow oldFlow = flowMapper.getByWorkSpaceAndName(workspaceId, pluginFlow.getName()); Flow oldFlow = flowMapper.getByWorkSpaceAndName(workspaceId, pluginFlow.getName());
String version = oldFlow.getVersionName(); String version = oldFlow.getVersionName();
Integer versionTag = Integer.valueOf(version.split(".")[1]); Integer versionTag = Integer.valueOf(version.split("\\.")[1]);
flow.setFlowId(oldFlow.getFlowId()); flow.setFlowId(oldFlow.getFlowId());
flow.setVersionName("V." + (versionTag + 1)); flow.setVersionName("V." + (versionTag + 1));
flowMapper.updateByIdSelective(flow); flowMapper.updateByIdSelective(flow);
...@@ -256,6 +260,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -256,6 +260,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
*/ */
public void buildDepend(List<PluginBaseNode> nodeList, HashMap<String, Integer> nameIdRel){ public void buildDepend(List<PluginBaseNode> nodeList, HashMap<String, Integer> nameIdRel){
for (PluginBaseNode pluginNode : nodeList){ for (PluginBaseNode pluginNode : nodeList){
if (null != pluginNode.getDependNodeNameList() && pluginNode.getDependNodeNameList().size() > 0){
pluginNode.getDependNodeNameList().forEach(dependNodeName -> { pluginNode.getDependNodeNameList().forEach(dependNodeName -> {
Integer nodeId = nameIdRel.get(pluginNode.getName()); Integer nodeId = nameIdRel.get(pluginNode.getName());
Integer dependNodeId = nameIdRel.get(dependNodeName); Integer dependNodeId = nameIdRel.get(dependNodeName);
...@@ -265,6 +270,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -265,6 +270,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
}); });
} }
} }
}
/** /**
* 校验插件端请求参数是否合法 * 校验插件端请求参数是否合法
...@@ -295,7 +301,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -295,7 +301,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
flowDagCheck.initDag(flowNameSet, fromFlowSet, toFlowSet, lineMap); flowDagCheck.initDag(flowNameSet, fromFlowSet, toFlowSet, lineMap);
//校验是否存在环路 //校验是否存在环路
DagCheckEnum loopCheck = flowDagCheck.checkDag(); DagCheckEnum loopCheck = flowDagCheck.checkDag();
ValidationUtil.isTrueValidation(DagCheckEnum.PASS.getCode().equals(loopCheck.getCode()), loopCheck.getMsg()); ValidationUtil.isTrueValidation(!DagCheckEnum.PASS.getCode().equals(loopCheck.getCode()), loopCheck.getMsg());
return workspace; return workspace;
} }
...@@ -345,16 +351,16 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -345,16 +351,16 @@ public class ApiFlowServiceImpl implements ApiFlowService {
nodeDagCheck.initDag(nodeList); nodeDagCheck.initDag(nodeList);
//校验开始节点名称 //校验开始节点名称
DagCheckEnum checkStart = nodeDagCheck.checkStart(); DagCheckEnum checkStart = nodeDagCheck.checkStart();
ValidationUtil.isTrueValidation(DagCheckEnum.PASS.getCode().equals(checkStart.getCode()), checkStart.getCode() == 0 ? checkStart.getMsg() : checkStart.getMsg() + "start"); ValidationUtil.isTrueValidation(!DagCheckEnum.PASS.getCode().equals(checkStart.getCode()), checkStart.getCode() == 0 ? checkStart.getMsg() : checkStart.getMsg() + "start");
//校验结束节点名称 //校验结束节点名称
DagCheckEnum endCheck = nodeDagCheck.checkEnd(); DagCheckEnum endCheck = nodeDagCheck.checkEnd();
ValidationUtil.isTrueValidation(DagCheckEnum.PASS.getCode().equals(endCheck.getCode()), endCheck.getCode() == 0 ? endCheck.getMsg() : endCheck.getMsg() + "end"); ValidationUtil.isTrueValidation(!DagCheckEnum.PASS.getCode().equals(endCheck.getCode()), endCheck.getCode() == 0 ? endCheck.getMsg() : endCheck.getMsg() + "end");
//校验是否有游离节点 //校验是否有游离节点
DagCheckEnum freeCheck = nodeDagCheck.checkFreeNode(); DagCheckEnum freeCheck = nodeDagCheck.checkFreeNode();
ValidationUtil.isTrueValidation(DagCheckEnum.PASS.getCode().equals(freeCheck.getCode()), freeCheck.getMsg()); ValidationUtil.isTrueValidation(!DagCheckEnum.PASS.getCode().equals(freeCheck.getCode()), freeCheck.getMsg());
//校验是否存在环路 //校验是否存在环路
DagCheckEnum loopCheck = nodeDagCheck.checkDag(); DagCheckEnum loopCheck = nodeDagCheck.checkDag();
ValidationUtil.isTrueValidation(DagCheckEnum.PASS.getCode().equals(loopCheck.getCode()), loopCheck.getMsg()); ValidationUtil.isTrueValidation(!DagCheckEnum.PASS.getCode().equals(loopCheck.getCode()), loopCheck.getMsg());
} }
@Override @Override
...@@ -365,7 +371,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -365,7 +371,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
ValidationUtil.dataNotBank(pluginFlow.getConfig().getExecType(), "工作流的调度类型不允许为空!"); ValidationUtil.dataNotBank(pluginFlow.getConfig().getExecType(), "工作流的调度类型不允许为空!");
if (FlowPropertyEnum.SCHEDULE_MODE.getCode().equals(pluginFlow.getConfig().getExecType())){ if (FlowPropertyEnum.SCHEDULE_MODE.getCode().equals(pluginFlow.getConfig().getExecType())){
ValidationUtil.dataNotBank(pluginFlow.getConfig().getFlowCron(), "工作流cron表达式不允许为空!"); ValidationUtil.dataNotBank(pluginFlow.getConfig().getFlowCron(), "工作流cron表达式不允许为空!");
ValidationUtil.isTrueValidation(CronExpression.isValidExpression(pluginFlow.getConfig().getFlowCron()), "工作流cron表达式不符合规范!"); ValidationUtil.isTrueValidation(!CronExpression.isValidExpression(pluginFlow.getConfig().getFlowCron()), "工作流cron表达式不符合规范!");
} }
if (!FlowPropertyEnum.NO_ALARML.getCode().equals(pluginFlow.getConfig().getAlarmlAction())){ if (!FlowPropertyEnum.NO_ALARML.getCode().equals(pluginFlow.getConfig().getAlarmlAction())){
ValidationUtil.dataNotBank(pluginFlow.getConfig().getAlarmEmail(), "设置告警时机时告警邮箱不允许为空!"); ValidationUtil.dataNotBank(pluginFlow.getConfig().getAlarmEmail(), "设置告警时机时告警邮箱不允许为空!");
...@@ -374,9 +380,9 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -374,9 +380,9 @@ public class ApiFlowServiceImpl implements ApiFlowService {
//判断是否是重发 //判断是否是重发
//是重发 //是重发
if (pluginFlow.isRePublish()){ if (pluginFlow.isRePublish()){
ValidationUtil.dataNotNull(flow, "工作流【"+ flow.getFlowName() + "】不存在!"); ValidationUtil.dataNotNull(flow, "工作流【"+ pluginFlow.getName() + "】不存在!");
}else {//不是重发 }else {//不是重发
ValidationUtil.isTrueValidation(null != flow, "工作流【"+ flow.getFlowName() + "】已存在!"); ValidationUtil.isTrueValidation(null != flow, "工作流【"+ pluginFlow.getName() + "】已存在!");
} }
} }
...@@ -420,11 +426,12 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -420,11 +426,12 @@ public class ApiFlowServiceImpl implements ApiFlowService {
NodeVersion nodeVersion = new NodeVersion(); NodeVersion nodeVersion = new NodeVersion();
BeanUtils.copyProperties(node, nodeVersion); BeanUtils.copyProperties(node, nodeVersion);
nodeVersion.setAddTime(currentDate); nodeVersion.setAddTime(currentDate);
nodeVersion.setFlowVersionId(flowVersion.getFlowVersionId());
nodeVersion.setVersionMark(FlowPropertyEnum.IS_CURRENTVERSION.getCode()); nodeVersion.setVersionMark(FlowPropertyEnum.IS_CURRENTVERSION.getCode());
if (null != node.getIsVirtual() && NodePropertyEnum.IS_VIRTUAL.equals(node.getIsVirtual())){ if (null != node.getIsVirtual() && NodePropertyEnum.IS_VIRTUAL.getCode().equals(node.getIsVirtual())){
Flow innerFlow = flowMapper.getById(node.getMapFlowId()); Flow innerFlow = flowMapper.getById(node.getMapFlowId());
FlowVersion innerFlowVersion = saveFlowVersion(innerFlow); FlowVersion innerFlowVersion = saveFlowVersion(innerFlow);
node.setMapFlowId(innerFlowVersion.getFlowVersionId()); nodeVersion.setMapFlowId(innerFlowVersion.getFlowVersionId());
} }
nodeVersionMapper.insertSelective(nodeVersion); nodeVersionMapper.insertSelective(nodeVersion);
idVersionIdRel.put(node.getNodeId(), nodeVersion.getNodeVersionId()); idVersionIdRel.put(node.getNodeId(), nodeVersion.getNodeVersionId());
......
...@@ -26,7 +26,7 @@ public class ApiWorkspaceServiceImpl implements ApiWorkspaceService { ...@@ -26,7 +26,7 @@ public class ApiWorkspaceServiceImpl implements ApiWorkspaceService {
public void add(String workspaceName) { public void add(String workspaceName) {
ValidationUtil.dataNotBank(workspaceName, "工作空间名称为空!"); ValidationUtil.dataNotBank(workspaceName, "工作空间名称为空!");
Workspace workspace = workspaceMapper.getByName(workspaceName); Workspace workspace = workspaceMapper.getByName(workspaceName);
ValidationUtil.dataNotNull(workspace, "工作空间已存在!"); ValidationUtil.isTrueValidation(null != workspace, "工作空间已存在!");
workspace = new Workspace(); workspace = new Workspace();
workspace.setWorkspaceName(workspaceName); workspace.setWorkspaceName(workspaceName);
workspace.setAddTime(new Date()); workspace.setAddTime(new Date());
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
<insert id="insert"> <insert id="insert">
<!-- generated @mbg.generated date: 2019-12-31 --> <!-- generated @mbg.generated date: 2019-12-31 -->
insert into node_dependency (node_id, dependency_id) insert into node_dependency (node_id, dependency_id)
values (#{nodeId,jdbcType=INTEGER}, #{dependencyId,jdbcType=INTEGER}) values (#{nodeId,jdbcType=INTEGER}, #{dependNodeId,jdbcType=INTEGER})
</insert> </insert>
<insert id="insertSelective" parameterType="com.byit.model.NodeDependencyKey"> <insert id="insertSelective" parameterType="com.byit.model.NodeDependencyKey">
<!-- generated @mbg.generated date: 2019-12-31 --> <!-- generated @mbg.generated date: 2019-12-31 -->
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
where node_version_id = #{nodeVersionId,jdbcType=INTEGER} where node_version_id = #{nodeVersionId,jdbcType=INTEGER}
</delete> </delete>
<insert id="insertSelective" parameterType="com.byit.model.NodeVersion"> <insert id="insertSelective" useGeneratedKeys="true" keyProperty="nodeVersionId" parameterType="com.byit.model.NodeVersion">
<!-- generated @mbg.generated date: 2019-12-31 --> <!-- generated @mbg.generated date: 2019-12-31 -->
insert into node_version insert into node_version
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
......
...@@ -2,7 +2,6 @@ package com.byit.job.dto.plugin; ...@@ -2,7 +2,6 @@ package com.byit.job.dto.plugin;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
...@@ -12,7 +11,7 @@ import java.util.List; ...@@ -12,7 +11,7 @@ import java.util.List;
*/ */
@Data @Data
public class PluginBaseNode implements Serializable { public class PluginBaseNode {
/** /**
* 名称 * 名称
*/ */
...@@ -37,7 +36,4 @@ public class PluginBaseNode implements Serializable { ...@@ -37,7 +36,4 @@ public class PluginBaseNode implements Serializable {
* 依赖的任务节点名称集合,只能是节点的名称,如果不是内嵌工作流不允许设置依赖 * 依赖的任务节点名称集合,只能是节点的名称,如果不是内嵌工作流不允许设置依赖
*/ */
private List<String> dependNodeNameList; private List<String> dependNodeNameList;
private static final long serialVersionUID = 1L;
} }
...@@ -2,6 +2,7 @@ package com.byit.job.dto.plugin; ...@@ -2,6 +2,7 @@ package com.byit.job.dto.plugin;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
...@@ -10,7 +11,7 @@ import java.util.List; ...@@ -10,7 +11,7 @@ import java.util.List;
* @create: 2019-12-30 10:44 * @create: 2019-12-30 10:44
*/ */
@Data @Data
public class PluginFlow extends PluginBaseNode { public class PluginFlow extends PluginBaseNode implements Serializable {
/** /**
* 责任人 * 责任人
...@@ -32,5 +33,5 @@ public class PluginFlow extends PluginBaseNode { ...@@ -32,5 +33,5 @@ public class PluginFlow extends PluginBaseNode {
*/ */
private PluginFlowConfig config; private PluginFlowConfig config;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 3L;
} }
...@@ -2,13 +2,15 @@ package com.byit.job.dto.plugin; ...@@ -2,13 +2,15 @@ package com.byit.job.dto.plugin;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
/** /**
* @description: 插件端的任务节点 * @description: 插件端的任务节点
* @author: gml * @author: gml
* @create: 2019-12-30 10:45 * @create: 2019-12-30 10:45
*/ */
@Data @Data
public class PluginNode extends PluginBaseNode { public class PluginNode extends PluginBaseNode implements Serializable {
/** /**
* 当前任务的类型 JAVA PYTHON SHELL SQL SCRIPT * 当前任务的类型 JAVA PYTHON SHELL SQL SCRIPT
...@@ -49,5 +51,5 @@ public class PluginNode extends PluginBaseNode { ...@@ -49,5 +51,5 @@ public class PluginNode extends PluginBaseNode {
*/ */
private PluginNodeConfig config; private PluginNodeConfig config;
private static final long serialVersionUID = 2L;
} }
...@@ -2,13 +2,15 @@ package com.byit.job.dto.plugin; ...@@ -2,13 +2,15 @@ package com.byit.job.dto.plugin;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
/** /**
* @description: 插件段的发布包 * @description: 插件段的发布包
* @author: gml * @author: gml
* @create: 2020-01-02 14:38 * @create: 2020-01-02 14:38
*/ */
@Data @Data
public class PluginPackage { public class PluginPackage implements Serializable {
/** /**
* 工作空间名称 * 工作空间名称
...@@ -20,4 +22,5 @@ public class PluginPackage { ...@@ -20,4 +22,5 @@ public class PluginPackage {
*/ */
private PluginFlow flow; private PluginFlow flow;
private static final long serialVersionUID = 11L;
} }
...@@ -2,11 +2,11 @@ package com.byit.utils; ...@@ -2,11 +2,11 @@ package com.byit.utils;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.byit.job.dto.PluginBeanJobInfo;
import com.byit.job.dto.plugin.PluginPackage; import com.byit.job.dto.plugin.PluginPackage;
import com.byit.job.enums.plugin.PluginEnum; import com.byit.job.enums.plugin.PluginEnum;
import com.byit.job.exceptions.plugin.PluginException; import com.byit.job.exceptions.plugin.PluginException;
import com.byit.job.handler.interfaces.IJobHandler; import com.byit.job.handler.interfaces.IJobHandler;
import com.byit.job.dto.PluginBeanJobInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -15,6 +15,8 @@ import java.net.URLDecoder; ...@@ -15,6 +15,8 @@ import java.net.URLDecoder;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import static com.alibaba.fastjson.serializer.SerializerFeature.WriteClassName;
/** /**
* @program: byit-myth-job->JobFactory * @program: byit-myth-job->JobFactory
* @description: 创建任务的工具类 * @description: 创建任务的工具类
...@@ -69,7 +71,8 @@ public class JobUtils { ...@@ -69,7 +71,8 @@ public class JobUtils {
//请求的路径 //请求的路径
String requestUrl = REQUEST_PREFIX + "127.0.0.1" + ":" + "8080" + REQUEST_FLOW_PUBLISH; String requestUrl = REQUEST_PREFIX + "127.0.0.1" + ":" + "8080" + REQUEST_FLOW_PUBLISH;
//发送请求 添加任务 //发送请求 添加任务
String addRequestResult = HttpUtil.post(requestUrl, "pluginPackageParam=" + JSON.toJSONString(pluginPackage)); String addRequestResult = HttpUtil.post(requestUrl, "param=" + JSON.toJSONString(pluginPackage, WriteClassName));
// String addRequestResult = HttpUtil.post(requestUrl, JSON.toJSONString(pluginPackage, WriteClassName));
log.info("--------------------添加任务完成,添加结果为:{}------------------------",addRequestResult); log.info("--------------------添加任务完成,添加结果为:{}------------------------",addRequestResult);
return addRequestResult; return addRequestResult;
} }
......
...@@ -29,7 +29,7 @@ public class Test { ...@@ -29,7 +29,7 @@ public class Test {
PluginFlow flow = new PluginFlow(); PluginFlow flow = new PluginFlow();
flow.setName(name); flow.setName(name);
flow.setRePublish(false); flow.setRePublish(true);
flow.setPrincipal("admin"); flow.setPrincipal("admin");
PluginFlowConfig flowConfig = new PluginFlowConfig(); PluginFlowConfig flowConfig = new PluginFlowConfig();
...@@ -42,6 +42,40 @@ public class Test { ...@@ -42,6 +42,40 @@ public class Test {
PluginNode start = getNode("start", "echo start", "echo start", null); PluginNode start = getNode("start", "echo start", "echo start", null);
PluginNode center = getNode("center", "echo center", "echo center", "start"); PluginNode center = getNode("center", "echo center", "echo center", "start");
PluginFlow innerFlow = getInnerFlow("inner", "start");
PluginNode end = getNode("end", "echo end", "echo end", "center,inner");
List<PluginBaseNode> nodeList = new ArrayList<>();
nodeList.add(start);
nodeList.add(center);
nodeList.add(end);
nodeList.add(innerFlow);
flow.setConfig(flowConfig);
flow.setNodeList(nodeList);
return flow;
}
public static PluginFlow getInnerFlow(String name, String dependNames){
PluginFlow flow = new PluginFlow();
flow.setName(name);
flow.setRePublish(true);
flow.setPrincipal("admin");
flow.setType("flow");
PluginFlowConfig flowConfig = new PluginFlowConfig();
flowConfig.setAlarmlAction("1");
flowConfig.setExecType("1");
flowConfig.setFlowCron("0 0 2 * * ? *");
flowConfig.setPriority("1");
flowConfig.setScheduleFollow("1");
flowConfig.setAlarmEmail("qwe@qq.com");
PluginNode start = getNode("start", "echo start", "echo start", null);
PluginNode center = getNode("center", "echo center", "echo center", "start");
PluginNode end = getNode("end", "echo end", "echo end", "center"); PluginNode end = getNode("end", "echo end", "echo end", "center");
List<PluginBaseNode> nodeList = new ArrayList<>(); List<PluginBaseNode> nodeList = new ArrayList<>();
...@@ -52,6 +86,9 @@ public class Test { ...@@ -52,6 +86,9 @@ public class Test {
flow.setConfig(flowConfig); flow.setConfig(flowConfig);
flow.setNodeList(nodeList); flow.setNodeList(nodeList);
if (StringUtils.isNotEmpty(dependNames)) {
flow.setDependNodeNameList(Arrays.asList(dependNames));
}
return flow; return flow;
} }
...@@ -69,7 +106,7 @@ public class Test { ...@@ -69,7 +106,7 @@ public class Test {
nodeConfig.setPriority("1"); nodeConfig.setPriority("1");
node.setConfig(nodeConfig); node.setConfig(nodeConfig);
if (StringUtils.isNotEmpty(dependNames)) { if (StringUtils.isNotEmpty(dependNames)) {
node.setDependNodeNameList(Arrays.asList(dependNames)); node.setDependNodeNameList(Arrays.asList(dependNames.split(",")));
} }
return node; return node;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment