Search in sources :

Example 1 with IMappedElement

use of org.eclipse.vorto.model.IMappedElement 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;
}
Also used : Stereotype(org.eclipse.vorto.model.Stereotype) IScriptEvalProvider(org.eclipse.vorto.mapping.engine.functions.IScriptEvalProvider) FunctionLibrary(org.apache.commons.jxpath.FunctionLibrary) IScriptEvaluator(org.eclipse.vorto.mapping.engine.functions.IScriptEvaluator) Infomodel(org.eclipse.vorto.model.Infomodel) ScriptClassFunction(org.eclipse.vorto.mapping.engine.functions.ScriptClassFunction) IMappedElement(org.eclipse.vorto.model.IMappedElement) FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) IScriptEvaluator(org.eclipse.vorto.mapping.engine.functions.IScriptEvaluator) IMappedElement(org.eclipse.vorto.model.IMappedElement) FunctionLibrary(org.apache.commons.jxpath.FunctionLibrary) Stereotype(org.eclipse.vorto.model.Stereotype) ScriptClassFunction(org.eclipse.vorto.mapping.engine.functions.ScriptClassFunction)

Aggregations

FunctionLibrary (org.apache.commons.jxpath.FunctionLibrary)1 IScriptEvalProvider (org.eclipse.vorto.mapping.engine.functions.IScriptEvalProvider)1 IScriptEvaluator (org.eclipse.vorto.mapping.engine.functions.IScriptEvaluator)1 ScriptClassFunction (org.eclipse.vorto.mapping.engine.functions.ScriptClassFunction)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