Search in sources :

Example 6 with Infomodel

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

the class DefaultPayloadMappingService method getOrCreateSpecification.

@Override
public IMappingSpecification getOrCreateSpecification(ModelId modelId) {
    ModelContent modelContent = getModelContent(modelId, createTargetPlatformKey(modelId));
    Infomodel infomodel = (Infomodel) modelContent.getModels().get(modelContent.getRoot());
    MappingSpecification specification = new MappingSpecification();
    specification.setInfoModel(infomodel);
    addReferencesRecursive(infomodel, infomodel.getTargetPlatformKey());
    return specification;
}
Also used : MappingSpecification(org.eclipse.vorto.mapping.engine.model.spec.MappingSpecification) IMappingSpecification(org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification) Infomodel(org.eclipse.vorto.model.Infomodel) ModelContent(org.eclipse.vorto.model.ModelContent)

Example 7 with Infomodel

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

the class TwinPayloadFactoryTest method testCreateRequestSingleMultipleFbProperties.

@Test
public void testCreateRequestSingleMultipleFbProperties() {
    FunctionblockModel fbm = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.createPrimitiveProperty("value", true, PrimitiveType.FLOAT)).build();
    Infomodel infomodel = Infomodel.Builder(ModelId.fromPrettyFormat("com.acme:TemperatureSensor:1.0.0")).withProperty(ModelProperty.Builder("indoorTemperature", fbm).build()).withProperty(ModelProperty.Builder("outdoorTemperature", fbm).build()).build();
    FunctionblockValue indoorTemperature = new FunctionblockValue(fbm);
    indoorTemperature.withStatusProperty("value", 20.2);
    FunctionblockValue outdoorTemperature = new FunctionblockValue(fbm);
    outdoorTemperature.withStatusProperty("value", 9.2);
    InfomodelValue infomodelValue = new InfomodelValue(infomodel);
    infomodelValue.withFunctionblock("indoorTemperature", indoorTemperature);
    infomodelValue.withFunctionblock("outdoorTemperature", outdoorTemperature);
    System.out.println(gson.toJson(TwinPayloadFactory.toShadowUpdateRequest(infomodelValue)));
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) FunctionblockValue(org.eclipse.vorto.model.runtime.FunctionblockValue) Infomodel(org.eclipse.vorto.model.Infomodel) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test)

Example 8 with Infomodel

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

the class TwinPayloadFactoryTest method testCreateRequestSingleMultipleFbProperties.

@Test
public void testCreateRequestSingleMultipleFbProperties() {
    FunctionblockModel fbm = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.createPrimitiveProperty("value", true, PrimitiveType.FLOAT)).build();
    Infomodel infomodel = Infomodel.Builder(ModelId.fromPrettyFormat("com.acme:TemperatureSensor:1.0.0")).withProperty(ModelProperty.Builder("indoorTemperature", fbm).build()).withProperty(ModelProperty.Builder("outdoorTemperature", fbm).build()).build();
    FunctionblockValue indoorTemperature = new FunctionblockValue(fbm);
    indoorTemperature.withStatusProperty("value", 20.2);
    FunctionblockValue outdoorTemperature = new FunctionblockValue(fbm);
    outdoorTemperature.withStatusProperty("value", 9.2);
    InfomodelValue infomodelValue = new InfomodelValue(infomodel);
    infomodelValue.withFunctionblock("indoorTemperature", indoorTemperature);
    infomodelValue.withFunctionblock("outdoorTemperature", outdoorTemperature);
    System.out.println(gson.toJson(TwinPayloadFactory.toDittoProtocol(infomodelValue, "com.acme:Sensor-1")));
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) FunctionblockValue(org.eclipse.vorto.model.runtime.FunctionblockValue) Infomodel(org.eclipse.vorto.model.Infomodel) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test)

Example 9 with Infomodel

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

the class TwinPayloadFactoryTest method testCreateRequestSingleFbPropertyforEntireInfomodel.

@Test
public void testCreateRequestSingleFbPropertyforEntireInfomodel() {
    FunctionblockModel fbm = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.createPrimitiveProperty("value", true, PrimitiveType.FLOAT)).build();
    Infomodel infomodel = Infomodel.Builder(ModelId.fromPrettyFormat("com.acme:TemperatureSensor:1.0.0")).withProperty(ModelProperty.Builder("temperature", fbm).build()).build();
    FunctionblockValue fbValue = new FunctionblockValue(fbm);
    fbValue.withStatusProperty("value", 20.2);
    InfomodelValue infomodelValue = new InfomodelValue(infomodel);
    infomodelValue.withFunctionblock("temperature", fbValue);
    System.out.println(gson.toJson(TwinPayloadFactory.toDittoProtocol(infomodelValue, "com.acme:Sensor-1")));
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) FunctionblockValue(org.eclipse.vorto.model.runtime.FunctionblockValue) Infomodel(org.eclipse.vorto.model.Infomodel) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test)

Example 10 with Infomodel

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

the class ModelContentToEcoreConverter method convertInformationModel.

private InformationModel convertInformationModel(Infomodel model, ModelContent context) {
    InformationModelBuilder builder = BuilderUtils.newInformationModel(new ModelId(ModelType.InformationModel, model.getId().getName(), model.getId().getNamespace(), model.getId().getVersion()));
    builder.withCategory(model.getCategory());
    builder.withDescription(model.getDescription());
    builder.withDisplayName(model.getDisplayName());
    builder.withVortolang(model.getVortolang());
    for (ModelProperty property : model.getFunctionblocks()) {
        FunctionblockModel fbModel = (FunctionblockModel) context.getModels().get((org.eclipse.vorto.model.ModelId) property.getType());
        org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel convertedFb = (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) convertFunctionblock(fbModel, context);
        builder.withReference(ModelIdFactory.newInstance(convertedFb));
        builder.withFunctionBlock(convertedFb, property.getName(), property.getDescription(), property.isMandatory());
    }
    return builder.build();
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) ModelProperty(org.eclipse.vorto.model.ModelProperty) InformationModelBuilder(org.eclipse.vorto.core.api.model.BuilderUtils.InformationModelBuilder) Infomodel(org.eclipse.vorto.model.Infomodel) ModelId(org.eclipse.vorto.core.api.model.model.ModelId)

Aggregations

Infomodel (org.eclipse.vorto.model.Infomodel)11 FunctionblockModel (org.eclipse.vorto.model.FunctionblockModel)7 Test (org.junit.Test)6 FunctionblockValue (org.eclipse.vorto.model.runtime.FunctionblockValue)5 InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)5 ModelId (org.eclipse.vorto.model.ModelId)3 ModelProperty (org.eclipse.vorto.model.ModelProperty)3 FunctionblockProperty (org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)2 MappingSpecification (org.eclipse.vorto.mapping.engine.model.spec.MappingSpecification)2 ModelContent (org.eclipse.vorto.model.ModelContent)2 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)1 Sets (com.google.common.collect.Sets)1 Arrays (java.util.Arrays)1 Base64 (java.util.Base64)1 JXPathContext (org.apache.commons.jxpath.JXPathContext)1 Logger (org.apache.log4j.Logger)1 InformationModelBuilder (org.eclipse.vorto.core.api.model.BuilderUtils.InformationModelBuilder)1 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)1 MappingModel (org.eclipse.vorto.core.api.model.mapping.MappingModel)1 MappingRule (org.eclipse.vorto.core.api.model.mapping.MappingRule)1