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;
}
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));
}
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;
}
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();
}
}
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);
}
}
Aggregations