use of com.haulmont.cuba.core.global.Scripting in project cuba by cuba-platform.
the class TimeBetweenQueryMacroHandler method getParam.
protected String getParam(String[] args, int idx, TimeZone timeZone) {
String arg = args[idx].trim();
String unit = args[3].trim();
Matcher matcher = PARAM_PATTERN.matcher(arg);
if (!matcher.find())
throw new RuntimeException("Invalid macro argument: " + arg);
int num = 0;
try {
String expr = matcher.group(2);
if (!Strings.isNullOrEmpty(expr)) {
Scripting scripting = AppBeans.get(Scripting.class);
num = scripting.evaluateGroovy(expr, new Binding());
}
} catch (NumberFormatException e) {
throw new RuntimeException("Invalid macro argument: " + arg, e);
}
Date date = computeDate(num, unit, timeZone);
String paramName = args[0].trim().replace(".", "_") + "_" + count + "_" + idx;
params.put(paramName, date);
return paramName;
}
use of com.haulmont.cuba.core.global.Scripting in project cuba by cuba-platform.
the class LookupFieldLoader method loadOptionsEnum.
@SuppressWarnings("unchecked")
protected void loadOptionsEnum(LookupField resultComponent, Element element) {
String optionsEnumClass = element.attributeValue("optionsEnum");
if (StringUtils.isNotEmpty(optionsEnumClass)) {
Scripting scripting = AppBeans.get(Scripting.class);
resultComponent.setOptionsEnum((Class<? extends EnumClass>) scripting.loadClass(optionsEnumClass));
}
}
Aggregations