Class JPAModifyUtil

java.lang.Object
com.sap.olingo.jpa.processor.core.processor.JPAModifyUtil

public final class JPAModifyUtil extends Object
This class provides some primitive util methods to support modifying operations like create or update.

The set method shall fill an object from a given Map. JPA processor provides in a Map the internal, JAVA attribute, names. Based on the JAVA naming conventions the corresponding Setter is called, as long as the Setter has the correct type.

Author:
Oliver Grande
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    createPrimaryKey​(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType et, Object instance)
     
    createPrimaryKey​(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType et, Map<String,​Object> jpaKeys, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType st)
    Create a filled instance of a JPA entity key.
    <T> void
    linkEntities​(Object sourceInstance, T targetInstance, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath pathInfo)
    Sets a link between a source and target instance.
    void
    setAttributes​(Map<String,​Object> jpaAttributes, Object instanze, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType st)
    Fills instance without filling its embedded components.
    void
    setAttributesDeep​(Map<String,​Object> jpaAttributes, Object instanze, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType st)
    Fills instance and its embedded components.
    void
    setForeignKey​(Object parentInstance, Object newInstance, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath pathInfo)
    Boxed missing getter

    Methods inherited from class java.lang.Object

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

    • JPAModifyUtil

      public JPAModifyUtil()
  • Method Details

    • createPrimaryKey

      public Object createPrimaryKey(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType et, Map<String,​Object> jpaKeys, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType st) throws ODataJPAProcessorException, ODataJPAInvocationTargetException
      Create a filled instance of a JPA entity key.
      For JPA entities having only one key, so do not use an IdClass, the corresponding value in jpaKeys is returned
      Parameters:
      et -
      jpaKeys -
      Returns:
      Throws:
      ODataJPAProcessorException
      ODataJPAInvocationTargetException
    • createPrimaryKey

      public Object createPrimaryKey(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType et, Object instance) throws ODataJPAProcessorException
      Parameters:
      et -
      instance -
      Returns:
      Throws:
      ODataJPAProcessorException
      ODataJPAInvocationTargetException
    • linkEntities

      public <T> void linkEntities(Object sourceInstance, T targetInstance, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath pathInfo) throws ODataJPAProcessorException
      Sets a link between a source and target instance. Prerequisite are existing setter and getter on the level of the sourceInstance. In case of to n associations it is expected that the getter always returns a collection. In case structured properties are passed either a getter returns always an instance or the corresponding type has a parameter less constructor.
      Parameters:
      parentInstance -
      newInstance -
      pathInfo -
      Throws:
      ODataJPAProcessorException
    • setForeignKey

      public void setForeignKey(Object parentInstance, Object newInstance, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath pathInfo) throws ODataJPAProcessorException
      Boxed missing getter
      Parameters:
      parentInstance -
      newInstance -
      pathInfo -
      Throws:
      ODataJPAProcessorException
    • setAttributes

      public void setAttributes(Map<String,​Object> jpaAttributes, Object instanze, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType st) throws ODataJPAProcessorException, ODataJPAInvocationTargetException
      Fills instance without filling its embedded components.
      Parameters:
      jpaAttributes - Map of attributes and values that shall be changed
      instanze - JPA POJO instance to take the changes
      st - Entity Type
      Throws:
      ODataJPAProcessorException - Thrown when ever a problem with invoking a getter or setter occurs except InvocationTargetException occurs.
      ODataJPAInvocationTargetException - Thrown when InvocationTargetException was thrown. ODataJPAInvocationTargetException contains the original cause and the OData path to the property which should be changed. The path starts with the entity type. The path parts a separated by JPAPath.PATH_SEPERATOR.
    • setAttributesDeep

      public void setAttributesDeep(Map<String,​Object> jpaAttributes, Object instanze, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType st) throws ODataJPAProcessorException, ODataJPAInvocationTargetException
      Fills instance and its embedded components. In case of embedded components it first tries to get an existing instance. If that is non provided a new one is created and set.
      Parameters:
      jpaAttributes - Map of attributes and values that shall be changed
      instanze - JPA POJO instance to take the changes
      st - Entity Type
      Throws:
      ODataJPAProcessorException - Thrown when ever a problem with invoking a getter or setter occurs except InvocationTargetException occurs.
      ODataJPAInvocationTargetException - Thrown when InvocationTargetException was thrown. ODataJPAInvocationTargetException contains the original cause and the OData path to the property which should be changed. The path starts with the entity type. The path parts a separated by JPAPath.PATH_SEPERATOR.