mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
enhancement #I5XWL2 数据库插件支持脚本的存储
This commit is contained in:
@@ -33,6 +33,7 @@ public enum NodeTypeEnum {
|
||||
WHILE("while", "循环条件", false, NodeWhileComponent.class),
|
||||
|
||||
BREAK("break", "循环跳出", false, NodeBreakComponent.class),
|
||||
|
||||
SCRIPT("script", "脚本", true, ScriptCommonComponent.class),
|
||||
|
||||
SWITCH_SCRIPT("switch_script", "选择脚本", true, ScriptSwitchComponent.class),
|
||||
@@ -102,21 +103,6 @@ public enum NodeTypeEnum {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据节点类型判断是否是脚本节点
|
||||
*
|
||||
* @param code 节点类型
|
||||
* @return 是否是脚本节点
|
||||
*/
|
||||
public static boolean isScriptNodeType(String code) {
|
||||
return SCRIPT.getCode().equals(code) ||
|
||||
SWITCH_SCRIPT.getCode().equals(code) ||
|
||||
IF_SCRIPT.getCode().equals(code) ||
|
||||
FOR_SCRIPT.getCode().equals(code) ||
|
||||
WHILE_SCRIPT.getCode().equals(code) ||
|
||||
BREAK_SCRIPT.getCode().equals(code);
|
||||
}
|
||||
|
||||
public static NodeTypeEnum guessTypeBySuperClazz(Class<?> clazz) {
|
||||
Class<?> superClazz = clazz;
|
||||
while (true) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
@@ -154,8 +155,13 @@ public class JDBCHelper {
|
||||
String type = getStringFromResultSet(rs, scriptNodeTypeField);
|
||||
String language = getStringFromResultSet(rs, scriptNodeLanguageField);
|
||||
|
||||
if (!NodeTypeEnum.isScriptNodeType(type)) {
|
||||
throw new ELSQLException("is not script node type; node id: " + id);
|
||||
NodeTypeEnum nodeTypeEnum = NodeTypeEnum.getEnumByCode(type);
|
||||
if (Objects.isNull(nodeTypeEnum)){
|
||||
throw new ELSQLException(StrUtil.format("Invalid type value[{}]", type));
|
||||
}
|
||||
|
||||
if (!nodeTypeEnum.isScript()) {
|
||||
throw new ELSQLException(StrUtil.format("The type value[{}] is not a script type", type));
|
||||
}
|
||||
|
||||
result.add(StrFormatter.format(NODE_XML_PATTERN, id, name, type, language, data));
|
||||
@@ -166,7 +172,7 @@ public class JDBCHelper {
|
||||
// 关闭连接
|
||||
close(conn, stmt, rs);
|
||||
}
|
||||
return CollUtil.join(result, StrUtil.CRLF);
|
||||
return CollUtil.join(result, StrUtil.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user