From 3d93df34bfa668ad71be8288dc698bad338b3526 Mon Sep 17 00:00:00 2001 From: canonical Date: Sun, 3 Sep 2023 18:33:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=AE=BE=E7=BD=AEmeta?= =?UTF-8?q?=E6=97=B6=E4=B9=9F=E5=85=81=E8=AE=B8=E5=8D=95=E7=8B=AC=E4=BD=BF?= =?UTF-8?q?=E7=94=A8view=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nop-quarkus-demo/reflect-config.json | 21 ++++++++ .../src/main/resources/nop-vfs-index.txt | 10 ++-- .../io/nop/rule/dao/NopRuleDaoConstants.java | 2 + .../rule/dao/entity/NopRuleDefinition.java | 9 ++++ .../NopRuleDefinition/NopRuleDefinition.xmeta | 4 ++ .../NopRuleDefinition.view.xml | 53 +++++++++++++++++-- .../main/java/io/nop/xui/utils/XuiHelper.java | 2 +- .../io/nop/xui/utils/XuiViewAnalyzer.java | 14 ++--- .../_vfs/nop/web/xlib/web/impl_GenPage.xpl | 2 +- .../java/io/nop/xlang/xmeta/SchemaLoader.java | 7 ++- 10 files changed, 106 insertions(+), 18 deletions(-) diff --git a/nop-demo/nop-quarkus-demo/src/main/resources/META-INF/native-image/io.nop.demo/nop-quarkus-demo/reflect-config.json b/nop-demo/nop-quarkus-demo/src/main/resources/META-INF/native-image/io.nop.demo/nop-quarkus-demo/reflect-config.json index 1971fbbc3..714243423 100644 --- a/nop-demo/nop-quarkus-demo/src/main/resources/META-INF/native-image/io.nop.demo/nop-quarkus-demo/reflect-config.json +++ b/nop-demo/nop-quarkus-demo/src/main/resources/META-INF/native-image/io.nop.demo/nop-quarkus-demo/reflect-config.json @@ -15780,6 +15780,10 @@ "name": "getJavaTypeName", "parameterTypes": [] }, + { + "name": "getJsonType", + "parameterTypes": [] + }, { "name": "getMandatoryJavaClass", "parameterTypes": [] @@ -36876,6 +36880,10 @@ "name": "getBeforeExecute", "parameterTypes": [] }, + { + "name": "getDecisionMatrxi", + "parameterTypes": [] + }, { "name": "getRoleIds", "parameterTypes": [] @@ -36894,6 +36902,12 @@ "java.lang.String" ] }, + { + "name": "setDecisionMatrix", + "parameterTypes": [ + "java.lang.String" + ] + }, { "name": "setRuleInputs", "parameterTypes": [ @@ -38394,6 +38408,13 @@ "io.nop.core.context.IServiceContext" ] }, + { + "name": "getInputJsonSchema", + "parameterTypes": [ + "io.nop.rule.api.beans.RuleKeyBean", + "io.nop.core.context.IServiceContext" + ] + }, { "name": "getOutputFields", "parameterTypes": [ diff --git a/nop-demo/nop-quarkus-demo/src/main/resources/nop-vfs-index.txt b/nop-demo/nop-quarkus-demo/src/main/resources/nop-vfs-index.txt index 7c885f6e6..1d1e35a81 100644 --- a/nop-demo/nop-quarkus-demo/src/main/resources/nop-vfs-index.txt +++ b/nop-demo/nop-quarkus-demo/src/main/resources/nop-vfs-index.txt @@ -308,6 +308,7 @@ /nop/report/imp/xpt.imp.xml /nop/report/spl/spl.xlib /nop/rule/_module +/nop/rule/auth/_nop-rule-api.action-auth.xml /nop/rule/auth/_nop-rule.action-auth.xml /nop/rule/auth/nop-rule.action-auth.xml /nop/rule/auth/nop-rule.data-auth.xml @@ -369,6 +370,9 @@ /nop/rule/pages/NopRuleRole/_gen/_NopRuleRole.view.xml /nop/rule/pages/NopRuleRole/main.page.yaml /nop/rule/pages/NopRuleRole/picker.page.yaml +/nop/rule/pages/RuleService/RuleService.view.xml +/nop/rule/pages/RuleService/_RuleService.view.xml +/nop/rule/pages/RuleService/main.page.yaml /nop/schema/action-auth.xdef /nop/schema/api.xdef /nop/schema/beans.xdef @@ -556,9 +560,9 @@ /nop/templates/antlr/src/main/java/{parser.packagePath}/{parser.name}ParseTreeParser.java.xgen /nop/templates/api-web/@init.xrun /nop/templates/api-web/src/main/resources/_vfs/{moduleId}/auth/_{apiModelName}-api.action-auth.xml.xgen -/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel}/_{serviceModel.name}.view.xml.xgen -/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel}/main.page.yaml.xgen -/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel}/{serviceModel.name}.view.xml.xgen +/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel.name}/_{serviceModel.name}.view.xml.xgen +/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel.name}/main.page.yaml.xgen +/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel.name}/{serviceModel.name}.view.xml.xgen /nop/templates/api/@init.xrun /nop/templates/api/{apiModuleName}/src/main/java/{apiPackagePath}/beans/_gen/_{messageModel.name}.java.xgen /nop/templates/api/{apiModuleName}/src/main/java/{apiPackagePath}/beans/{messageModel.name}.java.xgen diff --git a/nop-rule/nop-rule-dao/src/main/java/io/nop/rule/dao/NopRuleDaoConstants.java b/nop-rule/nop-rule-dao/src/main/java/io/nop/rule/dao/NopRuleDaoConstants.java index 039ac3bad..8f75aa2b1 100644 --- a/nop-rule/nop-rule-dao/src/main/java/io/nop/rule/dao/NopRuleDaoConstants.java +++ b/nop-rule/nop-rule-dao/src/main/java/io/nop/rule/dao/NopRuleDaoConstants.java @@ -12,4 +12,6 @@ public interface NopRuleDaoConstants extends _NopRuleDaoConstants { String OUTPUTS_NAME = "outputs"; String BEFORE_EXECUTE_NAME = "beforeExecute"; + + String DECISION_MATRIX_NAME = "decisionMatrix"; } diff --git a/nop-rule/nop-rule-dao/src/main/java/io/nop/rule/dao/entity/NopRuleDefinition.java b/nop-rule/nop-rule-dao/src/main/java/io/nop/rule/dao/entity/NopRuleDefinition.java index 8ab785974..2d2067da5 100644 --- a/nop-rule/nop-rule-dao/src/main/java/io/nop/rule/dao/entity/NopRuleDefinition.java +++ b/nop-rule/nop-rule-dao/src/main/java/io/nop/rule/dao/entity/NopRuleDefinition.java @@ -9,6 +9,7 @@ import java.util.Set; import static io.nop.rule.dao.NopRuleDaoConstants.BEFORE_EXECUTE_NAME; +import static io.nop.rule.dao.NopRuleDaoConstants.DECISION_MATRIX_NAME; import static io.nop.rule.dao.NopRuleDaoConstants.INPUTS_NAME; import static io.nop.rule.dao.NopRuleDaoConstants.OUTPUTS_NAME; import static io.nop.rule.dao.NopRuleDaoConstants.RULE_TAG_NAME; @@ -52,4 +53,12 @@ public String getBeforeExecute() { public void setBeforeExecute(String value) { getModelTextXmlComponent().setChildBodyXml(RULE_TAG_NAME, BEFORE_EXECUTE_NAME, value); } + + public String getDecisionMatrxi() { + return getModelTextXmlComponent().getChildBodyXml(DECISION_MATRIX_NAME); + } + + public void setDecisionMatrix(String value) { + getModelTextXmlComponent().setChildBodyXml(RULE_TAG_NAME, DECISION_MATRIX_NAME, value); + } } \ No newline at end of file diff --git a/nop-rule/nop-rule-meta/src/main/resources/_vfs/nop/rule/model/NopRuleDefinition/NopRuleDefinition.xmeta b/nop-rule/nop-rule-meta/src/main/resources/_vfs/nop/rule/model/NopRuleDefinition/NopRuleDefinition.xmeta index d9ba75fc5..d0e8c9bed 100644 --- a/nop-rule/nop-rule-meta/src/main/resources/_vfs/nop/rule/model/NopRuleDefinition/NopRuleDefinition.xmeta +++ b/nop-rule/nop-rule-meta/src/main/resources/_vfs/nop/rule/model/NopRuleDefinition/NopRuleDefinition.xmeta @@ -23,5 +23,9 @@ ui:uploadAccept=".rule.xlsx"> + + + + \ No newline at end of file diff --git a/nop-rule/nop-rule-web/src/main/resources/_vfs/nop/rule/pages/NopRuleDefinition/NopRuleDefinition.view.xml b/nop-rule/nop-rule-web/src/main/resources/_vfs/nop/rule/pages/NopRuleDefinition/NopRuleDefinition.view.xml index 62f38e80a..413357fcb 100644 --- a/nop-rule/nop-rule-web/src/main/resources/_vfs/nop/rule/pages/NopRuleDefinition/NopRuleDefinition.view.xml +++ b/nop-rule/nop-rule-web/src/main/resources/_vfs/nop/rule/pages/NopRuleDefinition/NopRuleDefinition.view.xml @@ -27,6 +27,7 @@
==baseInfo[基本信息]==== + __useImportFile importFile ruleName[规则名称] ruleVersion[规则版本] displayName[显示名称] ruleGroup[规则分组] ruleType[规则类型] status[状态] @@ -44,29 +45,67 @@ ==extConfig[扩展配置]== beforeExecute + + ==matrixConfig[决策矩阵配置]== + decisionMatrix + + + + + + ${__useImportFile} + + + ${!__useImportFile} return { "$ref": "inputDefinition" } + ${!__useImportFile} return { "$ref":"outputDefinition" } + + + ${ruleType == 'MATRX} +
-
- - + + + ==baseInfo[基本信息]==== + ruleName[规则名称] ruleVersion[规则版本] + displayName[显示名称] ruleGroup[规则分组] + ruleType[规则类型] status[状态] + description[描述] + remark[备注] + + ==authConfig[权限配置]=== + !ruleRoles + + ==inputsConfig[输入]=== + !ruleInputs + + ==outputsConfig[输出]=== + !ruleOutputs + + ==extConfig[扩展配置]== + beforeExecute + + ==matrixConfig[决策矩阵配置]== + decisionMatrix + @@ -80,6 +119,10 @@ return { "$ref": "viewOutputDefinition" } + + + ${ruleType == 'MATX'} + diff --git a/nop-ui/src/main/java/io/nop/xui/utils/XuiHelper.java b/nop-ui/src/main/java/io/nop/xui/utils/XuiHelper.java index 7cd93b665..53bae222b 100644 --- a/nop-ui/src/main/java/io/nop/xui/utils/XuiHelper.java +++ b/nop-ui/src/main/java/io/nop/xui/utils/XuiHelper.java @@ -199,7 +199,7 @@ public static String getFormSelection(UiFormModel formModel, IObjMeta objMeta) { public static Set getFormProps(UiFormModel formModel, IObjMeta objMeta) { Set propNames = new LinkedHashSet<>(); - if (formModel == null) + if (formModel == null || objMeta == null) return propNames; formModel.getTables().forEach(table -> { table.forEachRealCell((cell, ri, ci) -> { diff --git a/nop-ui/src/main/java/io/nop/xui/utils/XuiViewAnalyzer.java b/nop-ui/src/main/java/io/nop/xui/utils/XuiViewAnalyzer.java index 54938d52e..ed7b965a5 100644 --- a/nop-ui/src/main/java/io/nop/xui/utils/XuiViewAnalyzer.java +++ b/nop-ui/src/main/java/io/nop/xui/utils/XuiViewAnalyzer.java @@ -59,11 +59,12 @@ public class XuiViewAnalyzer { */ public FieldSelectionBean getListSelection(UiGridModel gridModel, IObjMeta objMeta) { FieldSelectionBean selection = new FieldSelectionBean(); - appendPkFields(selection, objMeta); + if (objMeta != null) + appendPkFields(selection, objMeta); for (UiGridColModel colModel : gridModel.getCols()) { String prop = colModel.getProp() == null ? colModel.getId() : colModel.getProp(); - IObjPropMeta propMeta = objMeta.getProp(prop); + IObjPropMeta propMeta = objMeta == null ? null : objMeta.getProp(prop); if (propMeta != null) { if (!propMeta.isReadable()) continue; @@ -107,10 +108,11 @@ public FieldSelectionBean getListSelection(UiGridModel gridModel, IObjMeta objMe public FieldSelectionBean getFormSelection(UiFormModel formModel, IObjMeta objMeta) { Guard.notNull(formModel, "formModel"); - Guard.notNull(objMeta, "objMeta"); + //Guard.notNull(objMeta, "objMeta"); FieldSelectionBean selection = new FieldSelectionBean(); - appendPkFields(selection, objMeta); + if (objMeta != null) + appendPkFields(selection, objMeta); if (formModel.getLayout() != null) { for (ILayoutGroupModel group : formModel.getLayout().getGroups()) { @@ -141,7 +143,7 @@ private void collectSelection(FieldSelectionBean selection, ILayoutGroupModel gr table.forEachLayoutCell(lc -> { UiFormCellModel cellModel = formModel.getCell(lc.getId()); String prop = cellModel == null || cellModel.getProp() == null ? lc.getId() : cellModel.getProp(); - IObjPropMeta propMeta = objMeta.getProp(prop); + IObjPropMeta propMeta = objMeta == null ? null : objMeta.getProp(prop); if (propMeta != null) { // 不可读的数据不会进入selection if (!propMeta.isReadable()) @@ -304,7 +306,7 @@ static void addDepend(Set depends, IObjMeta objMeta, Consumer ac continue; String prop = StringHelper.firstPart(depend, '.'); - if (objMeta.getProp(prop) == null) { + if (objMeta != null && objMeta.getProp(prop) == null) { onMissing.accept(depend); } else { action.accept(depend); diff --git a/nop-web/src/main/resources/_vfs/nop/web/xlib/web/impl_GenPage.xpl b/nop-web/src/main/resources/_vfs/nop/web/xlib/web/impl_GenPage.xpl index 03268e692..8ac99534a 100644 --- a/nop-web/src/main/resources/_vfs/nop/web/xlib/web/impl_GenPage.xpl +++ b/nop-web/src/main/resources/_vfs/nop/web/xlib/web/impl_GenPage.xpl @@ -12,7 +12,7 @@ let objMeta = SchemaLoader.loadXMeta(viewModel.objMeta); let controlLib = XplLibHelper.loadLib(viewModel.controlLib || '/nop/web/xlib/control.xlib'); let bizObjName = viewModel.bizObjName; - let i18nRoot = objMeta['i18n:root'] || bizObjName; + let i18nRoot = objMeta?.['i18n:root'] || bizObjName; diff --git a/nop-xlang/src/main/java/io/nop/xlang/xmeta/SchemaLoader.java b/nop-xlang/src/main/java/io/nop/xlang/xmeta/SchemaLoader.java index 50ffededb..154514607 100644 --- a/nop-xlang/src/main/java/io/nop/xlang/xmeta/SchemaLoader.java +++ b/nop-xlang/src/main/java/io/nop/xlang/xmeta/SchemaLoader.java @@ -7,7 +7,7 @@ */ package io.nop.xlang.xmeta; -import io.nop.api.core.util.Guard; +import io.nop.commons.util.StringHelper; import io.nop.core.lang.xml.XNode; import io.nop.core.resource.component.ResourceComponentManager; import io.nop.xlang.XLangConstants; @@ -19,13 +19,16 @@ public class SchemaLoader { public static IObjMeta loadXMeta(String path) { - Guard.notEmpty(path, "metaPath"); + if (StringHelper.isEmpty(path)) + return null; IObjMeta meta = (IObjMeta) ResourceComponentManager.instance().loadComponentModel(path, XLangConstants.MODEL_TYPE_XMETA); return meta; } public static IXDefinition loadXDefinition(String path) { + if(StringHelper.isEmpty(path)) + return null; IXDefinition xdef = (IXDefinition) ResourceComponentManager.instance().loadComponentModel(path, XLangConstants.MODEL_TYPE_XDEF); return xdef;