Search in sources :

Example 1 with MangoJavaScript

use of com.infiniteautomation.mango.util.script.MangoJavaScript in project ma-modules-public by infiniteautomation.

the class EventHandlersRestController method validateScript.

private MangoJavaScriptResultModel validateScript(MangoJavaScriptModel model, String noChangeTranslationKey) {
    // Set to potentially return a String
    model.setResultDataType(DataType.NUMERIC.name());
    MangoJavaScript jsVo = model.toVO();
    jsVo.setWrapInFunction(true);
    return new MangoJavaScriptResultModel(javaScriptService.testScript(jsVo, noChangeTranslationKey));
}
Also used : MangoJavaScriptResultModel(com.infiniteautomation.mango.rest.latest.model.javascript.MangoJavaScriptResultModel) MangoJavaScript(com.infiniteautomation.mango.util.script.MangoJavaScript)

Example 2 with MangoJavaScript

use of com.infiniteautomation.mango.util.script.MangoJavaScript in project ma-modules-public by infiniteautomation.

the class MangoJavaScriptModel method toVO.

public MangoJavaScript toVO() {
    MangoJavaScript vo = new MangoJavaScript();
    vo.setWrapInFunction(wrapInFunction);
    vo.setContext(convertContext());
    vo.setLogLevel(logLevel);
    PermissionService service = Common.getBean(PermissionService.class);
    vo.setPermissions(new ScriptPermissions(service.explodeLegacyPermissionGroupsToRoles(permissions)));
    if (resultDataType != null)
        vo.setResultDataType(DataType.fromName(resultDataType));
    vo.setScript(script);
    vo.setAdditionalContext(additionalContext);
    return vo;
}
Also used : PermissionService(com.infiniteautomation.mango.spring.service.PermissionService) MangoJavaScript(com.infiniteautomation.mango.util.script.MangoJavaScript) ScriptPermissions(com.infiniteautomation.mango.util.script.ScriptPermissions)

Aggregations

MangoJavaScript (com.infiniteautomation.mango.util.script.MangoJavaScript)2 MangoJavaScriptResultModel (com.infiniteautomation.mango.rest.latest.model.javascript.MangoJavaScriptResultModel)1 PermissionService (com.infiniteautomation.mango.spring.service.PermissionService)1 ScriptPermissions (com.infiniteautomation.mango.util.script.ScriptPermissions)1