!126 修正不规范的问题,chain的name和id混用情况
Merge pull request !126 from ousinka/master
This commit is contained in:
commit
e5b35e4e00
|
@ -49,6 +49,13 @@ public class LiteFlowChainBuilder {
|
||||||
//在parser中chain的build是2段式的,因为涉及到依赖问题,以前是递归parser
|
//在parser中chain的build是2段式的,因为涉及到依赖问题,以前是递归parser
|
||||||
//2.6.8之后取消了递归的模式,两段式组装,先把带有chainName的chain对象放进去,第二段再组装chain里面的condition
|
//2.6.8之后取消了递归的模式,两段式组装,先把带有chainName的chain对象放进去,第二段再组装chain里面的condition
|
||||||
//所以这里setChainName的时候需要判断下
|
//所以这里setChainName的时候需要判断下
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param chainName
|
||||||
|
* @return
|
||||||
|
* @deprecated 请使用 {@link #setChainId(String)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public LiteFlowChainBuilder setChainName(String chainName) {
|
public LiteFlowChainBuilder setChainName(String chainName) {
|
||||||
if (FlowBus.containChain(chainName)) {
|
if (FlowBus.containChain(chainName)) {
|
||||||
this.chain = FlowBus.getChain(chainName);
|
this.chain = FlowBus.getChain(chainName);
|
||||||
|
@ -57,6 +64,15 @@ public class LiteFlowChainBuilder {
|
||||||
}
|
}
|
||||||
return this;
|
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) {
|
public LiteFlowChainBuilder setCondition(Condition condition) {
|
||||||
//这里把condition组装进conditionList,
|
//这里把condition组装进conditionList,
|
||||||
|
|
|
@ -86,6 +86,12 @@ public class LiteFlowChainELBuilder {
|
||||||
//在parser中chain的build是2段式的,因为涉及到依赖问题,以前是递归parser
|
//在parser中chain的build是2段式的,因为涉及到依赖问题,以前是递归parser
|
||||||
//2.6.8之后取消了递归的模式,两段式组装,先把带有chainName的chain对象放进去,第二段再组装chain里面的condition
|
//2.6.8之后取消了递归的模式,两段式组装,先把带有chainName的chain对象放进去,第二段再组装chain里面的condition
|
||||||
//所以这里setChainName的时候需要判断下
|
//所以这里setChainName的时候需要判断下
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param chainName
|
||||||
|
* @return
|
||||||
|
* @deprecated 请使用 {@link #setChainId(String)}
|
||||||
|
*/
|
||||||
public LiteFlowChainELBuilder setChainName(String chainName) {
|
public LiteFlowChainELBuilder setChainName(String chainName) {
|
||||||
if (FlowBus.containChain(chainName)) {
|
if (FlowBus.containChain(chainName)) {
|
||||||
this.chain = FlowBus.getChain(chainName);
|
this.chain = FlowBus.getChain(chainName);
|
||||||
|
@ -94,6 +100,15 @@ public class LiteFlowChainELBuilder {
|
||||||
}
|
}
|
||||||
return this;
|
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) {
|
public LiteFlowChainELBuilder setEL(String elStr) {
|
||||||
if (StrUtil.isBlank(elStr)) {
|
if (StrUtil.isBlank(elStr)) {
|
||||||
|
|
|
@ -305,9 +305,17 @@ public abstract class NodeComponent{
|
||||||
return getSlot().getChainReqDataFromQueue(this.getCurrChainName());
|
return getSlot().getChainReqDataFromQueue(this.getCurrChainName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 请使用 {@link #getChainId()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getChainName(){
|
public String getChainName(){
|
||||||
return getSlot().getChainName();
|
return getSlot().getChainName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getChainId(){
|
||||||
|
return getSlot().getChainId();
|
||||||
|
}
|
||||||
|
|
||||||
public String getDisplayName(){
|
public String getDisplayName(){
|
||||||
if(StrUtil.isEmpty(this.name)){
|
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){
|
public void setCurrChainName(String currChainName){
|
||||||
this.currChainNameTL.set(currChainName);
|
this.currChainNameTL.set(currChainName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 请使用 {@link #getCurrChainId()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getCurrChainName(){
|
public String getCurrChainName(){
|
||||||
return this.currChainNameTL.get();
|
return this.currChainNameTL.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 请使用 {@link #removeCurrChainId()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void removeCurrChainName(){
|
public void removeCurrChainName(){
|
||||||
this.currChainNameTL.remove();
|
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){
|
public void setCmpData(String cmpData){
|
||||||
this.cmpDataTL.set(cmpData);
|
this.cmpDataTL.set(cmpData);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class Chain implements Executable {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(Chain.class);
|
private static final Logger LOG = LoggerFactory.getLogger(Chain.class);
|
||||||
|
|
||||||
private String chainName;
|
private String chainId;
|
||||||
|
|
||||||
private List<Condition> conditionList = new ArrayList<>();
|
private List<Condition> conditionList = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -40,13 +40,13 @@ public class Chain implements Executable {
|
||||||
private List<Condition> finallyConditionList = new ArrayList<>();
|
private List<Condition> finallyConditionList = new ArrayList<>();
|
||||||
|
|
||||||
public Chain(String chainName){
|
public Chain(String chainName){
|
||||||
this.chainName = chainName;
|
this.chainId = chainName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chain(){}
|
public Chain(){}
|
||||||
|
|
||||||
public Chain(String chainName, List<Condition> conditionList) {
|
public Chain(String chainName, List<Condition> conditionList) {
|
||||||
this.chainName = chainName;
|
this.chainId = chainName;
|
||||||
this.conditionList = conditionList;
|
this.conditionList = conditionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,29 +58,46 @@ public class Chain implements Executable {
|
||||||
this.conditionList = conditionList;
|
this.conditionList = conditionList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 请使用{@link #getChainId()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getChainName() {
|
public String getChainName() {
|
||||||
return chainName;
|
return chainId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param chainName
|
||||||
|
* @deprecated 请使用 {@link #setChainId(String)}
|
||||||
|
*/
|
||||||
public void setChainName(String chainName) {
|
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的主方法
|
//执行chain的主方法
|
||||||
@Override
|
@Override
|
||||||
public void execute(Integer slotIndex) throws Exception {
|
public void execute(Integer slotIndex) throws Exception {
|
||||||
if (CollUtil.isEmpty(conditionList)) {
|
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);
|
Slot slot = DataBus.getSlot(slotIndex);
|
||||||
try {
|
try {
|
||||||
//设置主ChainName
|
//设置主ChainName
|
||||||
slot.setChainName(chainName);
|
slot.setChainId(chainId);
|
||||||
//执行前置
|
//执行前置
|
||||||
this.executePre(slotIndex);
|
this.executePre(slotIndex);
|
||||||
//执行主体Condition
|
//执行主体Condition
|
||||||
for (Condition condition : conditionList) {
|
for (Condition condition : conditionList) {
|
||||||
condition.setCurrChainName(chainName);
|
condition.setCurrChainName(chainId);
|
||||||
condition.execute(slotIndex);
|
condition.execute(slotIndex);
|
||||||
}
|
}
|
||||||
}catch (ChainEndException e){
|
}catch (ChainEndException e){
|
||||||
|
@ -89,8 +106,8 @@ public class Chain implements Executable {
|
||||||
throw e;
|
throw e;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
//这里事先取到exception set到slot里,为了方便finally取到exception
|
//这里事先取到exception set到slot里,为了方便finally取到exception
|
||||||
if (slot.isSubChain(chainName)){
|
if (slot.isSubChain(chainId)){
|
||||||
slot.setSubException(chainName, e);
|
slot.setSubException(chainId, e);
|
||||||
}else{
|
}else{
|
||||||
slot.setException(e);
|
slot.setException(e);
|
||||||
}
|
}
|
||||||
|
@ -121,8 +138,8 @@ public class Chain implements Executable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExecuteName() {
|
public String getExecuteId() {
|
||||||
return chainName;
|
return chainId;
|
||||||
}
|
}
|
||||||
public List<Condition> getPreConditionList() {
|
public List<Condition> getPreConditionList() {
|
||||||
return preConditionList;
|
return preConditionList;
|
||||||
|
|
|
@ -18,9 +18,28 @@ public interface Executable{
|
||||||
|
|
||||||
ExecuteTypeEnum getExecuteType();
|
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){
|
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.removeSlotIndex();
|
||||||
instance.removeIsEnd();
|
instance.removeIsEnd();
|
||||||
instance.removeTag();
|
instance.removeTag();
|
||||||
instance.removeCurrChainName();
|
instance.removeCurrChainId();
|
||||||
instance.removeCmpData();
|
instance.removeCmpData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ public class Node implements Executable,Cloneable{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExecuteName() {
|
public String getExecuteId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,8 +211,8 @@ public class Node implements Executable,Cloneable{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCurrChainName(String currentChainName) {
|
public void setCurrChainId(String currentChainId) {
|
||||||
instance.setCurrChainName(currentChainName);
|
instance.setCurrChainId(currentChainId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCmpData() {
|
public String getCmpData() {
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
package com.yomahub.liteflow.flow.element.condition;
|
package com.yomahub.liteflow.flow.element.condition;
|
||||||
|
|
||||||
import com.yomahub.liteflow.common.LocalDefaultFlowConstant;
|
|
||||||
import com.yomahub.liteflow.enums.ExecuteTypeEnum;
|
import com.yomahub.liteflow.enums.ExecuteTypeEnum;
|
||||||
import com.yomahub.liteflow.flow.element.Executable;
|
import com.yomahub.liteflow.flow.element.Executable;
|
||||||
import com.yomahub.liteflow.enums.ConditionTypeEnum;
|
import com.yomahub.liteflow.enums.ConditionTypeEnum;
|
||||||
|
@ -38,7 +37,7 @@ public abstract class Condition implements Executable{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getExecuteName() {
|
public String getExecuteId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +63,22 @@ public abstract class Condition implements Executable{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @deprecated 请使用 {@link #setCurrChainId(String)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getCurrChainName() {
|
public String getCurrChainName() {
|
||||||
return currChainName;
|
return currChainName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCurrChainId() {
|
||||||
|
return currChainName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCurrChainName(String currChainName) {
|
public void setCurrChainId(String currChainName) {
|
||||||
this.currChainName = currChainName;
|
this.currChainName = currChainName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package com.yomahub.liteflow.parser.helper;
|
package com.yomahub.liteflow.parser.helper;
|
||||||
|
|
||||||
import cn.hutool.core.annotation.AnnotationUtil;
|
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.yomahub.liteflow.annotation.*;
|
|
||||||
import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
|
import com.yomahub.liteflow.builder.LiteFlowNodeBuilder;
|
||||||
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
|
import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
|
||||||
import com.yomahub.liteflow.builder.prop.NodePropBean;
|
import com.yomahub.liteflow.builder.prop.NodePropBean;
|
||||||
|
@ -85,6 +83,10 @@ public class ParserHelper {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xml 形式的主要解析过程
|
||||||
|
* @param documentList documentList
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
* xml 形式的主要解析过程
|
* xml 形式的主要解析过程
|
||||||
* @param documentList documentList
|
* @param documentList documentList
|
||||||
|
@ -119,6 +121,31 @@ public class ParserHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void parseDocument(List<Document> documentList, Set<String> chainNameSet, Consumer<Element> parseOneChainConsumer) {
|
||||||
|
//先在元数据里放上chain
|
||||||
|
//先放有一个好处,可以在parse的时候先映射到FlowBus的chainMap,然后再去解析
|
||||||
|
//这样就不用去像之前的版本那样回归调用
|
||||||
|
//同时也解决了不能循环依赖的问题
|
||||||
|
documentList.forEach(document -> {
|
||||||
|
// 解析chain节点
|
||||||
|
List<Element> chainList = document.getRootElement().elements(CHAIN);
|
||||||
|
|
||||||
|
//先在元数据里放上chain
|
||||||
|
chainList.forEach(e -> {
|
||||||
|
//校验加载的 chainName 是否有重复的
|
||||||
|
//TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
FlowBus.addChain(chainName);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// 清空
|
||||||
|
chainNameSet.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public static void parseChainDocument(List<Document> documentList, Set<String> chainNameSet, Consumer<Element> parseOneChainConsumer){
|
public static void parseChainDocument(List<Document> documentList, Set<String> chainNameSet, Consumer<Element> parseOneChainConsumer){
|
||||||
//先在元数据里放上chain
|
//先在元数据里放上chain
|
||||||
|
@ -133,7 +160,7 @@ public class ParserHelper {
|
||||||
chainList.forEach(e -> {
|
chainList.forEach(e -> {
|
||||||
//校验加载的 chainName 是否有重复的
|
//校验加载的 chainName 是否有重复的
|
||||||
//TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
//TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
||||||
String chainName = e.attributeValue(NAME);
|
String chainName = Optional.ofNullable(e.attributeValue(ID)).orElse(e.attributeValue(NAME));
|
||||||
if (!chainNameSet.add(chainName)) {
|
if (!chainNameSet.add(chainName)) {
|
||||||
throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName));
|
throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName));
|
||||||
}
|
}
|
||||||
|
@ -152,7 +179,7 @@ public class ParserHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parseNodeJson(List<JsonNode> flowJsonObjectList) {
|
public static void parseNodeJson(List<JsonNode> flowJsonObjectList) {
|
||||||
for (JsonNode flowJsonNode : flowJsonObjectList) {
|
for (JsonNode flowJsonNode : flowJsonObjectList) {
|
||||||
// 当存在<nodes>节点定义时,解析node节点
|
// 当存在<nodes>节点定义时,解析node节点
|
||||||
if (flowJsonNode.get(FLOW).has(NODES)) {
|
if (flowJsonNode.get(FLOW).has(NODES)) {
|
||||||
|
@ -180,6 +207,33 @@ public class ParserHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void parseJsonNode(List<JsonNode> flowJsonObjectList, Set<String> chainNameSet, Consumer<JsonNode> parseOneChainConsumer) {
|
||||||
|
//先在元数据里放上chain
|
||||||
|
//先放有一个好处,可以在parse的时候先映射到FlowBus的chainMap,然后再去解析
|
||||||
|
//这样就不用去像之前的版本那样回归调用
|
||||||
|
//同时也解决了不能循环依赖的问题
|
||||||
|
flowJsonObjectList.forEach(jsonObject -> {
|
||||||
|
// 解析chain节点
|
||||||
|
Iterator<JsonNode> iterator = jsonObject.get(FLOW).get(CHAIN).elements();
|
||||||
|
//先在元数据里放上chain
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
JsonNode innerJsonObject = iterator.next();
|
||||||
|
//校验加载的 chainName 是否有重复的
|
||||||
|
// TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
||||||
|
//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(chainName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 清空
|
||||||
|
chainNameSet.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parseChainJson(List<JsonNode> flowJsonObjectList, Set<String> chainNameSet, Consumer<JsonNode> parseOneChainConsumer){
|
public static void parseChainJson(List<JsonNode> flowJsonObjectList, Set<String> chainNameSet, Consumer<JsonNode> parseOneChainConsumer){
|
||||||
|
@ -195,12 +249,12 @@ public class ParserHelper {
|
||||||
JsonNode innerJsonObject = iterator.next();
|
JsonNode innerJsonObject = iterator.next();
|
||||||
//校验加载的 chainName 是否有重复的
|
//校验加载的 chainName 是否有重复的
|
||||||
// TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
// TODO 这里是否有个问题,当混合格式加载的时候,2个同名的Chain在不同的文件里,就不行了
|
||||||
String chainName = innerJsonObject.get(NAME).textValue();
|
String chainName = Optional.ofNullable(innerJsonObject.get(ID)).orElse(innerJsonObject.get(NAME)).textValue();
|
||||||
if (!chainNameSet.add(chainName)) {
|
if (!chainNameSet.add(chainName)) {
|
||||||
throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName));
|
throw new ChainDuplicateException(String.format("[chain name duplicate] chainName=%s", chainName));
|
||||||
}
|
}
|
||||||
|
|
||||||
FlowBus.addChain(innerJsonObject.get(NAME).textValue());
|
FlowBus.addChain(chainName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 清空
|
// 清空
|
||||||
|
@ -223,9 +277,9 @@ public class ParserHelper {
|
||||||
*/
|
*/
|
||||||
public static void parseOneChainEl(JsonNode chainNode) {
|
public static void parseOneChainEl(JsonNode chainNode) {
|
||||||
//构建chainBuilder
|
//构建chainBuilder
|
||||||
String chainName = chainNode.get(NAME).textValue();
|
String chainId = Optional.ofNullable(chainNode.get(ID)).orElse(chainNode.get(NAME)).textValue();
|
||||||
String el = chainNode.get(VALUE).textValue();
|
String el = chainNode.get(VALUE).textValue();
|
||||||
LiteFlowChainELBuilder chainELBuilder = LiteFlowChainELBuilder.createChain().setChainName(chainName);
|
LiteFlowChainELBuilder chainELBuilder = LiteFlowChainELBuilder.createChain().setChainId(chainId);
|
||||||
chainELBuilder.setEL(el).build();
|
chainELBuilder.setEL(el).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,10 +290,10 @@ public class ParserHelper {
|
||||||
*/
|
*/
|
||||||
public static void parseOneChainEl(Element e) {
|
public static void parseOneChainEl(Element e) {
|
||||||
//构建chainBuilder
|
//构建chainBuilder
|
||||||
String chainName = e.attributeValue(NAME);
|
String chainId = Optional.ofNullable(e.attributeValue(ID)).orElse(e.attributeValue(NAME));
|
||||||
String text = e.getText();
|
String text = e.getText();
|
||||||
String el = RegexUtil.removeComments(text);
|
String el = RegexUtil.removeComments(text);
|
||||||
LiteFlowChainELBuilder chainELBuilder = LiteFlowChainELBuilder.createChain().setChainName(chainName);
|
LiteFlowChainELBuilder chainELBuilder = LiteFlowChainELBuilder.createChain().setChainId(chainId);
|
||||||
chainELBuilder.setEL(el).build();
|
chainELBuilder.setEL(el).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class ScriptExecuteWrap {
|
||||||
|
|
||||||
private int slotIndex;
|
private int slotIndex;
|
||||||
|
|
||||||
private String currChainName;
|
private String currChainId;
|
||||||
|
|
||||||
private String nodeId;
|
private String nodeId;
|
||||||
|
|
||||||
|
@ -25,12 +25,29 @@ public class ScriptExecuteWrap {
|
||||||
this.slotIndex = slotIndex;
|
this.slotIndex = slotIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated 请使用 {@link #getCurrChainId()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public String getCurrChainName() {
|
public String getCurrChainName() {
|
||||||
return currChainName;
|
return currChainId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param currChainName
|
||||||
|
* @deprecated 请使用{@link #setCurrChainId(String)}
|
||||||
|
*/
|
||||||
public void setCurrChainName(String currChainName) {
|
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() {
|
public String getNodeId() {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -235,13 +236,31 @@ public class Slot{
|
||||||
return (boolean) metaDataMap.get(BREAK_PREFIX + key);
|
return (boolean) metaDataMap.get(BREAK_PREFIX + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param chainName
|
||||||
|
* @Deprecated 请使用 {@link #setChainId(String)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setChainName(String chainName) {
|
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)){
|
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);
|
return (String) metaDataMap.get(CHAIN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue