org.odata4j.producer.inmemory
Class InMemoryProducer

java.lang.Object
  extended by org.odata4j.producer.inmemory.InMemoryProducer
All Implemented Interfaces:
ODataProducer

public class InMemoryProducer
extends Object
implements ODataProducer

An in-memory implementation of an ODATA Producer. Uses the standard Java bean and property model to access information within entities.


Constructor Summary
InMemoryProducer(String namespace)
          Create a new instance of an in-memory POJO/JPA producer
InMemoryProducer(String namespace, int maxResults)
          Create a new instance of an in-memory POJO/JPA producer
 
Method Summary
 void close()
          Releases any resources managed by this producer.
 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.
 EntitiesResponse 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.
<TEntity,TKey>
void
register(Class<TEntity> entityClass, Class<TKey> keyClass, String entitySetName, Func<Iterable<TEntity>> get, Func1<TEntity,TKey> id)
          Register a new ODATA endpoint for an entity set.
<TEntity,TKey>
void
register(Class<TEntity> entityClass, Class<TKey> keyClass, String entitySetName, Func<Iterable<TEntity>> get, String idPropertyName)
           
<TEntity,TKey>
void
register(Class<TEntity> entityClass, PropertyModel propertyModel, Class<TKey> keyClass, String entitySetName, Func<Iterable<TEntity>> get, Func1<TEntity,TKey> id)
           
 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

InMemoryProducer

public InMemoryProducer(String namespace)
Create a new instance of an in-memory POJO/JPA producer

Parameters:
namespace - - the namespace that the schema registrations will be in

InMemoryProducer

public InMemoryProducer(String namespace,
                        int maxResults)
Create a new instance of an in-memory POJO/JPA producer

Parameters:
namespace - - the names apce that the schema registrations will be in
maxResults - - the maximum number of entities to return
Method Detail

close

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

Specified by:
close in interface ODataProducer

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 EntitiesResponse 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

register

public <TEntity,TKey> void register(Class<TEntity> entityClass,
                                    Class<TKey> keyClass,
                                    String entitySetName,
                                    Func<Iterable<TEntity>> get,
                                    Func1<TEntity,TKey> id)
Register a new ODATA endpoint for an entity set.

Parameters:
entityClass - the class of the entities that are to be stored in the set
keyClass - the class of the key element of the set
entitySetName - the alias the set will be known by; this is what is used in the ODATA URL
get - a function to iterate over the elements in the set
id - a function to extract the id from any given element in the set

register

public <TEntity,TKey> void register(Class<TEntity> entityClass,
                                    Class<TKey> keyClass,
                                    String entitySetName,
                                    Func<Iterable<TEntity>> get,
                                    String idPropertyName)

register

public <TEntity,TKey> void register(Class<TEntity> entityClass,
                                    PropertyModel propertyModel,
                                    Class<TKey> keyClass,
                                    String entitySetName,
                                    Func<Iterable<TEntity>> get,
                                    Func1<TEntity,TKey> id)

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