org.odata4j.producer.jpa
Class JPAProducer

java.lang.Object
  extended by org.odata4j.producer.jpa.JPAProducer
All Implemented Interfaces:
ODataProducer

public class JPAProducer
extends Object
implements ODataProducer


Constructor Summary
JPAProducer(EntityManagerFactory emf, EdmDataServices metadata, int maxResults)
           
JPAProducer(EntityManagerFactory emf, String namespace, int maxResults)
           
 
Method Summary
 void close()
          Releases any resources managed by this producer.
protected static Object coercePropertyValue(OProperty<?> prop, Class<?> javaType)
           
 EntityResponse createEntity(String entitySetName, OEntity entity)
          Creates a new OData entity.
 EntityResponse createEntity(String entitySetName, OEntityKey entityKey, String navProp, OEntity entity)
          Creates a new OData entity as a reference of an existing entity, implicitly linked to the existing entity by a navigation property.
 void deleteEntity(String entitySetName, OEntityKey entityKey)
          Deletes an existing entity.
 EntitiesResponse getEntities(String entitySetName, QueryInfo queryInfo)
          Gets all the entities for a given set matching the query information.
 EntityResponse getEntity(String entitySetName, OEntityKey entityKey)
          Obtains a single entity based on its type and key.
 EdmDataServices getMetadata()
          Obtains the service metadata for this producer.
 BaseResponse getNavProperty(String entitySetName, OEntityKey entityKey, String navProp, QueryInfo queryInfo)
          Given a specific entity, follow one of its navigation properties, applying constraints as appropriate.
 void mergeEntity(String entitySetName, OEntity entity)
          Modifies an existing entity using merge semantics.
 void updateEntity(String entitySetName, OEntity entity)
          Modifies an existing entity using update semantics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JPAProducer

public JPAProducer(EntityManagerFactory emf,
                   EdmDataServices metadata,
                   int maxResults)

JPAProducer

public JPAProducer(EntityManagerFactory emf,
                   String namespace,
                   int maxResults)
Method Detail

close

public void close()
Description copied from interface: ODataProducer
Releases any resources managed by this producer.

Specified by:
close in interface ODataProducer

coercePropertyValue

protected static Object coercePropertyValue(OProperty<?> prop,
                                            Class<?> javaType)

createEntity

public EntityResponse createEntity(String entitySetName,
                                   OEntity entity)
Description copied from interface: ODataProducer
Creates a new OData entity.

Specified by:
createEntity in interface ODataProducer
Parameters:
entitySetName - the entity-set name
entity - the request entity sent from the client
Returns:
the newly-created entity, fully populated with the key and default properties
See Also:
[odata.org] Creating new Entries

createEntity

public EntityResponse createEntity(String entitySetName,
                                   OEntityKey entityKey,
                                   String navProp,
                                   OEntity entity)
Description copied from interface: ODataProducer
Creates a new OData entity as a reference of an existing entity, implicitly linked to the existing entity by a navigation property.

Specified by:
createEntity in interface ODataProducer
Parameters:
entitySetName - the entity-set name of the existing entity
entityKey - the entity-key of the existing entity
navProp - the navigation property off of the existing entity
entity - the request entity sent from the client
Returns:
the newly-created entity, fully populated with the key and default properties, and linked to the existing entity
See Also:
[odata.org] Creating new Entries

deleteEntity

public void deleteEntity(String entitySetName,
                         OEntityKey entityKey)
Description copied from interface: ODataProducer
Deletes an existing entity.

Specified by:
deleteEntity in interface ODataProducer
Parameters:
entitySetName - the entity-set name of the entity
entityKey - the entity-key of the entity
See Also:
[odata.org] Deleting Entries

getEntities

public EntitiesResponse getEntities(String entitySetName,
                                    QueryInfo queryInfo)
Description copied from interface: ODataProducer
Gets all the entities for a given set matching the query information.

Specified by:
getEntities in interface ODataProducer
Parameters:
entitySetName - the entity-set name for entities to return
queryInfo - the additional constraints to apply to the entities
Returns:
a packaged collection of entities to pass back to the client

getEntity

public EntityResponse getEntity(String entitySetName,
                                OEntityKey entityKey)
Description copied from interface: ODataProducer
Obtains a single entity based on its type and key.

Specified by:
getEntity in interface ODataProducer
Parameters:
entitySetName - the entity-set name for the entity to return
entityKey - the unique entity-key within the set
Returns:
the matching entity

getMetadata

public EdmDataServices getMetadata()
Description copied from interface: ODataProducer
Obtains the service metadata for this producer.

Specified by:
getMetadata in interface ODataProducer
Returns:
a fully-constructed metadata object

getNavProperty

public BaseResponse getNavProperty(String entitySetName,
                                   OEntityKey entityKey,
                                   String navProp,
                                   QueryInfo queryInfo)
Description copied from interface: ODataProducer
Given a specific entity, follow one of its navigation properties, applying constraints as appropriate. Return the resulting entity, entities, or property value.

Specified by:
getNavProperty in interface ODataProducer
Parameters:
entitySetName - the entity-set of the entity to start with
entityKey - the unique entity-key of the entity to start with
navProp - the navigation property to follow
queryInfo - additional constraints to apply to the result
Returns:
the resulting entity, entities, or property value

mergeEntity

public void mergeEntity(String entitySetName,
                        OEntity entity)
Description copied from interface: ODataProducer
Modifies an existing entity using merge semantics.

Specified by:
mergeEntity in interface ODataProducer
Parameters:
entitySetName - the entity-set name
entity - the entity modifications sent from the client
See Also:
[odata.org] Updating Entries

updateEntity

public void updateEntity(String entitySetName,
                         OEntity entity)
Description copied from interface: ODataProducer
Modifies an existing entity using update semantics.

Specified by:
updateEntity in interface ODataProducer
Parameters:
entitySetName - the entity-set name
entity - the entity modifications sent from the client
See Also:
[odata.org] Updating Entries


http://odata4j.org