mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 04:02:09 +08:00
enhancement #IBJO4X 建立统一元数据操作类,所有元数据的操作的入口
This commit is contained in:
@@ -32,6 +32,7 @@ public class ForOperator extends BaseOperator<ForCondition> {
|
||||
else if (objects[0] instanceof Integer) {
|
||||
Integer forCount = OperatorHelper.convert(objects[0], Integer.class);
|
||||
node = new Node();
|
||||
node.setType(NodeTypeEnum.FOR);
|
||||
NodeForComponent nodeForComponent = new NodeForComponent() {
|
||||
@Override
|
||||
public int processFor() {
|
||||
@@ -40,6 +41,7 @@ public class ForOperator extends BaseOperator<ForCondition> {
|
||||
};
|
||||
nodeForComponent.setSelf(nodeForComponent);
|
||||
nodeForComponent.setNodeId(StrUtil.format("LOOP_{}", forCount));
|
||||
nodeForComponent.setType(NodeTypeEnum.FOR);
|
||||
node.setInstance(nodeForComponent);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.lifecycle.LifeCycleHolder;
|
||||
import com.yomahub.liteflow.log.LFLog;
|
||||
import com.yomahub.liteflow.log.LFLoggerManager;
|
||||
import com.yomahub.liteflow.meta.LiteflowMetaOperator;
|
||||
import com.yomahub.liteflow.parser.el.LocalJsonFlowELParser;
|
||||
import com.yomahub.liteflow.parser.el.LocalXmlFlowELParser;
|
||||
import com.yomahub.liteflow.parser.el.LocalYmlFlowELParser;
|
||||
@@ -45,6 +46,7 @@ import com.yomahub.liteflow.core.proxy.LiteFlowProxyUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -379,8 +381,12 @@ public class FlowBus {
|
||||
if (node == null || !node.getType().isScript()) {
|
||||
return;
|
||||
}
|
||||
// 更新脚本
|
||||
// 更新元数据模版中的脚本
|
||||
node.setScript(script);
|
||||
|
||||
// 更新Chain中的Node中的脚本
|
||||
LiteflowMetaOperator.getNodesInAllChain(nodeId).forEach(n -> n.setScript(script));
|
||||
|
||||
ScriptExecutorFactory.loadInstance()
|
||||
.getScriptExecutor(node.getLanguage())
|
||||
.load(nodeId, script);
|
||||
|
||||
@@ -204,6 +204,13 @@ public class Node implements Executable, Cloneable, Rollbackable{
|
||||
if (e instanceof ChainEndException) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 这里再次写一遍的原因是:如果抛错了,还是要看isEnd这个状态,如果为true的话,还是要优先处理ChainEndException
|
||||
if (instance.isEnd()) {
|
||||
String errorInfo = StrUtil.format("[{}] lead the chain to end", instance.getDisplayName());
|
||||
throw new ChainEndException(errorInfo);
|
||||
}
|
||||
|
||||
// 如果组件覆盖了isContinueOnError方法,返回为true,那即便出了异常,也会继续流程
|
||||
else if (getIsContinueOnErrorResult() || instance.isContinueOnError()) {
|
||||
String errorMsg = StrUtil.format("component[{}] cause error,but flow is still go on", id);
|
||||
|
||||
@@ -8,7 +8,10 @@ import com.yomahub.liteflow.flow.element.Node;
|
||||
import com.yomahub.liteflow.flow.instanceId.NodeInstanceIdManageSpiHolder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -30,6 +33,19 @@ public class LiteflowMetaOperator {
|
||||
return FlowBus.getChain(chainId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 找出含有指定nodeId的chain对象
|
||||
* @param nodeId 节点Id
|
||||
* @return Chain对象列表
|
||||
*/
|
||||
public static List<Chain> getChainsContainsNodeId(String nodeId){
|
||||
return FlowBus.getChainMap().values().stream().filter(
|
||||
chain -> getNodes(chain.getChainId()).stream().anyMatch(
|
||||
node -> node.getId().equals(nodeId)
|
||||
)
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新所有的规则
|
||||
* 可以手动重新从ruleSource指定的数据源进行刷新
|
||||
@@ -147,6 +163,19 @@ public class LiteflowMetaOperator {
|
||||
return NodeInstanceIdManageSpiHolder.getInstance().getNodeInstanceIdManageSpi().getNodeInstanceIds(chainId, nodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过nodeId找到在所有Chain中存在的Node对象列表
|
||||
* @param nodeId Node实例id
|
||||
* @return Node对象列表
|
||||
*/
|
||||
public static List<Node> getNodesInAllChain(String nodeId){
|
||||
return FlowBus.getChainMap().values().stream().flatMap(
|
||||
(Function<Chain, Stream<Node>>) chain -> Objects.requireNonNull(getNodes(chain.getChainId(), nodeId)).stream().filter(
|
||||
node -> node.getId().equals(nodeId)
|
||||
)
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新某一个脚本
|
||||
* @param nodeId 节点Id
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
<module>liteflow-script-aviator</module>
|
||||
<module>liteflow-script-java</module>
|
||||
<module>liteflow-script-javax</module>
|
||||
<module>liteflow-script-kotlin</module>
|
||||
<module>liteflow-script-javax-pro</module>
|
||||
<module>liteflow-script-kotlin</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
2
pom.xml
2
pom.xml
@@ -449,9 +449,7 @@
|
||||
<module>liteflow-solon-plugin</module>
|
||||
<module>liteflow-testcase-el</module>
|
||||
<module>liteflow-el-builder</module>
|
||||
<module>liteflow-script-plugin/liteflow-script-javax</module>
|
||||
<module>liteflow-benchmark</module>
|
||||
<module>liteflow-benchmark/liteflow-benchmark-script-javax-pro</module>
|
||||
</modules>
|
||||
|
||||
<distributionManagement>
|
||||
|
||||
Reference in New Issue
Block a user