|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.odata4j.producer.inmemory.InMemoryProducer
public class InMemoryProducer
An in-memory implementation of an ODATA Producer. Uses the standard Java bean and property model to access information within entities.
Nested Class Summary | |
---|---|
static class |
InMemoryProducer.RequestContext
|
Field Summary | |
---|---|
static String |
ID_PROPNAME
|
Constructor Summary | |
---|---|
InMemoryProducer(String namespace)
Creates a new instance of an in-memory POJO producer. |
|
InMemoryProducer(String namespace,
int maxResults)
Creates a new instance of an in-memory POJO producer. |
|
InMemoryProducer(String namespace,
String containerName,
int maxResults,
EdmDecorator decorator,
InMemoryTypeMapping typeMapping)
Creates a new instance of an in-memory POJO producer. |
|
InMemoryProducer(String namespace,
String containerName,
int maxResults,
EdmDecorator decorator,
InMemoryTypeMapping typeMapping,
boolean flattenEdm)
|
Method Summary | ||
---|---|---|
protected void |
addPropertiesFromObject(Object obj,
PropertyModel propertyModel,
EdmStructuralType structuralType,
List<OProperty<?>> properties,
PropertyPathHelper pathHelper)
Transforms a POJO into a list of OProperties based on a given EdmStructuralType. |
|
BaseResponse |
callFunction(EdmFunctionImport name,
Map<String,OFunctionParameter> params,
QueryInfo queryInfo)
Calls a function (aka Service Operation). |
|
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 |
createLink(OEntityId sourceEntity,
String targetNavProp,
OEntityId targetEntity)
Creates a link between two entities. |
|
void |
deleteEntity(String entitySetName,
OEntityKey entityKey)
Deletes an existing entity. |
|
void |
deleteLink(OEntityId sourceEntity,
String targetNavProp,
OEntityKey targetEntityKey)
Deletes an existing link between two entities. |
|
protected
|
fillInPojo(OStructuralObject sobj,
EdmStructuralType stype,
PropertyModel propertyModel,
Class<T> pojoClass)
Populates a new POJO instance of type pojoClass using data from the given structural object. |
|
protected InMemoryComplexTypeInfo<?> |
findComplexTypeInfoForClass(Class<?> clazz)
|
|
protected InMemoryEntityInfo<?> |
findEntityInfoForClass(Class<?> clazz)
|
|
protected InMemoryEntityInfo<?> |
findEntityInfoForEntitySet(String entitySetName)
|
|
protected EdmEntitySet |
findEntitySetForNavProperty(EdmNavigationProperty navProp)
|
|
|
findExtension(Class<TExtension> clazz)
Finds an extension instance given an interface, if one exists. |
|
protected void |
fireUnmarshalEvent(Object pojo,
OStructuralObject sobj,
org.odata4j.producer.inmemory.InMemoryProducer.TriggerType ttype)
|
|
String |
getContainerName()
|
|
EntitiesResponse |
getEntities(String entitySetName,
QueryInfo queryInfo)
Gets all the entities for a given set matching the query information. |
|
CountResponse |
getEntitiesCount(String entitySetName,
QueryInfo queryInfo)
Gets the count of all the entities for a given set matching the query information. |
|
protected EntitiesResponse |
getEntitiesResponse(InMemoryProducer.RequestContext rc,
EdmEntitySet targetEntitySet,
Enumerable<Object> objects,
PropertyModel propertyModel)
|
|
EntityResponse |
getEntity(String entitySetName,
OEntityKey entityKey,
EntityQueryInfo queryInfo)
Obtains a single entity based on its type and key. |
|
protected Object |
getEntityPojo(InMemoryProducer.RequestContext rc)
Given an entity set and an entity key, returns the pojo that is that entity instance. |
|
EntityIdResponse |
getLinks(OEntityId sourceEntity,
String targetNavProp)
Returns the value of an entity's navigation property as a collection of entity links (or a single link if the association cardinality is 1). |
|
EdmDataServices |
getMetadata()
Obtains the service metadata for this producer. |
|
MetadataProducer |
getMetadataProducer()
Obtains the ODataProducer implementation that serves the metadata as OData EDM constructs. |
|
protected BaseResponse |
getNavProperty(EdmNavigationProperty navProp,
InMemoryProducer.RequestContext rc)
Gets the entity(s) on the target end of a NavigationProperty. |
|
BaseResponse |
getNavProperty(String entitySetName,
OEntityKey entityKey,
String navProp,
QueryInfo queryInfo)
Given a specific entity, follow one of its navigation properties, applying constraints as appropriate. |
|
CountResponse |
getNavPropertyCount(String entitySetName,
OEntityKey entityKey,
String navProp,
QueryInfo queryInfo)
Given a specific entity, follow one of its navigation properties, applying constraints as appropriate. |
|
protected Iterable<?> |
getRelatedPojos(EdmNavigationProperty navProp,
Object srcObject,
InMemoryEntityInfo<?> srcInfo)
|
|
void |
mergeEntity(String entitySetName,
OEntity entity)
Modifies an existing entity using merge semantics. |
|
protected InMemoryEdmGenerator |
newEdmGenerator(String namespace,
InMemoryTypeMapping typeMapping,
String idPropName,
Map<String,InMemoryEntityInfo<?>> eis,
Map<String,InMemoryComplexTypeInfo<?>> complexTypesInfo)
|
|
|
register(Class<TEntity> entityClass,
Class<TKey> keyClass,
String entitySetName,
Func<Iterable<TEntity>> get,
Func1<TEntity,TKey> id)
Registers a new entity set based on a POJO type using the default property model. |
|
|
register(Class<TEntity> entityClass,
PropertyModel propertyModel,
String entitySetName,
Func<Iterable<TEntity>> get,
String... keys)
Registers a new entity set based on a POJO type and a property model. |
|
|
register(Class<TEntity> entityClass,
PropertyModel propertyModel,
String entitySetName,
String entityTypeName,
Func<Iterable<TEntity>> get,
Func1<InMemoryProducer.RequestContext,Iterable<TEntity>> getWithContext,
String... keys)
|
|
|
register(Class<TEntity> entityClass,
PropertyModel propertyModel,
String entitySetName,
String entityTypeName,
Func<Iterable<TEntity>> get,
String... keys)
|
|
|
register(Class<TEntity> entityClass,
String entitySetName,
Func<Iterable<TEntity>> get,
String... keys)
Registers a new entity based on a POJO, with support for composite keys. |
|
|
register(Class<TEntity> entityClass,
String entitySetName,
String entityTypeName,
Func<Iterable<TEntity>> get,
String... keys)
Registers a new entity based on a POJO, with support for composite keys. |
|
|
registerComplexType(Class<TEntity> complexTypeClass,
String typeName)
Registers a POJO class as an EdmComplexType. |
|
|
registerComplexType(Class<TEntity> complexTypeClass,
String typeName,
PropertyModel propertyModel)
|
|
void |
setIncludeNullPropertyValues(boolean value)
|
|
protected OEntity |
toOEntity(EdmEntitySet ees,
Object obj,
PropertyPathHelper pathHelper)
|
|
|
toPojo(OComplexObject entity,
Class<T> pojoClass)
Transforms an OComplexObject into a POJO of the given class |
|
|
toPojo(OEntity entity,
Class<T> pojoClass)
Transforms the given entity into a POJO of type pojoClass. |
|
void |
updateEntity(String entitySetName,
OEntity entity)
Modifies an existing entity using update semantics. |
|
void |
updateLink(OEntityId sourceEntity,
String targetNavProp,
OEntityKey oldTargetEntityKey,
OEntityId newTargetEntity)
Replaces an existing link between two entities. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ID_PROPNAME
Constructor Detail |
---|
public InMemoryProducer(String namespace)
namespace
- the namespace of the schema registrationspublic InMemoryProducer(String namespace, int maxResults)
namespace
- the namespace of the schema registrationsmaxResults
- the maximum number of entities to return in a single callpublic InMemoryProducer(String namespace, String containerName, int maxResults, EdmDecorator decorator, InMemoryTypeMapping typeMapping)
namespace
- the namespace of the schema registrationscontainerName
- the container name for generated metadatamaxResults
- the maximum number of entities to return in a single calldecorator
- a decorator to use for edm customizationstypeMapping
- optional mapping between java types and edm types, null for defaultpublic InMemoryProducer(String namespace, String containerName, int maxResults, EdmDecorator decorator, InMemoryTypeMapping typeMapping, boolean flattenEdm)
Method Detail |
---|
protected void addPropertiesFromObject(Object obj, PropertyModel propertyModel, EdmStructuralType structuralType, List<OProperty<?>> properties, PropertyPathHelper pathHelper)
obj
- the POJO to transformpropertyModel
- the PropertyModel to use to access POJO class
structure and values.structuralType
- the EdmStructuralTypeproperties
- put properties into this list.public BaseResponse callFunction(EdmFunctionImport name, Map<String,OFunctionParameter> params, QueryInfo queryInfo)
ODataProducer
callFunction
in interface ODataProducer
name
- the name of the functionparams
- the parameters to the functionqueryInfo
- additional query parameters to apply to collection-valued results
The return type of <Function> MUST be one of the following: An EDMSimpleType or collection of EDMSimpleTypes. An entity type or collection of entity types. A complex type or collection of complex types. A row type or collection of row types. <ReturnType> can contain a maximum of one <CollectionType> element. <ReturnType> can contain a maximum of one <ReferenceType> element. <ReturnType> can contain a maximum of one <RowType> element. A ref type or collection of ref types.
public void close()
ODataProducer
close
in interface ODataProducer
public EntityResponse createEntity(String entitySetName, OEntity entity)
ODataProducer
createEntity
in interface ODataProducer
entitySetName
- the entity-set nameentity
- the request entity sent from the client
public EntityResponse createEntity(String entitySetName, OEntityKey entityKey, String navProp, OEntity entity)
ODataProducer
createEntity
in interface ODataProducer
entitySetName
- the entity-set name of the existing entityentityKey
- the entity-key of the existing entitynavProp
- the navigation property off of the existing entityentity
- the request entity sent from the client
public void createLink(OEntityId sourceEntity, String targetNavProp, OEntityId targetEntity)
ODataProducer
createLink
in interface ODataProducer
sourceEntity
- an entity with at least one navigation propertytargetNavProp
- the navigation propertytargetEntity
- the link target entitypublic void deleteEntity(String entitySetName, OEntityKey entityKey)
ODataProducer
deleteEntity
in interface ODataProducer
entitySetName
- the entity-set name of the entityentityKey
- the entity-key of the entitypublic void deleteLink(OEntityId sourceEntity, String targetNavProp, OEntityKey targetEntityKey)
ODataProducer
deleteLink
in interface ODataProducer
sourceEntity
- an entity with at least one navigation propertytargetNavProp
- the navigation propertytargetEntityKey
- if the navigation property represents a set, the key identifying the target entity within the set, else n/aprotected <T> T fillInPojo(OStructuralObject sobj, EdmStructuralType stype, PropertyModel propertyModel, Class<T> pojoClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
protected InMemoryComplexTypeInfo<?> findComplexTypeInfoForClass(Class<?> clazz)
protected InMemoryEntityInfo<?> findEntityInfoForClass(Class<?> clazz)
protected InMemoryEntityInfo<?> findEntityInfoForEntitySet(String entitySetName)
protected EdmEntitySet findEntitySetForNavProperty(EdmNavigationProperty navProp)
public <TExtension extends OExtension<ODataProducer>> TExtension findExtension(Class<TExtension> clazz)
OExtensible
findExtension
in interface OExtensible<ODataProducer>
TExtension
- type of extensionclazz
- the extension interface
protected void fireUnmarshalEvent(Object pojo, OStructuralObject sobj, org.odata4j.producer.inmemory.InMemoryProducer.TriggerType ttype) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
public String getContainerName()
public EntitiesResponse getEntities(String entitySetName, QueryInfo queryInfo)
ODataProducer
getEntities
in interface ODataProducer
entitySetName
- the entity-set name for entities to returnqueryInfo
- the additional constraints to apply to the entities
public CountResponse getEntitiesCount(String entitySetName, QueryInfo queryInfo)
ODataProducer
getEntitiesCount
in interface ODataProducer
entitySetName
- the entity-set name for entities whose count is returnedqueryInfo
- the additional constraints to apply to the entities
protected EntitiesResponse getEntitiesResponse(InMemoryProducer.RequestContext rc, EdmEntitySet targetEntitySet, Enumerable<Object> objects, PropertyModel propertyModel)
public EntityResponse getEntity(String entitySetName, OEntityKey entityKey, EntityQueryInfo queryInfo)
ODataProducer
getEntity
in interface ODataProducer
entitySetName
- the entity-set name for entities to returnentityKey
- the unique entity-key of the entity to start withqueryInfo
- the additional constraints applicable to single-entity queries
protected Object getEntityPojo(InMemoryProducer.RequestContext rc)
rc
- the current ReqeustContext, may be valuable to the ei.getWithContext impl
public EntityIdResponse getLinks(OEntityId sourceEntity, String targetNavProp)
ODataProducer
getLinks
in interface ODataProducer
sourceEntity
- an entity with at least one navigation propertytargetNavProp
- the navigation property
public EdmDataServices getMetadata()
ODataProducer
getMetadata
in interface ODataProducer
public MetadataProducer getMetadataProducer()
ODataProducer
getMetadataProducer
in interface ODataProducer
protected BaseResponse getNavProperty(EdmNavigationProperty navProp, InMemoryProducer.RequestContext rc)
navProp
- the navigation propertyrc
- the request context
public BaseResponse getNavProperty(String entitySetName, OEntityKey entityKey, String navProp, QueryInfo queryInfo)
ODataProducer
getNavProperty
in interface ODataProducer
entitySetName
- the entity-set of the entity to start withentityKey
- the unique entity-key of the entity to start withnavProp
- the navigation property to followqueryInfo
- additional constraints to apply to the result
public CountResponse getNavPropertyCount(String entitySetName, OEntityKey entityKey, String navProp, QueryInfo queryInfo)
ODataProducer
getNavPropertyCount
in interface ODataProducer
entitySetName
- the entity-set of the entity to start withentityKey
- the unique entity-key of the entity to start withnavProp
- the navigation property to followqueryInfo
- additional constraints to apply to the result
protected Iterable<?> getRelatedPojos(EdmNavigationProperty navProp, Object srcObject, InMemoryEntityInfo<?> srcInfo)
public void mergeEntity(String entitySetName, OEntity entity)
ODataProducer
mergeEntity
in interface ODataProducer
entitySetName
- the entity-set nameentity
- the entity modifications sent from the clientprotected InMemoryEdmGenerator newEdmGenerator(String namespace, InMemoryTypeMapping typeMapping, String idPropName, Map<String,InMemoryEntityInfo<?>> eis, Map<String,InMemoryComplexTypeInfo<?>> complexTypesInfo)
public <TEntity,TKey> void register(Class<TEntity> entityClass, Class<TKey> keyClass, String entitySetName, Func<Iterable<TEntity>> get, Func1<TEntity,TKey> id)
public <TEntity,TKey> void register(Class<TEntity> entityClass, PropertyModel propertyModel, String entitySetName, Func<Iterable<TEntity>> get, String... keys)
entityClass
- the class of the entities that are to be stored in the setpropertyModel
- a way to get/set properties on the POJOentitySetName
- the alias the set will be known by; this is what is used in the ODATA URLget
- a function to iterate over the elements in the setkeys
- one or more keys for the entitypublic <TEntity> void register(Class<TEntity> entityClass, PropertyModel propertyModel, String entitySetName, String entityTypeName, Func<Iterable<TEntity>> get, Func1<InMemoryProducer.RequestContext,Iterable<TEntity>> getWithContext, String... keys)
public <TEntity> void register(Class<TEntity> entityClass, PropertyModel propertyModel, String entitySetName, String entityTypeName, Func<Iterable<TEntity>> get, String... keys)
public <TEntity> void register(Class<TEntity> entityClass, String entitySetName, Func<Iterable<TEntity>> get, String... keys)
entityClass
- the class of the entities that are to be stored in the setentitySetName
- the alias the set will be known by; this is what is used in the OData urlget
- a function to iterate over the elements in the setkeys
- one or more keys for the entitypublic <TEntity> void register(Class<TEntity> entityClass, String entitySetName, String entityTypeName, Func<Iterable<TEntity>> get, String... keys)
entityClass
- the class of the entities that are to be stored in the setentitySetName
- the alias the set will be known by; this is what is used in the OData urlentityTypeName
- type name of the entityget
- a function to iterate over the elements in the setkeys
- one or more keys for the entitypublic <TEntity> void registerComplexType(Class<TEntity> complexTypeClass, String typeName)
complexTypeClass
- The POJO ClasstypeName
- The name of the EdmComplexTypepublic <TEntity> void registerComplexType(Class<TEntity> complexTypeClass, String typeName, PropertyModel propertyModel)
public void setIncludeNullPropertyValues(boolean value)
protected OEntity toOEntity(EdmEntitySet ees, Object obj, PropertyPathHelper pathHelper)
public <T> T toPojo(OComplexObject entity, Class<T> pojoClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
public <T> T toPojo(OEntity entity, Class<T> pojoClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
public void updateEntity(String entitySetName, OEntity entity)
ODataProducer
updateEntity
in interface ODataProducer
entitySetName
- the entity-set nameentity
- the entity modifications sent from the clientpublic void updateLink(OEntityId sourceEntity, String targetNavProp, OEntityKey oldTargetEntityKey, OEntityId newTargetEntity)
ODataProducer
updateLink
in interface ODataProducer
sourceEntity
- an entity with at least one navigation propertytargetNavProp
- the navigation propertyoldTargetEntityKey
- if the navigation property represents a set, the key identifying the old target entity within the set, else n/anewTargetEntity
- the new link target entity
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |