Search in sources :

Example 1 with ProcessActionNode

use of com.axelor.apps.baml.xml.ProcessActionNode in project axelor-open-suite by axelor.

the class BamlServiceImpl method generateGroovyCode.

@Override
public String generateGroovyCode(String xml) throws AxelorException {
    ProcessActionRootNode rootNode = null;
    rootNode = BamlParser.parse(IOUtils.toInputStream(xml, "utf-8"));
    if (rootNode == null) {
        return null;
    }
    List<ProcessActionNode> processActionNodes = rootNode.getProcessActions();
    StringBuilder codeBuilder = new StringBuilder();
    if (processActionNodes != null) {
        ProcessActionNode processActionNode = processActionNodes.get(0);
        generateCode(codeBuilder, processActionNode);
    }
    return codeBuilder.toString();
}
Also used : ProcessActionNode(com.axelor.apps.baml.xml.ProcessActionNode) ProcessActionRootNode(com.axelor.apps.baml.xml.ProcessActionRootNode)

Example 2 with ProcessActionNode

use of com.axelor.apps.baml.xml.ProcessActionNode in project axelor-open-suite by axelor.

the class TestBamlParser method test.

public void test() {
    InputStream is = ResourceUtils.getResourceStream("BamlTest.xml");
    ProcessActionRootNode rootNode = BamlParser.parse(is);
    List<ProcessActionNode> processActionNodes = rootNode.getProcessActions();
    String script = "";
    if (processActionNodes != null) {
        script = processActionNodes.get(0).toCode(true);
    }
    Context ctx = new Context(User.class);
    GroovyScriptHelper helper = new GroovyScriptHelper(ctx);
    helper.eval(script);
}
Also used : Context(com.axelor.rpc.Context) InputStream(java.io.InputStream) ProcessActionNode(com.axelor.apps.baml.xml.ProcessActionNode) ProcessActionRootNode(com.axelor.apps.baml.xml.ProcessActionRootNode) GroovyScriptHelper(com.axelor.script.GroovyScriptHelper)

Aggregations

ProcessActionNode (com.axelor.apps.baml.xml.ProcessActionNode)2 ProcessActionRootNode (com.axelor.apps.baml.xml.ProcessActionRootNode)2 Context (com.axelor.rpc.Context)1 GroovyScriptHelper (com.axelor.script.GroovyScriptHelper)1 InputStream (java.io.InputStream)1