use of com.axelor.script.GroovyScriptHelper in project axelor-open-suite by axelor.
the class ConfiguratorServiceImpl method computeFormula.
@Override
public Object computeFormula(String groovyFormula, JsonContext values) {
User currentUser = AuthUtils.getUser();
Company company = currentUser != null ? currentUser.getActiveCompany() : null;
values.put("__user__", currentUser);
values.put("__date__", appBaseService.getTodayDate(company));
values.put("__datetime__", appBaseService.getTodayDateTime(company));
ScriptHelper scriptHelper = new GroovyScriptHelper(values);
return scriptHelper.eval(groovyFormula);
}
use of com.axelor.script.GroovyScriptHelper 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);
}
Aggregations