Class JPAModifyUtil
java.lang.Object
com.sap.olingo.jpa.processor.core.processor.JPAModifyUtil
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 -
Method Summary
Modifier and TypeMethodDescriptioncreatePrimaryKey(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> voidlinkEntities(Object sourceInstance, T targetInstance, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath pathInfo)Sets a link between a source and target instance.voidsetAttributes(Map<String,Object> jpaAttributes, Object instanze, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType st)Fills instance without filling its embedded components.voidsetAttributesDeep(Map<String,Object> jpaAttributes, Object instanze, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAStructuredType st)Fills instance and its embedded components.voidsetForeignKey(Object parentInstance, Object newInstance, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath pathInfo)Boxed missing getter
-
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, ODataJPAInvocationTargetExceptionCreate a filled instance of a JPA entity key.
For JPA entities having only one key, so do not use an IdClass, the corresponding value injpaKeysis returned- Parameters:
et-jpaKeys-- Returns:
- Throws:
ODataJPAProcessorExceptionODataJPAInvocationTargetException
-
createPrimaryKey
public Object createPrimaryKey(com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAEntityType et, Object instance) throws ODataJPAProcessorException- Parameters:
et-instance-- Returns:
- Throws:
ODataJPAProcessorExceptionODataJPAInvocationTargetException
-
linkEntities
public <T> void linkEntities(Object sourceInstance, T targetInstance, com.sap.olingo.jpa.metadata.core.edm.mapper.api.JPAAssociationPath pathInfo) throws ODataJPAProcessorExceptionSets 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 ODataJPAProcessorExceptionBoxed 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, ODataJPAInvocationTargetExceptionFills instance without filling its embedded components.- Parameters:
jpaAttributes- Map of attributes and values that shall be changedinstanze- JPA POJO instance to take the changesst- 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 byJPAPath.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, ODataJPAInvocationTargetExceptionFills 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 changedinstanze- JPA POJO instance to take the changesst- 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 byJPAPath.PATH_SEPERATOR.
-