Java Code Examples for org.apache.olingo.commons.api.data.Property#getType()
The following examples show how to use
org.apache.olingo.commons.api.data.Property#getType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonDeltaSerializerWithNavigations.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void writeComplex(final ServiceMetadata metadata, final EdmComplexType type, final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json) throws IOException, SerializerException { json.writeStartObject(); String derivedName = property.getType(); final EdmComplexType resolvedType = resolveComplexType(metadata, (EdmComplexType) type, derivedName); if (!isODataMetadataNone && !resolvedType.equals(type) || isODataMetadataFull) { json.writeStringField(Constants.JSON_TYPE, "#" + property.getType()); } writeComplexValue(metadata, resolvedType, property.asComplex().getValue(), selectedPaths, json); json.writeEndObject(); }
Example 2
Source File: JsonDeltaSerializer.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void writeComplex(final ServiceMetadata metadata, final EdmComplexType type, final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json) throws IOException, SerializerException { json.writeStartObject(); String derivedName = property.getType(); final EdmComplexType resolvedType = resolveComplexType(metadata, (EdmComplexType) type, derivedName); if (!isODataMetadataNone && !resolvedType.equals(type) || isODataMetadataFull) { json.writeStringField(Constants.JSON_TYPE, "#" + property.getType()); } writeComplexValue(metadata, resolvedType, property.asComplex().getValue(), selectedPaths, json); json.writeEndObject(); }
Example 3
Source File: ODataXmlSerializer.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void writeComplex(final ServiceMetadata metadata, final EdmProperty edmProperty, final Property property, final Set<List<String>> selectedPaths, final String xml10InvalidCharReplacement, final XMLStreamWriter writer, Set<List<String>> expandedPaths, Linked linked, ExpandOption expand) throws XMLStreamException, SerializerException{ writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, "#" + complexType(metadata, (EdmComplexType) edmProperty.getType(), property.getType())); String derivedName = property.getType(); final EdmComplexType resolvedType = resolveComplexType(metadata, (EdmComplexType) edmProperty.getType(), derivedName); if (null != linked) { if (linked instanceof Entity) { linked = ((Entity)linked).getProperty(property.getName()).asComplex(); } else if (linked instanceof ComplexValue) { List<Property> complexProperties = ((ComplexValue)linked).getValue(); for (Property prop : complexProperties) { if (prop.getName().equals(property.getName())) { linked = prop.asComplex(); break; } } } expandedPaths = expandedPaths == null || expandedPaths.isEmpty() ? null : ExpandSelectHelper.getReducedExpandItemsPaths(expandedPaths, property.getName()); } writeComplexValue(metadata, resolvedType, property.asComplex().getValue(), selectedPaths, xml10InvalidCharReplacement, writer, expandedPaths, linked, expand, property.getName()); }
Example 4
Source File: ODataXmlSerializer.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void writeComplexCollection(final ServiceMetadata metadata, final EdmComplexType type, final Property property, final Set<List<String>> selectedPaths, final String xml10InvalidCharReplacement, final XMLStreamWriter writer, Set<List<String>> expandedPaths, Linked linked, ExpandOption expand) throws XMLStreamException, SerializerException { EdmComplexType complexType = type; Set<List<String>> expandedPaths1 = expandedPaths != null && !expandedPaths.isEmpty() ? expandedPaths : ExpandSelectHelper.getExpandedItemsPath(expand); for (Object value : property.asCollection()) { expandedPaths = expandedPaths1; writer.writeStartElement(METADATA, Constants.ELEM_ELEMENT, NS_METADATA); String typeName = ((ComplexValue)value).getTypeName(); String propertyType = typeName != null ? typeName :property.getType(); if (derivedComplexType(type, propertyType ) != null) { writer.writeAttribute(METADATA, NS_METADATA, Constants.ATTR_TYPE, propertyType); } if(typeName!=null && !propertyType.equals(type.getFullQualifiedName().getFullQualifiedNameAsString())){ complexType = (EdmComplexType) (metadata.getEdm().getComplexType(new FullQualifiedName(propertyType))); }else{ complexType = type; } switch (property.getValueType()) { case COLLECTION_COMPLEX: expandedPaths = expandedPaths == null || expandedPaths.isEmpty() ? null : ExpandSelectHelper.getReducedExpandItemsPaths(expandedPaths, property.getName()); writeComplexValue(metadata, complexType, ((ComplexValue) value).getValue(), selectedPaths, xml10InvalidCharReplacement, writer, expandedPaths, (ComplexValue) value, expand, property.getName()); break; default: throw new SerializerException("Property type not yet supported!", SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName()); } writer.writeEndElement(); } }
Example 5
Source File: ODataJsonSerializer.java From olingo-odata4 with Apache License 2.0 | 4 votes |
private void writeComplex(final ServiceMetadata metadata, final EdmComplexType type, final Property property, final Set<List<String>> selectedPaths, final JsonGenerator json, Set<List<String>> expandedPaths, Linked linked, ExpandOption expand) throws IOException, SerializerException{ json.writeStartObject(); String derivedName = property.getType(); EdmComplexType resolvedType = null; if (!type.getFullQualifiedName().getFullQualifiedNameAsString(). equals(derivedName)) { if (type.getBaseType() != null && type.getBaseType().getFullQualifiedName().getFullQualifiedNameAsString(). equals(derivedName)) { resolvedType = resolveComplexType(metadata, type.getBaseType(), type.getFullQualifiedName().getFullQualifiedNameAsString()); } else { resolvedType = resolveComplexType(metadata, type, derivedName); } } else { resolvedType = resolveComplexType(metadata, type, derivedName); } if (!isODataMetadataNone && !resolvedType.equals(type) || isODataMetadataFull) { json.writeStringField(constants.getType(), "#" + resolvedType.getFullQualifiedName().getFullQualifiedNameAsString()); } if (null != linked) { if (linked instanceof Entity) { linked = ((Entity)linked).getProperty(property.getName()).asComplex(); } else if (linked instanceof ComplexValue) { List<Property> complexProperties = ((ComplexValue)linked).getValue(); for (Property prop : complexProperties) { if (prop.getName().equals(property.getName())) { linked = prop.asComplex(); break; } } } expandedPaths = expandedPaths == null || expandedPaths.isEmpty() ? null : ExpandSelectHelper.getReducedExpandItemsPaths(expandedPaths, property.getName()); } writeComplexValue(metadata, resolvedType, property.asComplex().getValue(), selectedPaths, json, expandedPaths, linked, expand, property.getName()); json.writeEndObject(); }