!128 enhancement #I5Y92X 支持选择组件跳转同时指定组件名和标签
Merge pull request !128 from 码农小易/dev
This commit is contained in:
commit
9f904eae00
|
@ -29,7 +29,9 @@ public class SwitchCondition extends Condition{
|
|||
|
||||
private final Map<String, Executable> targetMap = new HashMap<>();
|
||||
|
||||
private final String TAG_PREFIX = "tag:";
|
||||
private final String TAG_PREFIX = "tag";
|
||||
private final String TAG_FLAG = ":";
|
||||
|
||||
|
||||
@Override
|
||||
public void execute(Integer slotIndex) throws Exception {
|
||||
|
@ -46,13 +48,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.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;
|
||||
}
|
||||
|
|
|
@ -50,4 +50,18 @@ 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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitch5() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>h==>b",response.getExecuteStepStr());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,10 +37,18 @@ public class CmpConfig {
|
|||
|
||||
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH,nodeId = "f",nodeType = NodeTypeEnum.SWITCH)
|
||||
public String processF(NodeComponent bindCmp) {
|
||||
return ":td";
|
||||
}
|
||||
|
||||
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_SWITCH,nodeId = "g",nodeType = NodeTypeEnum.SWITCH)
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,4 +21,18 @@
|
|||
SWITCH(f).to(b.tag("td"), d)
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(g).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain5">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(h).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
</flow>
|
|
@ -49,4 +49,18 @@ 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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitch5() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>h==>b",response.getExecuteStepStr());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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";
|
||||
}
|
||||
}
|
|
@ -21,4 +21,18 @@
|
|||
SWITCH(f).to(b.tag("td"), d)
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(g).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain5">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(h).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
</flow>
|
|
@ -40,4 +40,18 @@ 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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitch5() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>h==>b",response.getExecuteStepStr());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ public class FSwitchCmp extends NodeSwitchComponent {
|
|||
|
||||
@Override
|
||||
public String processSwitch() throws Exception {
|
||||
return "tag:td";
|
||||
return ":td";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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";
|
||||
}
|
||||
}
|
|
@ -7,6 +7,8 @@
|
|||
<node id="d" class="com.yomahub.liteflow.test.switchcase.cmp.DCmp"/>
|
||||
<node id="e" class="com.yomahub.liteflow.test.switchcase.cmp.ESwitchCmp"/>
|
||||
<node id="f" class="com.yomahub.liteflow.test.switchcase.cmp.FSwitchCmp"/>
|
||||
<node id="g" class="com.yomahub.liteflow.test.switchcase.cmp.GSwitchCmp"/>
|
||||
<node id="h" class="com.yomahub.liteflow.test.switchcase.cmp.HSwitchCmp"/>
|
||||
</nodes>
|
||||
|
||||
<chain name="chain1">
|
||||
|
@ -30,4 +32,18 @@
|
|||
SWITCH(f).to(b.tag("td"), d)
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(g).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain5">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(h).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
</flow>
|
|
@ -51,4 +51,18 @@ 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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitch5() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>h==>b",response.getExecuteStepStr());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@ public class FSwitchCmp extends NodeSwitchComponent {
|
|||
|
||||
@Override
|
||||
public String processSwitch() throws Exception {
|
||||
return "tag:td";
|
||||
return ":td";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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";
|
||||
}
|
||||
}
|
|
@ -21,4 +21,18 @@
|
|||
SWITCH(f).to(b.tag("td"), d)
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(g).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain5">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(h).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
</flow>
|
|
@ -38,4 +38,17 @@ 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());
|
||||
}
|
||||
@Test
|
||||
public void testSwitch5() throws Exception{
|
||||
LiteflowResponse response = flowExecutor.execute2Resp("chain5", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>h==>b",response.getExecuteStepStr());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@ public class FSwitchCmp extends NodeSwitchComponent {
|
|||
|
||||
@Override
|
||||
public String processSwitch() throws Exception {
|
||||
return "tag:td";
|
||||
return ":td";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* <p>Title: liteflow</p>
|
||||
* <p>Description: 轻量级的组件式流程框架</p>
|
||||
* @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";
|
||||
}
|
||||
}
|
|
@ -21,4 +21,18 @@
|
|||
SWITCH(f).to(b.tag("td"), d)
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(g).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
|
||||
<chain name="chain5">
|
||||
THEN(
|
||||
a,
|
||||
SWITCH(h).to(b.tag("td"), d.tag("td"))
|
||||
);
|
||||
</chain>
|
||||
</flow>
|
Loading…
Reference in New Issue