feat: change chainName to chainId
This commit is contained in:
parent
d40198dc2e
commit
d651cc8fc1
|
@ -49,6 +49,13 @@ public class LiteFlowChainBuilder {
|
|||
//在parser中chain的build是2段式的,因为涉及到依赖问题,以前是递归parser
|
||||
//2.6.8之后取消了递归的模式,两段式组装,先把带有chainName的chain对象放进去,第二段再组装chain里面的condition
|
||||
//所以这里setChainName的时候需要判断下
|
||||
/**
|
||||
*
|
||||
* @param chainName
|
||||
* @return
|
||||
* @deprecated 请使用 {@link #setChainId(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public LiteFlowChainBuilder setChainName(String chainName) {
|
||||
if (FlowBus.containChain(chainName)) {
|
||||
this.chain = FlowBus.getChain(chainName);
|
||||
|
@ -57,6 +64,15 @@ public class LiteFlowChainBuilder {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LiteFlowChainBuilder setChainId(String chainId) {
|
||||
if (FlowBus.containChain(chainId)) {
|
||||
this.chain = FlowBus.getChain(chainId);
|
||||
} else {
|
||||
this.chain.setChainId(chainId);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LiteFlowChainBuilder setCondition(Condition condition) {
|
||||
//这里把condition组装进conditionList,
|
||||
|
|
|
@ -86,6 +86,12 @@ public class LiteFlowChainELBuilder {
|
|||
//在parser中chain的build是2段式的,因为涉及到依赖问题,以前是递归parser
|
||||
//2.6.8之后取消了递归的模式,两段式组装,先把带有chainName的chain对象放进去,第二段再组装chain里面的condition
|
||||
//所以这里setChainName的时候需要判断下
|
||||
/**
|
||||
*
|
||||
* @param chainName
|
||||
* @return
|
||||
* @deprecated 请使用 {@link #setChainId(String)}
|
||||
*/
|
||||
public LiteFlowChainELBuilder setChainName(String chainName) {
|
||||
if (FlowBus.containChain(chainName)) {
|
||||
this.chain = FlowBus.getChain(chainName);
|
||||
|
@ -94,6 +100,15 @@ public class LiteFlowChainELBuilder {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LiteFlowChainELBuilder setChainId(String chainId) {
|
||||
if (FlowBus.containChain(chainId)) {
|
||||
this.chain = FlowBus.getChain(chainId);
|
||||
} else {
|
||||
this.chain.setChainId(chainId);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LiteFlowChainELBuilder setEL(String elStr) {
|
||||
if (StrUtil.isBlank(elStr)) {
|
||||
|
|
|
@ -305,9 +305,17 @@ public abstract class NodeComponent{
|
|||
return getSlot().getChainReqDataFromQueue(this.getCurrChainName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link #getChainId()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getChainName(){
|
||||
return getSlot().getChainName();
|
||||
}
|
||||
|
||||
public String getChainId(){
|
||||
return getSlot().getChainId();
|
||||
}
|
||||
|
||||
public String getDisplayName(){
|
||||
if(StrUtil.isEmpty(this.name)){
|
||||
|
@ -317,17 +325,43 @@ public abstract class NodeComponent{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param currChainName
|
||||
* @deprecated 请使用 {@link #setCurrChainId(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCurrChainName(String currChainName){
|
||||
this.currChainNameTL.set(currChainName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link #getCurrChainId()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getCurrChainName(){
|
||||
return this.currChainNameTL.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link #removeCurrChainId()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void removeCurrChainName(){
|
||||
this.currChainNameTL.remove();
|
||||
}
|
||||
|
||||
public void setCurrChainId(String currChainName){
|
||||
this.currChainNameTL.set(currChainName);
|
||||
}
|
||||
|
||||
public String getCurrChainId(){
|
||||
return this.currChainNameTL.get();
|
||||
}
|
||||
|
||||
public void removeCurrChainId(){
|
||||
this.currChainNameTL.remove();
|
||||
}
|
||||
|
||||
public void setCmpData(String cmpData){
|
||||
this.cmpDataTL.set(cmpData);
|
||||
|
|
|
@ -29,7 +29,7 @@ public class Chain implements Executable {
|
|||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Chain.class);
|
||||
|
||||
private String chainName;
|
||||
private String chainId;
|
||||
|
||||
private List<Condition> conditionList = new ArrayList<>();
|
||||
|
||||
|
@ -40,13 +40,13 @@ public class Chain implements Executable {
|
|||
private List<Condition> finallyConditionList = new ArrayList<>();
|
||||
|
||||
public Chain(String chainName){
|
||||
this.chainName = chainName;
|
||||
this.chainId = chainName;
|
||||
}
|
||||
|
||||
public Chain(){}
|
||||
|
||||
public Chain(String chainName, List<Condition> conditionList) {
|
||||
this.chainName = chainName;
|
||||
this.chainId = chainName;
|
||||
this.conditionList = conditionList;
|
||||
}
|
||||
|
||||
|
@ -58,29 +58,46 @@ public class Chain implements Executable {
|
|||
this.conditionList = conditionList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 请使用{@link #getChainId()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getChainName() {
|
||||
return chainName;
|
||||
return chainId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param chainName
|
||||
* @deprecated 请使用 {@link #setChainId(String)}
|
||||
*/
|
||||
public void setChainName(String chainName) {
|
||||
this.chainName = chainName;
|
||||
this.chainId = chainName;
|
||||
}
|
||||
|
||||
public String getChainId() {
|
||||
return chainId;
|
||||
}
|
||||
|
||||
public void setChainId(String chainId) {
|
||||
this.chainId = chainId;
|
||||
}
|
||||
|
||||
//执行chain的主方法
|
||||
@Override
|
||||
public void execute(Integer slotIndex) throws Exception {
|
||||
if (CollUtil.isEmpty(conditionList)) {
|
||||
throw new FlowSystemException("no conditionList in this chain[" + chainName + "]");
|
||||
throw new FlowSystemException("no conditionList in this chain[" + chainId + "]");
|
||||
}
|
||||
Slot slot = DataBus.getSlot(slotIndex);
|
||||
try {
|
||||
//设置主ChainName
|
||||
slot.setChainName(chainName);
|
||||
slot.setChainId(chainId);
|
||||
//执行前置
|
||||
this.executePre(slotIndex);
|
||||
//执行主体Condition
|
||||
for (Condition condition : conditionList) {
|
||||
condition.setCurrChainName(chainName);
|
||||
condition.setCurrChainName(chainId);
|
||||
condition.execute(slotIndex);
|
||||
}
|
||||
}catch (ChainEndException e){
|
||||
|
@ -89,8 +106,8 @@ public class Chain implements Executable {
|
|||
throw e;
|
||||
}catch (Exception e){
|
||||
//这里事先取到exception set到slot里,为了方便finally取到exception
|
||||
if (slot.isSubChain(chainName)){
|
||||
slot.setSubException(chainName, e);
|
||||
if (slot.isSubChain(chainId)){
|
||||
slot.setSubException(chainId, e);
|
||||
}else{
|
||||
slot.setException(e);
|
||||
}
|
||||
|
@ -121,8 +138,8 @@ public class Chain implements Executable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getExecuteName() {
|
||||
return chainName;
|
||||
public String getExecuteId() {
|
||||
return chainId;
|
||||
}
|
||||
public List<Condition> getPreConditionList() {
|
||||
return preConditionList;
|
||||
|
|
|
@ -18,9 +18,28 @@ public interface Executable{
|
|||
|
||||
ExecuteTypeEnum getExecuteType();
|
||||
|
||||
String getExecuteName();
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @deprecated 请使用 {@link #getExecuteId()}
|
||||
*/
|
||||
@Deprecated
|
||||
default String getExecuteName() {
|
||||
return getExecuteId();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param currentChainName
|
||||
* @deprecated 请使用 {@link #setCurrChainId(String)}
|
||||
*/
|
||||
default void setCurrChainName(String currentChainName){
|
||||
setCurrChainId(currentChainName);
|
||||
}
|
||||
|
||||
String getExecuteId();
|
||||
|
||||
default void setCurrChainId(String currentChainId){
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public class Node implements Executable,Cloneable{
|
|||
instance.removeSlotIndex();
|
||||
instance.removeIsEnd();
|
||||
instance.removeTag();
|
||||
instance.removeCurrChainName();
|
||||
instance.removeCurrChainId();
|
||||
instance.removeCmpData();
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ public class Node implements Executable,Cloneable{
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getExecuteName() {
|
||||
public String getExecuteId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -211,8 +211,8 @@ public class Node implements Executable,Cloneable{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCurrChainName(String currentChainName) {
|
||||
instance.setCurrChainName(currentChainName);
|
||||
public void setCurrChainId(String currentChainId) {
|
||||
instance.setCurrChainId(currentChainId);
|
||||
}
|
||||
|
||||
public String getCmpData() {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
package com.yomahub.liteflow.flow.element.condition;
|
||||
|
||||
import com.yomahub.liteflow.common.LocalDefaultFlowConstant;
|
||||
import com.yomahub.liteflow.enums.ExecuteTypeEnum;
|
||||
import com.yomahub.liteflow.flow.element.Executable;
|
||||
import com.yomahub.liteflow.enums.ConditionTypeEnum;
|
||||
|
@ -38,7 +37,7 @@ public abstract class Condition implements Executable{
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getExecuteName() {
|
||||
public String getExecuteId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
@ -64,12 +63,22 @@ public abstract class Condition implements Executable{
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @deprecated 请使用 {@link #setCurrChainId(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getCurrChainName() {
|
||||
return currChainName;
|
||||
}
|
||||
|
||||
public String getCurrChainId() {
|
||||
return currChainName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrChainName(String currChainName) {
|
||||
public void setCurrChainId(String currChainName) {
|
||||
this.currChainName = currChainName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public class ParserHelper {
|
|||
chainList.forEach(e -> {
|
||||
//校验加载的 chainName 是否有重复的
|
||||
//TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
||||
String chainName = e.attributeValue(NAME);
|
||||
String chainName = Optional.ofNullable(e.attributeValue(ID)).orElse(e.attributeValue(NAME));
|
||||
if (!chainNameSet.add(chainName)) {
|
||||
throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName));
|
||||
}
|
||||
|
@ -163,12 +163,13 @@ public class ParserHelper {
|
|||
JsonNode innerJsonObject = iterator.next();
|
||||
//校验加载的 chainName 是否有重复的
|
||||
// TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
||||
String chainName = innerJsonObject.get(NAME).textValue();
|
||||
//String chainName = innerJsonObject.get(NAME).textValue();
|
||||
String chainName = Optional.ofNullable(innerJsonObject.get(ID)).orElse(innerJsonObject.get(NAME)).textValue();
|
||||
if (!chainNameSet.add(chainName)) {
|
||||
throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName));
|
||||
}
|
||||
|
||||
FlowBus.addChain(innerJsonObject.get(NAME).textValue());
|
||||
FlowBus.addChain(chainName);
|
||||
}
|
||||
});
|
||||
// 清空
|
||||
|
@ -217,7 +218,7 @@ public class ParserHelper {
|
|||
*/
|
||||
public static void parseOneChainEl(JsonNode chainNode) {
|
||||
//构建chainBuilder
|
||||
String chainName = chainNode.get(NAME).textValue();
|
||||
String chainName = Optional.ofNullable(chainNode.get(ID)).orElse(chainNode.get(NAME)).textValue();
|
||||
String el = chainNode.get(VALUE).textValue();
|
||||
LiteFlowChainELBuilder chainELBuilder = LiteFlowChainELBuilder.createChain().setChainName(chainName);
|
||||
chainELBuilder.setEL(el).build();
|
||||
|
@ -230,7 +231,7 @@ public class ParserHelper {
|
|||
*/
|
||||
public static void parseOneChainEl(Element e) {
|
||||
//构建chainBuilder
|
||||
String chainName = e.attributeValue(NAME);
|
||||
String chainName = Optional.ofNullable(e.attributeValue(ID)).orElse(e.attributeValue(NAME));
|
||||
String text = e.getText();
|
||||
String el = RegexUtil.removeComments(text);
|
||||
LiteFlowChainELBuilder chainELBuilder = LiteFlowChainELBuilder.createChain().setChainName(chainName);
|
||||
|
|
|
@ -9,7 +9,7 @@ public class ScriptExecuteWrap {
|
|||
|
||||
private int slotIndex;
|
||||
|
||||
private String currChainName;
|
||||
private String currChainId;
|
||||
|
||||
private String nodeId;
|
||||
|
||||
|
@ -25,12 +25,29 @@ public class ScriptExecuteWrap {
|
|||
this.slotIndex = slotIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link #getCurrChainId()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getCurrChainName() {
|
||||
return currChainName;
|
||||
return currChainId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param currChainName
|
||||
* @deprecated 请使用{@link #setCurrChainId(String)}
|
||||
*/
|
||||
public void setCurrChainName(String currChainName) {
|
||||
this.currChainName = currChainName;
|
||||
this.currChainId = currChainName;
|
||||
}
|
||||
|
||||
public String getCurrChainId() {
|
||||
return currChainId;
|
||||
}
|
||||
|
||||
public void setCurrChainId(String currChainId) {
|
||||
this.currChainId = currChainId;
|
||||
}
|
||||
|
||||
public String getNodeId() {
|
||||
|
|
|
@ -18,6 +18,7 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -235,13 +236,31 @@ public class Slot{
|
|||
return (boolean) metaDataMap.get(BREAK_PREFIX + key);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param chainName
|
||||
* @Deprecated 请使用 {@link #setChainId(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setChainName(String chainName) {
|
||||
setChainId(chainName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 请使用 {@link #getChainId()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getChainName() {
|
||||
return getChainId();
|
||||
}
|
||||
|
||||
public void setChainId(String chainId) {
|
||||
if (!hasMetaData(CHAIN_NAME)){
|
||||
this.putMetaDataMap(CHAIN_NAME, chainName);
|
||||
this.putMetaDataMap(CHAIN_NAME, chainId);
|
||||
}
|
||||
}
|
||||
|
||||
public String getChainName() {
|
||||
public String getChainId() {
|
||||
return (String) metaDataMap.get(CHAIN_NAME);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue