Skip to content

Commit

Permalink
修正复杂输入类型的导入处理
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Sep 6, 2023
1 parent 00cc0cb commit 94f01ab
Show file tree
Hide file tree
Showing 9 changed files with 707 additions and 16 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ static class Item {

List<Object> makeChildren(String childrenProp, String childKeyProp) {
if (children == null) {
children = childKeyProp == null ? new ArrayList<>() : new KeyedList<>(obj -> BeanTool.getProperty(obj, childKeyProp));
BeanTool.instance().setProperty(record, childrenProp, children);
children = childKeyProp == null ? new ArrayList<>() : new KeyedList<>(obj -> BeanTool.getComplexProperty(obj, childKeyProp));
BeanTool.setComplexProperty(record, childrenProp, children);
}
return children;
}
Expand All @@ -113,7 +113,7 @@ private static <T> void _flattenTree(Collection<T> list, String childrenProp, bo
Collection<T> c = (Collection<T>) BeanTool.getProperty(item, childrenProp);
if (c != null) {
if(removeChildren)
BeanTool.setProperty(item, childrenProp,null);
BeanTool.setComplexProperty(item, childrenProp,null);
_flattenTree(c, childrenProp, removeChildren,ret);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@

<normalizeFieldsExpr><![CDATA[
import io.nop.excel.imp.util.ImportDataHelper;
ImportDataHelper.normalizeTree(record.inputs, "props","ext:level","name");
ImportDataHelper.normalizeTree(record.inputs, "schema.props","ext:level","name");
record.inputs = _.toKeyedList(record.inputs,'name');
]]></normalizeFieldsExpr>
</sheet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void saveRuleModel(RuleModel ruleModel, NopRuleDefinition entity) {
ruleModel.setDecisionTree(null);

XNode node = DslModelHelper.dslModelToXNode(NopRuleDaoConstants.XDEF_PATH_RULE, ruleModel);
entity.setModelText(node.xml());
entity.getModelTextXmlComponent().setNode(node);

if (tree == null) {
entity.getRuleNodes().clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</prop>

<prop name="importFile" displayName="Excel规则文件" readable="false" updatable="false" insertable="false"
ui:uploadAccept=".rule.xlsx">
ui:uploadAccept=".rule.xlsx" internal="true">
<schema stdDomain="file"/>
</prop>

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,17 @@ A,@var:NopRuleDefinition@ruleId,testMatrix,1,Test Matrix,default,MATX,,"<rule di
<schema/>
</input>
<input displayName=""基础信息"" mandatory=""true"" name=""baseInfo"" type=""Object"" ext:level=""0"">
<schema/>
<schema implementsTypes="""">
<props>
<prop displayName=""年龄"" mandatory=""true"" name=""age"" type=""Integer"" ext:level=""1""
i18n-en:displayName=""Age"">
<schema type=""Integer""/>
</prop>
<prop displayName=""性别"" mandatory=""true"" name=""gender"" type=""Integer"" ext:level=""1"">
<schema type=""Integer""/>
</prop>
</props>
</schema>
</input>
<input computed=""true"" displayName=""性别"" mandatory=""true"" name=""gender"" type=""Integer"" ext:level=""0"">
<defaultExpr>baseInfo.gender</defaultExpr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
<!--初始化代码-->
<col id="beforeExecute" x:abstract="true"/>

<!--Excel规则文件-->
<col id="importFile"/>

<!--决策矩阵配置-->
<col id="decisionMatrix" x:abstract="true"/>
</cols>
Expand All @@ -69,8 +66,7 @@
createTime[创建时间] updatedBy[修改人]
updateTime[修改时间]
remark[备注]
beforeExecute[初始化代码] importFile[Excel规则文件]
decisionMatrix[决策矩阵配置]
beforeExecute[初始化代码] decisionMatrix[决策矩阵配置]
</layout>
</form>
<form id="add" editMode="add" title="新增-规则模型定义" i18n-en:title="Add Rule Definition" x:prototype="edit"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.nop.core.CoreConstants;
import io.nop.core.lang.eval.IEvalAction;
import io.nop.core.lang.xml.XNode;
import io.nop.core.lang.xml.json.StdJsonToXNodeTransformer;
import io.nop.core.lang.xml.parse.XNodeParser;
import io.nop.core.reflect.ReflectionManager;
import io.nop.core.type.IFunctionType;
Expand Down Expand Up @@ -185,7 +184,16 @@ public XNode transformToNode(Object value) {
return node;
}
}
return StdJsonToXNodeTransformer.INSTANCE.transformToXNode(value);

if (value instanceof String) {
String str = value.toString();
if (isSupportContentScript() && !str.startsWith("<")) {
XNode node = XNode.make(CoreConstants.DUMMY_TAG_NAME);
node.content(value);
return node;
}
}
return XNode.fromValue(value);
}
}

Expand Down

0 comments on commit 94f01ab

Please sign in to comment.