Class JPATupleChildConverter

java.lang.Object
com.sap.olingo.jpa.processor.core.converter.JPATupleChildConverter
All Implemented Interfaces:
JPAResultConverter

public class JPATupleChildConverter extends Object
Converts the query result based on Tuples from JPA format into Olingo format.

To reduce the memory footprint each converted row is set to null. This is done as currently the query result is stored in an ArrayList and deleting a row, which is not the last row, leads to an array copy, which can consume a lot of time. For the same reason no trimToSize() is called. As an alternative to an ArrayList also a simple linked list could be used, but this comes with the draw back that each entry would consume round about double space in the list.

Author:
Oliver Grande
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.olingo.commons.api.edm.EdmEntityType
     
    protected static String
     
    protected com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType
     
    protected JPAExpandResult
     
    protected com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument
     
    protected org.apache.olingo.server.api.ServiceMetadata
     
    protected String
     
    protected org.apache.olingo.server.api.uri.UriHelper
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    JPATupleChildConverter​(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument sd, org.apache.olingo.server.api.uri.UriHelper uriHelper, org.apache.olingo.server.api.ServiceMetadata serviceMetadata)
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    buildConcatenatedKey​(javax.persistence.Tuple row, List<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> leftColumns)
     
    protected String
    buildPath​(String prefix, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationAttribute association)
     
    protected void
    convertAttribute​(Object value, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath jpaPath, Map<String,​org.apache.olingo.commons.api.data.ComplexValue> complexValueBuffer, List<org.apache.olingo.commons.api.data.Property> properties, javax.persistence.Tuple parentRow, String prefix, org.apache.olingo.commons.api.data.Entity odataEntity)
     
    protected org.apache.olingo.commons.api.data.Entity
    convertRow​(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType rowEntity, javax.persistence.Tuple row, Collection<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> reqestedSelection)
     
    protected void
    createCollectionProperties​(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType jpaStructuredType, javax.persistence.Tuple row, List<org.apache.olingo.commons.api.data.Property> properties)
     
    protected void
    createComplexValue​(Map<String,​org.apache.olingo.commons.api.data.ComplexValue> complexValueBuffer, List<org.apache.olingo.commons.api.data.Property> properties, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute attribute, javax.persistence.Tuple parentRow, String bufferKey, String rootURI)
     
    protected Collection<org.apache.olingo.commons.api.data.Link>
    createExpand​(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType jpaStructuredType, javax.persistence.Tuple row, String prefix, String rootURI)
     
    protected void
    createId​(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType rowEntity, javax.persistence.Tuple row, org.apache.olingo.commons.api.data.Entity odataEntity)
     
    protected URI
    createId​(org.apache.olingo.commons.api.data.Entity entity)
     
    protected String
    determineAlias​(String alias, String prefix)
     
    protected com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType
    determineCollectionRoot​(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType et, List<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAElement> pathList)
     
    protected org.apache.olingo.commons.api.edm.EdmEntityType
     
    protected String
     
    protected String
    determineSetName​(JPAExpandResult jpaQueryResult, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument sd)
     
    getCollectionResult​(JPACollectionResult jpaResult, Collection<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> reqestedSelection)
     
    Map<String,​org.apache.olingo.commons.api.data.EntityCollection>
    getResult​(JPAExpandResult jpaResult, Collection<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> reqestedSelection)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EMPTY_PREFIX

      protected static final String EMPTY_PREFIX
      See Also:
      Constant Field Values
    • jpaConversionTargetEntity

      protected com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType jpaConversionTargetEntity
    • jpaQueryResult

      protected JPAExpandResult jpaQueryResult
    • uriHelper

      protected final org.apache.olingo.server.api.uri.UriHelper uriHelper
    • setName

      protected String setName
    • sd

      protected final com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument sd
    • serviceMetadata

      protected final org.apache.olingo.server.api.ServiceMetadata serviceMetadata
    • edmType

      protected org.apache.olingo.commons.api.edm.EdmEntityType edmType
  • Constructor Details

    • JPATupleChildConverter

      public JPATupleChildConverter(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument sd, org.apache.olingo.server.api.uri.UriHelper uriHelper, org.apache.olingo.server.api.ServiceMetadata serviceMetadata)
    • JPATupleChildConverter

      public JPATupleChildConverter(JPATupleChildConverter converter)
  • Method Details

    • getCollectionResult

      public Map<String,​List<Object>> getCollectionResult(JPACollectionResult jpaResult, Collection<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> reqestedSelection) throws org.apache.olingo.server.api.ODataApplicationException
      Throws:
      org.apache.olingo.server.api.ODataApplicationException
    • getResult

      public Map<String,​org.apache.olingo.commons.api.data.EntityCollection> getResult(JPAExpandResult jpaResult, Collection<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> reqestedSelection) throws org.apache.olingo.server.api.ODataApplicationException
      Throws:
      org.apache.olingo.server.api.ODataApplicationException
    • convertRow

      protected org.apache.olingo.commons.api.data.Entity convertRow(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType rowEntity, javax.persistence.Tuple row, Collection<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> reqestedSelection) throws org.apache.olingo.server.api.ODataApplicationException
      Throws:
      org.apache.olingo.server.api.ODataApplicationException
    • createCollectionProperties

      protected void createCollectionProperties(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType jpaStructuredType, javax.persistence.Tuple row, List<org.apache.olingo.commons.api.data.Property> properties) throws ODataJPAQueryException
      Throws:
      ODataJPAQueryException
    • createId

      protected URI createId(org.apache.olingo.commons.api.data.Entity entity)
    • createId

      protected void createId(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType rowEntity, javax.persistence.Tuple row, org.apache.olingo.commons.api.data.Entity odataEntity) throws org.apache.olingo.server.api.ODataApplicationException
      Throws:
      org.apache.olingo.server.api.ODataApplicationException
    • determineEdmType

      protected org.apache.olingo.commons.api.edm.EdmEntityType determineEdmType()
    • determineSetName

      protected String determineSetName(JPAExpandResult jpaQueryResult, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAServiceDocument sd) throws ODataJPAQueryException
      Throws:
      ODataJPAQueryException
    • buildConcatenatedKey

      protected String buildConcatenatedKey(javax.persistence.Tuple row, List<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath> leftColumns)
    • buildPath

      protected String buildPath(String prefix, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationAttribute association)
    • convertAttribute

      protected void convertAttribute(Object value, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAPath jpaPath, Map<String,​org.apache.olingo.commons.api.data.ComplexValue> complexValueBuffer, List<org.apache.olingo.commons.api.data.Property> properties, javax.persistence.Tuple parentRow, String prefix, @Nullable org.apache.olingo.commons.api.data.Entity odataEntity) throws com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException, org.apache.olingo.server.api.ODataApplicationException
      Throws:
      com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException
      org.apache.olingo.server.api.ODataApplicationException
    • createComplexValue

      protected void createComplexValue(Map<String,​org.apache.olingo.commons.api.data.ComplexValue> complexValueBuffer, List<org.apache.olingo.commons.api.data.Property> properties, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAttribute attribute, javax.persistence.Tuple parentRow, String bufferKey, String rootURI) throws com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException, org.apache.olingo.server.api.ODataApplicationException
      Throws:
      com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException
      org.apache.olingo.server.api.ODataApplicationException
    • createExpand

      protected Collection<org.apache.olingo.commons.api.data.Link> createExpand(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType jpaStructuredType, javax.persistence.Tuple row, String prefix, String rootURI) throws org.apache.olingo.server.api.ODataApplicationException
      Throws:
      org.apache.olingo.server.api.ODataApplicationException
    • determineAlias

      protected final String determineAlias(String alias, String prefix)
    • determineCollectionRoot

      protected final com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType determineCollectionRoot(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType et, List<com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAElement> pathList) throws com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException
      Throws:
      com.sap.olingo.jpa.metadata.core.edm.mapper.exception.ODataJPAModelException
    • determinePrefix

      protected final String determinePrefix(String alias)