From ef424a60372f3169b0c0f34846ce28125553b0c5 Mon Sep 17 00:00:00 2001 From: zy <953725892@qq.com> Date: Sun, 8 Oct 2023 23:51:01 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#I7SVZF=20=E7=A7=BB=E9=99=A4abstract?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liteflow/common/ChainConstant.java | 3 --- .../liteflow/parser/helper/ParserHelper.java | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java b/liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java index a550a5c41..8f34d1652 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java @@ -83,9 +83,6 @@ public interface ChainConstant { String NOT = "NOT"; String MAX_WAIT_SECONDS = "maxWaitSeconds"; - - String ABSTRACT = "abstract"; - String EXTENDS = "extends"; } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java index bb44c4375..ce9d5843c 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java @@ -154,7 +154,7 @@ public class ParserHelper { } FlowBus.addChain(chainName); - if(BooleanUtil.toBoolean(e.attributeValue(ABSTRACT))==true){ + if(RegexUtil.isAbstractChain(e.getText())){ abstratChainMap.put(chainName,e); } }); @@ -170,7 +170,8 @@ public class ParserHelper { //首先需要对继承自抽象Chain的chain进行字符串替换 parseImplChain(abstratChainMap, implChainSet, chain); //如果一个chain不为抽象chain,则进行解析 - if(BooleanUtil.toBoolean(chain.attributeValue(ABSTRACT))==false){ + String chainName = Optional.ofNullable(chain.attributeValue(ID)).orElse(chain.attributeValue(NAME)); + if(!abstratChainMap.containsKey(chainName)){ parseOneChainConsumer.accept(chain); } } @@ -235,8 +236,7 @@ public class ParserHelper { } FlowBus.addChain(chainName); - - if(innerJsonObject.hasNonNull(ABSTRACT) && innerJsonObject.get(ABSTRACT).asBoolean()) { + if(RegexUtil.isAbstractChain(innerJsonObject.get(VALUE).textValue())){ abstratChainMap.put(chainName,innerJsonObject); } } @@ -252,7 +252,8 @@ public class ParserHelper { //首先需要对继承自抽象Chain的chain进行字符串替换 parseImplChain(abstratChainMap, implChainSet, chainNode); //如果一个chain不为抽象chain,则进行解析 - if(chainNode.get(ABSTRACT) == null || !chainNode.get(ABSTRACT).asBoolean()){ + String chainName = Optional.ofNullable(chainNode).map(JsonNode::textValue).orElse(null); + if(!abstratChainMap.containsKey(chainName)){ parseOneChainConsumer.accept(chainNode); } } @@ -302,7 +303,7 @@ public class ParserHelper { * @param implChainSet 已经解析过的实现Chain */ private static void parseImplChain(Map abstratChainMap, Set implChainSet, Element chain) { - if(chain.attributeValue(EXTENDS)!=null){ + if(ObjectUtil.isNotNull(chain.attributeValue(EXTENDS))){ String baseChainId = chain.attributeValue(EXTENDS); Element baseChain = abstratChainMap.get(baseChainId); if(baseChain!=null) { @@ -320,7 +321,7 @@ public class ParserHelper { * @param implChainSet 已经解析过的实现Chain */ private static void parseImplChain(Map abstratChainMap, Set implChainSet, JsonNode chainNode) { - if(chainNode.hasNonNull(EXTENDS)){ + if(ObjectUtil.isNotNull(chainNode.hasNonNull(EXTENDS))){ String baseChainId = chainNode.get(EXTENDS).textValue(); JsonNode baseChain= abstratChainMap.get(baseChainId); if(baseChain!=null) { @@ -382,8 +383,7 @@ public class ParserHelper { private static final String REGEX_COMMENT = "(?