diff --git a/io.sc.engine.rule.client.spring/src/main/java/io/sc/engine/rule/client/spring/util/EngineSpringApplicationContextUtil.java b/io.sc.engine.rule.client.spring/src/main/java/io/sc/engine/rule/client/spring/util/EngineSpringApplicationContextUtil.java new file mode 100644 index 00000000..8a090429 --- /dev/null +++ b/io.sc.engine.rule.client.spring/src/main/java/io/sc/engine/rule/client/spring/util/EngineSpringApplicationContextUtil.java @@ -0,0 +1,62 @@ +package io.sc.engine.rule.client.spring.util; + +import java.lang.reflect.Method; + +import javax.sql.DataSource; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; + +/** + * 决策引擎中用于支持 spring 应用上下文辅助类 + */ +public class EngineSpringApplicationContextUtil { + private static ApplicationContext applicationContext; //静态属性,用于在脚本中直接通过静态类获取 spring 应用上下文 + + /** + * 获取 spring 应用上下文 + * @return spring 应用上下文 + */ + public static ApplicationContext getApplicationContext() { + return applicationContext; + } + + /** + * 设置 spring 应用上下文 + * @param applicationContext spring 应用上下文 + */ + public static void setApplicationContext(ApplicationContext applicationContext) { + EngineSpringApplicationContextUtil.applicationContext =applicationContext; + } + + /** + * 获取默认数据源 + * @return 默认数据源 + */ + public static DataSource getDefaultDataSource() { + return applicationContext.getBean(DataSource.class); + } + + /** + * 获取数据源 + * @param name 数据源名称 + * @return 数据源 + * @throws Exception 违例 + */ + public static DataSource getDataSource(String name) throws Exception { + Object datasourceService =applicationContext.getBean("frDatasourceService"); + Method method =datasourceService.getClass().getMethod("getDatasource", String.class); + return (DataSource)method.invoke(datasourceService,name); + } + + /** + * 获取 spring bean + * @param requiredType bean 类型 + * @return Bean + * @throws BeansException 违例 + * @param 泛型 + */ + public static T getBean(Class requiredType) throws BeansException{ + return applicationContext.getBean(requiredType); + } +} diff --git a/io.sc.engine.rule.client/src/main/java/io/sc/engine/rule/client/runtime/EngineRuntime.java b/io.sc.engine.rule.client/src/main/java/io/sc/engine/rule/client/runtime/EngineRuntime.java new file mode 100644 index 00000000..e56d20df --- /dev/null +++ b/io.sc.engine.rule.client/src/main/java/io/sc/engine/rule/client/runtime/EngineRuntime.java @@ -0,0 +1,39 @@ +package io.sc.engine.rule.client.runtime; + +import java.util.Map; + +import io.sc.engine.rule.client.Executor; +import io.sc.engine.rule.client.runtime.impl.GroovyEngineRuntime; +import io.sc.engine.rule.core.code.impl.support.ResourceResult; +import io.sc.engine.rule.core.code.impl.support.ResourceWrapper; + +public abstract class EngineRuntime { + public static final String GROOVY ="groovy"; + + public static EngineRuntime getInstance(String lang) { + if(GROOVY.equalsIgnoreCase(lang)) { + return GroovyEngineRuntime.getInstance(); + }else { + return null; + } + } + + public static EngineRuntime getInstance() { + return getInstance(GROOVY); + } + + public abstract ResourceResult executeById(Executor executor,String resourceId,ResourceWrapper wrapper,String json) throws Exception; + public abstract ResourceResult executeById(Executor executor,String resourceId,ResourceWrapper wrapper,String subModelCode,String json) throws Exception; + + public abstract ResourceResult executeByCode(Executor executor,String resourceCode,Integer version,ResourceWrapper wrapper,String json) throws Exception; + public abstract ResourceResult executeByCode(Executor executor,String resourceCode,Integer version,ResourceWrapper wrapper,String subModelCode,String json) throws Exception; + + public abstract ResourceResult executeById(Executor executor,String resourceId,ResourceWrapper wrapper,Map map) throws Exception; + public abstract ResourceResult executeById(Executor executor,String resourceId,ResourceWrapper wrapper,String subModelCode,Map map) throws Exception; + + public abstract ResourceResult executeByCode(Executor executor,String resourceCode,Integer version,ResourceWrapper wrapper,Map map) throws Exception; + public abstract ResourceResult executeByCode(Executor executor,String resourceCode,Integer version,ResourceWrapper wrapper,String subModelCode,Map map) throws Exception; + + public abstract void compileById(String resourceId,ResourceWrapper wrapper) throws Exception; + public abstract void compileByCode(String resourceCode,Integer version,ResourceWrapper wrapper) throws Exception; +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/impl/support/processor/ExecutionFlow.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/impl/support/processor/ExecutionFlow.java new file mode 100644 index 00000000..e385326f --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/code/impl/support/processor/ExecutionFlow.java @@ -0,0 +1,363 @@ +package io.sc.engine.rule.core.code.impl.support.processor; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import io.sc.engine.rule.core.mxgraph.parser.ExecutionFlowParser; +import io.sc.engine.rule.core.mxgraph.po.CommandSetNode; +import io.sc.engine.rule.core.mxgraph.po.ConditionNode; +import io.sc.engine.rule.core.mxgraph.po.ConfigurableResourceAbstractNode; +import io.sc.engine.rule.core.mxgraph.po.EdgeNode; +import io.sc.engine.rule.core.mxgraph.po.GraphNode; +import io.sc.engine.rule.core.mxgraph.po.ParallelNode; +import io.sc.engine.rule.core.mxgraph.po.ResourceAbstractNode; +import io.sc.engine.rule.core.mxgraph.po.SubModelAbstractNode; +import io.sc.engine.rule.core.po.model.Parameter; +import io.sc.engine.rule.core.po.model.processor.ExecutionFlowParameterProcessor; +import io.sc.engine.rule.core.util.ExpressionReplacer; + + +public class ExecutionFlow { + public static GraphNode parse(String json) throws Exception{ + if(json!=null && json.trim().length()>1) { + ExecutionFlowParser parser =new ExecutionFlowParser(); + GraphNode result =parser.parse(json); + return result; + } + return null; + } + + /** + * 生成执行流 groovy 代码 + * @param parameter 参数 + * @param processor 参数处理器 + * @return groovy 代码 + * @throws Exception 违例 + */ + public static String generateGroovyCode(Parameter parameter,ExecutionFlowParameterProcessor processor) throws Exception{ + try { + Map methodNameCache =new HashMap(); + GraphNode node =parse(processor.getExecutionFlow()); + return _generateGroovyCode(methodNameCache,parameter,node); + }catch(Exception e) { + throw new RuntimeException("There was a Error when generate " + parameter.getName()+ "'s ExecutionFlow groovy source code.", e); + } + } + + /** + * 生成执行流 groovy 代码 + * @param methodNameCache 方法名缓存,用于在生成 groovy 代码时,去除重复的方法名,通常会发生在多条边指向同一个节点时,该节点产生的方法会出现多次 + * @param parameter 参数 + * @param node 决策树第一个有效节点(即第一个条件节点) + * @return groovy 代码 + */ + private static String _generateGroovyCode(Map methodNameCache,Parameter parameter,GraphNode node) { + if(node!=null) { + StringBuilder sb =new StringBuilder(); + String methodName ="Flow_" + parameter.getCode() + "_" + node.getId(); + if(node instanceof ConditionNode) { + ConditionNode conditionNode =(ConditionNode)node; + if(!methodNameCache.containsKey(methodName)) { + sb.append(generateConditionGroovyCode(methodNameCache,parameter,conditionNode,methodName)); + methodNameCache.put(methodName, null); + } + }else if(node instanceof ParallelNode) { + ParallelNode parallelNode =(ParallelNode)node; + if(!methodNameCache.containsKey(methodName)) { + sb.append(generateParallelGroovyCode(methodNameCache,parameter,parallelNode,methodName)); + methodNameCache.put(methodName, null); + } + }else if(node instanceof CommandSetNode) { + CommandSetNode expressionNode =(CommandSetNode)node; + if(!methodNameCache.containsKey(methodName)) { + sb.append(generateCommandSetGroovyCode(methodNameCache,parameter,expressionNode,methodName)); + methodNameCache.put(methodName, null); + } + }else if(node instanceof ResourceAbstractNode) { + ResourceAbstractNode modelAbstractNode =(ResourceAbstractNode)node; + if(!methodNameCache.containsKey(methodName)) { + sb.append(generateResourceAbstractGroovyCode(methodNameCache,parameter,modelAbstractNode,methodName)); + methodNameCache.put(methodName, null); + } + }else if(node instanceof ConfigurableResourceAbstractNode) { + ConfigurableResourceAbstractNode configurableModelAbstractNode =(ConfigurableResourceAbstractNode)node; + if(!methodNameCache.containsKey(methodName)) { + sb.append(generateConfigurableResourceAbstractGroovyCode(methodNameCache,parameter,configurableModelAbstractNode,methodName)); + methodNameCache.put(methodName, null); + } + }else if(node instanceof SubModelAbstractNode) { + SubModelAbstractNode subModelAbstractNode =(SubModelAbstractNode)node; + if(!methodNameCache.containsKey(methodName)) { + sb.append(generateModelAbstractGroovyCode(methodNameCache,parameter,subModelAbstractNode,methodName)); + methodNameCache.put(methodName, null); + } + } + return sb.toString(); + } + return null; + } + + /** + * 生成执行流条件节点 groovy 代码 + * @param methodNameCache 方法名缓存 + * @param parameter 参数 + * @param conditionNode 条件节点 + * @param methodName 方法名 + * @param returnType 返回值类型 + * @return groovy 代码 + */ + private static String generateConditionGroovyCode(Map methodNameCache,Parameter parameter,ConditionNode node,String methodName) { + StringBuilder sb =new StringBuilder(); + sb.append("\tprivate static void ").append(methodName).append("(Executor executor,Argument ").append(ExpressionReplacer.ARGUMENT_NAME).append("){//条件判断").append("\n"); + List branches =node.getOuts(); //获取条件的所有出口边 + if(branches!=null && branches.size()>0) { + List outs =orderEdges(branches); //对出口边进行排序,有条件的放前面,无条件的放后面 + for(int i=0;i0) { + for(String split : commandSplits) { + sb.append("\t\t\t").append(split).append("\n"); + } + } + } + sb.append("\t\t\t").append("Flow_").append(parameter.getCode()).append("_").append(nexNode.getId()).append("(").append("executor,").append(ExpressionReplacer.ARGUMENT_NAME).append(");").append("\n"); + sb.append("\t\t}"); + } + sb.append("\n\t}\n\n"); + //继续生成后续方法 + for(GraphNode out :outs) { + sb.append(_generateGroovyCode(methodNameCache,parameter,out.getOuts().get(0))); + } + } + return sb.toString(); + } + + /** + * 生成执行流并发网关节点 groovy 代码 + * @param methodNameCache 方法名缓存 + * @param parameter 参数 + * @param conditionNode 条件节点 + * @param methodName 方法名 + * @param returnType 返回值类型 + * @return groovy 代码 + */ + private static String generateParallelGroovyCode(Map methodNameCache,Parameter parameter,ParallelNode node,String methodName) { + StringBuilder sb =new StringBuilder(); + sb.append("\tprivate static void ").append(methodName).append("(Executor executor,Argument ").append(ExpressionReplacer.ARGUMENT_NAME).append("){//并发网关").append("\n"); + List outs =node.getOuts(); //获取条件的所有出口边 + if(outs!=null && outs.size()>0) { + for(int i=0;i methodNameCache,Parameter parameter,CommandSetNode node,String methodName) { + StringBuilder sb =new StringBuilder(); + sb.append("\tprivate static void ").append(methodName).append("(Executor executor,Argument ").append(ExpressionReplacer.ARGUMENT_NAME).append("){//指令集").append("\n"); + String commands =node.getCommands(); + if(commands!=null && !commands.isEmpty()) { + sb.append("\t\t").append(ExpressionReplacer.groovy(commands,null)).append("\n"); + //继续调用后续方法 + List edges =node.getOuts(); //获取条件的所有出口边 + if(edges!=null && edges.size()>0) { + for(GraphNode edge : edges) { + GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点 + sb.append("\t\t").append("Flow_").append(parameter.getCode()).append("_").append(nexNode.getId()).append("(").append("executor,").append(ExpressionReplacer.ARGUMENT_NAME).append(");").append("\n"); + } + } + } + sb.append("\t}").append("\n\n"); + + //继续生成后续方法 + List edges =node.getOuts(); //获取条件的所有出口边 + if(edges!=null && edges.size()>0) { + for(GraphNode edge : edges) { + GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点 + sb.append(_generateGroovyCode(methodNameCache,parameter,nexNode)); + } + } + return sb.toString(); + } + + /** + * 生成执行流模型摘要节点 groovy 代码 + * @param methodNameCache 方法名缓存 + * @param parameter 参数 + * @param expressionNode 表达式节点 + * @param methodName 方法名 + * @param returnType 返回值类型 + * @return 代码 + */ + private static String generateResourceAbstractGroovyCode(Map methodNameCache,Parameter parameter,ResourceAbstractNode node,String methodName) { + StringBuilder sb =new StringBuilder(); + sb.append("\tprivate static void ").append(methodName).append("(Executor executor,Argument ").append(ExpressionReplacer.ARGUMENT_NAME).append("){//资源").append("\n"); + String code =node.getCode(); + String version =node.getVersion(); + if(version==null || version.trim().equals("")) { + version ="null"; + } + sb.append("\t\t").append("ResourceResult result =executor.executeByCode(\"").append(code).append("\",").append(version).append(",arg.toMap())").append(";\n"); + sb.append("\t\t").append("arg.mergeResult(result);").append("\n"); + //继续调用后续方法 + List edges =node.getOuts(); //获取条件的所有出口边 + if(edges!=null && edges.size()>0) { + for(GraphNode edge : edges) { + GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点 + sb.append("\t\t").append("Flow_").append(parameter.getCode()).append("_").append(nexNode.getId()).append("(").append("executor,").append(ExpressionReplacer.ARGUMENT_NAME).append(");").append("\n"); + } + } + sb.append("\t}").append("\n\n"); + + //继续生成后续方法 + edges =node.getOuts(); //获取条件的所有出口边 + if(edges!=null && edges.size()>0) { + for(GraphNode edge : edges) { + GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点 + sb.append(_generateGroovyCode(methodNameCache,parameter,nexNode)); + } + } + return sb.toString(); + } + + /** + * 生成执行流可配置模型摘要节点 groovy 代码 + * @param methodNameCache 方法名缓存 + * @param parameter 参数 + * @param expressionNode 表达式节点 + * @param methodName 方法名 + * @param returnType 返回值类型 + * @return 代码 + */ + private static String generateConfigurableResourceAbstractGroovyCode(Map methodNameCache,Parameter parameter,ConfigurableResourceAbstractNode node,String methodName) { + StringBuilder sb =new StringBuilder(); + sb.append("\tprivate static void ").append(methodName).append("(Executor executor,Argument ").append(ExpressionReplacer.ARGUMENT_NAME).append("){//可配置资源").append("\n"); + String code =node.getCode(); + String version =node.getVersion(); + String inputCommands =node.getInputCommands(); + String outputCommands =node.getOutputCommands(); + if(version==null || version.trim().equals("")) { + version ="null"; + } + + sb.append("\t\t//准备调用资源的输入参数\n"); + sb.append("\t\t").append("Map map =new HashMap();").append("\n"); + sb.append("\t\t").append(ExpressionReplacer.groovy(inputCommands,null).replace("\n", "\n\t\t")).append("\n"); + sb.append("\n"); + sb.append("\t\t//调用资源\n"); + sb.append("\t\t").append("ResourceResult result =executor.executeByCode(\"").append(code).append("\",").append(version).append(",map);").append("\n"); + sb.append("\n"); + sb.append("\t\t//处理资源调用完毕后的输出值\n"); + sb.append("\t\t").append(ExpressionReplacer.groovy(outputCommands,null).replace("\n", "\n\t\t")).append("\n"); + //继续调用后续方法 + List edges =node.getOuts(); //获取条件的所有出口边 + if(edges!=null && edges.size()>0) { + for(GraphNode edge : edges) { + GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点 + sb.append("\t\t").append("Flow_").append(parameter.getCode()).append("_").append(nexNode.getId()).append("(").append("executor,").append(ExpressionReplacer.ARGUMENT_NAME).append(");").append("\n"); + } + } + sb.append("\t}").append("\n\n"); + + //继续生成后续方法 + edges =node.getOuts(); //获取条件的所有出口边 + if(edges!=null && edges.size()>0) { + for(GraphNode edge : edges) { + GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点 + sb.append(_generateGroovyCode(methodNameCache,parameter,nexNode)); + } + } + return sb.toString(); + } + + /** + * 生成执行流子模型节点 groovy 代码 + * @param methodNameCache 方法名缓存 + * @param parameter 参数 + * @param expressionNode 表达式节点 + * @param methodName 方法名 + * @param returnType 返回值类型 + * @return 代码 + */ + private static String generateModelAbstractGroovyCode(Map methodNameCache,Parameter parameter,SubModelAbstractNode node,String methodName) { + StringBuilder sb =new StringBuilder(); + sb.append("\tprivate static void ").append(methodName).append("(Executor executor,Argument ").append(ExpressionReplacer.ARGUMENT_NAME).append("){//模型").append("\n"); + String code =node.getCode(); + sb.append("\t\t").append("").append(code).append("(executor,arg);\n"); + //继续调用后续方法 + List edges =node.getOuts(); //获取条件的所有出口边 + if(edges!=null && edges.size()>0) { + for(GraphNode edge : edges) { + GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点 + sb.append("\t\t").append("Flow_").append(parameter.getCode()).append("_").append(nexNode.getId()).append("(").append("executor,").append(ExpressionReplacer.ARGUMENT_NAME).append(");").append("\n"); + } + } + sb.append("\t}").append("\n\n"); + + //继续生成后续方法 + edges =node.getOuts(); //获取条件的所有出口边 + if(edges!=null && edges.size()>0) { + for(GraphNode edge : edges) { + GraphNode nexNode =edge.getOuts().get(0); //出口边指向的节点 + sb.append(_generateGroovyCode(methodNameCache,parameter,nexNode)); + } + } + + return sb.toString(); + } + + /** + * 对条件边进行排序,将有条件值的排在前面,无条件值的放在后面,以便生成 groovy 代码时,将无条件值的转为 else 语句 + * @param nodes 条件边 + * @return 排序后的条件边 + */ + private static List orderEdges(List nodes){ + List result =new ArrayList(); + for(GraphNode node : nodes) { + if(node instanceof EdgeNode) { + EdgeNode edge =(EdgeNode)node; + String value =edge.getValue(); + if(value!=null && !"".equals(value.trim())) { + result.add(0, edge); + }else { + result.add(edge); + } + } + } + return result; + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/enums/DictionaryType.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/enums/DictionaryType.java new file mode 100644 index 00000000..0d803817 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/enums/DictionaryType.java @@ -0,0 +1,22 @@ +package io.sc.engine.rule.core.enums; + +/** + * 数据字典类型枚举 + * @author wangshaoping + * + */ +public enum DictionaryType { + FOLDER, //文件夹 + JAVA_CLASS, //Java类 + UD_JAVA_CLASS, //自定义Java类 + ENUM; //枚举 + + public int getOrder() { + switch(this) { + case FOLDER: + return 0; + default: + return 1; + } + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/enums/ExecuteMode.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/enums/ExecuteMode.java new file mode 100644 index 00000000..e60df455 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/enums/ExecuteMode.java @@ -0,0 +1,9 @@ +package io.sc.engine.rule.core.enums; + +/** + * 执行模式 + */ +public enum ExecuteMode { + TOP_DOWN, //自上而下执行 + DOWN_TOP //自下而上执行 +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/mxgraph/po/EdgeNode.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/mxgraph/po/EdgeNode.java new file mode 100644 index 00000000..43a685e3 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/mxgraph/po/EdgeNode.java @@ -0,0 +1,106 @@ +package io.sc.engine.rule.core.mxgraph.po; + +/** + * 连接边节点 + * @author wangshaoping + * + */ +public class EdgeNode extends GraphNode{ + private String valueType; //值类型 + private String value; //值 + private String sourceId; //源节点ID + private String targetId; //目标节点ID + private String commands; //命令 + + /** + * 获取值类型 + * @return 值类型 + */ + public String getValueType() { + return valueType; + } + + /** + * 设置值类型 + * @param valueType 值类型 + */ + public void setValueType(String valueType) { + this.valueType = valueType; + } + + /** + * 获取值 + * @return 值 + */ + public String getValue() { + return value; + } + + /** + * 设置值 + * @param value 值 + */ + public void setValue(String value) { + this.value = value; + } + + /** + * 获取源节点ID + * @return 源节点ID + */ + public String getSourceId() { + return sourceId; + } + + /** + * 设置源节点ID + * @param sourceId 源节点ID + */ + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + /** + * 获取目标节点ID + * @return 目标节点ID + */ + public String getTargetId() { + return targetId; + } + + /** + * 设置目标节点ID + * @param targetId 目标节点ID + */ + public void setTargetId(String targetId) { + this.targetId = targetId; + } + + /** + * 获取命令 + * @return 命令 + */ + public String getCommands() { + return commands; + } + + /** + * 设置命令 + * @param commands 命令 + */ + public void setCommands(String commands) { + this.commands = commands; + } + + @Override + public String toString() { + return "EdgeNode [id=" + id + + ", label=" + label + + ", valueType=" + valueType + + ", value=" + value + + ", sourceId=" + sourceId + + ", targetId=" + targetId + + ", commands=" + commands + + ", outs=" + outs + "]"; + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/mxgraph/support/ExecutionFlowMxGraph.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/mxgraph/support/ExecutionFlowMxGraph.java new file mode 100644 index 00000000..2c3eb008 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/mxgraph/support/ExecutionFlowMxGraph.java @@ -0,0 +1,55 @@ +package io.sc.engine.rule.core.mxgraph.support; + +import org.w3c.dom.Element; + +import com.mxgraph.model.mxCell; +import com.mxgraph.model.mxIGraphModel; +import com.mxgraph.view.mxGraph; +import com.mxgraph.view.mxStylesheet; + +/** + * 自定义执行流 mxGraph 类 + * @author wangshaoping + * + */ +public class ExecutionFlowMxGraph extends mxGraph { + public ExecutionFlowMxGraph() { + super(); + } + + public ExecutionFlowMxGraph(mxIGraphModel model, mxStylesheet stylesheet) { + super(model, stylesheet); + } + + public ExecutionFlowMxGraph(mxIGraphModel model) { + super(model); + } + + public ExecutionFlowMxGraph(mxStylesheet stylesheet) { + super(stylesheet); + } + + @Override + + /** + * 覆盖默认实现 + * 用于获取 User Object 节点的 label + */ + public String convertValueToString(Object cell) { + if(cell==null) { + return null; + } + if(cell instanceof mxCell) { + mxCell _cell =(mxCell)cell; + Object value =_cell.getValue(); + if(value!=null) { + if(value instanceof Element) { + Element element =(Element)value; + String label =element.getAttribute("label"); + return HtmlUtil.text(label); + } + } + } + return super.convertValueToString(cell); + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/dictionary/EnumDictionary.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/dictionary/EnumDictionary.java new file mode 100644 index 00000000..6a92ba29 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/dictionary/EnumDictionary.java @@ -0,0 +1,22 @@ +package io.sc.engine.rule.core.po.dictionary; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonTypeName; + +@JsonTypeName("ENUM") +@JsonIgnoreProperties(ignoreUnknown=true) +public class EnumDictionary extends ReleasableDictionary { + protected List items =new ArrayList(); + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/dictionary/EnumItem.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/dictionary/EnumItem.java new file mode 100644 index 00000000..0406ad9b --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/dictionary/EnumItem.java @@ -0,0 +1,52 @@ +package io.sc.engine.rule.core.po.dictionary; + +/** + * 枚举项 + * @author wangshaoping + * + */ +public class EnumItem { + protected String id; //ID + protected String value; //值 + protected String title; //标题 + protected String description; //描述 + protected Integer order; //排序 + protected String config; //配置 + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public Integer getOrder() { + return order; + } + public void setOrder(Integer order) { + this.order = order; + } + public String getConfig() { + return config; + } + public void setConfig(String config) { + this.config = config; + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/lib/processor/EmptyIndicatorProcessor.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/lib/processor/EmptyIndicatorProcessor.java new file mode 100644 index 00000000..d1e083af --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/lib/processor/EmptyIndicatorProcessor.java @@ -0,0 +1,21 @@ +package io.sc.engine.rule.core.po.lib.processor; + +import io.sc.engine.rule.core.enums.ProcessorType; +import io.sc.engine.rule.core.po.lib.IndicatorProcessor; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * 指标处理器(空操作) + * @author wangshaoping + * + */ +@JsonTypeName("EMPTY") +@JsonIgnoreProperties(ignoreUnknown=true) +public class EmptyIndicatorProcessor extends IndicatorProcessor { + @Override + public ProcessorType getType() { + return ProcessorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/lib/validator/EmailIndicatorValidator.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/lib/validator/EmailIndicatorValidator.java new file mode 100644 index 00000000..cf5cc4d5 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/lib/validator/EmailIndicatorValidator.java @@ -0,0 +1,21 @@ +package io.sc.engine.rule.core.po.lib.validator; + +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.core.po.lib.IndicatorValidator; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * 验证器(邮箱地址) + * @author wangshaoping + * + */ +@JsonTypeName("EMAIL") +@JsonIgnoreProperties(ignoreUnknown=true) +public class EmailIndicatorValidator extends IndicatorValidator { + @Override + public ValidatorType getType() { + return ValidatorType.EMAIL; + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/lib/validator/EmptyIndicatorValidator.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/lib/validator/EmptyIndicatorValidator.java new file mode 100644 index 00000000..d627d4b5 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/lib/validator/EmptyIndicatorValidator.java @@ -0,0 +1,21 @@ +package io.sc.engine.rule.core.po.lib.validator; + +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.core.po.lib.IndicatorValidator; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * 验证器(空) + * @author wangshaoping + * + */ +@JsonTypeName("EMPTY") +@JsonIgnoreProperties(ignoreUnknown=true) +public class EmptyIndicatorValidator extends IndicatorValidator { + @Override + public ValidatorType getType() { + return ValidatorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/processor/EmptyParameterProcessor.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/processor/EmptyParameterProcessor.java new file mode 100644 index 00000000..26c7506c --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/processor/EmptyParameterProcessor.java @@ -0,0 +1,21 @@ +package io.sc.engine.rule.core.po.model.processor; + +import io.sc.engine.rule.core.enums.ProcessorType; +import io.sc.engine.rule.core.po.model.ParameterProcessor; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * 模型参数处理器(空操作) + * @author wangshaoping + * + */ +@JsonTypeName("EMPTY") +@JsonIgnoreProperties(ignoreUnknown=true) +public class EmptyParameterProcessor extends ParameterProcessor { + @Override + public ProcessorType getType() { + return ProcessorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/processor/ExecutionFlowParameterProcessor.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/processor/ExecutionFlowParameterProcessor.java new file mode 100644 index 00000000..4122e401 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/processor/ExecutionFlowParameterProcessor.java @@ -0,0 +1,31 @@ +package io.sc.engine.rule.core.po.model.processor; + +import io.sc.engine.rule.core.enums.ProcessorType; +import io.sc.engine.rule.core.po.model.ParameterProcessor; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * 模型参数处理器(执行流) + * @author wangshaoping + * + */ +@JsonTypeName("EXECUTION_FLOW") +@JsonIgnoreProperties(ignoreUnknown=true) +public class ExecutionFlowParameterProcessor extends ParameterProcessor { + private String executionFlow;//执行流 + + @Override + public ProcessorType getType() { + return ProcessorType.EXECUTION_FLOW; + } + + public String getExecutionFlow() { + return executionFlow; + } + + public void setExecutionFlow(String executionFlow) { + this.executionFlow = executionFlow; + } +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/validator/EmailParameterValidator.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/validator/EmailParameterValidator.java new file mode 100644 index 00000000..6deff8c2 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/validator/EmailParameterValidator.java @@ -0,0 +1,17 @@ +package io.sc.engine.rule.core.po.model.validator; + +import io.sc.engine.rule.core.po.model.ParameterValidator; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * 验证器(邮箱地址) + * @author wangshaoping + * + */ +@JsonTypeName("EMAIL") +@JsonIgnoreProperties(ignoreUnknown=true) +public class EmailParameterValidator extends ParameterValidator { + +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/validator/EmptyParameterValidator.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/validator/EmptyParameterValidator.java new file mode 100644 index 00000000..59601997 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/po/model/validator/EmptyParameterValidator.java @@ -0,0 +1,17 @@ +package io.sc.engine.rule.core.po.model.validator; + +import io.sc.engine.rule.core.po.model.ParameterValidator; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * 验证器(空) + * @author wangshaoping + * + */ +@JsonTypeName("EMPTY") +@JsonIgnoreProperties(ignoreUnknown=true) +public class EmptyParameterValidator extends ParameterValidator { + +} diff --git a/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/util/ESql.java b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/util/ESql.java new file mode 100644 index 00000000..889c6f97 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/java/io/sc/engine/rule/core/util/ESql.java @@ -0,0 +1,43 @@ +package io.sc.engine.rule.core.util; + +import java.sql.SQLException; + +import javax.sql.DataSource; + +import groovy.lang.Closure; +import groovy.sql.Sql; + +@SuppressWarnings("rawtypes") +public class ESql { + public static void withInstance(DataSource dataSource,Closure c) throws SQLException { + withDatasourceInstance(dataSource,c); + } + + public static void withInstance(String url,String user,String password,Closure c) throws SQLException { + withJdbcInstance(url,user,password,c); + } + + public static void withDatasourceInstance(DataSource dataSource,Closure c) throws SQLException { + Sql sql =null; + try { + sql =new Sql(dataSource); + c.call(sql); + } finally { + if (sql != null) { + sql.close(); + } + } + } + + public static void withJdbcInstance(String url,String user,String password,Closure c) throws SQLException { + Sql sql =null; + try { + sql = Sql.newInstance(url, user, password); + c.call(sql); + } finally { + if (sql != null) { + sql.close(); + } + } + } +} diff --git a/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/i18n/enums.properties b/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/i18n/enums.properties new file mode 100644 index 00000000..18ac4119 --- /dev/null +++ b/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/i18n/enums.properties @@ -0,0 +1,157 @@ +#================================================ +# \u8D44\u6E90\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ResourceType.FOLDER=Folder +io.sc.engine.rule.core.enums.ResourceType.MODEL=Model +io.sc.engine.rule.core.enums.ResourceType.SCORE_CARD=Score Card + +#================================================ +# \u6A21\u578B\u5206\u7C7B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ModelCategory.QUANTITATIVE=Quantitative +io.sc.engine.rule.core.enums.ModelCategory.QUALITATIVE=Qualitative +io.sc.engine.rule.core.enums.ModelCategory.ADJUSTMENT=Adjustment +io.sc.engine.rule.core.enums.ModelCategory.RULE=Rule +io.sc.engine.rule.core.enums.ModelCategory.OTHER=Other + +#================================================ +# \u6A21\u578B\u6267\u884C\u6A21\u5F0F\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ExecuteMode.TOP_DOWN=Top-Down +io.sc.engine.rule.core.enums.ExecuteMode.DOWN_TOP=Down-Top + +#================================================ +# \u6A21\u578B\u72B6\u6001\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DeployStatus=Deploy Status +io.sc.engine.rule.core.enums.DeployStatus.SKETCH=Sketch +io.sc.engine.rule.core.enums.DeployStatus.HISTORY=History +io.sc.engine.rule.core.enums.DeployStatus.ON_LINE=OnLine +io.sc.engine.rule.core.enums.DeployStatus.OFF_LINE=OffLine +io.sc.engine.rule.core.enums.DeployStatus.APPROVING=Approving + +#================================================ +# \u53C2\u6570\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterType.IN=Input +io.sc.engine.rule.core.enums.ParameterType.IN_OPTION=Input(Option) +io.sc.engine.rule.core.enums.ParameterType.IN_SUB_OUT=Sub Model Output +io.sc.engine.rule.core.enums.ParameterType.INDICATOR=Indicator +io.sc.engine.rule.core.enums.ParameterType.INTERMEDIATE=Intermediate +io.sc.engine.rule.core.enums.ParameterType.RULE_RESULT=Rule Out +io.sc.engine.rule.core.enums.ParameterType.SINGLE_RULE_RESULT=Single Rule Out +io.sc.engine.rule.core.enums.ParameterType.OUT=Out +io.sc.engine.rule.core.enums.ParameterType.CONSTANT=Constant + +#================================================ +# \u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ProcessorType.EMPTY=Empty +io.sc.engine.rule.core.enums.ProcessorType.OPTION_VALUE=Option Value +io.sc.engine.rule.core.enums.ProcessorType.ARITHMETIC=Arithmetic +io.sc.engine.rule.core.enums.ProcessorType.TERNARY=Ternary +io.sc.engine.rule.core.enums.ProcessorType.WHEN_THEN=When-Then +io.sc.engine.rule.core.enums.ProcessorType.RULE=Rule +io.sc.engine.rule.core.enums.ProcessorType.SINGLE_RULE=Single Rule +io.sc.engine.rule.core.enums.ProcessorType.NUMBER_RANGE=Number Range +io.sc.engine.rule.core.enums.ProcessorType.CONDITION_RANGE=Condition Range +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE_2C=Simple Decision Table +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE=Decision Table +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TREE=Decision Tree +io.sc.engine.rule.core.enums.ProcessorType.EXECUTION_FLOW=Execution Flow +io.sc.engine.rule.core.enums.ProcessorType.PMML=PMML +io.sc.engine.rule.core.enums.ProcessorType.GROOVY_SCRIPT=Groovy Script +io.sc.engine.rule.core.enums.ProcessorType.SQL=SQL Asignment Value +io.sc.engine.rule.core.enums.ProcessorType.HTTP_REQUEST=Http Request + +#================================================ +# HTTP \u8BF7\u6C42\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpMethodType.GET=GET +io.sc.engine.rule.core.enums.HttpMethodType.POST=POST +io.sc.engine.rule.core.enums.HttpMethodType.PUT=PUT +io.sc.engine.rule.core.enums.HttpMethodType.DELETE=DELETE +io.sc.engine.rule.core.enums.HttpMethodType.HEAD=HEAD +io.sc.engine.rule.core.enums.HttpMethodType.PATCH=PATCH +io.sc.engine.rule.core.enums.HttpMethodType.OPTIONS=OPTIONS +io.sc.engine.rule.core.enums.HttpMethodType.TRACE=TRACE + +#================================================ +# HTTP \u8BA4\u8BC1\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpAuthorizationType.NONE=No Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.API_KEY=API Key +io.sc.engine.rule.core.enums.HttpAuthorizationType.BASIC_AUTH=Basic Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.BEARER=Bearer Token + +#================================================ +# \u53C2\u6570\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterProcessorType.optionParameterCode=Option Value +io.sc.engine.rule.core.enums.ParameterProcessorType.ARITHMETIC=Arithmetic +io.sc.engine.rule.core.enums.ParameterProcessorType.TERNARY=Ternary +io.sc.engine.rule.core.enums.ParameterProcessorType.WHEN_THEN=When-Then +io.sc.engine.rule.core.enums.ParameterProcessorType.NUMBER_RANGE=Number Range +io.sc.engine.rule.core.enums.ParameterProcessorType.CONDITION_RANGE=Condition Range +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE_2C=Simple Decision Table +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE=Decision Table +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TREE=Decision Tree +io.sc.engine.rule.core.enums.ParameterProcessorType.EXECUTION_FLOW=Execution Flow +io.sc.engine.rule.core.enums.ParameterProcessorType.PMML=PMML +io.sc.engine.rule.core.enums.ParameterProcessorType.SCRIPT=Script + +#================================================ +# \u6570\u636E\u5B57\u5178\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DictionaryType.FOLDER=Folder +io.sc.engine.rule.core.enums.DictionaryType.JAVA_CLASS=Java Class +io.sc.engine.rule.core.enums.DictionaryType.UD_JAVA_CLASS=User Defined Class +io.sc.engine.rule.core.enums.DictionaryType.ENUM=Enumerate + +#================================================ +# \u5E93\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.LibType.INDICATOR=Indicator Lib + +#================================================ +# \u6307\u6807\u9A8C\u8BC1\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ValidatorType.EMPTY=Empty +io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY=Not Empty +io.sc.engine.rule.core.enums.ValidatorType.TRUE=True +io.sc.engine.rule.core.enums.ValidatorType.FALSE=False +io.sc.engine.rule.core.enums.ValidatorType.INTEGER_RANGE=Integer Range +io.sc.engine.rule.core.enums.ValidatorType.DECIMAL_RANGE=Decimal Range +io.sc.engine.rule.core.enums.ValidatorType.EMAIL=Email +io.sc.engine.rule.core.enums.ValidatorType.LENGTH_RANGE=Length Range +io.sc.engine.rule.core.enums.ValidatorType.DATE_RANGE=Date Range +io.sc.engine.rule.core.enums.ValidatorType.PATTERN=Regular Expression + +# \u6307\u6807\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorProcessorType.ARITHMETIC=Arithmetic +io.sc.engine.rule.core.enums.IndicatorProcessorType.TERNARY=Ternary +io.sc.engine.rule.core.enums.IndicatorProcessorType.WHEN_THEN=When-Then +io.sc.engine.rule.core.enums.IndicatorProcessorType.NUMBER_RANGE=Number Range +io.sc.engine.rule.core.enums.IndicatorProcessorType.CONDITION_RANGE=Condition Range +io.sc.engine.rule.core.enums.IndicatorProcessorType.SCRIPT=Script + +# \u6307\u6807\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorType.INTERFACE=Interface +io.sc.engine.rule.core.enums.IndicatorType.INDICATOR=Indicator + +#================================================ +# \u8BC4\u5206\u5361\u53D8\u91CF\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ScoreCardVarType.OPTION=Option +io.sc.engine.rule.core.enums.ScoreCardVarType.NUMBER_RANGE=Range +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_OPTION=Option(Indicator) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_NUMBER_RANGE=Range(Indicator) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_VALUE=Indicator Value +io.sc.engine.rule.core.enums.ScoreCardVarType.RESULT=Result + +#================================================ +# \u6D4B\u8BD5\u7528\u4F8B\u53C2\u6570\u6765\u6E90\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.TestCaseOwnerType.MODEL=Model +io.sc.engine.rule.core.enums.TestCaseOwnerType.SCORE_CARD=Score Card +io.sc.engine.rule.core.enums.TestCaseOwnerType.LIB=Lib \ No newline at end of file diff --git a/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/i18n/enums_tw_CN.properties b/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/i18n/enums_tw_CN.properties new file mode 100644 index 00000000..991c0d3a --- /dev/null +++ b/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/i18n/enums_tw_CN.properties @@ -0,0 +1,159 @@ +#================================================ +# \u8D44\u6E90\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ResourceType.FOLDER=\u6587\u4EF6\u593E +io.sc.engine.rule.core.enums.ResourceType.MODEL=\u6A21\u578B +io.sc.engine.rule.core.enums.ResourceType.SCORE_CARD=\u8A55\u5206\u5361 + +#================================================ +# \u6A21\u578B\u5206\u7C7B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ModelCategory.QUANTITATIVE=\u5B9A\u91CF +io.sc.engine.rule.core.enums.ModelCategory.QUALITATIVE=\u5B9A\u6027 +io.sc.engine.rule.core.enums.ModelCategory.ADJUSTMENT=\u8ABF\u6574\u9805 +io.sc.engine.rule.core.enums.ModelCategory.RULE=\u898F\u5247 +io.sc.engine.rule.core.enums.ModelCategory.OTHER=\u5176\u4ED6 + +#================================================ +# \u6A21\u578B\u6267\u884C\u6A21\u5F0F\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ExecuteMode.TOP_DOWN=\u81EA\u4E0A\u800C\u4E0B +io.sc.engine.rule.core.enums.ExecuteMode.DOWN_TOP=\u81EA\u4E0B\u800C\u4E0A + +#================================================ +# \u6A21\u578B\u72B6\u6001\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DeployStatus=\u767C\u4F48\u72C0\u614B +io.sc.engine.rule.core.enums.DeployStatus.SKETCH=\u8349\u7A3F +io.sc.engine.rule.core.enums.DeployStatus.HISTORY=\u6B77\u53F2 +io.sc.engine.rule.core.enums.DeployStatus.ON_LINE=\u4E0A\u7DDA +io.sc.engine.rule.core.enums.DeployStatus.OFF_LINE=\u4E0B\u7DDA +io.sc.engine.rule.core.enums.DeployStatus.APPROVING=\u5BE9\u6279\u4E2D + +#================================================ +# \u53C2\u6570\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterType.IN=\u8F38\u5165\u503C +io.sc.engine.rule.core.enums.ParameterType.IN_OPTION=\u8F38\u5165\u503C(\u9078\u9805) +io.sc.engine.rule.core.enums.ParameterType.IN_SUB_OUT=\u5B50\u6A21\u578B\u7D50\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.INDICATOR=\u6307\u6A19 +io.sc.engine.rule.core.enums.ParameterType.INTERMEDIATE=\u4E2D\u9593\u503C +io.sc.engine.rule.core.enums.ParameterType.RULE_RESULT=\u898F\u5247\u7D50\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.SINGLE_RULE_RESULT=\u55AE\u898F\u5247\u7D50\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.OUT=\u7D50\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.CONSTANT=\u5E38\u91CF + +#================================================ +# \u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ProcessorType.EMPTY=\u7A7A +io.sc.engine.rule.core.enums.ProcessorType.OPTION_VALUE=\u9078\u9805\u503C +io.sc.engine.rule.core.enums.ProcessorType.ARITHMETIC=\u7B97\u6578\u904B\u7B97 +io.sc.engine.rule.core.enums.ProcessorType.TERNARY=\u4E09\u5143\u64CD\u4F5C +io.sc.engine.rule.core.enums.ProcessorType.WHEN_THEN=When Then \u904B\u7B97 +io.sc.engine.rule.core.enums.ProcessorType.RULE=\u898F\u5247 +io.sc.engine.rule.core.enums.ProcessorType.SINGLE_RULE=\u55AE\u898F\u5247 +io.sc.engine.rule.core.enums.ProcessorType.NUMBER_RANGE=\u6578\u503C\u5206\u6BB5\u51FD\u6578 +io.sc.engine.rule.core.enums.ProcessorType.CONDITION_RANGE=\u689D\u4EF6\u5206\u6BB5\u51FD\u6578 +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE_2C=\u7C21\u55AE\u6C7A\u7B56\u8868 +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE=\u6C7A\u7B56\u8868 +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TREE=\u6C7A\u7B56\u6A39 +io.sc.engine.rule.core.enums.ProcessorType.EXECUTION_FLOW=\u57F7\u884C\u6D41 +io.sc.engine.rule.core.enums.ProcessorType.PMML=\u9810\u6E2C\u6A21\u578B\u6A19\u8A18\u8A9E\u8A00 +io.sc.engine.rule.core.enums.ProcessorType.GROOVY_SCRIPT=Groovy \u8173\u672C\u4EE3\u78BC +io.sc.engine.rule.core.enums.ProcessorType.SQL=SQL \u8CE6\u503C +io.sc.engine.rule.core.enums.ProcessorType.HTTP_REQUEST=Http \u8ACB\u6C42 + +#================================================ +# HTTP \u8BF7\u6C42\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpMethodType.GET=GET +io.sc.engine.rule.core.enums.HttpMethodType.POST=POST +io.sc.engine.rule.core.enums.HttpMethodType.PUT=PUT +io.sc.engine.rule.core.enums.HttpMethodType.DELETE=DELETE +io.sc.engine.rule.core.enums.HttpMethodType.HEAD=HEAD +io.sc.engine.rule.core.enums.HttpMethodType.PATCH=PATCH +io.sc.engine.rule.core.enums.HttpMethodType.OPTIONS=OPTIONS +io.sc.engine.rule.core.enums.HttpMethodType.TRACE=TRACE + +#================================================ +# HTTP \u8BA4\u8BC1\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpAuthorizationType.NONE=No Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.API_KEY=API Key +io.sc.engine.rule.core.enums.HttpAuthorizationType.BASIC_AUTH=Basic Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.BEARER=Bearer Token + +#================================================ +# \u53C2\u6570\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterProcessorType.OPTION_VALUE=\u9078\u9805\u503C +io.sc.engine.rule.core.enums.ParameterProcessorType.ARITHMETIC=\u7B97\u6578\u904B\u7B97 +io.sc.engine.rule.core.enums.ParameterProcessorType.TERNARY=\u4E09\u5143\u64CD\u4F5C +io.sc.engine.rule.core.enums.ParameterProcessorType.WHEN_THEN=When Then \u904B\u7B97 +io.sc.engine.rule.core.enums.ParameterProcessorType.NUMBER_RANGE=\u6578\u503C\u5206\u6BB5\u51FD\u6578 +io.sc.engine.rule.core.enums.ParameterProcessorType.CONDITION_RANGE=\u689D\u4EF6\u5206\u6BB5\u51FD\u6578 +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE_2C=\u7C21\u55AE\u6C7A\u7B56\u8868 +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE=\u6C7A\u7B56\u8868 +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TREE=\u6C7A\u7B56\u6A39 +io.sc.engine.rule.core.enums.ParameterProcessorType.EXECUTION_FLOW=\u57F7\u884C\u6D41 +io.sc.engine.rule.core.enums.ParameterProcessorType.PMML=\u9810\u6E2C\u6A21\u578B\u6A19\u8A18\u8A9E\u8A00 +io.sc.engine.rule.core.enums.ParameterProcessorType.SCRIPT=\u8173\u672C\u4EE3\u78BC + +#================================================ +# \u6570\u636E\u5B57\u5178\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DictionaryType.FOLDER=\u6587\u4EF6\u593E +io.sc.engine.rule.core.enums.DictionaryType.JAVA_CLASS=Java \u985E +io.sc.engine.rule.core.enums.DictionaryType.UD_JAVA_CLASS=\u81EA\u5B9A\u7FA9\u985E +io.sc.engine.rule.core.enums.DictionaryType.ENUM=\u679A\u8209 + +#================================================ +# \u5E93\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.LibType.INDICATOR=\u6307\u6A19\u5EAB + +#================================================ +# \u6307\u6807\u9A8C\u8BC1\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ValidatorType.EMPTY=\u7A7A +io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY=\u975E\u7A7A +io.sc.engine.rule.core.enums.ValidatorType.TRUE=\u771F +io.sc.engine.rule.core.enums.ValidatorType.FALSE=\u5047 +io.sc.engine.rule.core.enums.ValidatorType.INTEGER_RANGE=\u6574\u6578\u7BC4\u570D +io.sc.engine.rule.core.enums.ValidatorType.DECIMAL_RANGE=\u5C0F\u6578\u7BC4\u570D +io.sc.engine.rule.core.enums.ValidatorType.EMAIL=\u90F5\u7BB1 +io.sc.engine.rule.core.enums.ValidatorType.LENGTH_RANGE=\u9577\u5EA6\u7BC4\u570D +io.sc.engine.rule.core.enums.ValidatorType.DATE_RANGE=\u65E5\u671F\u7BC4\u570D +io.sc.engine.rule.core.enums.ValidatorType.PATTERN=\u6B63\u5247\u8868\u9054\u5F0F + +# \u6307\u6807\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorProcessorType.ARITHMETIC=\u7B97\u6578\u904B\u7B97 +io.sc.engine.rule.core.enums.IndicatorProcessorType.TERNARY=\u4E09\u5143\u64CD\u4F5C +io.sc.engine.rule.core.enums.IndicatorProcessorType.WHEN_THEN=When Then \u904B\u7B97 +io.sc.engine.rule.core.enums.IndicatorProcessorType.NUMBER_RANGE=\u6578\u503C\u5206\u6BB5\u51FD\u6578 +io.sc.engine.rule.core.enums.IndicatorProcessorType.CONDITION_RANGE=\u689D\u4EF6\u5206\u6BB5\u51FD\u6578 +io.sc.engine.rule.core.enums.IndicatorProcessorType.DECISION_TABLE_2C=\u7C21\u55AE\u6C7A\u7B56\u8868 +io.sc.engine.rule.core.enums.IndicatorProcessorType.DECISION_TABLE=\u6C7A\u7B56\u8868 +io.sc.engine.rule.core.enums.IndicatorProcessorType.SCRIPT=\u8173\u672C\u4EE3\u78BC + +# \u6307\u6807\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorType.INTERFACE=\u63A5\u53E3 +io.sc.engine.rule.core.enums.IndicatorType.INDICATOR=\u6307\u6A19 + +#================================================ +# \u8BC4\u5206\u5361\u53D8\u91CF\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ScoreCardVarType.OPTION=\u9078\u9805 +io.sc.engine.rule.core.enums.ScoreCardVarType.NUMBER_RANGE=\u5206\u6BB5 +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_OPTION=\u9078\u9805(\u6307\u6A19) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_NUMBER_RANGE=\u5206\u6BB5(\u6307\u6A19) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_VALUE=\u6307\u6A19\u503C +io.sc.engine.rule.core.enums.ScoreCardVarType.RESULT=\u7D50\u679C\u503C + +#================================================ +# \u6D4B\u8BD5\u7528\u4F8B\u53C2\u6570\u6765\u6E90\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.TestCaseOwnerType.MODEL=\u6A21\u578B +io.sc.engine.rule.core.enums.TestCaseOwnerType.SCORE_CARD=\u8A55\u5206\u5361 +io.sc.engine.rule.core.enums.TestCaseOwnerType.LIB=\u6307\u6A19\u5EAB \ No newline at end of file diff --git a/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/i18n/enums_zh_CN.properties b/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/i18n/enums_zh_CN.properties new file mode 100644 index 00000000..1f8169bf --- /dev/null +++ b/io.sc.engine.rule.core/src/main/resources/io/sc/engine/rule/core/i18n/enums_zh_CN.properties @@ -0,0 +1,159 @@ +#================================================ +# \u8D44\u6E90\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ResourceType.FOLDER=\u6587\u4EF6\u5939 +io.sc.engine.rule.core.enums.ResourceType.MODEL=\u6A21\u578B +io.sc.engine.rule.core.enums.ResourceType.SCORE_CARD=\u8BC4\u5206\u5361 + +#================================================ +# \u6A21\u578B\u5206\u7C7B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ModelCategory.QUANTITATIVE=\u5B9A\u91CF +io.sc.engine.rule.core.enums.ModelCategory.QUALITATIVE=\u5B9A\u6027 +io.sc.engine.rule.core.enums.ModelCategory.ADJUSTMENT=\u8C03\u6574\u9879 +io.sc.engine.rule.core.enums.ModelCategory.RULE=\u89C4\u5219 +io.sc.engine.rule.core.enums.ModelCategory.OTHER=\u5176\u4ED6 + +#================================================ +# \u6A21\u578B\u6267\u884C\u6A21\u5F0F\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ExecuteMode.TOP_DOWN=\u81EA\u4E0A\u800C\u4E0B +io.sc.engine.rule.core.enums.ExecuteMode.DOWN_TOP=\u81EA\u4E0B\u800C\u4E0A + +#================================================ +# \u6A21\u578B\u72B6\u6001\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DeployStatus=\u53D1\u5E03\u72B6\u6001 +io.sc.engine.rule.core.enums.DeployStatus.SKETCH=\u8349\u7A3F +io.sc.engine.rule.core.enums.DeployStatus.HISTORY=\u5386\u53F2 +io.sc.engine.rule.core.enums.DeployStatus.ON_LINE=\u4E0A\u7EBF +io.sc.engine.rule.core.enums.DeployStatus.OFF_LINE=\u4E0B\u7EBF +io.sc.engine.rule.core.enums.DeployStatus.APPROVING=\u5BA1\u6279\u4E2D + +#================================================ +# \u53C2\u6570\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterType.IN=\u8F93\u5165\u503C +io.sc.engine.rule.core.enums.ParameterType.IN_OPTION=\u8F93\u5165\u503C(\u9009\u9879) +io.sc.engine.rule.core.enums.ParameterType.IN_SUB_OUT=\u5B50\u6A21\u578B\u7ED3\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.INDICATOR=\u6307\u6807 +io.sc.engine.rule.core.enums.ParameterType.INTERMEDIATE=\u4E2D\u95F4\u503C +io.sc.engine.rule.core.enums.ParameterType.RULE_RESULT=\u89C4\u5219\u7ED3\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.SINGLE_RULE_RESULT=\u5355\u89C4\u5219\u7ED3\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.OUT=\u7ED3\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.CONSTANT=\u5E38\u91CF + +#================================================ +# \u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ProcessorType.EMPTY=\u7A7A +io.sc.engine.rule.core.enums.ProcessorType.OPTION_VALUE=\u9009\u9879\u503C +io.sc.engine.rule.core.enums.ProcessorType.ARITHMETIC=\u7B97\u6570\u8FD0\u7B97 +io.sc.engine.rule.core.enums.ProcessorType.TERNARY=\u4E09\u5143\u64CD\u4F5C +io.sc.engine.rule.core.enums.ProcessorType.WHEN_THEN=When Then \u8FD0\u7B97 +io.sc.engine.rule.core.enums.ProcessorType.RULE=\u89C4\u5219 +io.sc.engine.rule.core.enums.ProcessorType.SINGLE_RULE=\u5355\u89C4\u5219 +io.sc.engine.rule.core.enums.ProcessorType.NUMBER_RANGE=\u6570\u503C\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.ProcessorType.CONDITION_RANGE=\u6761\u4EF6\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE_2C=\u7B80\u5355\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE=\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TREE=\u51B3\u7B56\u6811 +io.sc.engine.rule.core.enums.ProcessorType.EXECUTION_FLOW=\u6267\u884C\u6D41 +io.sc.engine.rule.core.enums.ProcessorType.PMML=\u9884\u6D4B\u6A21\u578B\u6807\u8BB0\u8BED\u8A00 +io.sc.engine.rule.core.enums.ProcessorType.GROOVY_SCRIPT=Groovy \u811A\u672C\u4EE3\u7801 +io.sc.engine.rule.core.enums.ProcessorType.SQL=SQL \u8D4B\u503C +io.sc.engine.rule.core.enums.ProcessorType.HTTP_REQUEST=Http \u8BF7\u6C42 + +#================================================ +# HTTP \u8BF7\u6C42\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpMethodType.GET=GET +io.sc.engine.rule.core.enums.HttpMethodType.POST=POST +io.sc.engine.rule.core.enums.HttpMethodType.PUT=PUT +io.sc.engine.rule.core.enums.HttpMethodType.DELETE=DELETE +io.sc.engine.rule.core.enums.HttpMethodType.HEAD=HEAD +io.sc.engine.rule.core.enums.HttpMethodType.PATCH=PATCH +io.sc.engine.rule.core.enums.HttpMethodType.OPTIONS=OPTIONS +io.sc.engine.rule.core.enums.HttpMethodType.TRACE=TRACE + +#================================================ +# HTTP \u8BA4\u8BC1\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpAuthorizationType.NONE=No Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.API_KEY=API Key +io.sc.engine.rule.core.enums.HttpAuthorizationType.BASIC_AUTH=Basic Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.BEARER=Bearer Token + +#================================================ +# \u53C2\u6570\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterProcessorType.OPTION_VALUE=\u9009\u9879\u503C +io.sc.engine.rule.core.enums.ParameterProcessorType.ARITHMETIC=\u7B97\u6570\u8FD0\u7B97 +io.sc.engine.rule.core.enums.ParameterProcessorType.TERNARY=\u4E09\u5143\u64CD\u4F5C +io.sc.engine.rule.core.enums.ParameterProcessorType.WHEN_THEN=When Then \u8FD0\u7B97 +io.sc.engine.rule.core.enums.ParameterProcessorType.NUMBER_RANGE=\u6570\u503C\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.ParameterProcessorType.CONDITION_RANGE=\u6761\u4EF6\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE_2C=\u7B80\u5355\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE=\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TREE=\u51B3\u7B56\u6811 +io.sc.engine.rule.core.enums.ParameterProcessorType.EXECUTION_FLOW=\u6267\u884C\u6D41 +io.sc.engine.rule.core.enums.ParameterProcessorType.PMML=\u9884\u6D4B\u6A21\u578B\u6807\u8BB0\u8BED\u8A00 +io.sc.engine.rule.core.enums.ParameterProcessorType.SCRIPT=\u811A\u672C\u4EE3\u7801 + +#================================================ +# \u6570\u636E\u5B57\u5178\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DictionaryType.FOLDER=\u6587\u4EF6\u5939 +io.sc.engine.rule.core.enums.DictionaryType.JAVA_CLASS=Java \u7C7B +io.sc.engine.rule.core.enums.DictionaryType.UD_JAVA_CLASS=\u81EA\u5B9A\u4E49\u7C7B +io.sc.engine.rule.core.enums.DictionaryType.ENUM=\u679A\u4E3E + +#================================================ +# \u5E93\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.LibType.INDICATOR=\u6307\u6807\u5E93 + +#================================================ +# \u6307\u6807\u9A8C\u8BC1\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ValidatorType.EMPTY=\u7A7A +io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY=\u975E\u7A7A +io.sc.engine.rule.core.enums.ValidatorType.TRUE=\u771F +io.sc.engine.rule.core.enums.ValidatorType.FALSE=\u5047 +io.sc.engine.rule.core.enums.ValidatorType.INTEGER_RANGE=\u6574\u6570\u8303\u56F4 +io.sc.engine.rule.core.enums.ValidatorType.DECIMAL_RANGE=\u5C0F\u6570\u8303\u56F4 +io.sc.engine.rule.core.enums.ValidatorType.EMAIL=\u90AE\u7BB1 +io.sc.engine.rule.core.enums.ValidatorType.LENGTH_RANGE=\u957F\u5EA6\u8303\u56F4 +io.sc.engine.rule.core.enums.ValidatorType.DATE_RANGE=\u65E5\u671F\u8303\u56F4 +io.sc.engine.rule.core.enums.ValidatorType.PATTERN=\u6B63\u5219\u8868\u8FBE\u5F0F + +# \u6307\u6807\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorProcessorType.ARITHMETIC=\u7B97\u6570\u8FD0\u7B97 +io.sc.engine.rule.core.enums.IndicatorProcessorType.TERNARY=\u4E09\u5143\u64CD\u4F5C +io.sc.engine.rule.core.enums.IndicatorProcessorType.WHEN_THEN=When Then \u8FD0\u7B97 +io.sc.engine.rule.core.enums.IndicatorProcessorType.NUMBER_RANGE=\u6570\u503C\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.IndicatorProcessorType.CONDITION_RANGE=\u6761\u4EF6\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.IndicatorProcessorType.DECISION_TABLE_2C=\u7B80\u5355\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.IndicatorProcessorType.DECISION_TABLE=\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.IndicatorProcessorType.SCRIPT=\u811A\u672C\u4EE3\u7801 + +# \u6307\u6807\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorType.INTERFACE=\u63A5\u53E3 +io.sc.engine.rule.core.enums.IndicatorType.INDICATOR=\u6307\u6807 + +#================================================ +# \u8BC4\u5206\u5361\u53D8\u91CF\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ScoreCardVarType.OPTION=\u9009\u9879 +io.sc.engine.rule.core.enums.ScoreCardVarType.NUMBER_RANGE=\u5206\u6BB5 +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_OPTION=\u9009\u9879(\u6307\u6807) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_NUMBER_RANGE=\u5206\u6BB5(\u6307\u6807) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_VALUE=\u6307\u6807\u503C +io.sc.engine.rule.core.enums.ScoreCardVarType.RESULT=\u7ED3\u679C\u503C + +#================================================ +# \u6D4B\u8BD5\u7528\u4F8B\u53C2\u6570\u6765\u6E90\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.TestCaseOwnerType.MODEL=\u6A21\u578B +io.sc.engine.rule.core.enums.TestCaseOwnerType.SCORE_CARD=\u8BC4\u5206\u5361 +io.sc.engine.rule.core.enums.TestCaseOwnerType.LIB=\u6307\u6807\u5E93 \ No newline at end of file diff --git a/io.sc.engine.rule.frontend/public/webjars/luckysheet/2.1.13/css/EwaAntH.gif b/io.sc.engine.rule.frontend/public/webjars/luckysheet/2.1.13/css/EwaAntH.gif new file mode 100644 index 00000000..d593cf07 Binary files /dev/null and b/io.sc.engine.rule.frontend/public/webjars/luckysheet/2.1.13/css/EwaAntH.gif differ diff --git a/io.sc.engine.rule.frontend/public/webjars/luckysheet/2.1.13/css/EwaAntV.gif b/io.sc.engine.rule.frontend/public/webjars/luckysheet/2.1.13/css/EwaAntV.gif new file mode 100644 index 00000000..44d32409 Binary files /dev/null and b/io.sc.engine.rule.frontend/public/webjars/luckysheet/2.1.13/css/EwaAntV.gif differ diff --git a/io.sc.engine.rule.server/gradle.properties b/io.sc.engine.rule.server/gradle.properties new file mode 100644 index 00000000..e69de29b diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/controller/DictionaryWebController.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/controller/DictionaryWebController.java new file mode 100644 index 00000000..8178e2a5 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/controller/DictionaryWebController.java @@ -0,0 +1,223 @@ +package io.sc.engine.rule.server.dictionary.controller; + +import io.sc.engine.rule.core.code.SourceCode; +import io.sc.engine.rule.core.po.dictionary.Dictionary; +import io.sc.engine.rule.server.dictionary.converter.DictionaryEntityConverter; +import io.sc.engine.rule.server.dictionary.entity.DictionaryEntity; +import io.sc.engine.rule.server.dictionary.repository.DictionaryRepository; +import io.sc.engine.rule.server.dictionary.service.DictionaryService; +import io.sc.engine.rule.server.dictionary.vo.DictionaryVo; +import io.sc.engine.rule.server.model.service.support.ParemterHints; +import io.sc.engine.rule.server.plugins.PluginManager; +import io.sc.engine.rule.server.plugins.item.DictionaryExampleItem; +import io.sc.engine.rule.server.plugins.item.wrapper.DictionaryExampleWrapper; +import io.sc.platform.core.support.KeyValue; +import io.sc.platform.core.util.ObjectMapper4Json; +import io.sc.platform.mvc.controller.support.RestCrudController; +import io.sc.platform.mvc.support.FileDownloader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.*; + +/** + * 数据字典管理器 Controller + * @author wangshaoping + * + */ +@RestController("io.sc.engine.rule.server.dictionary.controller.DictionaryWebController" /* 避免和 io.sc.platform.system.dictionary.controller.DictionaryWebController 冲突 */) +@RequestMapping("/api/re/dictionary") +public class DictionaryWebController extends RestCrudController { + private static final Logger log =LoggerFactory.getLogger(DictionaryWebController.class); + @Autowired private MessageSource messageSource; + + /** + * 深度复制数据字典 + * @param id 被复制的数据字典ID + * @throws Exception 违例 + */ + @PostMapping("deepClone/{id}") + public void deepClone(@PathVariable(name="id",required=true)String id) throws Exception{ + if(StringUtils.hasText(id)) { + service.deepClone(id); + } + } + + /** + * 深度复制数据字典(新数据字典) + * @param id 被复制的数据字典ID + * @throws Exception 违例 + */ + @PostMapping("deepCloneNew/{id}") + public void deepCloneNew(@PathVariable(name="id",required=true)String id) throws Exception{ + if(StringUtils.hasText(id)) { + service.deepCloneNew(id); + } + } + + /** + * 发布数据字典 + * @param id 被发布的数据字典ID + * @return 发布后的数据字典对象 + * @throws Exception 违例 + */ + @PostMapping("deploy/{id}") + public DictionaryEntity deploy(@PathVariable(name="id",required=true)String id) throws Exception{ + return service.deploy(id); + } + + /** + * 获取所有数据字典 + * @param locale 区域 + * @return 所有类型为 Java Class 的数据字典 + * @throws Exception 违例 + */ + @GetMapping("getAllDictionaryMap") + public List> getAllDictionaryMap(Locale locale) throws Exception { + Map map =service.getAllDictionaryMap(locale); + if(map!=null && map.size()>0) { + List> list =new ArrayList>(); + for(String key : map.keySet()) { + list.add(new KeyValue(key,map.get(key))); + } + return list; + } + return Collections.emptyList(); + } + + /** + * 获取数据字典的所有版本 + * @param code 代码 + * @return 字典的所有版本 + * @throws Exception 违例 + */ + @GetMapping("isc/getVersionsByCode") + public List> getVersionsByCode(@RequestParam(name="code",required = false)String code) throws Exception { + if(StringUtils.hasText(code)) { + Map map =service.getVersionsByCode(code); + if(map!=null && map.size()>0) { + List> list =new ArrayList>(); + for(Integer key : map.keySet()) { + list.add(new KeyValue(key,map.get(key))); + } + return list; + } + } + return Collections.emptyList(); + } + + @GetMapping("listParemterHintsByUserDefinedJavaClassDictionaryId/{dictionaryId}") + public ParemterHints listParemterHintsByUserDefinedJavaClassDictionaryId(@PathVariable(name="dictionaryId",required=true)String dictionaryId) throws Exception{ + return service.listParemterHintsByUserDefinedJavaClassDictionaryId(dictionaryId); + } + + /** + * 导入数据字典 + * @param multipartFile 数据字典配置文件 + * @param locale 区域 + * @return 客户端 javascript + * @throws Exception 违例 + */ + @PostMapping("import") + public void imports(@RequestParam(name="file",required=false) MultipartFile multipartFile,Locale locale) throws Exception{ + if(multipartFile!=null && !multipartFile.isEmpty()) { + Dictionary po =null; + //解析文件 + try { + po = ObjectMapper4Json.getMapper().readValue(multipartFile.getInputStream(), Dictionary.class); + } catch (Exception e) { + log.error("",e); + throw e; + } + //导入 + try { + service.imports(DictionaryEntityConverter.fromPo(po)); + }catch (Exception e) { + log.error("",e); + throw e; + } + } + } + + /** + * 导出数据字典 + * @param id 被导出的数据字典ID + * @param request HTTP请求对象 + * @param response HTTP响应对象 + * @throws Exception 违例 + */ + @RequestMapping(value="export/{id}") + @ResponseBody + public void exports(@PathVariable(name="id",required=true)String id,HttpServletRequest request, HttpServletResponse response) throws Exception{ + Dictionary po =service.exports(id); + if(po!=null) { + String json =ObjectMapper4Json.getMapper().writeValueAsString(po); + InputStream in =new ByteArrayInputStream(json.getBytes("UTF-8")); + FileDownloader.download(request, response, po.getName() + ".json", in); + } + } + + /** + * 列出所有数据字典示例贡献项 + * @param request HTTP请求对象 + * @param response HTTP响应对象 + * @param locale 区域 + * @return 所有数据字典示例贡献项 + * @throws Exception 违例 + */ + @RequestMapping(value="isc/listDictionaryExampleContributionItems", method=RequestMethod.GET) + @ResponseBody + public List listDictionaryExampleContributionItems(HttpServletRequest request,HttpServletResponse response,Locale locale) throws Exception{ + List items = PluginManager.getInstance().getDictionaryExampleItemEntries(); + if(items!=null && items.size()>0) { + List result =new ArrayList(); + for(DictionaryExampleItem item : items) { + result.add(DictionaryExampleWrapper.from(item)); + } + updateDictionaryExampleContributionItemTitle(result,locale); + return result; + } + return Collections.emptyList(); + } + + /** + * 创建示例 + * @param contributionIds 示例贡献项ID集合 + * @throws Exception 违例 + */ + @RequestMapping(value="createExample",method=RequestMethod.POST) + @ResponseBody + public void createExample(@RequestBody Set contributionIds) throws Exception{ + service.createExample(contributionIds); + } + + /** + * 生成自定义Java类数据字典示例 JSON + * @param dictionaryId 数据字典ID + * @return 示例 JSON + * @throws Exception 违例 + */ + @RequestMapping(value="generateUserDefinedJavaClassDictionarySampleJsonCode/{dictionaryId}",method=RequestMethod.POST) + @ResponseBody + public SourceCode generateUserDefinedJavaClassDictionarySampleJsonCode(@PathVariable(name="dictionaryId",required=true)String dictionaryId) throws Exception{ + return service.generateUserDefinedJavaClassDictionarySampleJsonCode(dictionaryId); + } + + private void updateDictionaryExampleContributionItemTitle(List items,Locale locale) throws Exception{ + if(items!=null && items.size()>0){ + for(DictionaryExampleWrapper item : items){ + item.setName(messageSource.getMessage(item.getId(), null, locale)); + item.setDescription(messageSource.getMessage(item.getId()+".description", null,locale)); + } + } + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/controller/EnumItemWebController.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/controller/EnumItemWebController.java new file mode 100644 index 00000000..80b1c687 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/controller/EnumItemWebController.java @@ -0,0 +1,19 @@ +package io.sc.engine.rule.server.dictionary.controller; + +import io.sc.engine.rule.server.dictionary.entity.EnumItemEntity; +import io.sc.engine.rule.server.dictionary.repository.EnumItemRepository; +import io.sc.engine.rule.server.dictionary.service.EnumItemService; +import io.sc.engine.rule.server.dictionary.vo.EnumItemVo; +import io.sc.platform.mvc.controller.support.RestCrudController; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * 枚举类型数据字典的枚举项管理器 Controller + * + */ +@Controller +@RequestMapping("/api/re/dictionary/enumItem") +public class EnumItemWebController extends RestCrudController { + +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/converter/DictionaryEntityConverter.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/converter/DictionaryEntityConverter.java new file mode 100644 index 00000000..3809127e --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/converter/DictionaryEntityConverter.java @@ -0,0 +1,231 @@ +package io.sc.engine.rule.server.dictionary.converter; + +import java.util.ArrayList; +import java.util.List; + +import io.sc.engine.rule.core.po.dictionary.Dictionary; +import io.sc.engine.rule.core.po.dictionary.EnumDictionary; +import io.sc.engine.rule.core.po.dictionary.FolderDictionary; +import io.sc.engine.rule.core.po.dictionary.JavaClassDictionary; +import io.sc.engine.rule.core.po.dictionary.ReleasableDictionary; +import io.sc.engine.rule.core.po.dictionary.UserDefinedJavaClassDictionary; +import io.sc.engine.rule.server.dictionary.entity.DictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.EnumDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.EnumItemEntity; +import io.sc.engine.rule.server.dictionary.entity.FolderDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.JavaClassDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.ReleasableDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.UserDefinedJavaClassDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.UserDefinedJavaClassFieldEntity; + +/** + * 数据字典实体转换器,用于实现持久化实体和PO对象之间的互相转换 + * @author wangshaoping + * + */ +public class DictionaryEntityConverter { + /** + * 将实体转换成实体,主要目的解决实体获取懒加载属性值时发生数据库查询(通过spring data 查询的实体其实是一个动态代理对象,对于实体懒加载属性的获取时会发生数据库查询) + * @param entity 实体对象 + * @return 实体对象(和 spring data 实体解耦的实体对象) + */ + public static DictionaryEntity toEntity(DictionaryEntity entity) { + if(entity!=null) { + DictionaryEntity clone =null; + if(entity instanceof FolderDictionaryEntity) {//文件夹 + clone =new FolderDictionaryEntity(); + }else if(entity instanceof JavaClassDictionaryEntity) {//Java Class + JavaClassDictionaryEntity _entity =(JavaClassDictionaryEntity)entity; + JavaClassDictionaryEntity _clone =new JavaClassDictionaryEntity(); + _clone.setJavaClassName(_entity.getJavaClassName()); + clone =_clone; + }else if(entity instanceof UserDefinedJavaClassDictionaryEntity) {//用户定义 Java Class + clone =new UserDefinedJavaClassDictionaryEntity(); + }else if(entity instanceof EnumDictionaryEntity) {//枚举类型 + clone =new EnumDictionaryEntity(); + }else { + clone =new FolderDictionaryEntity(); + } + + if(entity instanceof ReleasableDictionaryEntity) { + ReleasableDictionaryEntity _entity =(ReleasableDictionaryEntity)entity; + ReleasableDictionaryEntity _clone =(ReleasableDictionaryEntity)clone; + _clone.setStatus(_entity.getStatus()); + _clone.setVersion(_entity.getVersion()); + } + + clone.setId(entity.getId()); + clone.setCode(entity.getCode()); + clone.setName(entity.getName()); + clone.setDescription(entity.getDescription()); + clone.setOrder(entity.getOrder()); + + return clone; + } + return null; + } + + /** + * 将实体转换成实体,主要目的解决实体获取懒加载属性值时发生数据库查询(通过spring data 查询的实体其实是一个动态代理对象,对于实体懒加载属性的获取时会发生数据库查询) + * @param entities 实体对象集合 + * @return 实体对象集合(和 spring data 实体解耦的实体对象集合) + */ + public static List toEntity(List entities){ + if(entities!=null && entities.size()>0) { + List clones =new ArrayList(entities.size()); + for(DictionaryEntity entity : entities) { + clones.add(toEntity(entity)); + } + return clones; + } + return null; + } + + /** + * 将实体转换成 PO 对象 + * @param entity 实体对象 + * @return PO 对象 + */ + public static Dictionary toPo(DictionaryEntity entity) { + if(entity!=null) { + Dictionary po =null; + if(entity instanceof FolderDictionaryEntity) {//文件夹 + po =new FolderDictionary(); + }else if(entity instanceof JavaClassDictionaryEntity) {//Java Class + JavaClassDictionaryEntity _entity =(JavaClassDictionaryEntity)entity; + JavaClassDictionary _po =new JavaClassDictionary(); + _po.setJavaClassName(_entity.getJavaClassName()); + po =_po; + }else if(entity instanceof UserDefinedJavaClassDictionaryEntity) {//用户定义 Java Class + UserDefinedJavaClassDictionaryEntity _entity =(UserDefinedJavaClassDictionaryEntity)entity; + UserDefinedJavaClassDictionary _po =new UserDefinedJavaClassDictionary(); + _po.setFields(UserDefinedJavaClassFieldConverter.toPo(_entity.getFields())); + po =_po; + }else if(entity instanceof EnumDictionaryEntity) {//枚举类型 + EnumDictionaryEntity _entity =(EnumDictionaryEntity)entity; + EnumDictionary _po =new EnumDictionary(); + _po.setItems(EnumItemConverter.toPo(_entity.getItems())); + po =_po; + }else { + po =new FolderDictionary(); + } + + if(entity instanceof ReleasableDictionaryEntity) { + ReleasableDictionaryEntity _entity =(ReleasableDictionaryEntity)entity; + ReleasableDictionary _po =(ReleasableDictionary)po; + _po.setStatus(_entity.getStatus()); + _po.setVersion(_entity.getVersion()); + } + + po.setId(entity.getId()); + po.setCode(entity.getCode()); + po.setName(entity.getName()); + po.setDescription(entity.getDescription()); + po.setOrder(entity.getOrder()); + po.setChildren(toPo(entity.getChildren())); + return po; + } + return null; + } + + /** + * 将实体集合转换成 PO 对象集合 + * @param entities 实体集合 + * @return PO 对象集合 + */ + public static List toPo(List entities){ + if(entities!=null && entities.size()>0) { + List pos =new ArrayList(entities.size()); + for(DictionaryEntity entity : entities) { + pos.add(toPo(entity)); + } + return pos; + } + return null; + } + + /** + * 将 PO 对象转换成实体对象 + * @param po PO 对象 + * @return 实体对象 + */ + public static DictionaryEntity fromPo(Dictionary po) { + if(po!=null) { + DictionaryEntity entity =null; + if(po instanceof FolderDictionary) { + entity =new FolderDictionaryEntity(); + }else if(po instanceof JavaClassDictionary) { + JavaClassDictionary _po =(JavaClassDictionary)po; + JavaClassDictionaryEntity _entity =new JavaClassDictionaryEntity(); + _entity.setJavaClassName(_po.getJavaClassName()); + entity =_entity; + }else if(po instanceof UserDefinedJavaClassDictionary) { + UserDefinedJavaClassDictionary _po =(UserDefinedJavaClassDictionary)po; + UserDefinedJavaClassDictionaryEntity _entity =new UserDefinedJavaClassDictionaryEntity(); + + List fields =UserDefinedJavaClassFieldConverter.fromPo(_po.getFields()); + if(fields!=null && fields.size()>0) { + for(UserDefinedJavaClassFieldEntity field : fields) { + field.setDictionary(_entity); + } + } + _entity.setFields(fields); + + entity =_entity; + }else if(po instanceof EnumDictionary) { + EnumDictionary _po =(EnumDictionary)po; + EnumDictionaryEntity _entity =new EnumDictionaryEntity(); + + List items =EnumItemConverter.fromPo(_po.getItems()); + if(items!=null && items.size()>0) { + for(EnumItemEntity item : items) { + item.setDictionary(_entity); + } + } + _entity.setItems(items); + entity =_entity; + }else { + entity =new FolderDictionaryEntity(); + } + + if(po instanceof ReleasableDictionary) { + ReleasableDictionary _po =(ReleasableDictionary)po; + ReleasableDictionaryEntity _entity =(ReleasableDictionaryEntity)entity; + _entity.setStatus(_po.getStatus()); + _entity.setVersion(_po.getVersion()); + } + + entity.setId(po.getId()); + entity.setCode(po.getCode()); + entity.setName(po.getName()); + entity.setDescription(po.getDescription()); + entity.setOrder(po.getOrder()); + + List children =fromPo(po.getChildren()); + if(children!=null && children.size()>0) { + for(DictionaryEntity child : children) { + child.setParent(entity); + } + } + entity.setChildren(children); + return entity; + } + return null; + } + + /** + * 将 PO 对象集合转换成实体对象集合 + * @param pos PO 对象集合 + * @return 实体对象集合 + */ + public static List fromPo(List pos){ + if(pos!=null && pos.size()>0) { + List entities =new ArrayList(pos.size()); + for(Dictionary po : pos) { + entities.add(fromPo(po)); + } + return entities; + } + return null; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/converter/EnumItemConverter.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/converter/EnumItemConverter.java new file mode 100644 index 00000000..072c0f13 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/converter/EnumItemConverter.java @@ -0,0 +1,88 @@ +package io.sc.engine.rule.server.dictionary.converter; + +import java.util.ArrayList; +import java.util.List; + +import io.sc.engine.rule.core.po.dictionary.EnumItem; +import io.sc.engine.rule.server.dictionary.entity.EnumItemEntity; + +/** + * 枚举项转换器,用于实现持久化实体和PO对象之间的互相转换 + * @author wangshaoping + * + */ +public class EnumItemConverter { + /** + * 将实体转换成 PO 对象 + * @param entity 实体对象 + * @return PO 对象 + */ + public static EnumItem toPo(EnumItemEntity entity) { + if(entity!=null) { + EnumItem po =new EnumItem(); + po.setId(entity.getId()); + po.setValue(entity.getValue()); + po.setTitle(entity.getTitle()); + po.setDescription(entity.getDescription()); + po.setOrder(entity.getOrder()); + po.setConfig(entity.getConfig()); + return po; + } + return null; + } + + /** + * 将实体集合转换成 PO 对象集合 + * @param entities 实体集合 + * @return PO 对象集合 + */ + public static List toPo(List entities){ + if(entities!=null && entities.size()>0) { + List pos =new ArrayList(entities.size()); + if(entities!=null && entities.size()>0) { + for(EnumItemEntity entity : entities) { + pos.add(toPo(entity)); + } + } + return pos; + } + return null; + } + + /** + * 将 PO 对象转换成实体对象 + * @param po PO 对象 + * @return 实体对象 + */ + public static EnumItemEntity fromPo(EnumItem po) { + if(po!=null) { + EnumItemEntity entity =new EnumItemEntity(); + entity.setId(po.getId()); + entity.setValue(po.getValue()); + entity.setTitle(po.getTitle()); + entity.setDescription(po.getDescription()); + entity.setOrder(po.getOrder()); + entity.setConfig(po.getConfig()); + return entity; + } + return null; + } + + /** + * 将 PO 对象集合转换成实体对象集合 + * @param pos PO 对象集合 + * @return 实体对象集合 + */ + public static List fromPo(List pos){ + if(pos!=null && pos.size()>0) { + List entities =new ArrayList(pos.size()); + if(pos!=null && pos.size()>0) { + for(EnumItem po : pos) { + entities.add(fromPo(po)); + } + } + return entities; + } + return null; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/entity/DictionaryEntity.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/entity/DictionaryEntity.java new file mode 100644 index 00000000..9d0d8643 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/entity/DictionaryEntity.java @@ -0,0 +1,218 @@ +package io.sc.engine.rule.server.dictionary.entity; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.sc.engine.rule.core.enums.DictionaryType; +import io.sc.engine.rule.server.dictionary.vo.DictionaryVo; +import io.sc.platform.orm.DeepClone; +import io.sc.platform.orm.IdClearable; +import io.sc.platform.orm.entity.AuditorEntity; +import org.hibernate.annotations.GenericGenerator; +import org.springframework.beans.BeanUtils; + +import javax.persistence.*; +import javax.validation.constraints.Size; +import java.util.ArrayList; +import java.util.List; + +/** + * 数据字典实体类 + */ +@Entity(name="io.sc.engine.rule.server.dictionary.entity.DictionaryEntity" /* 避免和 io.sc.platform.system.dictionary.jpa.entity.DictionaryEntity 冲突 */) +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name="TYPE_",discriminatorType=DiscriminatorType.STRING,length=20) +@Table(name="RE_DICTIONARY") +@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="type",defaultImpl=FolderDictionaryEntity.class) +@JsonSubTypes({ + @JsonSubTypes.Type(value=FolderDictionaryEntity.class), //文件夹 + @JsonSubTypes.Type(value=JavaClassDictionaryEntity.class), //Java Class + @JsonSubTypes.Type(value=UserDefinedJavaClassDictionaryEntity.class), //自定义 Java Class 类型的数据字典 + @JsonSubTypes.Type(value=EnumDictionaryEntity.class) //枚举类型的数据字典 +}) +public abstract class DictionaryEntity extends AuditorEntity implements DeepClone, IdClearable { + //类型(用于区分子类) + @Column(name="TYPE_", insertable=false,updatable=false) + @Enumerated(EnumType.STRING) + protected DictionaryType type; + + //ID,主键 + @Id + @GeneratedValue(generator = "system-uuid") + @GenericGenerator(name = "system-uuid", strategy = "uuid2") + @Column(name="ID_", length=36) + @Size(max=36) + protected String id; + + //代码 + @Column(name="CODE_", length=254) + @Size(max=254) + protected String code; + + //名称 + @Column(name="NAME_", length=254) + @Size(max=254) + protected String name; + + //描述 + @Column(name="DESCRIPTION_") + protected String description; + + //排序 + @Column(name="ORDER_") + protected Integer order; + + //父 + @ManyToOne(fetch=FetchType.LAZY) + @JoinColumn(name="PARENT_ID_") + private DictionaryEntity parent; + + //孩子集合 + @OneToMany(mappedBy="parent",cascade= {CascadeType.PERSIST}) + @OrderBy("order") + private List children =new ArrayList(); + + public void toVo(DictionaryVo vo){ + if(vo!=null){ + super.toVo(vo); + vo.setId(this.getId()); + vo.setType(this.getType()); + vo.setCode(this.getCode()); + vo.setName(this.getName()); + vo.setDescription(this.getDescription()); + vo.setOrder(this.getOrder()); + vo.setParent(this.getParent()==null?null:this.getParent().getId()); + } + } + + public DictionaryEntity() {} + public DictionaryEntity(String id) { + this.id =id; + } + + public DictionaryType getType() { + return type; + } + public void setType(DictionaryType type) { + this.type = type; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public Integer getOrder() { + return order; + } + public void setOrder(Integer order) { + this.order = order; + } + public DictionaryEntity getParent() { + return parent; + } + public void setParent(DictionaryEntity parent) { + this.parent = parent; + } + public List getChildren() { + return children; + } + public void setChildren(List children) { + this.children = children; + } + /** + * 重新设置父 + * @param parent 新父 + */ + public void resetParent(DictionaryEntity parent){ + if(this.parent!=parent){ + //首先移除之前的关系 + if(this.parent!=null){ + List children =this.parent.getChildren(); + if(children!=null && children.contains(this)){ + children.remove(this); + } + } + //建立新的父子关系 + if(parent!=null){ + List children =parent.getChildren(); + if(children!=null && !children.contains(this)){ + children.add(this); + } + } + this.parent =parent; + } + } + + /** + * 添加子 + * @param children 子 + */ + public void addChildren(DictionaryEntity... children){ + if(children!=null && children.length>0){ + for(DictionaryEntity child : children){ + child.resetParent(this); + } + } + } + + /** + * 移除子 + * @param children 子 + */ + public void removeChildren(DictionaryEntity... children){ + if(children!=null && children.length>0){ + for(DictionaryEntity child : children){ + if(this.children!=null && this.children.contains(child)){ + this.children.remove(child); + } + child.resetParent(null); + } + } + } + + @Override + public Object deepClone() throws Exception{ + DictionaryEntity entity =this.getClass().newInstance(); + BeanUtils.copyProperties(this, entity, "children"); + //children + List children =this.getChildren(); + if(children!=null && children.size()>0) { + for(DictionaryEntity child : children) { + DictionaryEntity clone =(DictionaryEntity)child.deepClone(); + clone.setParent(entity); + entity.getChildren().add(clone); + } + } + return entity; + } + + @Override + public void clearId() { + this.setId(null); + //children + List children =this.getChildren(); + if(children!=null && children.size()>0) { + for(DictionaryEntity child : children) { + child.clearId(); + } + } + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/entity/EnumDictionaryEntity.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/entity/EnumDictionaryEntity.java new file mode 100644 index 00000000..255229c8 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/entity/EnumDictionaryEntity.java @@ -0,0 +1,131 @@ +package io.sc.engine.rule.server.dictionary.entity; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.sc.engine.rule.core.enums.DictionaryType; +import io.sc.engine.rule.server.dictionary.vo.EnumDictionaryVo; +import io.sc.platform.orm.util.EntityVoUtil; +import org.springframework.beans.BeanUtils; + +import javax.persistence.CascadeType; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.persistence.OneToMany; +import java.util.ArrayList; +import java.util.List; + +/** + * 枚举类型数据字典实体类 + */ +@Entity +@DiscriminatorValue("ENUM") +@JsonTypeName("ENUM") +public class EnumDictionaryEntity extends ReleasableDictionaryEntity { + //包含的枚举项列表 + @OneToMany(mappedBy="dictionary",cascade= {CascadeType.PERSIST}) + protected List items =new ArrayList(); + + @Override + public EnumDictionaryVo toVo() { + EnumDictionaryVo vo =new EnumDictionaryVo(); + super.toVo(vo); + vo.setItems(EntityVoUtil.toVo(this.getItems())); + return vo; + } + + public EnumDictionaryEntity() {} + public EnumDictionaryEntity(String id) { + this.id =id; + } + + @Override + public DictionaryType getType() { + return DictionaryType.ENUM; + } + + public List getItems() { + return items; + } + public void setItems(List items) { + this.items = items; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + EnumDictionaryEntity other = (EnumDictionaryEntity) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + @Override + public Object deepClone() throws Exception { + EnumDictionaryEntity entity =new EnumDictionaryEntity(); + BeanUtils.copyProperties(this, entity, "children","items"); + + //children + List children =this.getChildren(); + if(children!=null && children.size()>0) { + for(DictionaryEntity child : children) { + DictionaryEntity clone =(DictionaryEntity)child.deepClone(); + clone.setParent(entity); + entity.getChildren().add(clone); + } + } + //items + List items =this.getItems(); + if(items!=null && items.size()>0) { + for(EnumItemEntity item : items) { + EnumItemEntity clone =(EnumItemEntity)item.deepClone(); + clone.setDictionary(entity); + entity.getItems().add(clone); + } + } + return entity; + } + + @Override + public void clearId() { + super.clearId(); + //fields + List items =this.getItems(); + if(items!=null && items.size()>0) { + for(EnumItemEntity item : items) { + item.clearId(); + } + } + } + @Override + public String toString() { + return "EnumDictionaryEntity [" + + " type=" + type + + " id=" + id + + ", code=" + code + + ", name=" + name + + ", description=" + description + + ", order=" + order + + ", version=" + version + + + ", creator=" + creator + + ", createDate=" + createDate + + ", lastModifier=" + lastModifier + + ", lastModifyDate=" + lastModifyDate + + "]"; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/entity/EnumItemEntity.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/entity/EnumItemEntity.java new file mode 100644 index 00000000..51931640 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/entity/EnumItemEntity.java @@ -0,0 +1,135 @@ +package io.sc.engine.rule.server.dictionary.entity; + +import io.sc.engine.rule.server.dictionary.vo.EnumItemVo; +import io.sc.platform.orm.DeepClone; +import io.sc.platform.orm.IdClearable; +import io.sc.platform.orm.entity.AuditorEntity; +import org.hibernate.annotations.GenericGenerator; +import org.springframework.beans.BeanUtils; + +import javax.persistence.*; +import javax.validation.constraints.Size; + +/** + * 枚举项实体类 + */ +@Entity +@Table(name="RE_DICTIONARY_ENUM_ITEM") +public class EnumItemEntity extends AuditorEntity implements DeepClone, IdClearable { + //ID,主键 + @Id + @GeneratedValue(generator = "system-uuid") + @GenericGenerator(name = "system-uuid", strategy = "uuid2") + @Column(name="ID_", length=36) + @Size(max=36) + protected String id; + + //值 + @Column(name="VALUE_") + protected String value; + + //标题 + @Column(name="TITLE_", length=1024) + protected String title; + + //描述 + @Column(name="DESCRIPTION_", length=1024) + @Size(max=255) + protected String description; + + //排序 + @Column(name="ORDER_") + protected Integer order; + + //配置 + @Column(name="CONFIG_") + protected String config; + + //所属选项字典 + @ManyToOne(fetch=FetchType.LAZY) + @JoinColumn(name="DICTIONARY_ID_") + protected DictionaryEntity dictionary; + + @Override + public EnumItemVo toVo() { + EnumItemVo vo =new EnumItemVo(); + super.toVo(vo); + vo.setId(this.getId()); + vo.setValue(this.getValue()); + vo.setTitle(this.getTitle()); + vo.setDescription(this.getDescription()); + vo.setOrder(this.getOrder()); + vo.setConfig(this.getConfig()); + vo.setDictionary(this.getDictionary()==null?null:this.getDictionary().getId()); + return vo; + } + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public Integer getOrder() { + return order; + } + public void setOrder(Integer order) { + this.order = order; + } + public String getConfig() { + return config; + } + public void setConfig(String config) { + this.config = config; + } + public DictionaryEntity getDictionary() { + return dictionary; + } + public void setDictionary(DictionaryEntity dictionary) { + this.dictionary = dictionary; + } + public EnumItemEntity() {} + public EnumItemEntity(String id) { + this.id =id; + } + + public Object deepClone() { + EnumItemEntity entity =new EnumItemEntity(); + BeanUtils.copyProperties(this, entity); + return entity; + } + + @Override + public void clearId() { + this.setId(null); + } + @Override + public String toString() { + return "EnumItemEntity [" + + "id=" + id + + ", value=" + value + + ", title=" + title + + ", description=" + description + + ", order=" + order + + ", config=" + config + + "]"; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/exception/EnumItemEntityAlreadyExistsException.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/exception/EnumItemEntityAlreadyExistsException.java new file mode 100644 index 00000000..da5f6ce9 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/exception/EnumItemEntityAlreadyExistsException.java @@ -0,0 +1,26 @@ +package io.sc.engine.rule.server.dictionary.exception; + +/** + * 数据字典枚举项已经存在违例类 + */ +public class EnumItemEntityAlreadyExistsException extends RuntimeException{ + public EnumItemEntityAlreadyExistsException() { + super(); + } + + public EnumItemEntityAlreadyExistsException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public EnumItemEntityAlreadyExistsException(String message, Throwable cause) { + super(message, cause); + } + + public EnumItemEntityAlreadyExistsException(String message) { + super(message); + } + + public EnumItemEntityAlreadyExistsException(Throwable cause) { + super(cause); + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/repository/DictionaryRepository.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/repository/DictionaryRepository.java new file mode 100644 index 00000000..6df5a8d8 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/repository/DictionaryRepository.java @@ -0,0 +1,88 @@ +package io.sc.engine.rule.server.dictionary.repository; + +import java.util.List; + +import org.springframework.context.annotation.Bean; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import io.sc.engine.rule.core.enums.DeployStatus; +import io.sc.engine.rule.server.dictionary.entity.DictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.EnumDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.FolderDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.JavaClassDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.ReleasableDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.UserDefinedJavaClassDictionaryEntity; +import io.sc.platform.orm.repository.DaoRepository; +import org.springframework.stereotype.Service; + +@Service("io.sc.engine.rule.server.dictionary.repository.DictionaryRepository" /* 避免和 io.sc.platform.system.dictionary.jpa.repository.DictionaryEntity 冲突 */) +public interface DictionaryRepository extends DaoRepository{ + //==================================================================================== + // DictionaryEntity + //==================================================================================== + @Query("select e from io.sc.engine.rule.server.dictionary.entity.DictionaryEntity e where e.parent.id is null") + public List findRootDictionaries(); + + //==================================================================================== + // DictionaryEntity <-- FolderDictionaryEntity + //==================================================================================== + @Query("select e from FolderDictionaryEntity e where e.id=:id") + public FolderDictionaryEntity findFolderById(@Param("id") String id); + + @Query("select e from FolderDictionaryEntity e where e.parent.id=:parentId and e.name=:name") + public List findFolderByNameWithParentId(@Param("name") String name,@Param("parentId") String parentId); + + @Query("select e from FolderDictionaryEntity e where e.parent.id is null and e.name=:name") + public List findFolderByNameWithNullParentId(@Param("name") String name); + + //==================================================================================== + // DictionaryEntity <-- ReleasableDictionaryEntity + @Query("select e from ReleasableDictionaryEntity e") + public List findReleasableDictionaries(); + + //==================================================================================== + @Query("select e from ReleasableDictionaryEntity e where e.id=:id") + public ReleasableDictionaryEntity findReleasableDictionaryById(@Param("id") String id); + + @Query("select e from ReleasableDictionaryEntity e where e.code=:code") + public List findReleasableDictionaryByCode(@Param("code")String code); + + @Query("select e from ReleasableDictionaryEntity e where e.code=:code and e.name=:name") + public List findReleasableDictionaryByCodeAndName(@Param("code")String code,@Param("name")String name); + + @Query("select e from ReleasableDictionaryEntity e where e.code=:code or e.name=:name") + public List findReleasableDictionaryByCodeOrName(@Param("code")String code,@Param("name")String name); + + @Query("select e from ReleasableDictionaryEntity e where e.code=:code and e.status=:status") + public List findReleasableDictionaryByCodeAndStatus(@Param("code")String code,@Param("status")DeployStatus status); + + @Query("select e from ReleasableDictionaryEntity e where e.code=:code and e.version=:version") + public ReleasableDictionaryEntity findReleasableDictionaryByCodeAndVersion(@Param("code")String code,@Param("version")Integer version); + + @Query("select max(e.version)+1 from ReleasableDictionaryEntity e where e.code=:code") + public Integer getReleasableDictionaryNextVersion(@Param("code") String code); + + @Query("select e from ReleasableDictionaryEntity e where e.code=:code order by e.version") + public List findReleasableDictionaryByCodeOrderByVersion(@Param("code")String code); + + @Query("select e from ReleasableDictionaryEntity e order by e.version") + public List findReleasableDictionaryByOrderByVersion(); + + //==================================================================================== + // LibEntity <-- ReleasableDictionaryEntity <-- JavaClassDictionaryEntity + //==================================================================================== + @Query("select e from JavaClassDictionaryEntity e where e.id=:id") + public JavaClassDictionaryEntity findJavaClassDictionaryById(@Param("id") String id); + + //==================================================================================== + // LibEntity <-- ReleasableDictionaryEntity <-- EnumDictionaryEntity + //==================================================================================== + @Query("select e from EnumDictionaryEntity e where e.id=:id") + public EnumDictionaryEntity findEnumDictionaryById(@Param("id") String id); + + //==================================================================================== + // LibEntity <-- ReleasableDictionaryEntity <-- UserDefinedJavaClassDictionaryEntity + //==================================================================================== + @Query("select e from UserDefinedJavaClassDictionaryEntity e where e.id=:id") + public UserDefinedJavaClassDictionaryEntity findUserDefinedJavaClassDictionaryById(@Param("id") String id); +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/repository/EnumDictionaryRepository.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/repository/EnumDictionaryRepository.java new file mode 100644 index 00000000..7abf3e6b --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/repository/EnumDictionaryRepository.java @@ -0,0 +1,8 @@ +package io.sc.engine.rule.server.dictionary.repository; + +import io.sc.engine.rule.server.dictionary.entity.EnumDictionaryEntity; +import io.sc.platform.orm.repository.DaoRepository; + +public interface EnumDictionaryRepository extends DaoRepository{ + +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/repository/EnumItemRepository.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/repository/EnumItemRepository.java new file mode 100644 index 00000000..d7bc881d --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/repository/EnumItemRepository.java @@ -0,0 +1,11 @@ +package io.sc.engine.rule.server.dictionary.repository; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import io.sc.engine.rule.server.dictionary.entity.EnumItemEntity; +import io.sc.platform.orm.repository.DaoRepository; + +public interface EnumItemRepository extends DaoRepository{ + @Query("select max(e.order)+1 from EnumItemEntity e where e.dictionary.id=:dictionaryId") + public Integer getNextOrder(@Param("dictionaryId") String dictionaryId); +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/DictionaryService.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/DictionaryService.java new file mode 100644 index 00000000..206c76eb --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/DictionaryService.java @@ -0,0 +1,142 @@ +package io.sc.engine.rule.server.dictionary.service; + +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import io.sc.engine.rule.core.code.SourceCode; +import io.sc.engine.rule.core.po.dictionary.Dictionary; +import io.sc.engine.rule.server.dictionary.entity.DictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.ReleasableDictionaryEntity; +import io.sc.engine.rule.server.dictionary.repository.DictionaryRepository; +import io.sc.engine.rule.server.model.service.support.ParemterHints; +import io.sc.engine.rule.server.util.CodeAndNameMapping; +import io.sc.platform.orm.service.DaoService; + +/** + * 数据字典服务接口 + */ +public interface DictionaryService extends DaoService{ + + /** + * 深度克隆数据字典实体 + * @param id 数据字典实体ID + * @return 克隆后的数据字典实体 + * @throws Exception 违例 + */ + public DictionaryEntity deepClone(String id) throws Exception; + + /** + * 深度克隆数据字典实体(新数据字典) + * @param id 数据字典实体ID + * @return 克隆后的数据字典实体 + * @throws Exception 违例 + */ + public DictionaryEntity deepCloneNew(String id) throws Exception; + + /** + * 发布数据字典实体 + * @param id 数据字典实体ID + * @return 发布数据字典实体 + * @throws Exception 违例 + */ + public DictionaryEntity deploy(String id) throws Exception; + + /** + * 获取所有数据字典 Map(key: code; value: name),示例如下: + * java.lang.String : 字符串 //系统内建类型 + * Student : 学生 //用户自定义类型 + * Sex : 性别 //枚举类型 + * @param locale 区域 + * @return 所有数据字典 Map + * @throws Exception 违例 + */ + public Map getAllDictionaryMap(Locale locale) throws Exception; + + /** + * 获取所有数据字典 Map(key: code; value: name) Json 字符串 + * @param locale 区域 + * @return 数据字典 Map(key: code; value: name) Json 字符串 + * @throws Exception 违例 + */ + public String getAllDictionaryMapJsonString(Locale locale) throws Exception; + + /** + * 获取数据字典版本 + * @param code 数据字典代码 + * @return 数据字典版本 + * @throws Exception 违例 + */ + public Map getVersionsByCode(String code) throws Exception; + + /** + * 通过资源ID获取该资源引用的所有数据字典实体集合 + * @param resourceId 资源ID + * @return 资源引用的所有数据字典实体集合 + * @throws Exception 违例 + */ + public List findReleasableDictionaryEntitiesByResourceId(String resourceId) throws Exception; + + /** + * 通过指标库ID获取该指标库引用的所有数据字典实体集合 + * @param libId 库ID + * @return 指标库引用的所有数据字典实体集合 + * @throws Exception 违例 + */ + public List findReleasableDictionaryEntitiesByLibId(String libId) throws Exception; + + /** + * 导出指定的数据字典 + * @param id 数据字典ID + * @return 数据字典 PO 对象 + * @throws Exception 违例 + */ + public Dictionary exports(String id) throws Exception; + + /** + * 导入数据字典 + * @param entity 数据字典实体对象 + * @throws Exception 违例 + */ + public void imports(DictionaryEntity entity) throws Exception; + + /** + * 创建数据字典示例 + * @param contributionIds 数据字典定义贡献项ID集合 + * @throws Exception 违例 + */ + public void createExample(Set contributionIds) throws Exception; + + /** + * 创建数据字典示例 + * @param contributionId 数据字典定义贡献项ID + * @throws Exception 违例 + */ + public void createExample(String contributionId) throws Exception; + + /** + * 生成自定义Java类数据字典示例 JSON + * @param dictionaryId 数据字典ID + * @return 示例 JSON + * @throws Exception 违例 + */ + public SourceCode generateUserDefinedJavaClassDictionarySampleJsonCode(String dictionaryId) throws Exception; + + /** + * 通过自定义Java类数据字典ID获取自定义Java类字段名称列表 + * @param dictionaryId 自定义Java类数据字典ID + * @return 自定义Java类字段名称列表 + * @throws Exception 违例 + */ + public ParemterHints listParemterHintsByUserDefinedJavaClassDictionaryId(String dictionaryId) throws Exception; + + /** + * 通过自定义Java类数据字典ID获取自定义Java类字段的名称和代码mapping + * @param dictionaryId 参数ID + * @return 自定义Java类字段的名称和代码mapping + * @throws Exception 违例 + */ + public CodeAndNameMapping loadCodeAndNameMappingByUserDefinedJavaClassDictionaryId(String dictionaryId) throws Exception; + +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/EnumItemService.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/EnumItemService.java new file mode 100644 index 00000000..16f08f54 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/EnumItemService.java @@ -0,0 +1,9 @@ +package io.sc.engine.rule.server.dictionary.service; + +import io.sc.engine.rule.server.dictionary.entity.EnumItemEntity; +import io.sc.engine.rule.server.dictionary.repository.EnumItemRepository; +import io.sc.platform.orm.service.DaoService; + +public interface EnumItemService extends DaoService{ + +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/impl/DictionaryServiceImpl.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/impl/DictionaryServiceImpl.java new file mode 100644 index 00000000..95579cba --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/impl/DictionaryServiceImpl.java @@ -0,0 +1,535 @@ +package io.sc.engine.rule.server.dictionary.service.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.sc.engine.rule.core.code.SourceCode; +import io.sc.engine.rule.core.enums.DeployStatus; +import io.sc.engine.rule.core.enums.LibType; +import io.sc.engine.rule.core.enums.ResourceType; +import io.sc.engine.rule.core.enums.ValueType; +import io.sc.engine.rule.core.po.dictionary.Dictionary; +import io.sc.engine.rule.core.util.Strings; +import io.sc.engine.rule.server.dictionary.converter.DictionaryEntityConverter; +import io.sc.engine.rule.server.dictionary.entity.*; +import io.sc.engine.rule.server.dictionary.exception.DictionaryAlreadyExistsException; +import io.sc.engine.rule.server.dictionary.exception.FolderAlreadyExistsException; +import io.sc.engine.rule.server.dictionary.exception.JavaClassNotExistsException; +import io.sc.engine.rule.server.dictionary.repository.DictionaryRepository; +import io.sc.engine.rule.server.dictionary.service.DictionaryService; +import io.sc.engine.rule.server.dictionary.service.support.DictionaryEntityChangedEvent; +import io.sc.engine.rule.server.lib.entity.IndicatorEntity; +import io.sc.engine.rule.server.lib.entity.IndicatorLibEntity; +import io.sc.engine.rule.server.lib.entity.LibEntity; +import io.sc.engine.rule.server.lib.entity.ReleasableLibEntity; +import io.sc.engine.rule.server.lib.service.LibService; +import io.sc.engine.rule.server.model.entity.ModelEntity; +import io.sc.engine.rule.server.model.entity.ParameterEntity; +import io.sc.engine.rule.server.model.service.ModelService; +import io.sc.engine.rule.server.model.service.support.ParemterHints; +import io.sc.engine.rule.server.plugins.PluginManager; +import io.sc.engine.rule.server.plugins.item.DictionaryExampleItem; +import io.sc.engine.rule.server.resource.entity.ModelResourceEntity; +import io.sc.engine.rule.server.resource.entity.ResourceEntity; +import io.sc.engine.rule.server.resource.service.ResourceService; +import io.sc.engine.rule.server.util.CodeAndNameMapping; +import io.sc.platform.core.enums.AuditLogAction; +import io.sc.platform.core.util.ObjectMapper4Json; +import io.sc.platform.orm.entity.support.EntityChangedEventType; +import io.sc.platform.orm.service.impl.DaoServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.MessageSource; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.util.*; + +@Service("reDictionaryService") +public class DictionaryServiceImpl extends DaoServiceImpl implements DictionaryService{ + @Autowired private ApplicationContext applicationContext; + @Autowired private MessageSource messageSource; + @Autowired private ObjectMapper jsonObjectMapper; + @Autowired private ResourceService resourceService; + @Autowired private ModelService modelService; + @Autowired private LibService libService; + @Autowired private DictionaryService dictionaryService; + + @Override + @Transactional + public DictionaryEntity add(DictionaryEntity entity) throws Exception { + if(entity==null){ + throw exceptionProvider.getCreateNullObjectException(); + } + //规范代码和名称 + if(!StringUtils.hasText(entity.getCode())) { + entity.setCode("D"+System.currentTimeMillis()); + } + entity.setName(Strings.replaceCR_LF(entity.getName())); //去除名称中的回车换行,通常在粘贴时会出现回车换行 + + checkConstraint(AuditLogAction.ADD,entity); + + if(entity instanceof ReleasableDictionaryEntity) { + ReleasableDictionaryEntity releasableDictionaryEntity =(ReleasableDictionaryEntity)entity; + Integer nextVersion =repository.getReleasableDictionaryNextVersion(releasableDictionaryEntity.getCode()); + releasableDictionaryEntity.setVersion(nextVersion==null?1:nextVersion); + releasableDictionaryEntity.setStatus(DeployStatus.SKETCH); + } + + DictionaryEntity newEntity =super.add(entity); + + //通知其他实体进行相应的更新 + applicationContext.publishEvent(new DictionaryEntityChangedEvent(EntityChangedEventType.ADD,null, newEntity)); + + return newEntity; + } + + @Override + @Transactional + public DictionaryEntity update(String primaryKey, DictionaryEntity entity) throws Exception { + if(primaryKey==null){ + throw exceptionProvider.getUpdateNullOldObjectPrimaryKeyException(); + } + if(entity==null){ + throw exceptionProvider.getUpdateNullNewObjectException(); + } + + //规范代码和名称 + if(!StringUtils.hasText(entity.getCode())) { + entity.setCode("D"+System.currentTimeMillis()); + } + entity.setName(Strings.replaceCR_LF(entity.getName())); //去除名称中的回车换行,通常在粘贴时会出现回车换行 + + checkConstraint(AuditLogAction.UPDATE,entity); + + if(entity instanceof ReleasableDictionaryEntity) {//数据字典 + ReleasableDictionaryEntity oldEntity =repository.findReleasableDictionaryById(primaryKey); + if(oldEntity==null) { + throw exceptionProvider.getUpdateOldObjectNotExistsException(primaryKey); + } + //通知其他实体进行相应的更新 + //applicationContext.publishEvent(new DictionaryEntityChangedEvent(EntityChangedEventType.UPDATE,oldEntity, (ReleasableDictionaryEntity)entity)); + return super.update(primaryKey, entity); + }else { + DictionaryEntity oldEntity =findById(primaryKey); + if(oldEntity==null) { + throw exceptionProvider.getUpdateOldObjectNotExistsException(primaryKey); + } + //通知其他实体进行相应的更新 + applicationContext.publishEvent(new DictionaryEntityChangedEvent(EntityChangedEventType.UPDATE,oldEntity, entity)); + return super.update(primaryKey, entity); + } + } + + @Override + public String remove(String primaryKey) throws Exception { + DictionaryEntity oldEntity =findById(primaryKey); + //通知其他实体进行相应的更新 + applicationContext.publishEvent(new DictionaryEntityChangedEvent(EntityChangedEventType.DELETE,oldEntity, null)); + return super.remove(primaryKey); + } + + @Override + public List remove(List primaryKeys) throws Exception { + if(primaryKeys!=null && !primaryKeys.isEmpty()) { + List willBeDeleted =repository.findAllById(primaryKeys); + if(willBeDeleted!=null && willBeDeleted.size()>0) { + for(DictionaryEntity entity : willBeDeleted) { + //通知其他实体进行相应的更新 + applicationContext.publishEvent(new DictionaryEntityChangedEvent(EntityChangedEventType.DELETE,entity, null)); + } + } + } + return super.remove(primaryKeys); + } + + @Override + public DictionaryEntity deepClone(String id) throws Exception { + if(StringUtils.hasText(id)) { + DictionaryEntity entity =repository.getOne(id); + if(entity!=null) { + DictionaryEntity cloneEntity =(DictionaryEntity)entity.deepClone(); + cloneEntity.clearId(); + if(cloneEntity instanceof ReleasableDictionaryEntity) { + ReleasableDictionaryEntity versionDictionaryEntity =(ReleasableDictionaryEntity)cloneEntity; + versionDictionaryEntity.setStatus(DeployStatus.SKETCH); + Integer nextVersion =repository.getReleasableDictionaryNextVersion(versionDictionaryEntity.getCode()); + if(nextVersion!=null) { + versionDictionaryEntity.setVersion(nextVersion); + }else { + versionDictionaryEntity.setVersion(1); + } + } + DictionaryEntity newEntity =repository.save(cloneEntity); + + //通知其他实体进行相应的更新 + applicationContext.publishEvent(new DictionaryEntityChangedEvent(EntityChangedEventType.ADD,null, newEntity)); + + return newEntity; + } + } + return null; + } + + @Override + public DictionaryEntity deepCloneNew(String id) throws Exception { + if(StringUtils.hasText(id)) { + DictionaryEntity entity =repository.getOne(id); + if(entity!=null) { + DictionaryEntity cloneEntity =(DictionaryEntity)entity.deepClone(); + cloneEntity.clearId(); + cloneEntity.setCode("D"+System.currentTimeMillis()); + cloneEntity.setName(cloneEntity.getName() + "(New)"); + if(cloneEntity instanceof ReleasableDictionaryEntity) { + ReleasableDictionaryEntity versionDictionaryEntity =(ReleasableDictionaryEntity)cloneEntity; + versionDictionaryEntity.setStatus(DeployStatus.SKETCH); + Integer nextVersion =repository.getReleasableDictionaryNextVersion(versionDictionaryEntity.getCode()); + if(nextVersion!=null) { + versionDictionaryEntity.setVersion(nextVersion); + }else { + versionDictionaryEntity.setVersion(1); + } + } + + DictionaryEntity newEntity =repository.save(cloneEntity); + + //通知其他实体进行相应的更新 + applicationContext.publishEvent(new DictionaryEntityChangedEvent(EntityChangedEventType.ADD,null, newEntity)); + + return newEntity; + } + } + return null; + } + + @Override + public DictionaryEntity deploy(String id) throws Exception { + if(StringUtils.hasText(id)) { + ReleasableDictionaryEntity entity =repository.findReleasableDictionaryById(id); + if(entity!=null) { + List deployedEntities =repository.findReleasableDictionaryByCodeAndStatus(entity.getCode(), DeployStatus.ON_LINE); + if(deployedEntities!=null && deployedEntities.size()>0) { + for(ReleasableDictionaryEntity deployedEntity : deployedEntities) { + deployedEntity.setStatus(DeployStatus.HISTORY); + } + repository.saveAll(deployedEntities); + } + entity.setStatus(DeployStatus.ON_LINE); + repository.save(entity); + return entity; + } + } + return null; + } + + @Override + public Map getAllDictionaryMap(Locale locale) throws Exception { + Map result =new LinkedHashMap(); + //内建 Java 类型 + ValueType[] types =ValueType.values(); + if(types!=null && types.length>0) { + for(ValueType type : types) { + String key =type.getJavaType(); + String value =messageSource.getMessage(key, null, locale); + result.put(key, value); + } + } + //用户定义的数据类型 + List releasableDictionaryEntities =repository.findReleasableDictionaries(); + if(releasableDictionaryEntities!=null && releasableDictionaryEntities.size()>0) { + for(ReleasableDictionaryEntity entity : releasableDictionaryEntities) { + result.put(entity.getCode(), entity.getName()); + } + } + return result; + } + + @Override + public String getAllDictionaryMapJsonString(Locale locale) throws Exception { + return jsonObjectMapper.writeValueAsString(getAllDictionaryMap(locale)); + } + + @Override + public Map getVersionsByCode(String code) throws Exception { + if(StringUtils.hasText(code)) { + List entities =repository.findReleasableDictionaryByCodeOrderByVersion(code); + if(entities!=null && entities.size()>0) { + Map result =new LinkedHashMap(); + for(ReleasableDictionaryEntity _entity : entities) { + result.put(_entity.getVersion(), _entity.getVersion()); + } + return result; + } + } + return null; + } + + @Override + public List findReleasableDictionaryEntitiesByResourceId(String resourceId) throws Exception { + Set result =new HashSet(); + if(StringUtils.hasText(resourceId)) { + //先添加资源所需的数据字典 + ResourceEntity resourceEntity =resourceService.findById(resourceId); + if(ResourceType.MODEL.equals(resourceEntity.getType())) { + ModelResourceEntity modelResourceEntity =resourceService.getRepository().findModelResourceById(resourceId); + ModelEntity modelEntity =modelResourceEntity.getModel(); + + List parameters =modelService.getAllParameters(modelEntity.getId()); + if(parameters!=null && parameters.size()>0) { + for(ParameterEntity parameter : parameters) { + if(!ValueType.isBaseType(parameter.getValueType())) { + String code =parameter.getValueType(); + Integer version =parameter.getValueTypeVersion(); + ReleasableDictionaryEntity dictionary =repository.findReleasableDictionaryByCodeAndVersion(code, version); + if(dictionary!=null) { + result.add(dictionary); + } + } + } + } + } + //再添加指标库所需的数据字典 + List libEntities =libService.findReleasableLibEntitiesByResourceId(resourceId); + if(libEntities!=null && libEntities.size()>0) { + for(ReleasableLibEntity libEntity : libEntities) { + List dictionaries =dictionaryService.findReleasableDictionaryEntitiesByLibId(libEntity.getId()); + if(dictionaries!=null && dictionaries.size()>0) { + for(ReleasableDictionaryEntity dictionary : dictionaries) { + result.add(dictionary); + } + } + } + } + } + return new ArrayList(result); + } + + @Override + public List findReleasableDictionaryEntitiesByLibId(String libId) throws Exception { + if(StringUtils.hasText(libId)) { + LibEntity libEntity =libService.findById(libId); + if(LibType.INDICATOR.equals(libEntity.getType())) { + IndicatorLibEntity indicatorLibEntity =libService.getRepository().findIndicatorLibById(libEntity.getId()); + List indicators =indicatorLibEntity.getIndicators(); + if(indicators!=null && indicators.size()>0) { + Set result =new HashSet(); + for(IndicatorEntity indicator : indicators) { + if(!ValueType.isBaseType(indicator.getValueType())) { + String code =indicator.getValueType(); + Integer version =indicator.getValueTypeVersion(); + ReleasableDictionaryEntity dictionary =repository.findReleasableDictionaryByCodeAndVersion(code, version); + if(dictionary!=null) { + result.add(dictionary); + } + } + } + return new ArrayList(result); + } + } + } + return null; + } + + @Override + public Dictionary exports(String id) throws Exception { + DictionaryEntity entity =findById(id); + if(entity!=null) { + Dictionary po =DictionaryEntityConverter.toPo(entity); + return po; + } + return null; + } + + @Override + public void imports(DictionaryEntity entity) throws Exception { + if(entity!=null) { + entity.clearId(); + repository.save(entity); + } + } + + @Override + public void createExample(Set contributionIds) throws Exception { + if(contributionIds!=null && contributionIds.size()>0) { + for(String contributionId : contributionIds) { + createExample(contributionId); + } + } + } + + @Override + public void createExample(String contributionId) throws Exception { + List items = PluginManager.getInstance().getDictionaryExampleItemEntries(); + if(items!=null && items.size()>0) { + for(DictionaryExampleItem item : items) { + if(item.getId().equalsIgnoreCase(contributionId)) { + String file =item.getFile(); + if(StringUtils.hasText(file)) { + Resource resource =new DefaultResourceLoader().getResource(file); + if(resource!=null && resource.exists()) { + Dictionary po = ObjectMapper4Json.getMapper().readValue(resource.getInputStream(), Dictionary.class); + imports(DictionaryEntityConverter.fromPo(po)); + } + break; + } + } + } + } + } + + @Override + public SourceCode generateUserDefinedJavaClassDictionarySampleJsonCode(String dictionaryId) throws Exception { + if(StringUtils.hasText(dictionaryId)) { + UserDefinedJavaClassDictionaryEntity entity =repository.findUserDefinedJavaClassDictionaryById(dictionaryId); + if(entity!=null) { + List fields =entity.getFields(); + if(fields!=null && fields.size()>0) { + StringBuilder sb =new StringBuilder(); + sb.append("{").append("\n"); + for(UserDefinedJavaClassFieldEntity field : fields) { + String sampleValue =ValueType.generateSampleValue(field.getValueType()); + sb.append("\t").append("\"").append(field.getCode()).append("\"").append(" : ").append(sampleValue).append(", /*").append(field.getName()).append("*/").append("\n"); + } + sb.append("}").append("\n"); + SourceCode result =new SourceCode(); + result.setSource(sb.toString()); + return result; + } + } + } + return null; + } + + @Override + public ParemterHints listParemterHintsByUserDefinedJavaClassDictionaryId(String dictionaryId) throws Exception { + ParemterHints hints =new ParemterHints(); + if(StringUtils.hasText(dictionaryId)) { + UserDefinedJavaClassDictionaryEntity dictionaryEntity =this.getRepository().findUserDefinedJavaClassDictionaryById(dictionaryId); + if(dictionaryEntity!=null) { + List fieldEntities =dictionaryEntity.getFields(); + if(fieldEntities!=null && fieldEntities.size()>0) { + for(UserDefinedJavaClassFieldEntity fieldEntity : fieldEntities) { + hints.addParameterName("${" + fieldEntity.getName() + "}"); + } + } + } + } + return hints; + } + + @Override + public CodeAndNameMapping loadCodeAndNameMappingByUserDefinedJavaClassDictionaryId(String dictionaryId) throws Exception{ + CodeAndNameMapping result =new CodeAndNameMapping(); + UserDefinedJavaClassDictionaryEntity dictionaryEntity =this.getRepository().findUserDefinedJavaClassDictionaryById(dictionaryId); + if(dictionaryEntity!=null) { + List fieldEntities =dictionaryEntity.getFields(); + if(fieldEntities!=null && fieldEntities.size()>0) { + for(UserDefinedJavaClassFieldEntity fieldEntity : fieldEntities) { + result.addCode2Name(fieldEntity.getCode(),fieldEntity.getName()); + result.addName2Code(fieldEntity.getName(),fieldEntity.getCode()); + } + } + } + return result; + } + + /** + * 检查约束条件,约束条件规则如下: + * + * 1. 在同一文件夹下不能出现名称相同的文件夹 + * 2. 在同一文件夹下不能出现相同代码或相同名称的数据字典 + * 3. 在同一文件夹下可以出现相同代码且相同名称的数据字典(不同版本) + * + * @param action 操作类型 + * @param entity 被检查的实体对象 + * @throws Exception 违例 + */ + private void checkConstraint(AuditLogAction action, DictionaryEntity entity) throws Exception { + switch(entity.getType()) { + case FOLDER: + if(isSameNameFolderInParentFolder(action,entity)) { throw new FolderAlreadyExistsException();} + break; + case JAVA_CLASS: + JavaClassDictionaryEntity dictionaryJavaClassEntity =(JavaClassDictionaryEntity)entity; + String javaClassName =dictionaryJavaClassEntity.getJavaClassName(); + try { + Class.forName(javaClassName); + } catch (Exception e) { + throw new JavaClassNotExistsException(); + } + if(!checkSameCodeOrNameConstraint(action,entity)) {throw new DictionaryAlreadyExistsException();} + break; + default: + if(!checkSameCodeOrNameConstraint(action,entity)) {throw new DictionaryAlreadyExistsException();} + break; + } + } + + /** + * 检查某个父文件夹下是否存在同名的子文件夹 + * + * @param action 操作类型 + * @param entity 被检查的实体对象 + * @return 是否存在同名的子文件夹(true:存在,false:不存在) + */ + private boolean isSameNameFolderInParentFolder(AuditLogAction action,DictionaryEntity entity) { + String parentId =entity.getParent().getId(); + List folderEntities =null; + if(StringUtils.hasText(parentId)) { + folderEntities =repository.findFolderByNameWithParentId(entity.getName(),parentId); + }else { + folderEntities =repository.findFolderByNameWithNullParentId(entity.getName()); + } + switch(action) { + case ADD: + if(folderEntities!=null && folderEntities.size()>0) { + return true; + } + break; + case UPDATE: + if(folderEntities!=null && folderEntities.size()>0) { + for(FolderDictionaryEntity folder : folderEntities) { + if(!folder.getId().equals(entity.getId())) { + return true; + } + } + } + break; + default: + + } + return false; + } + + /** + * 检查是否存在代码或者名称相同的数据字典 + * + * @param action 操作类型 + * @param entity 被检查的实体对象 + * @return 是否存在代码或者名称相同的数据字典 + */ + private boolean checkSameCodeOrNameConstraint(AuditLogAction action,DictionaryEntity entity) { + List dictionaries =repository.findReleasableDictionaryByCodeOrName(entity.getCode(), entity.getName()); + if(dictionaries!=null && dictionaries.size()>0) { + for(ReleasableDictionaryEntity dictionary : dictionaries) { + if(dictionary.getCode().equals(entity.getCode()) && dictionary.getName().equals(entity.getName())) {//代码和名称都相同 + if(!dictionary.getParent().getId().equals(entity.getParent().getId())) {//不属于同一个文件夹 + if(AuditLogAction.ADD.equals(action)) {//如果是新增:不允许;如果是更新:允许(通常发生在将数据字典移动到其他文件夹时) + return false; + } + } + }else {//代码和名称只有其中一个相同 + if(AuditLogAction.ADD.equals(action)) { + return false; + }else if(AuditLogAction.UPDATE.equals(action)) { + if(!dictionary.getParent().getId().equals(entity.getParent().getId())) {//不属于同一个文件夹 + return false; + } + } + } + } + } + return true; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/impl/EnumItemServiceImpl.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/impl/EnumItemServiceImpl.java new file mode 100644 index 00000000..da5d3b30 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/impl/EnumItemServiceImpl.java @@ -0,0 +1,70 @@ +package io.sc.engine.rule.server.dictionary.service.impl; + +import io.sc.engine.rule.server.dictionary.entity.EnumDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.EnumItemEntity; +import io.sc.engine.rule.server.dictionary.exception.EnumItemEntityAlreadyExistsException; +import io.sc.engine.rule.server.dictionary.repository.EnumDictionaryRepository; +import io.sc.engine.rule.server.dictionary.repository.EnumItemRepository; +import io.sc.engine.rule.server.dictionary.service.EnumItemService; +import io.sc.platform.orm.service.impl.DaoServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service("reDictionaryOptionItemService") +public class EnumItemServiceImpl extends DaoServiceImpl implements EnumItemService{ + @Autowired private EnumDictionaryRepository enumDictionaryRepository; + + @Override + public EnumItemEntity add(EnumItemEntity entity) throws Exception { + if(entity==null){ + throw exceptionProvider.getCreateNullObjectException(); + } + String dictionaryId =entity.getDictionary().getId(); + EnumDictionaryEntity dictionaryEntity =enumDictionaryRepository.getOne(dictionaryId); + if(dictionaryEntity!=null) { + List items =dictionaryEntity.getItems(); + if(items!=null && items.size()>0) { + for(EnumItemEntity item : items) { + if(item.getValue().equals(entity.getValue()) || item.getTitle().equals(entity.getTitle())) { + throw new EnumItemEntityAlreadyExistsException(); + } + } + } + } + + Integer nextOrder =repository.getNextOrder(entity.getDictionary().getId()); + if(nextOrder!=null) { + entity.setOrder(nextOrder); + }else { + entity.setOrder(1); + } + return super.add(entity); + } + + @Override + public EnumItemEntity update(String primaryKey, EnumItemEntity entity) throws Exception { + if(primaryKey==null){ + throw exceptionProvider.getUpdateNullOldObjectPrimaryKeyException(); + } + if(entity==null){ + throw exceptionProvider.getUpdateNullNewObjectException(); + } + String dictionaryId =entity.getDictionary().getId(); + EnumDictionaryEntity dictionaryEntity =enumDictionaryRepository.getOne(dictionaryId); + if(dictionaryEntity!=null) { + List items =dictionaryEntity.getItems(); + if(items!=null && items.size()>0) { + for(EnumItemEntity item : items) { + if(!item.getId().equals(entity.getId())) { + if(item.getValue().equals(entity.getValue()) || item.getTitle().equals(entity.getTitle())) { + throw new EnumItemEntityAlreadyExistsException(); + } + } + } + } + } + return super.update(primaryKey, entity); + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/support/DictionaryEntityChangedEvent.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/support/DictionaryEntityChangedEvent.java new file mode 100644 index 00000000..00ac48dc --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/service/support/DictionaryEntityChangedEvent.java @@ -0,0 +1,12 @@ +package io.sc.engine.rule.server.dictionary.service.support; + +import io.sc.engine.rule.server.dictionary.entity.DictionaryEntity; +import io.sc.platform.orm.entity.support.EntityChangedEvent; +import io.sc.platform.orm.entity.support.EntityChangedEventType; + +public class DictionaryEntityChangedEvent extends EntityChangedEvent{ + + public DictionaryEntityChangedEvent(EntityChangedEventType type, DictionaryEntity oldEntity, DictionaryEntity newEntity) { + super(type, oldEntity, newEntity); + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/vo/DictionaryVo.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/vo/DictionaryVo.java new file mode 100644 index 00000000..69161684 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/vo/DictionaryVo.java @@ -0,0 +1,72 @@ +package io.sc.engine.rule.server.dictionary.vo; + +import io.sc.engine.rule.core.enums.DictionaryType; +import io.sc.platform.orm.api.vo.AuditorVo; + +/** + * 数据字典 VO 类 + */ +public class DictionaryVo extends AuditorVo { + protected DictionaryType type; + + //ID,主键 + protected String id; + + //代码 + protected String code; + + //名称 + protected String name; + + //描述 + protected String description; + + //排序 + protected Integer order; + + private String parent; + + public DictionaryType getType() { + return type; + } + public void setType(DictionaryType type) { + this.type = type; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public Integer getOrder() { + return order; + } + public void setOrder(Integer order) { + this.order = order; + } + public String getParent() { + return parent; + } + public void setParent(String parent) { + this.parent = parent; + } + +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/vo/EnumDictionaryVo.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/vo/EnumDictionaryVo.java new file mode 100644 index 00000000..92bb8c77 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/vo/EnumDictionaryVo.java @@ -0,0 +1,32 @@ +package io.sc.engine.rule.server.dictionary.vo; + +import io.sc.engine.rule.core.enums.DictionaryType; + +import java.util.ArrayList; +import java.util.List; + +/** + * 枚举类型数据字典 Vo 类 + */ +public class EnumDictionaryVo extends ReleasableDictionaryVo { + //包含的枚举项列表 + protected List items =new ArrayList(); + + public EnumDictionaryVo() {} + public EnumDictionaryVo(String id) { + this.id =id; + } + + @Override + public DictionaryType getType() { + return DictionaryType.ENUM; + } + + public List getItems() { + return items; + } + public void setItems(List items) { + this.items = items; + } + +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/vo/EnumItemVo.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/vo/EnumItemVo.java new file mode 100644 index 00000000..7d09041b --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/dictionary/vo/EnumItemVo.java @@ -0,0 +1,76 @@ +package io.sc.engine.rule.server.dictionary.vo; + +import io.sc.platform.orm.api.vo.AuditorVo; + +/** + * 枚举项 Vo 类 + */ +public class EnumItemVo extends AuditorVo { + //ID,主键 + protected String id; + + //值 + protected String value; + + //标题 + protected String title; + + //描述 + protected String description; + + //排序 + protected Integer order; + + //配置 + protected String config; + + //所属选项字典 + protected String dictionary; + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public Integer getOrder() { + return order; + } + public void setOrder(Integer order) { + this.order = order; + } + public String getConfig() { + return config; + } + public void setConfig(String config) { + this.config = config; + } + public String getDictionary() { + return dictionary; + } + public void setDictionary(String dictionary) { + this.dictionary = dictionary; + } + public EnumItemVo() {} + public EnumItemVo(String id) { + this.id =id; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/jpa/listener/handler/DictionaryEntityEventHandler.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/jpa/listener/handler/DictionaryEntityEventHandler.java new file mode 100644 index 00000000..3b5ffecb --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/jpa/listener/handler/DictionaryEntityEventHandler.java @@ -0,0 +1,169 @@ +package io.sc.engine.rule.server.jpa.listener.handler; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import io.sc.engine.rule.server.dictionary.entity.DictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.ReleasableDictionaryEntity; +import io.sc.engine.rule.server.dictionary.entity.UserDefinedJavaClassFieldEntity; +import io.sc.engine.rule.server.dictionary.service.DictionaryService; +import io.sc.engine.rule.server.dictionary.service.UserDefinedJavaClassFieldService; +import io.sc.engine.rule.server.lib.entity.IndicatorEntity; +import io.sc.engine.rule.server.lib.service.IndicatorService; +import io.sc.engine.rule.server.model.entity.ParameterEntity; +import io.sc.engine.rule.server.model.service.ParameterService; +import io.sc.platform.orm.entity.support.AbstractJpaEntityPersistentEventHandler; + +/** + * 数据字典实体持久化事件处理器 + */ +@Service("reDictionaryEntityEventHandler") +public class DictionaryEntityEventHandler extends AbstractJpaEntityPersistentEventHandler{ + private static final Logger log =LoggerFactory.getLogger(DictionaryEntityEventHandler.class); + @Autowired private DictionaryService dictionaryService; + @Autowired private UserDefinedJavaClassFieldService userDefinedJavaClassFieldService; + @Autowired private IndicatorService indicatorService; + @Autowired private ParameterService parameterService; + + @Override + protected void afterAdd(DictionaryEntity newEntity) { + updateParentDictionaryEntityLastModifyDate(newEntity); + } + + @Override + protected void beforeUpdate(DictionaryEntity oldEntity, DictionaryEntity newEntity) { + if(oldEntity!=null && newEntity!=null) { + if(oldEntity instanceof ReleasableDictionaryEntity) {//可发布的数据字典 + updateDictionaryCodeAndName((ReleasableDictionaryEntity)oldEntity,(ReleasableDictionaryEntity)newEntity); + + //更新引用了该数据字典的实体的值类型代码,这些实体包括: 自定义java类字段、指标、参数 + updateUserDefinedJavaClassFieldValueType((ReleasableDictionaryEntity)oldEntity,(ReleasableDictionaryEntity)newEntity);//更新用户自定义 Java Class 字段的值类型 + updateIndicatorValueType((ReleasableDictionaryEntity)oldEntity,(ReleasableDictionaryEntity)newEntity);//更新指标库中指标的值类型 + updateParameterValueType((ReleasableDictionaryEntity)oldEntity,(ReleasableDictionaryEntity)newEntity);//更新参数的值类型 + } + } + updateParentDictionaryEntityLastModifyDate(oldEntity); + } + + @Override + protected void beforeDelete(DictionaryEntity oldEntity) { + updateParentDictionaryEntityLastModifyDate(oldEntity); + } + + @Override + protected void beforeDelete(Iterable iterable) { + updateParentDictionaryEntityLastModifyDate(iterable.iterator().next()); + } + + /** + * 更新数据字典所属的父的最后更新日期 + * @param entity 数据字典实体 + */ + private void updateParentDictionaryEntityLastModifyDate(DictionaryEntity entity) { + if(entity!=null) { + DictionaryEntity parent =entity.getParent(); + if(parent!=null) { + DictionaryEntity parentEntity =dictionaryService.getRepository().getOne(parent.getId()); + if(parentEntity!=null) { + if(log.isDebugEnabled()) {log.debug("更新 [父数据字典] 最后修改日期");} + parentEntity.setLastModifyDate(new Date()); + dictionaryService.getRepository().save(parentEntity); + } + } + } + } + + /** + * 更新可发布的数据字典的代码和名称 + * 目的: 保证不同版本的代码和名称相同 + * @param oldEntity 原可发布的数据字典 + * @param newEntity 新可发布的数据字典 + */ + private void updateDictionaryCodeAndName(ReleasableDictionaryEntity oldEntity,ReleasableDictionaryEntity newEntity) { + if(oldEntity!=null && newEntity!=null) { + if(oldEntity instanceof ReleasableDictionaryEntity) {//可发布的数据字典 + if(!oldEntity.getCode().equals(newEntity.getCode()) || !oldEntity.getName().equals(newEntity.getName())) { + if(log.isDebugEnabled()) {log.debug("更新 [可发布的数据字典] 代码或名称,具有相同代码不同版本的所有 [数据字典] 的代码和名称保持一致");} + //查找和更新原代码相同的可发布数据字典 + List entities =dictionaryService.getRepository().findReleasableDictionaryByCode(oldEntity.getCode()); + List willBeUpdates =new ArrayList(); + if(entities!=null && entities.size()>0) { + for(ReleasableDictionaryEntity entity : entities) { + if(!oldEntity.getId().equals(entity.getId())) {//排除自己 + entity.setCode(newEntity.getCode()); + entity.setName(newEntity.getName()); + willBeUpdates.add(entity); + } + } + dictionaryService.getRepository().saveAll(willBeUpdates); + } + } + } + } + } + + /** + * 更新用户自定义 Java Class 字段的值类型 + * 当可版本化的数据字典(非文件夹)的[代码]发生改变后,那么用户自定义 Java Class 字段的[值类型]如果引用了该数据字典[代码]也应该更新。 + * 目的: 保持一致性 + * @param oldEntity 原对象 + * @param newEntity 新对象 + */ + private void updateUserDefinedJavaClassFieldValueType(ReleasableDictionaryEntity oldEntity,ReleasableDictionaryEntity newEntity) { + if(oldEntity!=null && newEntity!=null && !oldEntity.getCode().equals(newEntity.getCode())) { + if(log.isDebugEnabled()) {log.debug("更新 [自定义Java类字段] 引用的值类型(数据字典)的代码");} + List entities =userDefinedJavaClassFieldService.getRepository().findByValueType(oldEntity.getCode()); + if(entities!=null && entities.size()>0) { + for(UserDefinedJavaClassFieldEntity entity : entities) { + entity.setValueType(newEntity.getCode()); + } + userDefinedJavaClassFieldService.getRepository().saveAll(entities); + } + } + } + + /** + * 更新指标库中指标的值类型 + * 当可版本化的数据字典(非文件夹)的[代码]发生改变后,那么指标库中指标的[值类型]如果引用了该数据字典[代码]也应该更新。 + * 目的: 保持一致性 + * @param oldEntity 原对象 + * @param newEntity 新对象 + */ + private void updateIndicatorValueType(ReleasableDictionaryEntity oldEntity,ReleasableDictionaryEntity newEntity) { + if(oldEntity!=null && newEntity!=null && !oldEntity.getCode().equals(newEntity.getCode())) { + if(log.isDebugEnabled()) {log.debug("更新 [指标] 引用的值类型(数据字典)的代码");} + List entities =indicatorService.getRepository().findByValueType(oldEntity.getCode()); + if(entities!=null && entities.size()>0) { + for(IndicatorEntity entity : entities) { + entity.setValueType(newEntity.getCode()); + } + indicatorService.getRepository().saveAll(entities); + } + } + } + + /** + * 更新参数的值类型 + * 当可版本化的数据字典(非文件夹)的[代码]发生改变后,那么参数[值类型]如果引用了该数据字典[代码]也应该更新。 + * 目的: 保持一致性 + * @param oldEntity 原对象 + * @param newEntity 新对象 + */ + private void updateParameterValueType(ReleasableDictionaryEntity oldEntity,ReleasableDictionaryEntity newEntity) { + if(oldEntity!=null && newEntity!=null && !oldEntity.getCode().equals(newEntity.getCode())) { + if(log.isDebugEnabled()) {log.debug("更新 [参数] 引用的值类型(数据字典)的代码");} + List entities =parameterService.getRepository().findByValueType(oldEntity.getCode()); + if(entities!=null && entities.size()>0) { + for(ParameterEntity entity : entities) { + entity.setValueType(newEntity.getCode()); + } + parameterService.getRepository().saveAll(entities); + } + } + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/entity/processor/EmptyIndicatorProcessorEntity.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/entity/processor/EmptyIndicatorProcessorEntity.java new file mode 100644 index 00000000..3d92f55c --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/entity/processor/EmptyIndicatorProcessorEntity.java @@ -0,0 +1,30 @@ +package io.sc.engine.rule.server.lib.entity.processor; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.sc.engine.rule.core.enums.ProcessorType; +import io.sc.engine.rule.server.lib.entity.IndicatorProcessorEntity; +import io.sc.engine.rule.server.lib.vo.processor.EmptyIndicatorProcessorVo; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * 指标处理器(空操作)实体类 + */ +@Entity +@DiscriminatorValue("EMPTY") +@JsonTypeName("EMPTY") +public class EmptyIndicatorProcessorEntity extends IndicatorProcessorEntity { + @Override + public EmptyIndicatorProcessorVo toVo() { + EmptyIndicatorProcessorVo vo =new EmptyIndicatorProcessorVo(); + super.toVo(vo); + vo.setType(this.getType()); + return vo; + } + + @Override + public ProcessorType getType() { + return ProcessorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/entity/validator/EmailIndicatorValidatorEntity.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/entity/validator/EmailIndicatorValidatorEntity.java new file mode 100644 index 00000000..b9249f84 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/entity/validator/EmailIndicatorValidatorEntity.java @@ -0,0 +1,30 @@ +package io.sc.engine.rule.server.lib.entity.validator; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.server.lib.entity.IndicatorValidatorEntity; +import io.sc.engine.rule.server.lib.vo.validator.EmailIndicatorValidatorVo; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * 验证器(邮箱地址)实体类 + */ +@Entity +@DiscriminatorValue("EMAIL") +@JsonTypeName("EMAIL") +public class EmailIndicatorValidatorEntity extends IndicatorValidatorEntity { + @Override + public EmailIndicatorValidatorVo toVo() { + EmailIndicatorValidatorVo vo =new EmailIndicatorValidatorVo(); + super.toVo(vo); + vo.setType(this.getType()); + return vo; + } + + @Override + public ValidatorType getType() { + return ValidatorType.EMAIL; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/entity/validator/EmptyIndicatorValidatorEntity.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/entity/validator/EmptyIndicatorValidatorEntity.java new file mode 100644 index 00000000..ca8a8045 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/entity/validator/EmptyIndicatorValidatorEntity.java @@ -0,0 +1,30 @@ +package io.sc.engine.rule.server.lib.entity.validator; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.server.lib.entity.IndicatorValidatorEntity; +import io.sc.engine.rule.server.lib.vo.validator.EmptyIndicatorValidatorVo; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * 验证器(空)实体类 + */ +@Entity +@DiscriminatorValue("EMPTY") +@JsonTypeName("EMPTY") +public class EmptyIndicatorValidatorEntity extends IndicatorValidatorEntity { + @Override + public EmptyIndicatorValidatorVo toVo() { + EmptyIndicatorValidatorVo vo =new EmptyIndicatorValidatorVo(); + super.toVo(vo); + vo.setType(this.getType()); + return vo; + } + + @Override + public ValidatorType getType() { + return ValidatorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/vo/processor/EmptyIndicatorProcessorVo.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/vo/processor/EmptyIndicatorProcessorVo.java new file mode 100644 index 00000000..f5da27dc --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/vo/processor/EmptyIndicatorProcessorVo.java @@ -0,0 +1,14 @@ +package io.sc.engine.rule.server.lib.vo.processor; + +import io.sc.engine.rule.core.enums.ProcessorType; +import io.sc.engine.rule.server.lib.vo.IndicatorProcessorVo; + +/** + * 指标处理器(空操作)Vo 类 + */ +public class EmptyIndicatorProcessorVo extends IndicatorProcessorVo { + @Override + public ProcessorType getType() { + return ProcessorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/vo/validator/EmailIndicatorValidatorVo.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/vo/validator/EmailIndicatorValidatorVo.java new file mode 100644 index 00000000..2aa23cdc --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/vo/validator/EmailIndicatorValidatorVo.java @@ -0,0 +1,14 @@ +package io.sc.engine.rule.server.lib.vo.validator; + +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.server.lib.vo.IndicatorValidatorVo; + +/** + * 验证器(邮箱地址)Vo 类 + */ +public class EmailIndicatorValidatorVo extends IndicatorValidatorVo { + @Override + public ValidatorType getType() { + return ValidatorType.EMAIL; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/vo/validator/EmptyIndicatorValidatorVo.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/vo/validator/EmptyIndicatorValidatorVo.java new file mode 100644 index 00000000..2f9e3ec7 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/lib/vo/validator/EmptyIndicatorValidatorVo.java @@ -0,0 +1,14 @@ +package io.sc.engine.rule.server.lib.vo.validator; + +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.server.lib.vo.IndicatorValidatorVo; + +/** + * 验证器(空)Vo 类 + */ +public class EmptyIndicatorValidatorVo extends IndicatorValidatorVo { + @Override + public ValidatorType getType() { + return ValidatorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/entity/processor/EmptyParameterProcessorEntity.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/entity/processor/EmptyParameterProcessorEntity.java new file mode 100644 index 00000000..6f106c8c --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/entity/processor/EmptyParameterProcessorEntity.java @@ -0,0 +1,29 @@ +package io.sc.engine.rule.server.model.entity.processor; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.sc.engine.rule.core.enums.ProcessorType; +import io.sc.engine.rule.server.model.entity.ParameterProcessorEntity; +import io.sc.engine.rule.server.model.vo.processor.EmptyParameterProcessorVo; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * 模型参数处理器(空操作)实体类 + */ +@Entity +@DiscriminatorValue("EMPTY") +@JsonTypeName("EMPTY") +public class EmptyParameterProcessorEntity extends ParameterProcessorEntity { + @Override + public EmptyParameterProcessorVo toVo() { + EmptyParameterProcessorVo vo =new EmptyParameterProcessorVo(); + super.toVo(vo); + return vo; + } + + @Override + public ProcessorType getType() { + return ProcessorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/entity/validator/EmailParameterValidatorEntity.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/entity/validator/EmailParameterValidatorEntity.java new file mode 100644 index 00000000..1da6b5e0 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/entity/validator/EmailParameterValidatorEntity.java @@ -0,0 +1,29 @@ +package io.sc.engine.rule.server.model.entity.validator; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.server.model.entity.ParameterValidatorEntity; +import io.sc.engine.rule.server.model.vo.validator.EmailParameterValidatorVo; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * 验证器(邮箱地址)实体类 + */ +@Entity +@DiscriminatorValue("EMAIL") +@JsonTypeName("EMAIL") +public class EmailParameterValidatorEntity extends ParameterValidatorEntity { + @Override + public EmailParameterValidatorVo toVo() { + EmailParameterValidatorVo vo =new EmailParameterValidatorVo(); + super.toVo(vo); + return vo; + } + + @Override + public ValidatorType getType() { + return ValidatorType.EMAIL; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/entity/validator/EmptyParameterValidatorEntity.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/entity/validator/EmptyParameterValidatorEntity.java new file mode 100644 index 00000000..0d3aec86 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/entity/validator/EmptyParameterValidatorEntity.java @@ -0,0 +1,29 @@ +package io.sc.engine.rule.server.model.entity.validator; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.server.model.entity.ParameterValidatorEntity; +import io.sc.engine.rule.server.model.vo.validator.EmptyParameterValidatorVo; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +/** + * 验证器(空)实体类 + */ +@Entity +@DiscriminatorValue("EMPTY") +@JsonTypeName("EMPTY") +public class EmptyParameterValidatorEntity extends ParameterValidatorEntity { + @Override + public EmptyParameterValidatorVo toVo() { + EmptyParameterValidatorVo vo =new EmptyParameterValidatorVo(); + super.toVo(vo); + return vo; + } + + @Override + public ValidatorType getType() { + return ValidatorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/vo/processor/EmptyParameterProcessorVo.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/vo/processor/EmptyParameterProcessorVo.java new file mode 100644 index 00000000..eb92b79f --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/vo/processor/EmptyParameterProcessorVo.java @@ -0,0 +1,14 @@ +package io.sc.engine.rule.server.model.vo.processor; + +import io.sc.engine.rule.core.enums.ProcessorType; +import io.sc.engine.rule.server.model.vo.ParameterProcessorVo; + +/** + * 模型参数处理器(空操作)Vo 类 + */ +public class EmptyParameterProcessorVo extends ParameterProcessorVo { + @Override + public ProcessorType getType() { + return ProcessorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/vo/validator/EmailParameterValidatorVo.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/vo/validator/EmailParameterValidatorVo.java new file mode 100644 index 00000000..6dc49cdf --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/vo/validator/EmailParameterValidatorVo.java @@ -0,0 +1,14 @@ +package io.sc.engine.rule.server.model.vo.validator; + +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.server.model.vo.ParameterValidatorVo; + +/** + * 验证器(邮箱地址)实体类 + */ +public class EmailParameterValidatorVo extends ParameterValidatorVo { + @Override + public ValidatorType getType() { + return ValidatorType.EMAIL; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/vo/validator/EmptyParameterValidatorVo.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/vo/validator/EmptyParameterValidatorVo.java new file mode 100644 index 00000000..7aeae459 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/model/vo/validator/EmptyParameterValidatorVo.java @@ -0,0 +1,14 @@ +package io.sc.engine.rule.server.model.vo.validator; + +import io.sc.engine.rule.core.enums.ValidatorType; +import io.sc.engine.rule.server.model.vo.ParameterValidatorVo; + +/** + * 验证器(空)实体类 + */ +public class EmptyParameterValidatorVo extends ParameterValidatorVo { + @Override + public ValidatorType getType() { + return ValidatorType.EMPTY; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/plugins/item/DictionaryExampleItem.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/plugins/item/DictionaryExampleItem.java new file mode 100644 index 00000000..7efe68f8 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/plugins/item/DictionaryExampleItem.java @@ -0,0 +1,105 @@ +package io.sc.engine.rule.server.plugins.item; + +/** + * 数据字典示例插件项 + */ +public class DictionaryExampleItem { + protected String id; //ID + protected String parentId; //父ID + protected Integer order =0; //顺序 + protected String file; //数据字典示例文件URL + + //附加属性 + private String configurationFileUrl; //贡献项配置文件位置URL + + /** + * 获取ID + * @return ID + */ + public String getId() { + return id; + } + + /** + * 设置ID + * @param id ID + */ + public void setId(String id) { + this.id = id; + } + + /** + * 获取父ID + * @return 父ID + */ + public String getParentId() { + return parentId; + } + + /** + * 设置父ID + * @param parentId 父ID + */ + public void setParentId(String parentId) { + this.parentId = parentId; + } + + /** + * 获取顺序 + * @return 顺序 + */ + public Integer getOrder() { + return order; + } + + /** + * 设置顺序 + * @param order 顺序 + */ + public void setOrder(Integer order) { + this.order = order; + } + + /** + * 获取数据字典示例文件URL + * @return 资源示例文件URL + */ + public String getFile() { + return file; + } + + /** + * 设置数据字典示例文件URL + * @param file 资源示例文件URL + */ + public void setFile(String file) { + this.file = file; + } + + /** + * 获取贡献项配置文件位置URL + * @return 贡献项配置文件位置URL + */ + public String getConfigurationFileUrl() { + return configurationFileUrl; + } + + /** + * 设置贡献项配置文件位置URL + * @param configurationFileUrl 贡献项配置文件位置URL + */ + public void setConfigurationFileUrl(String configurationFileUrl) { + this.configurationFileUrl = configurationFileUrl; + } + + @Override + public String toString() { + return "DictionaryExampleContributionItem [" + + "id=" + id + + ", parentId=" + parentId + + ", order=" + order + + ", file=" + file + + ", configurationFileUrl=" + configurationFileUrl + + "]"; + } +} diff --git a/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/plugins/item/wrapper/DictionaryExampleWrapper.java b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/plugins/item/wrapper/DictionaryExampleWrapper.java new file mode 100644 index 00000000..433efb2e --- /dev/null +++ b/io.sc.engine.rule.server/src/main/java/io/sc/engine/rule/server/plugins/item/wrapper/DictionaryExampleWrapper.java @@ -0,0 +1,175 @@ +package io.sc.engine.rule.server.plugins.item.wrapper; + +import io.sc.engine.rule.server.plugins.item.DictionaryExampleItem; + +import java.util.ArrayList; +import java.util.List; + +/** + * 数据字典示例插件项封装器 + */ +public class DictionaryExampleWrapper { + private String id; //id + private String parentId; //父id + private String file; //数据字典示例文件URL + private Integer order =0; //顺序 + private String configurationFileUrl; //贡献项配置文件位置URL + private String name; //用于显示国际化消息名称 + private String description; //用于显示国际化消息描述 + + /** + * 从数据字典示例贡献项对象构建封装器对象 + * @param item 数据字典示例贡献项对象 + * @return 数据字典示例贡献项封装器对象 + */ + public static DictionaryExampleWrapper from(DictionaryExampleItem item) { + DictionaryExampleWrapper wrapper =new DictionaryExampleWrapper(); + wrapper.setId(item.getId()); + wrapper.setParentId(item.getParentId()); + wrapper.setFile(item.getFile()); + wrapper.setOrder(item.getOrder()); + wrapper.setConfigurationFileUrl(item.getConfigurationFileUrl()); + return wrapper; + } + + /** + * 从数据字典示例贡献项对象列表构建封装器对象列表 + * @param list 数据字典示例贡献项对象列表 + * @return 数据字典示例贡献项封装器对象列表 + */ + public static List from(List list){ + if(list==null) { + return null; + } + List result =new ArrayList(); + for(DictionaryExampleItem item : list) { + result.add(from(item)); + } + return result; + } + + /** + * 获取ID + * @return ID + */ + public String getId() { + return id; + } + + /** + * 设置ID + * @param id ID + */ + public void setId(String id) { + this.id = id; + } + + /** + * 获取父ID + * @return 父ID + */ + public String getParentId() { + return parentId; + } + + /** + * 设置父ID + * @param parentId 父ID + */ + public void setParentId(String parentId) { + this.parentId = parentId; + } + + /** + * 获取数据字典示例文件URL + * @return 数据字典示例文件URL + */ + public String getFile() { + return file; + } + + /** + * 设置数据字典示例文件URL + * @param file 数据字典示例文件URL + */ + public void setFile(String file) { + this.file = file; + } + + /** + * 获取顺序 + * @return 顺序 + */ + public Integer getOrder() { + return order; + } + + /** + * 设置顺序 + * @param order 顺序 + */ + public void setOrder(Integer order) { + this.order = order; + } + + /** + * 获取贡献项配置文件位置URL + * @return 贡献项配置文件位置URL + */ + public String getConfigurationFileUrl() { + return configurationFileUrl; + } + + /** + * 设置贡献项配置文件位置URL + * @param configurationFileUrl 贡献项配置文件位置URL + */ + public void setConfigurationFileUrl(String configurationFileUrl) { + this.configurationFileUrl = configurationFileUrl; + } + + /** + * 获取名称 + * @return 名称 + */ + public String getName() { + return name; + } + + /** + * 设置名称 + * @param name 名称 + */ + public void setName(String name) { + this.name = name; + } + + /** + * 获取描述 + * @return 描述 + */ + public String getDescription() { + return description; + } + + /** + * 设置描述 + * @param description 描述 + */ + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "DictionaryExampleWrapper [" + + "id=" + id + + ", parentId=" + parentId + + ", file=" + file + + ", order=" + order + + ", configurationFileUrl=" + configurationFileUrl + + ", name=" + name + + ", description=" + description + + "]"; + } +} diff --git a/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/enums.properties b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/enums.properties new file mode 100644 index 00000000..5f5b22a5 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/enums.properties @@ -0,0 +1,154 @@ +#================================================ +# \u8D44\u6E90\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ResourceType.FOLDER=Folder +io.sc.engine.rule.core.enums.ResourceType.MODEL=Model +io.sc.engine.rule.core.enums.ResourceType.SCORE_CARD=Score Card + +#================================================ +# \u6A21\u578B\u5206\u7C7B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ModelCategory.QUANTITATIVE=Quantitative +io.sc.engine.rule.core.enums.ModelCategory.QUALITATIVE=Qualitative +io.sc.engine.rule.core.enums.ModelCategory.ADJUSTMENT=Adjustment +io.sc.engine.rule.core.enums.ModelCategory.RULE=Rule +io.sc.engine.rule.core.enums.ModelCategory.OTHER=Other + +#================================================ +# \u6A21\u578B\u6267\u884C\u6A21\u5F0F\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ExecuteMode.TOP_DOWN=Top-Down +io.sc.engine.rule.core.enums.ExecuteMode.DOWN_TOP=Down-Top + +#================================================ +# \u6A21\u578B\u72B6\u6001\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DeployStatus.HISTORY=History +io.sc.engine.rule.core.enums.DeployStatus.RELEASE=Release +io.sc.engine.rule.core.enums.DeployStatus.SKETCH=Sketch + +#================================================ +# \u53C2\u6570\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterType.IN=Input +io.sc.engine.rule.core.enums.ParameterType.IN_OPTION=Input(Option) +io.sc.engine.rule.core.enums.ParameterType.IN_SUB_OUT=Sub Model Output +io.sc.engine.rule.core.enums.ParameterType.INDICATOR=Indicator +io.sc.engine.rule.core.enums.ParameterType.INTERMEDIATE=Intermediate +io.sc.engine.rule.core.enums.ParameterType.RULE_RESULT=Rule Out +io.sc.engine.rule.core.enums.ParameterType.SINGLE_RULE_RESULT=Single Rule Out +io.sc.engine.rule.core.enums.ParameterType.OUT=Out +io.sc.engine.rule.core.enums.ParameterType.CONSTANT=Constant + +#================================================ +# \u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ProcessorType.EMPTY=Empty +io.sc.engine.rule.core.enums.ProcessorType.OPTION_VALUE=Option Value +io.sc.engine.rule.core.enums.ProcessorType.ARITHMETIC=Arithmetic +io.sc.engine.rule.core.enums.ProcessorType.TERNARY=Ternary +io.sc.engine.rule.core.enums.ProcessorType.WHEN_THEN=When-Then +io.sc.engine.rule.core.enums.ProcessorType.RULE=Rule +io.sc.engine.rule.core.enums.ProcessorType.SINGLE_RULE=Single Rule +io.sc.engine.rule.core.enums.ProcessorType.NUMBER_RANGE=Number Range +io.sc.engine.rule.core.enums.ProcessorType.CONDITION_RANGE=Condition Range +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE_2C=Simple Decision Table +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE=Decision Table +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TREE=Decision Tree +io.sc.engine.rule.core.enums.ProcessorType.EXECUTION_FLOW=Execution Flow +io.sc.engine.rule.core.enums.ProcessorType.PMML=PMML +io.sc.engine.rule.core.enums.ProcessorType.GROOVY_SCRIPT=Groovy Script +io.sc.engine.rule.core.enums.ProcessorType.SQL=SQL Asignment Value +io.sc.engine.rule.core.enums.ProcessorType.HTTP_REQUEST=Http Request + +#================================================ +# HTTP \u8BF7\u6C42\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpMethodType.GET=GET +io.sc.engine.rule.core.enums.HttpMethodType.POST=POST +io.sc.engine.rule.core.enums.HttpMethodType.PUT=PUT +io.sc.engine.rule.core.enums.HttpMethodType.DELETE=DELETE +io.sc.engine.rule.core.enums.HttpMethodType.HEAD=HEAD +io.sc.engine.rule.core.enums.HttpMethodType.PATCH=PATCH +io.sc.engine.rule.core.enums.HttpMethodType.OPTIONS=OPTIONS +io.sc.engine.rule.core.enums.HttpMethodType.TRACE=TRACE + +#================================================ +# HTTP \u8BA4\u8BC1\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpAuthorizationType.NONE=No Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.API_KEY=API Key +io.sc.engine.rule.core.enums.HttpAuthorizationType.BASIC_AUTH=Basic Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.BEARER=Bearer Token + +#================================================ +# \u53C2\u6570\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterProcessorType.optionParameterCode=Option Value +io.sc.engine.rule.core.enums.ParameterProcessorType.ARITHMETIC=Arithmetic +io.sc.engine.rule.core.enums.ParameterProcessorType.TERNARY=Ternary +io.sc.engine.rule.core.enums.ParameterProcessorType.WHEN_THEN=When-Then +io.sc.engine.rule.core.enums.ParameterProcessorType.NUMBER_RANGE=Number Range +io.sc.engine.rule.core.enums.ParameterProcessorType.CONDITION_RANGE=Condition Range +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE_2C=Simple Decision Table +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE=Decision Table +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TREE=Decision Tree +io.sc.engine.rule.core.enums.ParameterProcessorType.EXECUTION_FLOW=Execution Flow +io.sc.engine.rule.core.enums.ParameterProcessorType.PMML=PMML +io.sc.engine.rule.core.enums.ParameterProcessorType.SCRIPT=Script + +#================================================ +# \u6570\u636E\u5B57\u5178\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DictionaryType.FOLDER=Folder +io.sc.engine.rule.core.enums.DictionaryType.JAVA_CLASS=Java Class +io.sc.engine.rule.core.enums.DictionaryType.UD_JAVA_CLASS=User Defined Class +io.sc.engine.rule.core.enums.DictionaryType.ENUM=Enumerate + +#================================================ +# \u5E93\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.LibType.INDICATOR=Indicator Lib + +#================================================ +# \u6307\u6807\u9A8C\u8BC1\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ValidatorType.EMPTY=Empty +io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY=Not Empty +io.sc.engine.rule.core.enums.ValidatorType.TRUE=True +io.sc.engine.rule.core.enums.ValidatorType.FALSE=False +io.sc.engine.rule.core.enums.ValidatorType.INTEGER_RANGE=Integer Range +io.sc.engine.rule.core.enums.ValidatorType.DECIMAL_RANGE=Decimal Range +io.sc.engine.rule.core.enums.ValidatorType.EMAIL=Email +io.sc.engine.rule.core.enums.ValidatorType.LENGTH_RANGE=Length Range +io.sc.engine.rule.core.enums.ValidatorType.DATE_RANGE=Date Range +io.sc.engine.rule.core.enums.ValidatorType.PATTERN=Regular Expression + +# \u6307\u6807\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorProcessorType.ARITHMETIC=Arithmetic +io.sc.engine.rule.core.enums.IndicatorProcessorType.TERNARY=Ternary +io.sc.engine.rule.core.enums.IndicatorProcessorType.WHEN_THEN=When-Then +io.sc.engine.rule.core.enums.IndicatorProcessorType.NUMBER_RANGE=Number Range +io.sc.engine.rule.core.enums.IndicatorProcessorType.CONDITION_RANGE=Condition Range +io.sc.engine.rule.core.enums.IndicatorProcessorType.SCRIPT=Script + +# \u6307\u6807\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorType.INTERFACE=Interface +io.sc.engine.rule.core.enums.IndicatorType.INDICATOR=Indicator + +#================================================ +# \u8BC4\u5206\u5361\u53D8\u91CF\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ScoreCardVarType.OPTION=Option +io.sc.engine.rule.core.enums.ScoreCardVarType.NUMBER_RANGE=Range +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_OPTION=Option(Indicator) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_NUMBER_RANGE=Range(Indicator) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_VALUE=Indicator Value +io.sc.engine.rule.core.enums.ScoreCardVarType.RESULT=Result + +#================================================ +# \u6D4B\u8BD5\u7528\u4F8B\u53C2\u6570\u6765\u6E90\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.TestCaseOwnerType.MODEL=Model +io.sc.engine.rule.core.enums.TestCaseOwnerType.SCORE_CARD=Score Card +io.sc.engine.rule.core.enums.TestCaseOwnerType.LIB=Lib \ No newline at end of file diff --git a/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/enums_zh_CN.properties b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/enums_zh_CN.properties new file mode 100644 index 00000000..80c565c0 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/enums_zh_CN.properties @@ -0,0 +1,158 @@ +#================================================ +# \u8D44\u6E90\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ResourceType.FOLDER=\u6587\u4EF6\u5939 +io.sc.engine.rule.core.enums.ResourceType.MODEL=\u6A21\u578B +io.sc.engine.rule.core.enums.ResourceType.SCORE_CARD=\u8BC4\u5206\u5361 + +#================================================ +# \u6A21\u578B\u5206\u7C7B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ModelCategory.QUANTITATIVE=\u5B9A\u91CF +io.sc.engine.rule.core.enums.ModelCategory.QUALITATIVE=\u5B9A\u6027 +io.sc.engine.rule.core.enums.ModelCategory.ADJUSTMENT=\u8C03\u6574\u9879 +io.sc.engine.rule.core.enums.ModelCategory.RULE=\u89C4\u5219 +io.sc.engine.rule.core.enums.ModelCategory.OTHER=\u5176\u4ED6 + +#================================================ +# \u6A21\u578B\u6267\u884C\u6A21\u5F0F\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ExecuteMode.TOP_DOWN=\u81EA\u4E0A\u800C\u4E0B +io.sc.engine.rule.core.enums.ExecuteMode.DOWN_TOP=\u81EA\u4E0B\u800C\u4E0A + +#================================================ +# \u6A21\u578B\u72B6\u6001\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DeployStatus=\u53D1\u5E03\u72B6\u6001 +io.sc.engine.rule.core.enums.DeployStatus.HISTORY=\u5386\u53F2 +io.sc.engine.rule.core.enums.DeployStatus.RELEASE=\u53D1\u5E03 +io.sc.engine.rule.core.enums.DeployStatus.SKETCH=\u8349\u7A3F +io.sc.engine.rule.core.enums.DeployStatus.APPROVING=\u5BA1\u6279\u4E2D + +#================================================ +# \u53C2\u6570\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterType.IN=\u8F93\u5165\u503C +io.sc.engine.rule.core.enums.ParameterType.IN_OPTION=\u8F93\u5165\u503C(\u9009\u9879) +io.sc.engine.rule.core.enums.ParameterType.IN_SUB_OUT=\u5B50\u6A21\u578B\u7ED3\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.INDICATOR=\u6307\u6807 +io.sc.engine.rule.core.enums.ParameterType.INTERMEDIATE=\u4E2D\u95F4\u503C +io.sc.engine.rule.core.enums.ParameterType.RULE_RESULT=\u89C4\u5219\u7ED3\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.SINGLE_RULE_RESULT=\u5355\u89C4\u5219\u7ED3\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.OUT=\u7ED3\u679C\u503C +io.sc.engine.rule.core.enums.ParameterType.CONSTANT=\u5E38\u91CF + +#================================================ +# \u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ProcessorType.EMPTY=\u7A7A +io.sc.engine.rule.core.enums.ProcessorType.OPTION_VALUE=\u9009\u9879\u503C +io.sc.engine.rule.core.enums.ProcessorType.ARITHMETIC=\u7B97\u6570\u8FD0\u7B97 +io.sc.engine.rule.core.enums.ProcessorType.TERNARY=\u4E09\u5143\u64CD\u4F5C +io.sc.engine.rule.core.enums.ProcessorType.WHEN_THEN=When Then \u8FD0\u7B97 +io.sc.engine.rule.core.enums.ProcessorType.RULE=\u89C4\u5219 +io.sc.engine.rule.core.enums.ProcessorType.SINGLE_RULE=\u5355\u89C4\u5219 +io.sc.engine.rule.core.enums.ProcessorType.NUMBER_RANGE=\u6570\u503C\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.ProcessorType.CONDITION_RANGE=\u6761\u4EF6\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE_2C=\u7B80\u5355\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TABLE=\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.ProcessorType.DECISION_TREE=\u51B3\u7B56\u6811 +io.sc.engine.rule.core.enums.ProcessorType.EXECUTION_FLOW=\u6267\u884C\u6D41 +io.sc.engine.rule.core.enums.ProcessorType.PMML=\u9884\u6D4B\u6A21\u578B\u6807\u8BB0\u8BED\u8A00 +io.sc.engine.rule.core.enums.ProcessorType.GROOVY_SCRIPT=Groovy \u811A\u672C\u4EE3\u7801 +io.sc.engine.rule.core.enums.ProcessorType.SQL=SQL \u8D4B\u503C +io.sc.engine.rule.core.enums.ProcessorType.HTTP_REQUEST=Http \u8BF7\u6C42 + +#================================================ +# HTTP \u8BF7\u6C42\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpMethodType.GET=GET +io.sc.engine.rule.core.enums.HttpMethodType.POST=POST +io.sc.engine.rule.core.enums.HttpMethodType.PUT=PUT +io.sc.engine.rule.core.enums.HttpMethodType.DELETE=DELETE +io.sc.engine.rule.core.enums.HttpMethodType.HEAD=HEAD +io.sc.engine.rule.core.enums.HttpMethodType.PATCH=PATCH +io.sc.engine.rule.core.enums.HttpMethodType.OPTIONS=OPTIONS +io.sc.engine.rule.core.enums.HttpMethodType.TRACE=TRACE + +#================================================ +# HTTP \u8BA4\u8BC1\u65B9\u6CD5\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.HttpAuthorizationType.NONE=No Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.API_KEY=API Key +io.sc.engine.rule.core.enums.HttpAuthorizationType.BASIC_AUTH=Basic Auth +io.sc.engine.rule.core.enums.HttpAuthorizationType.BEARER=Bearer Token + +#================================================ +# \u53C2\u6570\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ParameterProcessorType.OPTION_VALUE=\u9009\u9879\u503C +io.sc.engine.rule.core.enums.ParameterProcessorType.ARITHMETIC=\u7B97\u6570\u8FD0\u7B97 +io.sc.engine.rule.core.enums.ParameterProcessorType.TERNARY=\u4E09\u5143\u64CD\u4F5C +io.sc.engine.rule.core.enums.ParameterProcessorType.WHEN_THEN=When Then \u8FD0\u7B97 +io.sc.engine.rule.core.enums.ParameterProcessorType.NUMBER_RANGE=\u6570\u503C\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.ParameterProcessorType.CONDITION_RANGE=\u6761\u4EF6\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE_2C=\u7B80\u5355\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TABLE=\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.ParameterProcessorType.DECISION_TREE=\u51B3\u7B56\u6811 +io.sc.engine.rule.core.enums.ParameterProcessorType.EXECUTION_FLOW=\u6267\u884C\u6D41 +io.sc.engine.rule.core.enums.ParameterProcessorType.PMML=\u9884\u6D4B\u6A21\u578B\u6807\u8BB0\u8BED\u8A00 +io.sc.engine.rule.core.enums.ParameterProcessorType.SCRIPT=\u811A\u672C\u4EE3\u7801 + +#================================================ +# \u6570\u636E\u5B57\u5178\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.DictionaryType.FOLDER=\u6587\u4EF6\u5939 +io.sc.engine.rule.core.enums.DictionaryType.JAVA_CLASS=Java \u7C7B +io.sc.engine.rule.core.enums.DictionaryType.UD_JAVA_CLASS=\u81EA\u5B9A\u4E49\u7C7B +io.sc.engine.rule.core.enums.DictionaryType.ENUM=\u679A\u4E3E + +#================================================ +# \u5E93\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.LibType.INDICATOR=\u6307\u6807\u5E93 + +#================================================ +# \u6307\u6807\u9A8C\u8BC1\u5668\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ValidatorType.EMPTY=\u7A7A +io.sc.engine.rule.core.enums.ValidatorType.NOT_EMPTY=\u975E\u7A7A +io.sc.engine.rule.core.enums.ValidatorType.TRUE=\u771F +io.sc.engine.rule.core.enums.ValidatorType.FALSE=\u5047 +io.sc.engine.rule.core.enums.ValidatorType.INTEGER_RANGE=\u6574\u6570\u8303\u56F4 +io.sc.engine.rule.core.enums.ValidatorType.DECIMAL_RANGE=\u5C0F\u6570\u8303\u56F4 +io.sc.engine.rule.core.enums.ValidatorType.EMAIL=\u90AE\u7BB1 +io.sc.engine.rule.core.enums.ValidatorType.LENGTH_RANGE=\u957F\u5EA6\u8303\u56F4 +io.sc.engine.rule.core.enums.ValidatorType.DATE_RANGE=\u65E5\u671F\u8303\u56F4 +io.sc.engine.rule.core.enums.ValidatorType.PATTERN=\u6B63\u5219\u8868\u8FBE\u5F0F + +# \u6307\u6807\u5904\u7406\u5668\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorProcessorType.ARITHMETIC=\u7B97\u6570\u8FD0\u7B97 +io.sc.engine.rule.core.enums.IndicatorProcessorType.TERNARY=\u4E09\u5143\u64CD\u4F5C +io.sc.engine.rule.core.enums.IndicatorProcessorType.WHEN_THEN=When Then \u8FD0\u7B97 +io.sc.engine.rule.core.enums.IndicatorProcessorType.NUMBER_RANGE=\u6570\u503C\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.IndicatorProcessorType.CONDITION_RANGE=\u6761\u4EF6\u5206\u6BB5\u51FD\u6570 +io.sc.engine.rule.core.enums.IndicatorProcessorType.DECISION_TABLE_2C=\u7B80\u5355\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.IndicatorProcessorType.DECISION_TABLE=\u51B3\u7B56\u8868 +io.sc.engine.rule.core.enums.IndicatorProcessorType.SCRIPT=\u811A\u672C\u4EE3\u7801 + +# \u6307\u6807\u7C7B\u578B\u679A\u4E3E +io.sc.engine.rule.core.enums.IndicatorType.INTERFACE=\u63A5\u53E3 +io.sc.engine.rule.core.enums.IndicatorType.INDICATOR=\u6307\u6807 + +#================================================ +# \u8BC4\u5206\u5361\u53D8\u91CF\u7C7B\u578B\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.ScoreCardVarType.OPTION=\u9009\u9879 +io.sc.engine.rule.core.enums.ScoreCardVarType.NUMBER_RANGE=\u5206\u6BB5 +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_OPTION=\u9009\u9879(\u6307\u6807) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_NUMBER_RANGE=\u5206\u6BB5(\u6307\u6807) +io.sc.engine.rule.core.enums.ScoreCardVarType.INDICATOR_VALUE=\u6307\u6807\u503C +io.sc.engine.rule.core.enums.ScoreCardVarType.RESULT=\u7ED3\u679C\u503C + +#================================================ +# \u6D4B\u8BD5\u7528\u4F8B\u53C2\u6570\u6765\u6E90\u679A\u4E3E +#================================================ +io.sc.engine.rule.core.enums.TestCaseOwnerType.MODEL=\u6A21\u578B +io.sc.engine.rule.core.enums.TestCaseOwnerType.SCORE_CARD=\u8BC4\u5206\u5361 +io.sc.engine.rule.core.enums.TestCaseOwnerType.LIB=\u6307\u6807\u5E93 \ No newline at end of file diff --git a/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/example.properties b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/example.properties new file mode 100644 index 00000000..efc4658f --- /dev/null +++ b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/example.properties @@ -0,0 +1,9 @@ +#================================================================================ +# \u8d44\u6e90 +#================================================================================ +# \u5f15\u64ce +re.engine.example.resource.engine=Engine Sample +re.engine.example.resource.engine.description= + +re.engine.example.resource.engine.base=Base Sample +re.engine.example.resource.engine.base.description=Engine Base Sample diff --git a/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/example_zh_CN.properties b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/example_zh_CN.properties new file mode 100644 index 00000000..f17a62a7 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/example_zh_CN.properties @@ -0,0 +1,9 @@ +#================================================================================ +# \u8d44\u6e90 +#================================================================================ +# \u5f15\u64ce +re.engine.example.resource.engine=\u5f15\u64ce\u793a\u4f8b +re.engine.example.resource.engine.description= + +re.engine.example.resource.engine.base=\u57fa\u672c\u793a\u4f8b +re.engine.example.resource.engine.base.description=\u5f15\u64ce\u81ea\u5e26\u57fa\u672c\u793a\u4f8b \ No newline at end of file diff --git a/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/exception.properties b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/exception.properties new file mode 100644 index 00000000..8ea6b606 --- /dev/null +++ b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/exception.properties @@ -0,0 +1,31 @@ +# \u811A\u672C\u8BED\u6CD5\u9A8C\u8BC1\u8FDD\u4F8B +javax.script.ScriptException=Script has some Error + +# \u6570\u636E\u5B57\u5178 +io.sc.engine.rule.server.dictionary.exception.FolderDictionaryAlreadyExistsException=folder with same name already exists! +io.sc.engine.rule.server.dictionary.exception.DictionaryAlreadyExistsException=dictionary with same code or name already exists! +io.sc.engine.rule.server.dictionary.exception.JavaClassNotExistsException=can NOT found the java class! +io.sc.engine.rule.server.dictionary.exception.UserDefinedJavaClassFieldAlreadyExistsException=java class field with same code or name already exists! +io.sc.engine.rule.server.dictionary.exception.UserDefinedJavaClassFieldCodeOrNameNotAllowSameWithDictionaryException=NOT allow field has same code or name with dictionary! +io.sc.engine.rule.server.dictionary.exception.EnumItemEntityAlreadyExistsException=Enumrate Item with same value or title already exists! + +# \u6307\u6807\u5E93 +io.sc.engine.rule.server.lib.exception.FolderAlreadyExistsException=folder with same name already exists! +io.sc.engine.rule.server.lib.exception.LibAlreadyExistsException=lib with same code or name already exists! +io.sc.engine.rule.server.lib.exception.IndicatorAlreadyExistsException=indicator with same code or name already exists! +io.sc.engine.rule.server.lib.exception.CsvIndicatorFormatException=CSV Record Format Error! Cause By:

1. Record property's count NOT currect(TIP: include CR or LF) + +# \u8D44\u6E90\u5E93 +io.sc.engine.rule.server.resource.exception.FolderAlreadyExistsException=folder with same name already exists! +io.sc.engine.rule.server.resource.exception.ResourceAlreadyExistsException=resource with same code or name already exists! + +# \u6A21\u578B +io.sc.engine.rule.server.model.exception.ModelEntityAlreadyExistsException=model or sub model with same code or name already exists! +io.sc.engine.rule.server.model.exception.ParameterEntityAlreadyExistsException=parameter with same code or name already exists! + +# \u8BC4\u5206\u5361 +io.sc.engine.rule.server.scorecard.exception.ScoreCardVarAlreadyExistsException=score card variable with same code or name already exists! +io.sc.engine.rule.server.scorecard.exception.ScoreCardVarCodeAndIndicatorCodeSameException=score card variable has a code same with indicator! + +# \u5BFC\u5165\u5BFC\u51FA\u9519\u8BEF +io.sc.engine.rule.server.import.exception.IllegalImportFileException=the import File is Illegal! diff --git a/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/exception_zh_CN.properties b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/exception_zh_CN.properties new file mode 100644 index 00000000..16f1f4bc --- /dev/null +++ b/io.sc.engine.rule.server/src/main/resources/io/sc/engine/rule/server/i18n/exception_zh_CN.properties @@ -0,0 +1,31 @@ +# \u811A\u672C\u8BED\u6CD5\u9A8C\u8BC1\u8FDD\u4F8B +javax.script.ScriptException=\u811A\u672C\u51FA\u73B0\u8BED\u6CD5\u9519\u8BEF + +# \u6570\u636E\u5B57\u5178 +io.sc.engine.rule.server.dictionary.exception.FolderDictionaryAlreadyExistsException=\u540C\u540D\u6587\u4EF6\u5939\u5DF2\u7ECF\u5B58\u5728! +io.sc.engine.rule.server.dictionary.exception.DictionaryAlreadyExistsException=\u76F8\u540C\u4EE3\u7801\u6216\u540D\u79F0\u7684\u6570\u636E\u5B57\u5178\u5DF2\u7ECF\u5B58\u5728! +io.sc.engine.rule.server.dictionary.exception.JavaClassNotExistsException=\u672A\u627E\u5230\u6307\u5B9A\u7684 Java \u7C7B! +io.sc.engine.rule.server.dictionary.exception.UserDefinedJavaClassFieldAlreadyExistsException=\u76F8\u540C\u4EE3\u7801\u6216\u540D\u79F0\u7684\u5B57\u6BB5\u5DF2\u7ECF\u5B58\u5728! +io.sc.engine.rule.server.dictionary.exception.UserDefinedJavaClassFieldCodeOrNameNotAllowSameWithDictionaryException=\u5B57\u4EE3\u7801\u6216\u540D\u79F0\u4E0D\u4E88\u8BB8\u548C\u6570\u636E\u5B57\u5178\u7684\u4EE3\u7801\u6216\u540D\u79F0\u76F8\u540C! +io.sc.engine.rule.server.dictionary.exception.EnumItemEntityAlreadyExistsException=\u76F8\u540C\u503C\u6216\u6807\u9898\u7684\u679A\u4E3E\u9879\u5DF2\u7ECF\u5B58\u5728! + +# \u6307\u6807\u5E93 +io.sc.engine.rule.server.lib.exception.FolderAlreadyExistsException=\u540C\u540D\u6587\u4EF6\u5939\u5DF2\u7ECF\u5B58\u5728! +io.sc.engine.rule.server.lib.exception.LibAlreadyExistsException=\u76F8\u540C\u4EE3\u7801\u6216\u540D\u79F0\u7684\u5E93\u5DF2\u7ECF\u5B58\u5728! +io.sc.engine.rule.server.lib.exception.IndicatorAlreadyExistsException=\u76F8\u540C\u4EE3\u7801\u6216\u540D\u79F0\u7684\u6307\u6807\u5DF2\u7ECF\u5B58\u5728! +io.sc.engine.rule.server.lib.exception.CsvIndicatorFormatException=CSV \u6587\u4EF6\u683C\u5F0F\u9519\u8BEF!\u53EF\u80FD\u7684\u539F\u56E0:

1.\u5C5E\u6027\u4E2A\u6570\u4E0D\u6B63\u786E(\u51FA\u73B0\u56DE\u8F66\u6362\u884C) + +# \u8D44\u6E90\u5E93 +io.sc.engine.rule.server.resource.exception.FolderAlreadyExistsException=\u540C\u540D\u6587\u4EF6\u5939\u5DF2\u7ECF\u5B58\u5728! +io.sc.engine.rule.server.resource.exception.ResourceAlreadyExistsException=\u76F8\u540C\u4EE3\u7801\u6216\u540D\u79F0\u7684\u8D44\u6E90\u5DF2\u7ECF\u5B58\u5728! + +# \u6A21\u578B +io.sc.engine.rule.server.model.exception.ModelEntityAlreadyExistsException=\u76F8\u540C\u4EE3\u7801\u6216\u540D\u79F0\u7684\u6A21\u578B\u6216\u5B50\u6A21\u578B\u5DF2\u7ECF\u5B58\u5728! +io.sc.engine.rule.server.model.exception.ParameterEntityAlreadyExistsException=\u76F8\u540C\u4EE3\u7801\u6216\u540D\u79F0\u7684\u53C2\u6570\u5DF2\u7ECF\u5B58\u5728! + +# \u8BC4\u5206\u5361 +io.sc.engine.rule.server.scorecard.exception.ScoreCardVarAlreadyExistsException=\u76F8\u540C\u4EE3\u7801\u6216\u540D\u79F0\u7684\u8BC4\u5206\u5361\u53D8\u91CF\u5DF2\u7ECF\u5B58\u5728! +io.sc.engine.rule.server.scorecard.exception.ScoreCardVarCodeAndIndicatorCodeSameException=\u8BC4\u5206\u5361\u53D8\u91CF\u4EE3\u7801\u4E0D\u80FD\u548C\u6307\u6807\u4EE3\u7801\u76F8\u540C! + +# \u5BFC\u5165\u5BFC\u51FA\u9519\u8BEF +io.sc.engine.rule.server.import.exception.IllegalImportFileException=\u5BFC\u5165\u7684\u6587\u4EF6\u4E0D\u662F\u4E00\u4E2A\u5408\u6CD5\u7684\u6587\u4EF6! diff --git a/io.sc.platform.attachment.api/src/main/java/io/sc/platform/attachment/api/DiskAttachmentVo.java b/io.sc.platform.attachment.api/src/main/java/io/sc/platform/attachment/api/DiskAttachmentVo.java new file mode 100644 index 00000000..fd2fad18 --- /dev/null +++ b/io.sc.platform.attachment.api/src/main/java/io/sc/platform/attachment/api/DiskAttachmentVo.java @@ -0,0 +1,15 @@ +package io.sc.platform.attachment.api; + +import io.sc.platform.orm.api.vo.AuditorVo; + +public class DiskAttachmentVo extends AttachmentVo { + private String path; + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } +} diff --git a/io.sc.platform.attachment/src/main/java/io/sc/platform/attachment/jpa/entity/DiskAttachmentEntity.java b/io.sc.platform.attachment/src/main/java/io/sc/platform/attachment/jpa/entity/DiskAttachmentEntity.java new file mode 100644 index 00000000..4ec3b86f --- /dev/null +++ b/io.sc.platform.attachment/src/main/java/io/sc/platform/attachment/jpa/entity/DiskAttachmentEntity.java @@ -0,0 +1,34 @@ +package io.sc.platform.attachment.jpa.entity; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.sc.platform.attachment.api.DiskAttachmentVo; + +import javax.persistence.Column; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; +import javax.validation.constraints.Size; + +@Entity +@DiscriminatorValue("DISK") +@JsonTypeName("DISK") +public class DiskAttachmentEntity extends AttachmentEntity { + @Column(name="PATH_", length=1024) + @Size(max=1024) + protected String path; + + @Override + public DiskAttachmentVo toVo() { + DiskAttachmentVo vo =new DiskAttachmentVo(); + super.toVo(vo); + vo.setPath(this.getPath()); + return vo; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } +}