Search in sources :

Example 6 with FunctionLibrary

use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.

the class SpecGattConverter method getScriptFunctions.

@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
    FunctionLibrary library = new FunctionLibrary();
    IScriptEvaluator evaluator = evalProvider.createEvaluator("button");
    evaluator.addScriptFunction(new ScriptClassFunction("convertSensorValue", "function convertSensorValue(value) { return value*0.01; }"));
    library.addFunctions(evaluator.getFunctions());
    return library;
}
Also used : IScriptEvaluator(org.eclipse.vorto.mapping.engine.functions.IScriptEvaluator) FunctionLibrary(org.apache.commons.jxpath.FunctionLibrary) ScriptClassFunction(org.eclipse.vorto.mapping.engine.functions.ScriptClassFunction)

Example 7 with FunctionLibrary

use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.

the class SpecWithByteArrayConverter method getScriptFunctions.

@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
    FunctionLibrary library = new FunctionLibrary();
    IScriptEvaluator evaluator = evalProvider.createEvaluator("button");
    evaluator.addScriptFunction(new ScriptClassFunction("convertSensorValue", "function convertSensorValue(value) { return value; }"));
    library.addFunctions(evaluator.getFunctions());
    return library;
}
Also used : IScriptEvaluator(org.eclipse.vorto.mapping.engine.functions.IScriptEvaluator) FunctionLibrary(org.apache.commons.jxpath.FunctionLibrary) ScriptClassFunction(org.eclipse.vorto.mapping.engine.functions.ScriptClassFunction)

Example 8 with FunctionLibrary

use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.

the class SpecGattConverter method getScriptFunctions.

@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
    FunctionLibrary library = new FunctionLibrary();
    IScriptEvaluator evaluator = evalProvider.createEvaluator("button");
    evaluator.addScriptFunction(new ScriptClassFunction("convertSensorValue", "function convertSensorValue(value) { return value*0.01; }"));
    library.addFunctions(evaluator.getFunctions());
    return library;
}
Also used : IScriptEvaluator(org.eclipse.vorto.mapping.engine.functions.IScriptEvaluator) FunctionLibrary(org.apache.commons.jxpath.FunctionLibrary) ScriptClassFunction(org.eclipse.vorto.mapping.engine.functions.ScriptClassFunction)

Example 9 with FunctionLibrary

use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.

the class SpecWithConstraintConfigMapping 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;
}
Also used : IScriptEvaluator(org.eclipse.vorto.mapping.engine.functions.IScriptEvaluator) FunctionLibrary(org.apache.commons.jxpath.FunctionLibrary) ScriptClassFunction(org.eclipse.vorto.mapping.engine.functions.ScriptClassFunction)

Example 10 with FunctionLibrary

use of org.apache.commons.jxpath.FunctionLibrary in project vorto by eclipse.

the class SpecWithMaliciousFunction method getScriptFunctions.

@Override
public FunctionLibrary getScriptFunctions(IScriptEvalProvider evalProvider) {
    FunctionLibrary library = new FunctionLibrary();
    IScriptEvaluator evaluator = evalProvider.createEvaluator("button");
    evaluator.addScriptFunction(new ScriptClassFunction("convert", "function convert(value) { " + getMaliciousFunctionBody() + "}"));
    library.addFunctions(evaluator.getFunctions());
    return library;
}
Also used : IScriptEvaluator(org.eclipse.vorto.mapping.engine.functions.IScriptEvaluator) FunctionLibrary(org.apache.commons.jxpath.FunctionLibrary) ScriptClassFunction(org.eclipse.vorto.mapping.engine.functions.ScriptClassFunction)

Aggregations

FunctionLibrary (org.apache.commons.jxpath.FunctionLibrary)13 IScriptEvaluator (org.eclipse.vorto.mapping.engine.functions.IScriptEvaluator)12 ScriptClassFunction (org.eclipse.vorto.mapping.engine.functions.ScriptClassFunction)12 IScriptEvalProvider (org.eclipse.vorto.mapping.engine.functions.IScriptEvalProvider)1 FunctionblockModel (org.eclipse.vorto.model.FunctionblockModel)1 IMappedElement (org.eclipse.vorto.model.IMappedElement)1 Infomodel (org.eclipse.vorto.model.Infomodel)1 Stereotype (org.eclipse.vorto.model.Stereotype)1 CustomFunctions (org.openforis.idm.model.expression.internal.CustomFunctions)1