org.odata4j.consumer
Class AbstractODataConsumer

java.lang.Object
  extended by org.odata4j.consumer.AbstractODataConsumer
All Implemented Interfaces:
ODataConsumer
Direct Known Subclasses:
ODataCxfConsumer, ODataJerseyConsumer

public abstract class AbstractODataConsumer
extends Object
implements ODataConsumer

Useful base class for ODataConsumer implementations with common functionality.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.odata4j.consumer.ODataConsumer
ODataConsumer.Builder, ODataConsumer.Dump
 
Field Summary
 
Fields inherited from interface org.odata4j.consumer.ODataConsumer
dump
 
Constructor Summary
protected AbstractODataConsumer(String serviceRootUri)
           
 
Method Summary
 OFunctionRequest<OObject> callFunction(String functionName)
          Call a server-side function (also known as a service operation).
 OCreateRequest<OEntity> createEntity(String entitySetName)
          Creates a new entity in the given entity-set.
 OEntityRequest<Void> createLink(OEntityId sourceEntity, String targetNavProp, OEntityId targetEntity)
          Creates a new related entity link between two entities.
 OEntityDeleteRequest deleteEntity(OEntity entity)
          Deletes an existing entity.
 OEntityDeleteRequest deleteEntity(String entitySetName, Object keyValue)
          Deletes an existing entity.
 OEntityDeleteRequest deleteEntity(String entitySetName, OEntityKey key)
          Deletes an existing entity.
 OEntityRequest<Void> deleteLink(OEntityId sourceEntity, String targetNavProp, Object... targetKeyValues)
          Deletes related entity links between two entities by navigation property.
protected abstract  ODataClient getClient()
           
<T> OQueryRequest<T>
getEntities(Class<T> entityType, String entitySetHref)
          Gets entities from the given entity-set.
 OQueryRequest<OEntity> getEntities(ORelatedEntitiesLink link)
          Gets entities referred to by the given related-entities link.
 OQueryRequest<OEntity> getEntities(String entitySetHref)
          Gets entities from the given entity-set.
 OCountRequest getEntitiesCount(String entitySetName)
          Returns a single value request which can be extended by query options.
<T> OEntityGetRequest<T>
getEntity(Class<T> entityType, String entitySetName, Object keyValue)
          Gets the entity by entity-set name and entity-key value.
<T> OEntityGetRequest<T>
getEntity(Class<T> entityType, String entitySetName, OEntityKey key)
          Gets the entity by entity-set name and entity-key.
 OEntityGetRequest<OEntity> getEntity(OEntity entity)
          Gets the latest version of an entity using the given entity as a template.
 OEntityGetRequest<OEntity> getEntity(ORelatedEntityLink link)
          Gets the entity referred to by the given related entity link.
 OEntityGetRequest<OEntity> getEntity(String entitySetName, Object keyValue)
          Gets the entity by entity-set name and entity-key value.
 OEntityGetRequest<OEntity> getEntity(String entitySetName, OEntityKey key)
          Gets the entity by entity-set name and entity-key.
 Enumerable<EntitySetInfo> getEntitySets()
          Lists all top-level entity-sets for the OData service.
 OQueryRequest<OEntityId> getLinks(OEntityId sourceEntity, String targetNavProp)
          Gets related entity links for a given source entity by navigation property.
 EdmDataServices getMetadata()
          Gets the OData service metadata.
 String getServiceRootUri()
          Gets the OData service uri.
 OModifyRequest<OEntity> mergeEntity(OEntity entity)
          Modifies an existing entity using merge semantics.
 OModifyRequest<OEntity> mergeEntity(String entitySetName, Object keyValue)
          Modifies an existing entity using merge semantics.
 OModifyRequest<OEntity> mergeEntity(String entitySetName, OEntityKey key)
          Modifies an existing entity using merge semantics.
 OModifyRequest<OEntity> mergeEntity(String entitySetName, OEntityKey key, String entityTag)
           
 OModifyRequest<OEntity> updateEntity(OEntity entity)
          Modifies an existing entity using update semantics.
 OEntityRequest<Void> updateLink(OEntityId sourceEntity, OEntityId newTargetEntity, String targetNavProp, Object... oldTargetKeyValues)
          Updates related entity links between two entities by navigation property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractODataConsumer

protected AbstractODataConsumer(String serviceRootUri)
Method Detail

callFunction

public OFunctionRequest<OObject> callFunction(String functionName)
Description copied from interface: ODataConsumer
Call a server-side function (also known as a service operation).

The functioncall-request builder returned can be used to add parameters. Call OQueryRequest.execute() to issue request.

Specified by:
callFunction in interface ODataConsumer
Parameters:
functionName - the function name
Returns:
a new functioncall-request builder

createEntity

public OCreateRequest<OEntity> createEntity(String entitySetName)
Description copied from interface: ODataConsumer
Creates a new entity in the given entity-set.

The create-request builder returned can be used to construct the new entity. Call OCreateRequest.execute() to issue request.

Specified by:
createEntity in interface ODataConsumer
Parameters:
entitySetName - the name of the entity-set
Returns:
a new create-request builder

createLink

public OEntityRequest<Void> createLink(OEntityId sourceEntity,
                                       String targetNavProp,
                                       OEntityId targetEntity)
Description copied from interface: ODataConsumer
Creates a new related entity link between two entities.

Call OEntityRequest.execute() on the returned request builder to issue request.

Specified by:
createLink in interface ODataConsumer
Parameters:
sourceEntity - the entity to start from
targetNavProp - the relationship navigation property
targetEntity - the entity to use as the target of the relationship
Returns:
a request builder

deleteEntity

public OEntityDeleteRequest deleteEntity(OEntity entity)
Description copied from interface: ODataConsumer
Deletes an existing entity.

The delete-request builder returned can be used for further navigation. Call OEntityRequest.execute() to issue request.

Specified by:
deleteEntity in interface ODataConsumer
Parameters:
entity - the entity identity
Returns:
a new delete-request builder

deleteEntity

public OEntityDeleteRequest deleteEntity(String entitySetName,
                                         Object keyValue)
Description copied from interface: ODataConsumer
Deletes an existing entity.

The delete-request builder returned can be used for further navigation. Call OEntityRequest.execute() to issue request.

Specified by:
deleteEntity in interface ODataConsumer
Parameters:
entitySetName - the entity identity entity-set name
keyValue - the entity identity key value
Returns:
a new entity-request builder

deleteEntity

public OEntityDeleteRequest deleteEntity(String entitySetName,
                                         OEntityKey key)
Description copied from interface: ODataConsumer
Deletes an existing entity.

The delete-request builder returned can be used for further navigation. Call OEntityRequest.execute() to issue request.

Specified by:
deleteEntity in interface ODataConsumer
Parameters:
entitySetName - the entity identity entity-set name
key - the entity identity key
Returns:
a new entity-request builder

deleteLink

public OEntityRequest<Void> deleteLink(OEntityId sourceEntity,
                                       String targetNavProp,
                                       Object... targetKeyValues)
Description copied from interface: ODataConsumer
Deletes related entity links between two entities by navigation property.

Call OEntityRequest.execute() on the returned request builder to issue request.

Specified by:
deleteLink in interface ODataConsumer
Parameters:
sourceEntity - the entity to start from
targetNavProp - the relationship navigation property
targetKeyValues - the target entity-key, applicable if the navigation property represents a collection
Returns:
a request builder

getClient

protected abstract ODataClient getClient()

getEntities

public <T> OQueryRequest<T> getEntities(Class<T> entityType,
                                        String entitySetHref)
Description copied from interface: ODataConsumer
Gets entities from the given entity-set. The entities will be represented as the given java-type.

The query-request builder returned can be used for further server-side filtering. Call OQueryRequest.execute() to issue request.

Specified by:
getEntities in interface ODataConsumer
Type Parameters:
T - the entity representation as a java type
Parameters:
entityType - the entity representation as a java type
entitySetHref - the entity-set href
Returns:
a new query-request builder

getEntities

public OQueryRequest<OEntity> getEntities(ORelatedEntitiesLink link)
Description copied from interface: ODataConsumer
Gets entities referred to by the given related-entities link.

The query-request builder returned can be used for further server-side filtering. Call OQueryRequest.execute() to issue request.

Specified by:
getEntities in interface ODataConsumer
Parameters:
link - the link
Returns:
a new query-request builder

getEntities

public OQueryRequest<OEntity> getEntities(String entitySetHref)
Description copied from interface: ODataConsumer
Gets entities from the given entity-set.

The query-request builder returned can be used for further server-side filtering. Call OQueryRequest.execute() to issue request.

Specified by:
getEntities in interface ODataConsumer
Parameters:
entitySetHref - the entity-set href
Returns:
a new query-request builder

getEntitiesCount

public OCountRequest getEntitiesCount(String entitySetName)
Description copied from interface: ODataConsumer
Returns a single value request which can be extended by query options. The execution of the request will return a single value for $count.

Specified by:
getEntitiesCount in interface ODataConsumer
Parameters:
entitySetName - the entity identity entity-set name
Returns:
a new count-request builder

getEntity

public <T> OEntityGetRequest<T> getEntity(Class<T> entityType,
                                          String entitySetName,
                                          Object keyValue)
Description copied from interface: ODataConsumer
Gets the entity by entity-set name and entity-key value. The entity will be represented as the given java-type.

The entity-request builder returned can be used for further navigation. Call OEntityRequest.execute() to issue request.

Specified by:
getEntity in interface ODataConsumer
Type Parameters:
T - the entity representation as a java type
Parameters:
entityType - the entity representation as a java type
entitySetName - the name of the entity-set
keyValue - the entity-key value
Returns:
a new entity-request builder

getEntity

public <T> OEntityGetRequest<T> getEntity(Class<T> entityType,
                                          String entitySetName,
                                          OEntityKey key)
Description copied from interface: ODataConsumer
Gets the entity by entity-set name and entity-key. The entity will be represented as the given java-type.

The entity-request builder returned can be used for further navigation. Call OEntityRequest.execute() to issue request.

Specified by:
getEntity in interface ODataConsumer
Type Parameters:
T - the entity representation as a java type
Parameters:
entityType - the entity representation as a java type
entitySetName - the name of the entity-set
key - the entity-key
Returns:
a new entity-request builder

getEntity

public OEntityGetRequest<OEntity> getEntity(OEntity entity)
Description copied from interface: ODataConsumer
Gets the latest version of an entity using the given entity as a template.

The entity-request builder returned can be used for further navigation. Call OEntityRequest.execute() to issue request.

Specified by:
getEntity in interface ODataConsumer
Parameters:
entity - an existing entity to use as a template, using its entity-set and entity-key
Returns:
a new entity-request builder

getEntity

public OEntityGetRequest<OEntity> getEntity(ORelatedEntityLink link)
Description copied from interface: ODataConsumer
Gets the entity referred to by the given related entity link.

The entity-request builder returned can be used for further navigation. Call OEntityRequest.execute() to issue request.

Specified by:
getEntity in interface ODataConsumer
Parameters:
link - the link
Returns:
a new entity-request builder

getEntity

public OEntityGetRequest<OEntity> getEntity(String entitySetName,
                                            Object keyValue)
Description copied from interface: ODataConsumer
Gets the entity by entity-set name and entity-key value.

The entity-request builder returned can be used for further navigation. Call OEntityRequest.execute() to issue request.

Specified by:
getEntity in interface ODataConsumer
Parameters:
entitySetName - the name of the entity-set
keyValue - the entity-key value
Returns:
a new entity-request builder

getEntity

public OEntityGetRequest<OEntity> getEntity(String entitySetName,
                                            OEntityKey key)
Description copied from interface: ODataConsumer
Gets the entity by entity-set name and entity-key.

The entity-request builder returned can be used for further navigation. Call OEntityRequest.execute() to issue request.

Specified by:
getEntity in interface ODataConsumer
Parameters:
entitySetName - the name of the entity-set
key - the entity-key
Returns:
a new entity-request builder

getEntitySets

public Enumerable<EntitySetInfo> getEntitySets()
                                        throws ODataProducerException
Description copied from interface: ODataConsumer
Lists all top-level entity-sets for the OData service.

Specified by:
getEntitySets in interface ODataConsumer
Returns:
the entity-set information
Throws:
ODataProducerException - error from the producer

getLinks

public OQueryRequest<OEntityId> getLinks(OEntityId sourceEntity,
                                         String targetNavProp)
Description copied from interface: ODataConsumer
Gets related entity links for a given source entity by navigation property.

The entityid-request builder returned can be used for further server-side filtering. Call OQueryRequest.execute() to issue request.

Specified by:
getLinks in interface ODataConsumer
Parameters:
sourceEntity - the entity to start from
targetNavProp - the relationship navigation property
Returns:
a new entityid-request builder

getMetadata

public EdmDataServices getMetadata()
Description copied from interface: ODataConsumer
Gets the OData service metadata.

Specified by:
getMetadata in interface ODataConsumer
Returns:
the service metadata
See Also:
[msdn] 2.2 <edmx:DataServices>

getServiceRootUri

public String getServiceRootUri()
Description copied from interface: ODataConsumer
Gets the OData service uri.

e.g. http://services.odata.org/Northwind/Northwind.svc/

Specified by:
getServiceRootUri in interface ODataConsumer
Returns:
the service uri

mergeEntity

public OModifyRequest<OEntity> mergeEntity(OEntity entity)
Description copied from interface: ODataConsumer
Modifies an existing entity using merge semantics.

The modification-request builder returned can be used to modify the new entity. Call OModifyRequest.execute() to issue request.

Specified by:
mergeEntity in interface ODataConsumer
Parameters:
entity - the entity identity
Returns:
a new modification-request builder

mergeEntity

public OModifyRequest<OEntity> mergeEntity(String entitySetName,
                                           Object keyValue)
Description copied from interface: ODataConsumer
Modifies an existing entity using merge semantics.

The modification-request builder returned can be used to modify the new entity. Call OModifyRequest.execute() to issue request.

Specified by:
mergeEntity in interface ODataConsumer
Parameters:
entitySetName - the entity identity entity-set name
keyValue - the entity identity key value
Returns:
a new modification-request builder

mergeEntity

public OModifyRequest<OEntity> mergeEntity(String entitySetName,
                                           OEntityKey key)
Description copied from interface: ODataConsumer
Modifies an existing entity using merge semantics.

The modification-request builder returned can be used to modify the new entity. Call OModifyRequest.execute() to issue request.

Specified by:
mergeEntity in interface ODataConsumer
Parameters:
entitySetName - the entity identity entity-set name
key - the entity identity key
Returns:
a new modification-request builder

mergeEntity

public OModifyRequest<OEntity> mergeEntity(String entitySetName,
                                           OEntityKey key,
                                           String entityTag)

updateEntity

public OModifyRequest<OEntity> updateEntity(OEntity entity)
Description copied from interface: ODataConsumer
Modifies an existing entity using update semantics.

The modification-request builder returned can be used to redefine the new entity. Call OModifyRequest.execute() to issue request.

Specified by:
updateEntity in interface ODataConsumer
Parameters:
entity - the entity identity
Returns:
a new modification-request builder

updateLink

public OEntityRequest<Void> updateLink(OEntityId sourceEntity,
                                       OEntityId newTargetEntity,
                                       String targetNavProp,
                                       Object... oldTargetKeyValues)
Description copied from interface: ODataConsumer
Updates related entity links between two entities by navigation property.

Call OEntityRequest.execute() on the returned request builder to issue request.

Specified by:
updateLink in interface ODataConsumer
Parameters:
sourceEntity - the entity to start from
newTargetEntity - the entity to use as the new target of the relationship
targetNavProp - the relationship navigation property
oldTargetKeyValues - the target entity-key, applicable if the navigation property represents a collection
Returns:
a request builder


http://odata4j.org