use of org.eclipse.vorto.service.mapping.internal.converter.JavascriptFunctions in project vorto by eclipse.
the class MappingSpecificationBuilder method build.
public IMappingSpecification build() {
try {
Infomodel infomodel = this.repositoryClient.getContent(ModelId.fromPrettyFormat(this.modelId), Infomodel.class, this.targetPlatformKey).get();
DefaultMappingSpecification specification = new DefaultMappingSpecification();
specification.setInfomodel(infomodel);
for (ModelProperty fbProperty : infomodel.getFunctionblocks()) {
ModelId fbModelId = (ModelId) fbProperty.getType();
ModelId mappingId = fbProperty.getMappingReference();
FunctionblockModel fbm;
if (mappingId != null) {
fbm = this.repositoryClient.getContent(fbModelId, FunctionblockModel.class, mappingId).get();
} else {
fbm = this.repositoryClient.getContent(fbModelId, FunctionblockModel.class, this.targetPlatformKey).get();
}
if (fbm.getStereotype(STEREOTYPE_FUNCTIONS).isPresent()) {
Stereotype functionsStereotype = fbm.getStereotype(STEREOTYPE_FUNCTIONS).get();
JavascriptFunctions functions = new JavascriptFunctions(fbProperty.getName().toLowerCase());
for (String functionName : functionsStereotype.getAttributes().keySet()) {
if (!"_namespace".equalsIgnoreCase(functionName)) {
functions.addFunction(functionName, functionsStereotype.getAttributes().get(functionName));
}
}
this.library.addFunctions(functions);
}
specification.getFbs().put(fbProperty.getName(), fbm);
}
specification.setLibrary(this.library);
return specification;
} catch (Exception e) {
throw new MappingSpecificationProblem("Problem reading mapping specification", e);
}
}
use of org.eclipse.vorto.service.mapping.internal.converter.JavascriptFunctions in project vorto by eclipse.
the class SpecGattConverter method getCustomFunctions.
@Override
public Optional<Functions> getCustomFunctions() {
JavascriptFunctions functions = new JavascriptFunctions("button");
functions.addFunction("convertSensorValue", "function convertSensorValue(value) { return value*0.01; }");
return Optional.of(functions);
}
use of org.eclipse.vorto.service.mapping.internal.converter.JavascriptFunctions in project vorto by eclipse.
the class SpecWithByteArrayConverter method getCustomFunctions.
@Override
public Optional<Functions> getCustomFunctions() {
JavascriptFunctions functions = new JavascriptFunctions("button");
functions.addFunction("convertSensorValue", "function convertSensorValue(value) { return value*0.01; }");
return Optional.of(functions);
}
use of org.eclipse.vorto.service.mapping.internal.converter.JavascriptFunctions in project vorto by eclipse.
the class SpecWithCustomFunction method getCustomFunctions.
@Override
public Optional<Functions> getCustomFunctions() {
JavascriptFunctions functions = new JavascriptFunctions("button");
functions.addFunction("convertClickType", "function convertClickType(clickType) {if (clickType === 'SINGLE') return 1; else if (clickType === 'DOUBLE') return 2; else return 99;}");
return Optional.of(functions);
}
Aggregations