From af8f511fd81d8aefe129faa9abeceb99eb452661 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Tue, 30 May 2023 11:50:19 +0800 Subject: [PATCH 01/22] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20v1.1.0-SNAPS?= =?UTF-8?q?HOT=20=20=20=20=20=20-=20g6=E4=B8=8Eplantuml=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=9B=BE=E4=BC=98=E5=8C=96=E5=8C=BF=E5=90=8D=E5=AD=90=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qinluo <1558642210@qq.com> --- pom.xml | 4 ++-- smart-flow-admin/pom.xml | 2 +- .../flow/admin/g6/G6ComponentVisitor.java | 18 +++++++++++++++--- smart-flow-core/pom.xml | 2 +- smart-flow-helper/pom.xml | 2 +- .../flow/helper/view/PlantumlComponent.java | 11 +++++++++-- smart-flow-manager/pom.xml | 2 +- smart-flow-script/pom.xml | 2 +- .../smart-flow-script-groovy/pom.xml | 2 +- .../smart-flow-script-ognl/pom.xml | 2 +- .../smart-flow-script-qlexpress/pom.xml | 2 +- smart-flow-spring-extension/pom.xml | 2 +- smart-flow-springboot-starter/pom.xml | 2 +- 13 files changed, 36 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index fad2b38..a3693d0 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.smartboot.flow smart-flow-parent - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 pom smart-flow @@ -22,7 +22,7 @@ - 1.0.9 + 1.1.0-SNAPSHOT https://gitee.com/smartboot/smart-flow diff --git a/smart-flow-admin/pom.xml b/smart-flow-admin/pom.xml index 36a4042..34b146c 100644 --- a/smart-flow-admin/pom.xml +++ b/smart-flow-admin/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 diff --git a/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ComponentVisitor.java b/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ComponentVisitor.java index bda5b6d..a695b78 100644 --- a/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ComponentVisitor.java +++ b/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ComponentVisitor.java @@ -256,9 +256,18 @@ public class G6ComponentVisitor extends ComponentVisitor { assembler.getCombos().add(combo); assembler.comboStack().push(name); - + boolean comboAdded = true; if (pipeline != null) { - combo.setLabel(AuxiliaryUtils.isAnonymous(pipeline.getName()) ? "匿名子流程" : "子流程:" + pipeline.getName()); + + // 匿名子流程 combo不体现在图中 + if (AuxiliaryUtils.isAnonymous(pipeline.getName())) { + assembler.getCombos().remove(combo); + assembler.comboStack().pop(); + comboAdded = false; + } else { + combo.setLabel("子流程:" + pipeline.getName()); + } + pipeline.analyze(assembler); if (this.attributes.stream().anyMatch(p -> p.getAttribute() == Attributes.REFERENCED_PIPELINE) && pipeline.getNode(assembler) == null) { @@ -279,7 +288,10 @@ public class G6ComponentVisitor extends ComponentVisitor { components.get(0).analyze(assembler); } - assembler.comboStack().pop(); + if (comboAdded) { + assembler.comboStack().pop(); + } + assembler.setCy(assembler.getCy() + 0.3); } diff --git a/smart-flow-core/pom.xml b/smart-flow-core/pom.xml index 363a821..87bccea 100644 --- a/smart-flow-core/pom.xml +++ b/smart-flow-core/pom.xml @@ -5,7 +5,7 @@ org.smartboot.flow smart-flow-parent - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 diff --git a/smart-flow-helper/pom.xml b/smart-flow-helper/pom.xml index da0898b..4633131 100644 --- a/smart-flow-helper/pom.xml +++ b/smart-flow-helper/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 diff --git a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlComponent.java b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlComponent.java index 5d3abb8..df291f8 100644 --- a/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlComponent.java +++ b/smart-flow-helper/src/main/java/org/smartboot/flow/helper/view/PlantumlComponent.java @@ -133,9 +133,16 @@ public class PlantumlComponent extends ComponentVisitor { return; } - content.append("partition 子流程:").append(pipeline.getName()).append("{ \n"); + if (!AuxiliaryUtils.isAnonymous(pipeline.getName())) { + content.append("partition 子流程:").append(pipeline.getName()).append("{ \n"); + } + pipeline.generate(content); - content.append(" } \n"); + + if (!AuxiliaryUtils.isAnonymous(pipeline.getName())) { + content.append(" } \n"); + } + } else if (type == ComponentType.ADAPTER) { if (isAsync()) { content.append("-[dashed]->异步;\n"); diff --git a/smart-flow-manager/pom.xml b/smart-flow-manager/pom.xml index b76ede8..60064c7 100644 --- a/smart-flow-manager/pom.xml +++ b/smart-flow-manager/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 diff --git a/smart-flow-script/pom.xml b/smart-flow-script/pom.xml index b448dbd..ef5f1d3 100644 --- a/smart-flow-script/pom.xml +++ b/smart-flow-script/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 pom diff --git a/smart-flow-script/smart-flow-script-groovy/pom.xml b/smart-flow-script/smart-flow-script-groovy/pom.xml index 3552090..5a0772e 100644 --- a/smart-flow-script/smart-flow-script-groovy/pom.xml +++ b/smart-flow-script/smart-flow-script-groovy/pom.xml @@ -5,7 +5,7 @@ smart-flow-script org.smartboot.flow - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 diff --git a/smart-flow-script/smart-flow-script-ognl/pom.xml b/smart-flow-script/smart-flow-script-ognl/pom.xml index 0d038d0..25ba34a 100644 --- a/smart-flow-script/smart-flow-script-ognl/pom.xml +++ b/smart-flow-script/smart-flow-script-ognl/pom.xml @@ -5,7 +5,7 @@ smart-flow-script org.smartboot.flow - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 diff --git a/smart-flow-script/smart-flow-script-qlexpress/pom.xml b/smart-flow-script/smart-flow-script-qlexpress/pom.xml index b6ff520..103548b 100644 --- a/smart-flow-script/smart-flow-script-qlexpress/pom.xml +++ b/smart-flow-script/smart-flow-script-qlexpress/pom.xml @@ -5,7 +5,7 @@ smart-flow-script org.smartboot.flow - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 diff --git a/smart-flow-spring-extension/pom.xml b/smart-flow-spring-extension/pom.xml index c4cdc6c..4c7fbda 100644 --- a/smart-flow-spring-extension/pom.xml +++ b/smart-flow-spring-extension/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 diff --git a/smart-flow-springboot-starter/pom.xml b/smart-flow-springboot-starter/pom.xml index 2a57385..e226af5 100644 --- a/smart-flow-springboot-starter/pom.xml +++ b/smart-flow-springboot-starter/pom.xml @@ -5,7 +5,7 @@ smart-flow-parent org.smartboot.flow - 1.0.9 + 1.1.0-SNAPSHOT 4.0.0 -- Gitee From 12c2c19d6666f4af4f9088f8a4036b68706088ab Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Wed, 31 May 2023 21:15:01 +0800 Subject: [PATCH 02/22] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E5=8F=8D?= =?UTF-8?q?=E8=A7=A3=E6=9E=90g6=E5=9B=BE=E5=BD=A2=E7=94=9F=E6=88=90xml?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flow/admin/g6/G6ResultSerializer.java | 163 +++++++++++------- 1 file changed, 96 insertions(+), 67 deletions(-) diff --git a/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ResultSerializer.java b/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ResultSerializer.java index a3f0d84..41cb1e5 100644 --- a/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ResultSerializer.java +++ b/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ResultSerializer.java @@ -61,22 +61,22 @@ public class G6ResultSerializer { // start collect script. [BASIC, IF, CHOOSE] ScriptCollector.start(); - processNode(ctx, content, start); + processNode(ctx, content, start, 2); - content.append("\t"); + content.append("\t\n"); Map> scripts = ScriptCollector.end(); if (scripts != null && scripts.size() > 0) { scripts.forEach((k, v) -> content.append("\n\t")); + .append("\">").append(" ").append("\n")); } content.append("\n").append(END).append("\n"); return content.toString(); } - private void processNode(AnalyzerContext ctx, StringBuilder content, Node current) { + private void processNode(AnalyzerContext ctx, StringBuilder content, Node current, int numOfTab) { if (current == null) { return; } @@ -86,13 +86,17 @@ public class G6ResultSerializer { return; } - tryStartProcessCombo(ctx, content, current.getComboId()); + int nested = tryStartProcessCombo(ctx, content, current.getComboId(), numOfTab); + if (nested > 0) { + numOfTab += nested; + } ComponentInfo componentInfo = current.getComponentInfo(); ComponentType type = ComponentType.valueOf(componentInfo.getType()); if (type == ComponentType.BASIC) { - content.append("\t edges = ctx.sourceEdgeMap.get(current.getId()); AssertUtil.notNull(edges, "edges must not be null"); - - content.append("\t { + // check edges label must be true, and another is false or null. + for (Edge p : edges) { if (Objects.equals(p.getLabel(), "true")) { - content.append("\t\n"); - processNode(ctx, content, ctx.nodeMap.get(p.getTarget())); - content.append("\t\n"); + AuxiliaryUtils.appendTab(content, numOfTab + 1); + content.append("\n"); + processNode(ctx, content, ctx.nodeMap.get(p.getTarget()), numOfTab + 2); + AuxiliaryUtils.appendTab(content, numOfTab + 1); + content.append("\n"); } else if (Objects.equals(p.getLabel(), "false")) { - content.append("\t\n"); - processNode(ctx, content, ctx.nodeMap.get(p.getTarget())); - content.append("\t\n"); + AuxiliaryUtils.appendTab(content, numOfTab + 1); + content.append("\n"); + processNode(ctx, content, ctx.nodeMap.get(p.getTarget()), numOfTab + 2); + AuxiliaryUtils.appendTab(content, numOfTab + 1); + content.append("\n"); } - }); + } if (AuxiliaryUtils.isNotBlank(componentInfo.getType()) && AuxiliaryUtils.isNotBlank(componentInfo.getScriptName()) && AuxiliaryUtils.isNotBlank(componentInfo.getScript())) { ScriptCollector.collect(componentInfo.getScriptName(), componentInfo.getScript(), componentInfo.getScriptType()); } - - content.append("\n\t\n"); - tryEndProcessCombo(ctx, content, current); + content.append("\n"); + AuxiliaryUtils.appendTab(content, numOfTab); + content.append("\n"); + tryEndProcessCombo(ctx, content, current, numOfTab); if (endedNode != null) { ctx.endedNodes.pop(); - processNode(ctx, content, endedNode); + processNode(ctx, content, endedNode, numOfTab); } } else if (type == ComponentType.CHOOSE) { @@ -189,8 +197,9 @@ public class G6ResultSerializer { List edges = ctx.sourceEdgeMap.get(current.getId()); AssertUtil.notNull(edges, "edges must not be null"); AssertUtil.notBlank(AuxiliaryUtils.or(componentInfo.getDescribe(), componentInfo.getScriptName()), "CHOOSE组件执行类不能为空"); - - content.append("\t\n"); - // check edges label must has value, and one is default or null. - edges.forEach(p -> { + // check edges label must have value, and one is default or null. + for (Edge p : edges) { if (Objects.equals(p.getLabel(), "default") || AuxiliaryUtils.isBlank(p.getLabel())) { - content.append("\t\n"); - processNode(ctx, content, ctx.nodeMap.get(p.getTarget())); - content.append("\t\n"); + AuxiliaryUtils.appendTab(content, numOfTab + 1); + content.append("\n"); + processNode(ctx, content, ctx.nodeMap.get(p.getTarget()), numOfTab + 2); + AuxiliaryUtils.appendTab(content, numOfTab + 1); + content.append("\n"); } else { - content.append("\t\n"); - processNode(ctx, content, ctx.nodeMap.get(p.getTarget())); - content.append("\t\n"); + AuxiliaryUtils.appendTab(content, numOfTab + 1); + content.append("\n"); + processNode(ctx, content, ctx.nodeMap.get(p.getTarget()), numOfTab + 2); + AuxiliaryUtils.appendTab(content, numOfTab + 1); + content.append("\n"); } - }); + } if (AuxiliaryUtils.isNotBlank(componentInfo.getType()) && AuxiliaryUtils.isNotBlank(componentInfo.getScriptName()) @@ -222,58 +235,72 @@ public class G6ResultSerializer { ScriptCollector.collect(componentInfo.getScriptName(), componentInfo.getScript(), componentInfo.getScriptType()); } - content.append("\n\t\n"); - tryEndProcessCombo(ctx, content, current); + content.append("\n"); + AuxiliaryUtils.appendTab(content, numOfTab); + content.append("\n"); + if (nested > 0) { + numOfTab -= nested; + } + tryEndProcessCombo(ctx, content, current, numOfTab); if (endedNode != null) { ctx.endedNodes.pop(); - processNode(ctx, content, endedNode); + processNode(ctx, content, endedNode, numOfTab); } - } else { throw new FlowException("uncorrected type in node."); } } - private void tryStartProcessCombo(AnalyzerContext ctx, StringBuilder content, String comboId) { + private int tryStartProcessCombo(AnalyzerContext ctx, StringBuilder content, String comboId, int numsOfTab) { Combo combo = ctx.comboMap.get(comboId); - if (combo != null) { + if (combo == null) { + return 0; + } - // 没有进入,处理combo - if (!Objects.equals(ctx.enteredCombo.get(combo.getId()), true)) { - ctx.enteredCombo.put(combo.getId(), true); - ComponentInfo componentInfo = combo.getComponentInfo(); - ComponentType ctype = ComponentType.valueOf(componentInfo.getType()); + if (Objects.equals(ctx.enteredCombo.get(combo.getId()), true)) { + return 0; + } - if (AuxiliaryUtils.isNotBlank(combo.getParentId())) { - tryStartProcessCombo(ctx, content, combo.getParentId()); - } + // 没有进入,处理combo + int nested = 0; + ctx.enteredCombo.put(combo.getId(), true); + ComponentInfo componentInfo = combo.getComponentInfo(); + ComponentType ctype = ComponentType.valueOf(componentInfo.getType()); + + if (AuxiliaryUtils.isNotBlank(combo.getParentId())) { + nested = tryStartProcessCombo(ctx, content, combo.getParentId(), numsOfTab); + nested++; + } - if (ctype == ComponentType.ADAPTER) { - content.append("\n"); - } else if (AuxiliaryUtils.isNotBlank(componentInfo.getName()) && !AuxiliaryUtils.isAnonymous(componentInfo.getName())){ - content.append(""); - } - } + appendStandardAttributes(content, combo.getComponentInfo()); + appendExtensionAttributes(content, combo.getComponentInfo()); + content.append(">\n"); + } else if (AuxiliaryUtils.isNotBlank(componentInfo.getName()) && !AuxiliaryUtils.isAnonymous(componentInfo.getName())){ + AuxiliaryUtils.appendTab(content, numsOfTab); + content.append(""); } + + return nested; } - private void tryEndProcessCombo(AnalyzerContext ctx, StringBuilder content, Node current) { + private void tryEndProcessCombo(AnalyzerContext ctx, StringBuilder content, Node current, int numsOfTab) { if (AuxiliaryUtils.isBlank(current.getComboId())) { return; } @@ -295,10 +322,12 @@ public class G6ResultSerializer { nodes.remove(removeId); // end combo if (nodes.isEmpty()) { + content.append("\n"); + AuxiliaryUtils.appendTab(content, numsOfTab--); if (Objects.equals(cur.getComponentInfo().getType(), ComponentType.ADAPTER.name())) { - content.append("\n\n"); + content.append("\n"); } else if (AuxiliaryUtils.isNotBlank(cur.getComponentInfo().getName()) && !AuxiliaryUtils.isAnonymous(cur.getComponentInfo().getName())) { - content.append("\n\n"); + content.append("\n"); } if (AuxiliaryUtils.isBlank(cur.getParentId())) { -- Gitee From 9aadab867ccecb17a24a32452b8302a4843efe5d Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Mon, 12 Jun 2023 17:55:36 +0800 Subject: [PATCH 03/22] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BF=85=E5=A1=AB=E5=AD=97=E6=AE=B5=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qinluo <1558642210@qq.com> --- .../src/views/Engines/engine-edit-g6.vue | 20 +++++++++---------- dashboard/src/views/Engines/engine-edit.vue | 4 ++-- .../flow/admin/g6/G6ResultSerializer.java | 20 +++++++++++-------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/dashboard/src/views/Engines/engine-edit-g6.vue b/dashboard/src/views/Engines/engine-edit-g6.vue index e4dcb06..e2b243b 100644 --- a/dashboard/src/views/Engines/engine-edit-g6.vue +++ b/dashboard/src/views/Engines/engine-edit-g6.vue @@ -14,7 +14,7 @@

基本信息

- +
@@ -22,7 +22,7 @@
- +
@@ -32,7 +32,7 @@
- +
    @@ -125,7 +125,7 @@

脚本信息

- +
@@ -133,7 +133,7 @@
- +
ognl @@ -148,7 +148,7 @@
- +
@@ -166,7 +166,7 @@
- +
ognl @@ -181,7 +181,7 @@
- +
@@ -217,7 +217,7 @@
- +
@@ -225,7 +225,7 @@
- +
diff --git a/dashboard/src/views/Engines/engine-edit.vue b/dashboard/src/views/Engines/engine-edit.vue index 887a8a9..e02b2cc 100644 --- a/dashboard/src/views/Engines/engine-edit.vue +++ b/dashboard/src/views/Engines/engine-edit.vue @@ -6,14 +6,14 @@
- +
- +
diff --git a/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ResultSerializer.java b/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ResultSerializer.java index a3f0d84..306c7da 100644 --- a/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ResultSerializer.java +++ b/smart-flow-admin/src/main/java/org/smartboot/smart/flow/admin/g6/G6ResultSerializer.java @@ -40,11 +40,11 @@ public class G6ResultSerializer { public String serialize(G6Result result) { removeFixedNodesAndEdges(result); - // Check valid parameter - checkValid(result); - AnalyzerContext ctx = new AnalyzerContext(result); + // Check valid parameter + checkArguments(ctx); + Node start = findStartNode(result, ctx); Node end = findEndNode(result, ctx); @@ -375,11 +375,11 @@ public class G6ResultSerializer { result.getEdges().removeIf(p -> Objects.equals(p.getSource(), START_NODE) || Objects.equals(p.getTarget(), END_NODE)); } - private void checkValid(G6Result result) { - AssertUtil.notBlank(result.getName(), "engineName must not be blank!"); - AssertUtil.notBlank(result.getProcess(), "process must not be blank!"); - AssertUtil.isFalse(result.getNodes().isEmpty(), "Nodes size must greater than zero"); - AssertUtil.isFalse(result.getEdges().isEmpty(), "Edges size must greater than zero"); + private static void checkArguments(AnalyzerContext ctx) { + AssertUtil.notBlank(ctx.engineName, "engineName must not be blank!"); + AssertUtil.notBlank(ctx.pipelineName, "process must not be blank!"); + AssertUtil.isFalse(ctx.nodeMap.isEmpty(), "Nodes size must greater than zero"); + AssertUtil.isFalse(ctx.sourceEdgeMap.isEmpty(), "Edges size must greater than zero"); } private Node findStartNode(G6Result result, AnalyzerContext ctx) { @@ -444,8 +444,12 @@ public class G6ResultSerializer { public final Stack endedNodes = new SafeStack<>(); public final Map enteredCombo = new HashMap<>(); public final Map> comboNodeMap = new HashMap<>(); + public String engineName; + public String pipelineName; AnalyzerContext(G6Result result) { + engineName = result.getName(); + pipelineName = result.getProcess(); result.getNodes().forEach(p -> { nodeMap.put(p.getId(), p); if (AuxiliaryUtils.isNotBlank(p.getComboId())) { -- Gitee From dfdf73ba11104cde3791934e8a36f5a4d6e260f5 Mon Sep 17 00:00:00 2001 From: qinluo <1558642210@qq.com> Date: Thu, 15 Jun 2023 16:33:21 +0800 Subject: [PATCH 04/22] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qinluo <1558642210@qq.com> --- .../src/views/Engines/engine-edit-g6.vue | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/dashboard/src/views/Engines/engine-edit-g6.vue b/dashboard/src/views/Engines/engine-edit-g6.vue index e2b243b..32adbc3 100644 --- a/dashboard/src/views/Engines/engine-edit-g6.vue +++ b/dashboard/src/views/Engines/engine-edit-g6.vue @@ -1,5 +1,6 @@