use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.
the class SpecWithNestedEntityAndCustomFunction method getScriptFunctions.
@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
FunctionLibrary library = new FunctionLibrary();
IScriptEvaluator evaluator = evalProvider.createEvaluator("button");
evaluator.addScriptFunction(new ScriptClassFunction("convertClickType", "function convertClickType(clickType) {if (clickType === 'SINGLE') return 1; else if (clickType === 'DOUBLE') return 2; else return 99;}"));
library.addFunctions(evaluator.getFunctions());
return library;
}
use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.
the class MappingSpecification method getScriptFunctions.
@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider factory) {
FunctionLibrary library = new FunctionLibrary();
this.infoModel.getFunctionblocks().stream().forEach(property -> {
IMappedElement mappedElement = (IMappedElement) property.getType();
if (mappedElement.getStereotype(STEREOTYPE_FUNCTIONS).isPresent()) {
Stereotype functionsStereoType = mappedElement.getStereotype(STEREOTYPE_FUNCTIONS).get();
IScriptEvaluator evaluator = factory.createEvaluator(property.getName().toLowerCase());
functionsStereoType.getAttributes().keySet().stream().filter(functionName -> !functionName.equalsIgnoreCase(STEREOTYPE_NAMESPACE)).forEach(functionName -> evaluator.addScriptFunction(new ScriptClassFunction(functionName, functionsStereoType.getAttributes().get(functionName))));
library.addFunctions(evaluator.getFunctions());
}
});
return library;
}
use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.
the class SpecWithMultipleParams method getScriptFunctions.
@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
FunctionLibrary library = new FunctionLibrary();
IScriptEvaluator evaluator = evalProvider.createEvaluator("button");
evaluator.addScriptFunction(new ScriptClassFunction("convertArray", "function convertArray(arrayValue,header) { return header+String.fromCharCode(arrayValue[0])}"));
library.addFunctions(evaluator.getFunctions());
return library;
}
Aggregations