use of org.eclipse.vorto.repository.api.content.FunctionblockModel in project vorto by eclipse.
the class ModelRepositoryClientTest method testGetModelForNotAvailableTargetPlatform.
// FIXME : Repository REST URL Changes might have an impact on this test case. REST Endpoints should be tested along with repository
@Test
public void testGetModelForNotAvailableTargetPlatform() throws Exception {
FunctionblockModel accelerometer = modelRepo.getContent(ModelId.fromPrettyFormat("com.ipso.smartobjects.Accelerometer:0.0.1"), FunctionblockModel.class, "omadm").get();
assertNotNull(accelerometer);
}
use of org.eclipse.vorto.repository.api.content.FunctionblockModel 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.FunctionblockModel 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.FunctionblockModel 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;
}
use of org.eclipse.vorto.repository.api.content.FunctionblockModel in project vorto by eclipse.
the class SpecWithConditionFunction 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.FLOAT);
digitalInputStateProperty.setTargetPlatformKey("iotbutton");
digitalInputStateProperty.addStereotype(Stereotype.createWithConditionalXpath("(base64:decodeString(data))[0] == 104", "string:toString(base64:decodeString(data),'utf8')"));
buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty }));
addFunctionblockProperty("button", buttonModel);
}
Aggregations