Search in sources :

Example 26 with ModelProperty

use of org.eclipse.vorto.model.ModelProperty in project vorto by eclipse.

the class SpecWithConditionalProperties method createModel.

@Override
protected void createModel() {
    FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
    ModelProperty digitalInputStateProperty = new ModelProperty();
    digitalInputStateProperty.setMandatory(true);
    digitalInputStateProperty.setName("sensor_value");
    digitalInputStateProperty.setType(PrimitiveType.FLOAT);
    ModelProperty digitalInputStateProperty2 = new ModelProperty();
    digitalInputStateProperty2.setMandatory(true);
    digitalInputStateProperty2.setName("sensor_value2");
    digitalInputStateProperty2.setType(PrimitiveType.FLOAT);
    digitalInputStateProperty.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty.addStereotype(Stereotype.createWithConditionalXpath("count == 0", "/count"));
    digitalInputStateProperty2.setTargetPlatformKey("iotbutton");
    digitalInputStateProperty2.addStereotype(Stereotype.createWithConditionalXpath("count > 1", "/count"));
    buttonModel.setStatusProperties(Arrays.asList(new ModelProperty[] { digitalInputStateProperty, digitalInputStateProperty2 }));
    infomodel.getFunctionblocks().add(ModelProperty.Builder("button", buttonModel).build());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 27 with ModelProperty

use of org.eclipse.vorto.model.ModelProperty in project vorto by eclipse.

the class SpecWithConfiguration2 method createModel.

@Override
protected void createModel() {
    FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
    ModelProperty buttonEnableProperty = new ModelProperty();
    buttonEnableProperty.setMandatory(true);
    buttonEnableProperty.setName("enable");
    buttonEnableProperty.setType(PrimitiveType.BOOLEAN);
    buttonEnableProperty.setTargetPlatformKey("iotbutton");
    buttonEnableProperty.addStereotype(Stereotype.createWithXpath("/e"));
    buttonModel.setConfigurationProperties(Arrays.asList(new ModelProperty[] { buttonEnableProperty }));
    infomodel.getFunctionblocks().add(ModelProperty.Builder("button", buttonModel).build());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 28 with ModelProperty

use of org.eclipse.vorto.model.ModelProperty in project vorto by eclipse.

the class SpecWithConfiguration method createModel.

@Override
protected void createModel() {
    FunctionblockModel buttonModel = new FunctionblockModel(ModelId.fromPrettyFormat("demo.fb:PushButton:1.0.0"));
    ModelProperty buttonEnableProperty = new ModelProperty();
    buttonEnableProperty.setMandatory(true);
    buttonEnableProperty.setName("enable");
    buttonEnableProperty.setType(PrimitiveType.BOOLEAN);
    buttonEnableProperty.setTargetPlatformKey("iotbutton");
    buttonEnableProperty.addStereotype(Stereotype.createTarget());
    buttonModel.setConfigurationProperties(Arrays.asList(new ModelProperty[] { buttonEnableProperty }));
    infomodel.getFunctionblocks().add(ModelProperty.Builder("button", buttonModel).build());
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty)

Example 29 with ModelProperty

use of org.eclipse.vorto.model.ModelProperty in project vorto by eclipse.

the class ValidationTest method createModel.

private FunctionblockModel createModel(PrimitiveType type) {
    FunctionblockModel fbModel = new FunctionblockModel(ModelId.fromPrettyFormat("default:TestFB:1.0.0"));
    List<ModelProperty> properties = new ArrayList<>();
    properties.add(ModelProperty.createPrimitiveProperty("prop", true, type));
    fbModel.setStatusProperties(properties);
    return fbModel;
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty) ArrayList(java.util.ArrayList)

Example 30 with ModelProperty

use of org.eclipse.vorto.model.ModelProperty in project vorto by eclipse.

the class InfomodelValue method validate.

@Override
public ValidationReport validate() {
    ValidationReport report = new ValidationReport();
    for (ModelProperty fbProperty : meta.getFunctionblocks()) {
        if (fbProperty.isMandatory() && !functionblocks.containsKey(fbProperty.getName())) {
            report.addItem(fbProperty, "Mandatory property is missing!");
        } else {
            FunctionblockValue fbData = functionblocks.get(fbProperty.getName());
            if (fbData != null) {
                ValidationReport fbReport = fbData.validate();
                report.addReport(fbReport);
            }
        }
    }
    return report;
}
Also used : ModelProperty(org.eclipse.vorto.model.ModelProperty)

Aggregations

ModelProperty (org.eclipse.vorto.model.ModelProperty)39 FunctionblockModel (org.eclipse.vorto.model.FunctionblockModel)30 Property (org.eclipse.vorto.core.api.model.datatype.Property)5 EntityModel (org.eclipse.vorto.model.EntityModel)5 Infomodel (org.eclipse.vorto.model.Infomodel)5 ModelId (org.eclipse.vorto.core.api.model.model.ModelId)4 Constraint (org.eclipse.vorto.model.Constraint)4 EnumModel (org.eclipse.vorto.model.EnumModel)4 ModelEvent (org.eclipse.vorto.model.ModelEvent)3 ModelId (org.eclipse.vorto.model.ModelId)3 Operation (org.eclipse.vorto.model.Operation)3 Stereotype (org.eclipse.vorto.model.Stereotype)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 JXPathInvalidAccessException (org.apache.commons.jxpath.JXPathInvalidAccessException)2 JXPathNotFoundException (org.apache.commons.jxpath.JXPathNotFoundException)2 EntityBuilder (org.eclipse.vorto.core.api.model.BuilderUtils.EntityBuilder)2 EventBuilder (org.eclipse.vorto.core.api.model.BuilderUtils.EventBuilder)2