use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.
the class AbstractDataMapper method mapFunctionBlock.
private FunctionblockData mapFunctionBlock(ModelProperty fbProperty, JXPathContext context) {
FunctionblockData fbData = new FunctionblockData(fbProperty.getName());
FunctionblockModel fbModel = specification.getFunctionBlock(fbProperty.getName());
for (ModelProperty statusProperty : fbModel.getStatusProperties()) {
try {
Object mapped = this.mapProperty(statusProperty, context);
if (mapped != null) {
fbData.withStatusProperty(statusProperty.getName(), mapped);
}
} catch (JXPathNotFoundException | JXPathInvalidAccessException ex) {
if (statusProperty.isMandatory()) {
return null;
}
}
}
for (ModelProperty configProperty : fbModel.getConfigurationProperties()) {
try {
Object mapped = this.mapProperty(configProperty, context);
if (mapped != null) {
fbData.withConfigurationProperty(configProperty.getName(), mapped);
}
} catch (JXPathNotFoundException | JXPathInvalidAccessException ex) {
if (configProperty.isMandatory()) {
return null;
}
}
}
return onlyReturnIfPopulated(fbData);
}
use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.
the class AbstractDataMapper method map.
public MappedData map(DataInput input, MappingContext mappingContext) {
JXPathContext context = newContext(input.getValue());
context.setFunctions(converterLibrary);
InfomodelData normalized = new InfomodelData();
final Infomodel deviceInfoModel = specification.getInfoModel();
for (ModelProperty fbProperty : deviceInfoModel.getFunctionblocks()) {
if (mappingContext.isIncluded(fbProperty.getName())) {
FunctionblockData mappedFb = mapFunctionBlock(fbProperty, context);
if (mappedFb != null) {
normalized.withFunctionblock(mappedFb);
}
}
}
return this.doMap(normalized, mappingContext);
}
use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.
the class AbstractTestSpec method addFunctionblockProperty.
protected void addFunctionblockProperty(final String name, final FunctionblockModel fbm) {
FBS.put(name, fbm);
ModelProperty prop = new ModelProperty();
prop.setName(name);
prop.setType(fbm.getId());
infomodel.getFunctionblocks().add(prop);
}
use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.
the class SpecWithArrayPayload method createFBSpec.
@Override
protected void createFBSpec() {
FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
ModelProperty digitalInputStateProperty = new ModelProperty();
digitalInputStateProperty.setMandatory(true);
digitalInputStateProperty.setName("sensor_value");
digitalInputStateProperty.setType(PrimitiveType.STRING);
digitalInputStateProperty.setTargetPlatformKey("iotbutton");
digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("/@clickType[1]"));
buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
addFunctionblockProperty("button", buttonModel);
}
use of org.eclipse.vorto.repository.api.content.ModelProperty in project vorto by eclipse.
the class SpecWithBase64Converter method createButtonFb.
private FunctionblockModel createButtonFb() {
FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb.PushButton:1.0.0"), ModelType.Functionblock);
ModelProperty digitalInputStateProperty = new ModelProperty();
digitalInputStateProperty.setMandatory(true);
digitalInputStateProperty.setName("digital_input_state");
digitalInputStateProperty.setType(PrimitiveType.INT);
digitalInputStateProperty.setTargetPlatformKey("iotbutton");
digitalInputStateProperty.addStereotype(Stereotype.createWithXpath("base64:decodeString(/data)"));
buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
return buttonModel;
}
Aggregations