Skip to content

Commit

Permalink
修正DslModelToXNodeTransformer对于复杂扩展属性的处理
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Jan 17, 2025
1 parent 4323b81 commit 856e49d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class CliGenCommand implements Callable<Integer> {
static final Logger LOG = LoggerFactory.getLogger(CliGenCommand.class);


@CommandLine.Option(names = {"-t", "--template"},
@CommandLine.Option(names = {"-t", "--template"}, required = true,
description = "模板文件路径,至少需要指定一个模板。")
String[] templates;

Expand Down
17 changes: 16 additions & 1 deletion nop-cli-core/src/test/java/io/nop/cli/TestNopCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,22 @@ public void testRunBatchDemo() {
File devDir = new File(getModuleDir(), "../nop-cli/demo/");
System.setProperty(CoreConfigs.CFG_DEV_ROOT_PATH.getName(), devDir.getAbsolutePath());
System.setProperty(CoreConfigs.CFG_RESOURCE_DIR_OVERRIDE_VFS.getName(), file.getAbsolutePath());
String[] args = new String[]{"run-task", "v:/batch/batch-demo.task.xml", "-i", "{bizDate:'2024-12-08'}"};
String[] args = new String[]{"run-task", "v:/batch/batch-demo.task.xml", "-i", "{bizDate:'2024-12-08'}",
"-t","v:/worldline/temp"};
NopCliApplication app = new NopCliApplication();
app.setFactory(factory);
int ret = app.run(args);
assertEquals(0, ret);
System.getProperties().remove(CoreConfigs.CFG_RESOURCE_DIR_OVERRIDE_VFS.getName());
}

@Test
public void testApi() {
CoreInitialization.destroy();
File file = new File("C:\\workspace\\cardlite-product\\codegen\\_vfs");
System.setProperty(CoreConfigs.CFG_RESOURCE_DIR_OVERRIDE_VFS.getName(), file.getAbsolutePath());
String[] args = new String[]{"gen", "file:/C:/workspace/cardlite-sinopac/codegen/model/api/CAS-delta.api.xml",
"-t=v:/worldline/templates/api","-o", "C:/workspace/cardlite-sinopac/codegen/gen/api"};
NopCliApplication app = new NopCliApplication();
app.setFactory(factory);
int ret = app.run(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
*/
package io.nop.xlang.xdsl.json;

import io.nop.api.core.ApiConstants;
import io.nop.api.core.beans.TreeBean;
import io.nop.api.core.exceptions.NopException;
import io.nop.api.core.util.ISourceLocationGetter;
import io.nop.api.core.util.SourceLocation;
import io.nop.core.CoreConstants;
import io.nop.core.lang.eval.DisabledEvalScope;
import io.nop.core.lang.json.JObject;
import io.nop.core.lang.json.JsonEncodeString;
import io.nop.core.lang.xml.IObjectToXNodeTransformer;
import io.nop.core.lang.xml.XNode;
import io.nop.core.lang.xml.XNodeValuePosition;
Expand Down Expand Up @@ -164,8 +166,13 @@ protected void addToNode(IObjSchema schema, XNode node, Object map, String key,
} else if (key.indexOf(':') > 0) {
// 具有名字空间的属性
if (value instanceof Map<?, ?>) {
TreeBean bean = TreeBean.createFromJson((Map<String, Object>) value);
node.appendChild(XNode.fromTreeBean(bean));
Map<String,Object> mapValue = (Map<String, Object>) value;
if(mapValue.get(ApiConstants.TREE_BEAN_PROP_TYPE) == null){
node.setAttr(key, JsonEncodeString.of(null, value));
}else {
TreeBean bean = TreeBean.createFromJson(mapValue);
node.appendChild(XNode.fromTreeBean(bean));
}
} else {
node.setAttr(getLocation(map, key, value), key, value);
}
Expand Down

0 comments on commit 856e49d

Please sign in to comment.