-
{
const result = await trace_detail_g6(id);
- data.edges = result.data.edges;
- data.combos = result.data.combos;
+
for (let j = 0; j < result.data.nodes.length; j++) {
result.data.nodes[j].x = middle + (result.data.nodes[j].x * 300);
result.data.nodes[j].y = (result.data.nodes[j].y * 150 + 40);
@@ -454,12 +452,23 @@ export default {
if (result.data.nodes[j].type === 'diamond') {
result.data.nodes[j].size = [200, 110];
}
+
+ if (result.data.nodes[j].componentInfo && !result.data.nodes[j].componentInfo.script) {
+ result.data.nodes[j].componentInfo.subtype = '1';
+ }
}
+ for (let j = 0; j < result.data.combos.length; j++) {
+ result.data.combos[j].componentInfo.subtype = '1';
+ }
+
+ data.edges = result.data.edges;
+ data.combos = result.data.combos;
data.nodes = result.data.nodes;
engineInfo.value = {
name: result.data.name,
- process: result.data.process
+ process: result.data.process,
+ id: result.data.id,
}
console.log(data);
@@ -704,6 +713,7 @@ export default {
const params = {
name: engineInfo.name,
process: engineInfo.process,
+ id: engineInfo.id,
nodes:[],
edges:[],
combos:[]
@@ -736,6 +746,7 @@ export default {
},
initEditor(obj) {
+ console.log("created");
if (!scriptEditor && document.getElementById("scriptEditor")) {
scriptEditor = monaco.editor.create(document.getElementById("scriptEditor"), {
theme: "vs-dark", // 主题
@@ -782,11 +793,13 @@ export default {
});
}
- if (scriptEditor) {
+ console.log("created success!");
+
+ if (scriptEditor && obj.script) {
scriptEditor.setValue(obj.script);
}
- if (rollbackScriptEditor) {
+ if (rollbackScriptEditor && obj.rollbackScript) {
rollbackScriptEditor.setValue(obj.rollbackScript);
}
},
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 544357f..33f81de 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
@@ -77,12 +77,12 @@ public class G6ResultSerializer {
return;
}
-
Node peek = ctx.endedNodes.peek();
if (current == peek) {
return;
}
+ tryStartProcessCombo(ctx, content, current.getComboId());
ComponentInfo componentInfo = current.getComponentInfo();
ComponentType type = ComponentType.valueOf(componentInfo.getType());
@@ -96,14 +96,16 @@ public class G6ResultSerializer {
// execute
content.append("execute=\"").append(componentInfo.getDescribe()).append("\" ");
- appendStandardAttributes(content, current);
- appendExtensionAttributes(content, current);
+ appendStandardAttributes(content, current.getComponentInfo());
+ appendExtensionAttributes(content, current.getComponentInfo());
content.append("/>\n");
// next node;
Edge edge = first(ctx.sourceEdgeMap.get(current.getId()));
if (edge != null && ctx.nodeMap.get(edge.getTarget()) != null) {
+
+ tryEndProcessCombo(ctx, content, current);
processNode(ctx, content, ctx.nodeMap.get(edge.getTarget()));
}
} else if (type == ComponentType.IF) {
@@ -124,8 +126,8 @@ public class G6ResultSerializer {
// execute
content.append("test=\"").append(componentInfo.getDescribe()).append("\" ");
- appendStandardAttributes(content, current);
- appendExtensionAttributes(content, current);
+ appendStandardAttributes(content, current.getComponentInfo());
+ appendExtensionAttributes(content, current.getComponentInfo());
content.append(">\n");
@@ -145,7 +147,7 @@ public class G6ResultSerializer {
});
content.append("\n\t\n");
-
+ tryEndProcessCombo(ctx, content, current);
if (endedNode != null) {
ctx.endedNodes.pop();
processNode(ctx, content, endedNode);
@@ -168,8 +170,8 @@ public class G6ResultSerializer {
// execute
content.append("test=\"").append(componentInfo.getDescribe()).append("\" ");
- appendStandardAttributes(content, current);
- appendExtensionAttributes(content, current);
+ appendStandardAttributes(content, current.getComponentInfo());
+ appendExtensionAttributes(content, current.getComponentInfo());
content.append(">\n");
@@ -187,7 +189,7 @@ public class G6ResultSerializer {
});
content.append("\n\t\n");
-
+ tryEndProcessCombo(ctx, content, current);
if (endedNode != null) {
ctx.endedNodes.pop();
processNode(ctx, content, endedNode);
@@ -199,6 +201,80 @@ public class G6ResultSerializer {
}
+ private void tryStartProcessCombo(AnalyzerContext ctx, StringBuilder content, String comboId) {
+ Combo combo = ctx.comboMap.get(comboId);
+ if (combo != null) {
+
+ // 没有进入,处理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 (AuxiliaryUtils.isNotBlank(combo.getParentId())) {
+ tryStartProcessCombo(ctx, content, combo.getParentId());
+ }
+
+ if (ctype == ComponentType.ADAPTER) {
+ content.append("
\n");
+ } else if (AuxiliaryUtils.isNotBlank(componentInfo.getName()) && !AuxiliaryUtils.isAnonymous(componentInfo.getName())){
+ content.append("");
+ }
+ }
+
+ }
+ }
+
+ private void tryEndProcessCombo(AnalyzerContext ctx, StringBuilder content, Node current) {
+ if (AuxiliaryUtils.isBlank(current.getComboId())) {
+ return;
+ }
+
+ Combo combo = ctx.comboMap.get(current.getComboId());
+ if (combo == null) {
+ return;
+ }
+
+ String removeId = current.getId();
+
+ Stack processCombos = new SafeStack<>();
+ processCombos.add(combo.getId());
+ while (!processCombos.isEmpty()) {
+ String comboId = processCombos.pop();
+ Combo cur = ctx.comboMap.get(comboId);
+
+ List nodes = ctx.comboNodeMap.getOrDefault(comboId, new ArrayList<>(0));
+ nodes.remove(removeId);
+ // end combo
+ if (nodes.isEmpty()) {
+ if (Objects.equals(cur.getComponentInfo().getType(), ComponentType.ADAPTER.name())) {
+ content.append("\n\n");
+ } else if (AuxiliaryUtils.isNotBlank(cur.getComponentInfo().getName()) && !AuxiliaryUtils.isAnonymous(cur.getComponentInfo().getName())) {
+ content.append("\n\n");
+ }
+
+ if (AuxiliaryUtils.isBlank(cur.getParentId())) {
+ continue;
+ }
+
+ Combo parent = ctx.comboMap.get(cur.getParentId());
+ processCombos.add(parent.getId());
+ removeId = cur.getId();
+ }
+ }
+ }
+
private Node findBlockEndNode(AnalyzerContext ctx, Node current, ComponentType type) {
List
edges = ctx.sourceEdgeMap.get(current.getId());
@@ -283,12 +359,12 @@ public class G6ResultSerializer {
}).findFirst().orElse(null);
}
- private void appendExtensionAttributes(StringBuilder content, Node current) {
- current.getComponentInfo().getAttributes().forEach(p -> content.append(p.getName()).append("=\"").append(p.getValue()).append("\" "));
+ private void appendExtensionAttributes(StringBuilder content, ComponentInfo componentInfo) {
+ componentInfo.getAttributes().forEach(p -> content.append(p.getName()).append("=\"").append(p.getValue()).append("\" "));
}
- private void appendStandardAttributes(StringBuilder content, Node current) {
- current.getComponentInfo().getExtensionAttributes().forEach(content::append);
+ private void appendStandardAttributes(StringBuilder content, ComponentInfo componentInfo) {
+ componentInfo.getExtensionAttributes().forEach(content::append);
}
private T first(List list) {
@@ -301,10 +377,27 @@ public class G6ResultSerializer {
public final Map nodeMap = new HashMap<>();
public final Map comboMap = new HashMap<>();
public final Stack endedNodes = new SafeStack<>();
+ public final Map enteredCombo = new HashMap<>();
+ public final Map> comboNodeMap = new HashMap<>();
public AnalyzerContext(G6Result result) {
- result.getNodes().forEach(p -> nodeMap.put(p.getId(), p));
- result.getCombos().forEach(p -> comboMap.put(p.getId(), p));
+ result.getNodes().forEach(p -> {
+ nodeMap.put(p.getId(), p);
+ if (AuxiliaryUtils.isNotBlank(p.getComboId())) {
+ List nodes = comboNodeMap.getOrDefault(p.getComboId(), new ArrayList<>(8));
+ nodes.add(p.getId());
+ comboNodeMap.put(p.getComboId(), nodes);
+ }
+
+ });
+ result.getCombos().forEach(p -> {
+ comboMap.put(p.getId(), p);
+ if (AuxiliaryUtils.isNotBlank(p.getParentId())) {
+ List nodes = comboNodeMap.getOrDefault(p.getParentId(), new ArrayList<>(8));
+ nodes.add(p.getId());
+ comboNodeMap.put(p.getParentId(), nodes);
+ }
+ });
result.getEdges().forEach(p -> {
List edges = sourceEdgeMap.getOrDefault(p.getSource(), new ArrayList<>(0));
edges.add(p);
--
Gitee
From 75795685d783a547c92e35876d618f0eca019feb Mon Sep 17 00:00:00 2001
From: qinluo <1558642210@qq.com>
Date: Wed, 5 Apr 2023 23:51:39 +0800
Subject: [PATCH 19/52] =?UTF-8?q?qinluo:=20=20=20=20=20=20-=20g6=E7=BB=93?=
=?UTF-8?q?=E6=9E=9C=E4=BC=98=E5=8C=96=20=20=20=20=20=20-=20=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E5=B1=95=E7=A4=BA=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
dashboard/src/views/Engines/engine-edit-g6.vue | 2 +-
.../smart/flow/admin/g6/G6ComponentVisitor.java | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dashboard/src/views/Engines/engine-edit-g6.vue b/dashboard/src/views/Engines/engine-edit-g6.vue
index 8cf6fda..a00ff4f 100644
--- a/dashboard/src/views/Engines/engine-edit-g6.vue
+++ b/dashboard/src/views/Engines/engine-edit-g6.vue
@@ -57,7 +57,7 @@