From 6edd4b34c13b063407e6ebb230afd2886a8b9f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=81=E5=86=9C=E5=B0=8F=E6=98=93?= <237972113@qq.com> Date: Tue, 1 Nov 2022 14:32:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?enhancement=20#I5Y92X=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=BB=84=E4=BB=B6=E8=B7=B3=E8=BD=AC=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E6=8C=87=E5=AE=9A=E7=BB=84=E4=BB=B6=E5=90=8D=E5=92=8C?= =?UTF-8?q?=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../element/condition/SwitchCondition.java | 13 +++++++---- .../SwitchELDeclMultiSpringbootTest.java | 7 ++++++ .../test/switchcase/cmp/CmpConfig.java | 7 ++++-- .../src/test/resources/switchcase/flow.el.xml | 7 ++++++ .../SwitchELDeclSpringbootTest.java | 7 ++++++ .../test/switchcase/cmp/FSwitchCmp.java | 2 +- .../test/switchcase/cmp/GSwitchCmp.java | 23 +++++++++++++++++++ .../src/test/resources/switchcase/flow.el.xml | 7 ++++++ .../liteflow/test/switchcase/SwitchTest.java | 7 ++++++ .../test/switchcase/cmp/FSwitchCmp.java | 2 +- .../test/switchcase/cmp/GSwitchCmp.java | 18 +++++++++++++++ .../src/test/resources/switchcase/flow.el.xml | 8 +++++++ .../switchcase/SwitchELSpringbootTest.java | 7 ++++++ .../test/switchcase/cmp/FSwitchCmp.java | 2 +- .../test/switchcase/cmp/GSwitchCmp.java | 20 ++++++++++++++++ .../src/test/resources/switchcase/flow.el.xml | 7 ++++++ .../test/switchcase/SwitchELSpringTest.java | 7 ++++++ .../test/switchcase/cmp/FSwitchCmp.java | 2 +- .../test/switchcase/cmp/GSwitchCmp.java | 20 ++++++++++++++++ .../src/test/resources/switchcase/flow.el.xml | 7 ++++++ 20 files changed, 169 insertions(+), 11 deletions(-) create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java index 00ca79c8..2cec7dff 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java @@ -29,7 +29,8 @@ public class SwitchCondition extends Condition{ private final Map targetMap = new HashMap<>(); - private final String TAG_PREFIX = "tag:"; + private final String TAG_FLAG = ":"; + @Override public void execute(Integer slotIndex) throws Exception { @@ -46,13 +47,15 @@ public class SwitchCondition extends Condition{ if (StrUtil.isNotBlank(targetId)) { Executable targetExecutor; - //这里要判断是否跳转到tag - if (targetId.startsWith(TAG_PREFIX)){ - String targetTag = targetId.replaceAll(TAG_PREFIX, ""); + //这里要判断是否使用tag模式跳转 + if (targetId.contains(TAG_FLAG)){ + String[] target = targetId.split(TAG_FLAG, 2); + String _targetId = target[0]; + String _targetTag = target[1]; targetExecutor = targetMap.values().stream().filter(executable -> { if (executable instanceof Node){ Node node = (Node) executable; - return targetTag.equals(node.getTag()); + return (StrUtil.isEmpty(_targetId) || _targetId.equals(node.getId())) && (StrUtil.isEmpty(_targetTag) || _targetTag.equals(node.getTag())); }else{ return false; } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java index 0224b623..ad6ff11b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java @@ -50,4 +50,11 @@ public class SwitchELDeclMultiSpringbootTest extends BaseTest { Assert.assertEquals("a==>f==>b",response.getExecuteStepStr()); } + @Test + public void testSwitch4() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); + } + } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/CmpConfig.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/CmpConfig.java index e275f2cf..cd9fdced 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/CmpConfig.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/CmpConfig.java @@ -37,10 +37,13 @@ public class CmpConfig { @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH,nodeId = "f",nodeType = NodeTypeEnum.SWITCH) public String processF(NodeComponent bindCmp) { - return "tag:td"; + return ":td"; } - + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH,nodeId = "g",nodeType = NodeTypeEnum.SWITCH) + public String processG(NodeComponent bindCmp) { + return "d:td"; + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/switchcase/flow.el.xml index d534eb4e..e1e64a47 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/switchcase/flow.el.xml @@ -21,4 +21,11 @@ SWITCH(f).to(b.tag("td"), d) ); + + + THEN( + a, + SWITCH(g).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java index 310c7325..da80d7aa 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java @@ -49,4 +49,11 @@ public class SwitchELDeclSpringbootTest extends BaseTest { Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>f==>b",response.getExecuteStepStr()); } + + @Test + public void testSwitch4() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java index d800ed5e..afdd51b0 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java @@ -18,6 +18,6 @@ public class FSwitchCmp{ @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH, nodeType = NodeTypeEnum.SWITCH) public String processSwitch(NodeComponent bindCmp) throws Exception { - return "tag:td"; + return ":td"; } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java new file mode 100644 index 00000000..185e5550 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java @@ -0,0 +1,23 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.switchcase.cmp; + +import com.yomahub.liteflow.annotation.LiteflowMethod; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.enums.NodeTypeEnum; +import org.springframework.stereotype.Component; + +@Component("g") +public class GSwitchCmp { + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH, nodeType = NodeTypeEnum.SWITCH) + public String processSwitch(NodeComponent bindCmp) throws Exception { + return "d:td"; + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/switchcase/flow.el.xml index d534eb4e..e1e64a47 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/switchcase/flow.el.xml @@ -21,4 +21,11 @@ SWITCH(f).to(b.tag("td"), d) ); + + + THEN( + a, + SWITCH(g).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java index 1a3a2b15..24fbf541 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java @@ -40,4 +40,11 @@ public class SwitchTest extends BaseTest{ Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>f==>b",response.getExecuteStepStr()); } + + @Test + public void testSwitch4() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java index d9e34d9a..ad750f5e 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java @@ -13,6 +13,6 @@ public class FSwitchCmp extends NodeSwitchComponent { @Override public String processSwitch() throws Exception { - return "tag:td"; + return ":td"; } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java new file mode 100644 index 00000000..30336c44 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java @@ -0,0 +1,18 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.switchcase.cmp; + +import com.yomahub.liteflow.core.NodeSwitchComponent; + +public class GSwitchCmp extends NodeSwitchComponent { + + @Override + public String processSwitch() throws Exception { + return "d:td"; + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/switchcase/flow.el.xml index 886287ea..7e1ea4f1 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/switchcase/flow.el.xml @@ -7,6 +7,7 @@ + @@ -30,4 +31,11 @@ SWITCH(f).to(b.tag("td"), d) ); + + + THEN( + a, + SWITCH(g).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java index 39c99615..badcc6c2 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java @@ -51,4 +51,11 @@ public class SwitchELSpringbootTest extends BaseTest { Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>f==>b",response.getExecuteStepStr()); } + + @Test + public void testSwitch4() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java index 8defcaf8..ac83ec67 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java @@ -15,6 +15,6 @@ public class FSwitchCmp extends NodeSwitchComponent { @Override public String processSwitch() throws Exception { - return "tag:td"; + return ":td"; } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java new file mode 100644 index 00000000..a956a5ec --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.switchcase.cmp; + +import com.yomahub.liteflow.core.NodeSwitchComponent; +import org.springframework.stereotype.Component; + +@Component("g") +public class GSwitchCmp extends NodeSwitchComponent { + + @Override + public String processSwitch() throws Exception { + return "d:td"; + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/switchcase/flow.el.xml index d534eb4e..e1e64a47 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/switchcase/flow.el.xml @@ -21,4 +21,11 @@ SWITCH(f).to(b.tag("td"), d) ); + + + THEN( + a, + SWITCH(g).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java index 84bba91c..c5df4550 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java @@ -38,4 +38,11 @@ public class SwitchELSpringTest extends BaseTest { Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>f==>b",response.getExecuteStepStr()); } + + @Test + public void testSwitch4() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain4", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java index 8defcaf8..ac83ec67 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/FSwitchCmp.java @@ -15,6 +15,6 @@ public class FSwitchCmp extends NodeSwitchComponent { @Override public String processSwitch() throws Exception { - return "tag:td"; + return ":td"; } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java new file mode 100644 index 00000000..a956a5ec --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/GSwitchCmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.switchcase.cmp; + +import com.yomahub.liteflow.core.NodeSwitchComponent; +import org.springframework.stereotype.Component; + +@Component("g") +public class GSwitchCmp extends NodeSwitchComponent { + + @Override + public String processSwitch() throws Exception { + return "d:td"; + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/switchcase/flow.el.xml index d534eb4e..e1e64a47 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/switchcase/flow.el.xml @@ -21,4 +21,11 @@ SWITCH(f).to(b.tag("td"), d) ); + + + THEN( + a, + SWITCH(g).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file From 9162607cb07770b8661e89497d4e7b573b4f8609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=81=E5=86=9C=E5=B0=8F=E6=98=93?= <237972113@qq.com> Date: Mon, 7 Nov 2022 13:59:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=85=BC=E5=AE=B9SwitchComponent=E8=BF=94?= =?UTF-8?q?=E5=9B=9E"tag:xxx"=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../element/condition/SwitchCondition.java | 3 ++- .../SwitchELDeclMultiSpringbootTest.java | 7 ++++++ .../test/switchcase/cmp/CmpConfig.java | 5 ++++ .../src/test/resources/switchcase/flow.el.xml | 7 ++++++ .../SwitchELDeclSpringbootTest.java | 7 ++++++ .../test/switchcase/cmp/HSwitchCmp.java | 23 +++++++++++++++++++ .../src/test/resources/switchcase/flow.el.xml | 7 ++++++ .../liteflow/test/switchcase/SwitchTest.java | 7 ++++++ .../test/switchcase/cmp/HSwitchCmp.java | 18 +++++++++++++++ .../src/test/resources/switchcase/flow.el.xml | 8 +++++++ .../switchcase/SwitchELSpringbootTest.java | 7 ++++++ .../test/switchcase/cmp/HSwitchCmp.java | 20 ++++++++++++++++ .../src/test/resources/switchcase/flow.el.xml | 7 ++++++ .../test/switchcase/SwitchELSpringTest.java | 6 +++++ .../test/switchcase/cmp/HSwitchCmp.java | 20 ++++++++++++++++ .../src/test/resources/switchcase/flow.el.xml | 7 ++++++ 16 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java create mode 100644 liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java index 2cec7dff..d5fbd273 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/SwitchCondition.java @@ -29,6 +29,7 @@ public class SwitchCondition extends Condition{ private final Map targetMap = new HashMap<>(); + private final String TAG_PREFIX = "tag"; private final String TAG_FLAG = ":"; @@ -55,7 +56,7 @@ public class SwitchCondition extends Condition{ targetExecutor = targetMap.values().stream().filter(executable -> { if (executable instanceof Node){ Node node = (Node) executable; - return (StrUtil.isEmpty(_targetId) || _targetId.equals(node.getId())) && (StrUtil.isEmpty(_targetTag) || _targetTag.equals(node.getTag())); + return (StrUtil.startWith(_targetId, TAG_PREFIX) && _targetTag.equals(node.getTag())) || ((StrUtil.isEmpty(_targetId) || _targetId.equals(node.getId())) && (StrUtil.isEmpty(_targetTag) || _targetTag.equals(node.getTag()))); }else{ return false; } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java index ad6ff11b..87a50a77 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclMultiSpringbootTest.java @@ -57,4 +57,11 @@ public class SwitchELDeclMultiSpringbootTest extends BaseTest { Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); } + @Test + public void testSwitch5() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>h==>b",response.getExecuteStepStr()); + } + } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/CmpConfig.java b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/CmpConfig.java index cd9fdced..465067c4 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/CmpConfig.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/CmpConfig.java @@ -44,6 +44,11 @@ public class CmpConfig { public String processG(NodeComponent bindCmp) { return "d:td"; } + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH,nodeId = "h",nodeType = NodeTypeEnum.SWITCH) + public String processH(NodeComponent bindCmp) { + return "tag:td"; + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/switchcase/flow.el.xml index e1e64a47..fc93c329 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/switchcase/flow.el.xml @@ -28,4 +28,11 @@ SWITCH(g).to(b.tag("td"), d.tag("td")) ); + + + THEN( + a, + SWITCH(h).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java index da80d7aa..8a640b2d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELDeclSpringbootTest.java @@ -56,4 +56,11 @@ public class SwitchELDeclSpringbootTest extends BaseTest { Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); } + + @Test + public void testSwitch5() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>h==>b",response.getExecuteStepStr()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java new file mode 100644 index 00000000..44823626 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java @@ -0,0 +1,23 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.switchcase.cmp; + +import com.yomahub.liteflow.annotation.LiteflowMethod; +import com.yomahub.liteflow.core.NodeComponent; +import com.yomahub.liteflow.enums.LiteFlowMethodEnum; +import com.yomahub.liteflow.enums.NodeTypeEnum; +import org.springframework.stereotype.Component; + +@Component("h") +public class HSwitchCmp { + + @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH, nodeType = NodeTypeEnum.SWITCH) + public String processSwitch(NodeComponent bindCmp) throws Exception { + return "tag:td"; + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/switchcase/flow.el.xml index e1e64a47..fc93c329 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/switchcase/flow.el.xml @@ -28,4 +28,11 @@ SWITCH(g).to(b.tag("td"), d.tag("td")) ); + + + THEN( + a, + SWITCH(h).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java index 24fbf541..41cca1ba 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchTest.java @@ -47,4 +47,11 @@ public class SwitchTest extends BaseTest{ Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); } + + @Test + public void testSwitch5() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>h==>b",response.getExecuteStepStr()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java new file mode 100644 index 00000000..820b80bd --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java @@ -0,0 +1,18 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.switchcase.cmp; + +import com.yomahub.liteflow.core.NodeSwitchComponent; + +public class HSwitchCmp extends NodeSwitchComponent { + + @Override + public String processSwitch() throws Exception { + return "tag:td"; + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/switchcase/flow.el.xml index 7e1ea4f1..bce9c177 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/resources/switchcase/flow.el.xml @@ -8,6 +8,7 @@ + @@ -38,4 +39,11 @@ SWITCH(g).to(b.tag("td"), d.tag("td")) ); + + + THEN( + a, + SWITCH(h).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java index badcc6c2..c6270ea5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringbootTest.java @@ -58,4 +58,11 @@ public class SwitchELSpringbootTest extends BaseTest { Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); } + + @Test + public void testSwitch5() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>h==>b",response.getExecuteStepStr()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java new file mode 100644 index 00000000..68838816 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.switchcase.cmp; + +import com.yomahub.liteflow.core.NodeSwitchComponent; +import org.springframework.stereotype.Component; + +@Component("h") +public class HSwitchCmp extends NodeSwitchComponent { + + @Override + public String processSwitch() throws Exception { + return "tag:td"; + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/switchcase/flow.el.xml index e1e64a47..fc93c329 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springboot/src/test/resources/switchcase/flow.el.xml @@ -28,4 +28,11 @@ SWITCH(g).to(b.tag("td"), d.tag("td")) ); + + + THEN( + a, + SWITCH(h).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java index c5df4550..cc83086b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/SwitchELSpringTest.java @@ -45,4 +45,10 @@ public class SwitchELSpringTest extends BaseTest { Assert.assertTrue(response.isSuccess()); Assert.assertEquals("a==>g==>d",response.getExecuteStepStr()); } + @Test + public void testSwitch5() throws Exception{ + LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg"); + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals("a==>h==>b",response.getExecuteStepStr()); + } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java new file mode 100644 index 00000000..68838816 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/java/com/yomahub/liteflow/test/switchcase/cmp/HSwitchCmp.java @@ -0,0 +1,20 @@ +/** + *

Title: liteflow

+ *

Description: 轻量级的组件式流程框架

+ * @author Bryan.Zhang + * @email weenyc31@163.com + * @Date 2020/4/1 + */ +package com.yomahub.liteflow.test.switchcase.cmp; + +import com.yomahub.liteflow.core.NodeSwitchComponent; +import org.springframework.stereotype.Component; + +@Component("h") +public class HSwitchCmp extends NodeSwitchComponent { + + @Override + public String processSwitch() throws Exception { + return "tag:td"; + } +} diff --git a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/switchcase/flow.el.xml b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/switchcase/flow.el.xml index e1e64a47..fc93c329 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/switchcase/flow.el.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-springnative/src/test/resources/switchcase/flow.el.xml @@ -28,4 +28,11 @@ SWITCH(g).to(b.tag("td"), d.tag("td")) ); + + + THEN( + a, + SWITCH(h).to(b.tag("td"), d.tag("td")) + ); + \ No newline at end of file