private void writeCommonPropertyAttributes(StructuralProperty property) throws XMLStreamException { xmlWriter.writeAttribute(NAME, property.getName()); xmlWriter.writeAttribute(TYPE, property.getTypeName()); xmlWriter.writeAttribute(NULLABLE, Boolean.toString(property.isNullable())); } }
private boolean findAppropriateElement(Object entity, StructuralProperty property, Field field, String node, Map<String, Object> map, Map.Entry<String, Object> entry) throws ODataException { if (node.equalsIgnoreCase(entry.getKey()) && entry.getValue() != null) { Object value = getFieldValueByType(property.getTypeName(), entry.getValue(), map, true); if (value != null) { setFieldValue(field, entity, value); return true; } else { LOG.warn("There is no element with name '{}'", node); } } return false; }
private void writeCommonPropertyAttributes(StructuralProperty property) throws XMLStreamException { xmlWriter.writeAttribute(NAME, property.getName()); xmlWriter.writeAttribute(TYPE, property.getTypeName()); xmlWriter.writeAttribute(NULLABLE, Boolean.toString(property.isNullable())); } }
private boolean findAppropriateElement(Object entity, StructuralProperty property, Field field, String node, Map<String, Object> map, Map.Entry<String, Object> entry) throws ODataException { if (node.equalsIgnoreCase(entry.getKey()) && entry.getValue() != null) { Object value = getFieldValueByType(property.getTypeName(), entry.getValue(), map, true); if (value != null) { setFieldValue(field, entity, value); return true; } else { LOG.warn("There is no element with name '{}'", node); } } return false; }
/** * Gets the OData type name of the property; if the property is a collection, gets the OData type name of the * elements of the collection. * * @param property The property. * @return The OData type name of the property; if the property is a collection, the OData type name of the elements * of the collection. */ public static String getPropertyTypeName(StructuralProperty property) { return property.isCollection() ? property.getElementTypeName() : property.getTypeName(); }
/** * Gets the OData type name of the property; if the property is a collection, gets the OData type name of the * elements of the collection. * * @param property The property. * @return The OData type name of the property; if the property is a collection, the OData type name of the elements * of the collection. */ public static String getPropertyTypeName(StructuralProperty property) { return property.isCollection() ? property.getElementTypeName() : property.getTypeName(); }
/** * Populates the primitive property of the entity with the relevant field value. * * @param entity the entity * @param keySet the set of entity properties * @param property the primitive property * @param field the Java field * @param node the current node * @param map the map of field values * @throws ODataException If unable to fill primitive properties */ public void fillPrimitiveProperty(Object entity, Set<String> keySet, StructuralProperty property, Field field, String node, Map<String, Object> map) throws ODataException { for (String target : keySet) { if (node.equalsIgnoreCase(target)) { Object value = getFieldValueByType(property.getTypeName(), target, map, false); if (value != null) { setFieldValue(field, entity, value); break; } else { LOG.warn("There is no element with name '{}'", node); } } } }
/** * Populates the primitive property of the entity with the relevant field value. * * @param entity the entity * @param keySet the set of entity properties * @param property the primitive property * @param field the Java field * @param node the current node * @param map the map of field values * @throws ODataException If unable to fill primitive properties */ public void fillPrimitiveProperty(Object entity, Set<String> keySet, StructuralProperty property, Field field, String node, Map<String, Object> map) throws ODataException { for (String target : keySet) { if (node.equalsIgnoreCase(target)) { Object value = getFieldValueByType(property.getTypeName(), target, map, false); if (value != null) { setFieldValue(field, entity, value); break; } else { LOG.warn("There is no element with name '{}'", node); } } } }
/** * Write either a {@code <Property>} or {@code <NavigationProperty>} element * for the given {@code StructuralProperty}. * * @param property The given structural property. It can not be {@code null}. * @throws javax.xml.stream.XMLStreamException If unable to write to stream */ public void write(StructuralProperty property) throws XMLStreamException { LOG.debug("Writing property {} of type {}", property.getName(), property.getTypeName()); if (property instanceof NavigationProperty) { NavigationProperty navProperty = (NavigationProperty) property; xmlWriter.writeStartElement(NAVIGATION_PROPERTY); writeCommonPropertyAttributes(property); if (!isNullOrEmpty(navProperty.getPartnerName())) { xmlWriter.writeAttribute(PARTNER, navProperty.getPartnerName()); } xmlWriter.writeEndElement(); } else { xmlWriter.writeStartElement(PROPERTY); writeCommonPropertyAttributes(property); xmlWriter.writeEndElement(); } }
/** * Write either a {@code <Property>} or {@code <NavigationProperty>} element * for the given {@code StructuralProperty}. * * @param property The given structural property. It can not be {@code null}. * @throws javax.xml.stream.XMLStreamException If unable to write to stream */ public void write(StructuralProperty property) throws XMLStreamException { LOG.debug("Writing property {} of type {}", property.getName(), property.getTypeName()); if (property instanceof NavigationProperty) { NavigationProperty navProperty = (NavigationProperty) property; xmlWriter.writeStartElement(NAVIGATION_PROPERTY); writeCommonPropertyAttributes(property); if (!isNullOrEmpty(navProperty.getPartnerName())) { xmlWriter.writeAttribute(PARTNER, navProperty.getPartnerName()); } xmlWriter.writeEndElement(); } else { xmlWriter.writeStartElement(PROPERTY); writeCommonPropertyAttributes(property); xmlWriter.writeEndElement(); } }
Type propertyType = entityDataModel.getType(property.getTypeName()); if (propertyType == null) { throw new ODataRenderException("OData type not found for property: " + property);
throw new ODataUnmarshallingException("The type of the property '" + propertyName + "' is a " + "collection type: " + propertyTypeFromXML + ", but according to the entity data model it " + "is not a collection: " + property.getTypeName()); throw new ODataUnmarshallingException("The type of the property '" + propertyName + "' is not a " + "collection type: " + propertyTypeFromXML + ", but according to the entity data model it " + "is a collection: " + property.getTypeName());
Type propertyType = entityDataModel.getType(property.getTypeName()); if (propertyType == null) { throw new ODataRenderException("OData type not found for property: " + property);
throw new ODataUnmarshallingException("The type of the property '" + propertyName + "' is a " + "collection type: " + propertyTypeFromXML + ", but according to the entity data model it " + "is not a collection: " + property.getTypeName()); throw new ODataUnmarshallingException("The type of the property '" + propertyName + "' is not a " + "collection type: " + propertyTypeFromXML + ", but according to the entity data model it " + "is a collection: " + property.getTypeName());
Type propertyType = entityDataModel.getType(property.getTypeName()); if (propertyType == null) { throw new ODataRenderException("OData type not found for property: " + property);
Type propertyType = entityDataModel.getType(property.getTypeName()); if (propertyType == null) { throw new ODataRenderException("OData type not found for property: " + property);
for (StructuralProperty property : structuredType.getStructuralProperties()) { String propertyTypeName = property.isCollection() ? property.getElementTypeName() : property.getTypeName();
for (StructuralProperty property : structuredType.getStructuralProperties()) { String propertyTypeName = property.isCollection() ? property.getElementTypeName() : property.getTypeName();