Search in sources :

Example 6 with Property

use of org.eclipse.vorto.core.api.model.datatype.Property in project vorto by eclipse.

the class TestEntityFactory method createPrimitiveProperty.

public static Property createPrimitiveProperty(String propName, PrimitiveType type) {
    Property prop = DatatypeFactory.eINSTANCE.createProperty();
    prop.setName(propName);
    PrimitivePropertyType primi = DatatypeFactory.eINSTANCE.createPrimitivePropertyType();
    primi.setType(type);
    prop.setType(primi);
    return prop;
}
Also used : PrimitivePropertyType(org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType) Property(org.eclipse.vorto.core.api.model.datatype.Property)

Example 7 with Property

use of org.eclipse.vorto.core.api.model.datatype.Property in project vorto by eclipse.

the class CharacteristicPropertyImpl method setProperty.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setProperty(Property newProperty) {
    Property oldProperty = property;
    property = newProperty;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.CHARACTERISTIC_PROPERTY__PROPERTY, oldProperty, property));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) CharacteristicProperty(org.eclipse.vorto.codegen.ble.model.blegatt.CharacteristicProperty) Property(org.eclipse.vorto.core.api.model.datatype.Property)

Example 8 with Property

use of org.eclipse.vorto.core.api.model.datatype.Property in project vorto by eclipse.

the class TestEntityFactory method createEntity.

public static Entity createEntity() {
    Entity entity = DatatypeFactory.eINSTANCE.createEntity();
    Property stringProperty = createPrimitiveProperty("testString", PrimitiveType.STRING);
    entity.getProperties().add(stringProperty);
    return entity;
}
Also used : Entity(org.eclipse.vorto.core.api.model.datatype.Entity) Property(org.eclipse.vorto.core.api.model.datatype.Property)

Example 9 with Property

use of org.eclipse.vorto.core.api.model.datatype.Property in project vorto by eclipse.

the class UIComponentFactory method getByModelId.

public static IFunctionBlockUITemplate getByModelId(FunctionblockModel fbm, InvocationContext ctx) {
    IMapped<FunctionblockModel> mappedElement = ctx.getMappedElement(fbm, STEREOTYPE_COMPONENT);
    String uiType = mappedElement.getAttributeValue(ATTRIBUTE_TYPE, "default");
    if (uiType.equalsIgnoreCase("barchart")) {
        List<String> properties = new ArrayList<String>();
        for (Property property : fbm.getFunctionblock().getStatus().getProperties()) {
            IMapped<Property> uiAttribute = ctx.getMappedElement(property, STEREOTYPE_COMPONENT);
            String uiProperty = uiAttribute.getAttributeValue(ATTRIBUTE_TYPE, "");
            if (uiProperty.equalsIgnoreCase("value")) {
                properties.add(property.getName());
            }
        }
        return new BarChartUITemplate(properties);
    } else if (uiType.equalsIgnoreCase("map")) {
        String latitude = null;
        String longitude = null;
        for (Property property : fbm.getFunctionblock().getStatus().getProperties()) {
            IMapped<Property> uiAttribute = ctx.getMappedElement(property, STEREOTYPE_COMPONENT);
            String uiProperty = uiAttribute.getAttributeValue(ATTRIBUTE_TYPE, "");
            if (uiProperty.equalsIgnoreCase("longitude")) {
                longitude = property.getName();
            } else if (uiProperty.equalsIgnoreCase("latitude")) {
                latitude = property.getName();
            }
        }
        return new LocationMapUITemplate(longitude, latitude);
    } else if (uiType.equalsIgnoreCase("gauge")) {
        String value = null;
        String min = null;
        String max = null;
        String symbol = null;
        for (Property property : fbm.getFunctionblock().getStatus().getProperties()) {
            IMapped<Property> uiAttribute = ctx.getMappedElement(property, STEREOTYPE_COMPONENT);
            String uiProperty = uiAttribute.getAttributeValue(ATTRIBUTE_TYPE, "");
            if (uiProperty.equalsIgnoreCase("value")) {
                value = property.getName();
            } else if (uiProperty.equalsIgnoreCase("min")) {
                min = property.getName();
            } else if (uiProperty.equalsIgnoreCase("max")) {
                max = property.getName();
            } else if (uiProperty.equalsIgnoreCase("symbol")) {
                symbol = property.getName();
            }
        }
        return new GaugeUITemplate(symbol, min, max, value);
    } else {
        return new DefaultUITemplate();
    }
}
Also used : FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) GaugeUITemplate(org.eclipse.vorto.codegen.webui.templates.resources.ui.components.GaugeUITemplate) ArrayList(java.util.ArrayList) LocationMapUITemplate(org.eclipse.vorto.codegen.webui.templates.resources.ui.components.LocationMapUITemplate) BarChartUITemplate(org.eclipse.vorto.codegen.webui.templates.resources.ui.components.BarChartUITemplate) IMapped(org.eclipse.vorto.codegen.api.mapping.IMapped) Property(org.eclipse.vorto.core.api.model.datatype.Property) DefaultUITemplate(org.eclipse.vorto.codegen.webui.templates.resources.ui.components.DefaultUITemplate)

Example 10 with Property

use of org.eclipse.vorto.core.api.model.datatype.Property in project vorto by eclipse.

the class FunctionBlockXmlTemplate method handleProperties.

private void handleProperties(final Object lwm2mObject, final EList<Property> properties, final String operation, final InvocationContext context) {
    for (final Property property : properties) {
        final Item item = new Item();
        item.setOperations(operation);
        handleMappingRulesForProperties(lwm2mObject, property, item, context);
        // handle mandatory
        final Presence mandatory = property.getPresence();
        if (mandatory == null || !mandatory.isMandatory()) {
            // default mapping
            item.setMandatory(ATTR_MANDATORY_OPTIONAL_VALUE);
        } else {
            item.setMandatory(ATTR_MANDATORY_MANDATORY_VALUE);
        }
        // handle multiplicity
        final boolean multiplicity = property.isMultiplicity();
        if (multiplicity) {
            item.setMultipleInstances(ATTR_MULTIPLE_INSTANCES_MULTIPLE_VALUE);
        } else {
            item.setMultipleInstances(ATTR_MULTIPLE_INSTANCES_SINGLE_VALUE);
        }
        // handle name
        final String statusPropertyName = property.getName();
        // 1:1 mapping
        item.setName(statusPropertyName);
        handleRangeEnumeration(lwm2mObject, property, item);
        // handle type
        final PropertyType type = property.getType();
        if (type instanceof PrimitivePropertyTypeImpl) {
            final String primitiveTypeStr = ((PrimitivePropertyTypeImpl) type).getType().toString();
            final String lwm2mTypeStr = propertyType2Lwm2mType(primitiveTypeStr);
            item.setType(lwm2mTypeStr);
        } else {
            final String errMsg = unsupportedValueForPropertyMsg("PropertyType (Enum/Entity)", property, lwm2mObject);
            throw new IllegalArgumentException(errMsg);
        }
        // handle Description
        String statusPropDescr = property.getDescription();
        if (null == statusPropDescr) {
            // as default
            statusPropDescr = "";
        }
        item.setDescription(statusPropDescr);
        checkResourceIdConflictAndFillSet(item);
    }
}
Also used : Item(org.eclipse.vorto.codegen.lwm2m.generated.LWM2M.Object.Resources.Item) PrimitivePropertyTypeImpl(org.eclipse.vorto.core.api.model.datatype.impl.PrimitivePropertyTypeImpl) Presence(org.eclipse.vorto.core.api.model.datatype.Presence) PropertyType(org.eclipse.vorto.core.api.model.datatype.PropertyType) Property(org.eclipse.vorto.core.api.model.datatype.Property)

Aggregations

Property (org.eclipse.vorto.core.api.model.datatype.Property)11 FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)5 FunctionblockProperty (org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty)4 CharacteristicProperty (org.eclipse.vorto.codegen.ble.model.blegatt.CharacteristicProperty)3 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)3 FunctionBlock (org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)3 Enum (org.eclipse.vorto.core.api.model.datatype.Enum)2 ObjectPropertyType (org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType)2 PrimitivePropertyType (org.eclipse.vorto.core.api.model.datatype.PrimitivePropertyType)2 Event (org.eclipse.vorto.core.api.model.functionblock.Event)2 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 BasicEList (org.eclipse.emf.common.util.BasicEList)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 ChainedCodeGeneratorTask (org.eclipse.vorto.codegen.api.ChainedCodeGeneratorTask)1 GenerationResultZip (org.eclipse.vorto.codegen.api.GenerationResultZip)1