use of org.eclipse.vorto.core.api.model.datatype.Presence 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