public class

ODataConnector

extends Object
java.lang.Object
   ↳ org.mule.modules.odata.ODataConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Connector for consuming OData feeds by performing read, create, update and delete operations. Bath operations are also supported. This version of the connector does not use any kind of authentication.

Summary

Constants
String BATCH_PARTS
Fields
private String baseServiceUri The url of the target OData service
private ODataConsumer consumer The consumer to use
private ODataConsumerFactory consumerFactory An instance of ODataConsumerFactory to intanciate the ODataConsumer.
private ODataVersion consumerVersion The protocol version to be used when consuming external services
private FormatType formatType The format of the payload to be used during communication.
private static final Logger logger
private PropertyNamingFormat namingFormat The namig policy to be used when mapping pojo's attributes to OData entities.
private Map<Class<?>, Collection<FieldDescriptor>> propertiesCache
private String user The current usert
Public Constructors
ODataConnector()
Public Methods
BatchResult batch(MuleMessage message, List<NestedProcessor> processors)
Executes a series of insert/update/deletes in a batch grouped in one changeset.
void connect(String username, String password, String serviceUri)
void createEntity(MuleMessage message, Object entity, String entitySetName)
Inserts an entity from an input pojo.
void deleteEntity(MuleMessage message, Object entity, String entitySetName, String keyAttribute)
Deletes an entity represented by a pojo on the OData service To specify the entitie's id, your pojo can rather have an attribute of type Guid or to have a string attribute annotated with Guid
void disconnect()
String getConnectionIdentifier()
ODataConsumerFactory getConsumerFactory()
ODataVersion getConsumerVersion()
List<Object> getEntities(String returnClass, String entitySetName, String filter, String orderBy, String expand, Integer skip, Integer top, String select)
Reads entities from an specified set and returns it as a list of pojos.
FormatType getFormatType()
PropertyNamingFormat getNamingFormat()
boolean isConnected()
void setConsumerFactory(ODataConsumerFactory consumerFactory)
void setConsumerVersion(ODataVersion consumerVersion)
void setFormatType(FormatType formatType)
void setNamingFormat(PropertyNamingFormat namingFormat)
void updateEntity(MuleMessage message, Object entity, String entitySetName, String keyAttribute)
Updates an entity represented by a pojo on the OData service To specify the entitie's id, your pojo can rather have an attribute of type Guid or to have a string attribute annotated with Guid
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String BATCH_PARTS

Constant Value: "ODATA_CONNECTOR_BATCH_BODY_PARTS"

Fields

private String baseServiceUri

The url of the target OData service

private ODataConsumer consumer

The consumer to use

private ODataConsumerFactory consumerFactory

An instance of ODataConsumerFactory to intanciate the ODataConsumer. Normally you don't need to set this unless you require some custom initialization of the consumer or if you are doing test cases. If this property is not specified, then an instance of org.mule.modules.odata.factory.ODataConsumerFactoryImpl.ODataConsumerFactoryImpl is used

private ODataVersion consumerVersion

The protocol version to be used when consuming external services

private FormatType formatType

The format of the payload to be used during communication. Valid values are JSON and ATOM

private static final Logger logger

private PropertyNamingFormat namingFormat

The namig policy to be used when mapping pojo's attributes to OData entities. Depending on the OData service you're consuming, you might find that attributes usually follows a lower camel case format (e.g.: theAttribute) or an upper camel case format (e.g.: TheAttribute). The naming format assumes that your pojo's properties follow the lower camel case format (just as the java coding standard dictates) and translates to the format that the OData service is expecting. Valid values are: LOWER_CAMEL_CASE and UPPER_CAMEL_CASE.

private Map<Class<?>, Collection<FieldDescriptor>> propertiesCache

private String user

The current usert

Public Constructors

public ODataConnector ()

Public Methods

public BatchResult batch (MuleMessage message, List<NestedProcessor> processors)

Executes a series of insert/update/deletes in a batch grouped in one changeset.

Parameters
message The current mule message
processors Nested processors where each individual operation is to be performed
Returns

public void connect (String username, String password, String serviceUri)

Parameters
username The authorization username
password The authorization password
serviceUri The URI of the target OData Service
Throws
ConnectionException

public void createEntity (MuleMessage message, Object entity, String entitySetName)

Inserts an entity from an input pojo. To specify the entitie's id, your pojo can rather have an attribute of type Guid or to have a string attribute annotated with Guid

Parameters
message The current mule message
entity An object representing the entity
entitySetName The name of the set. If not specified then it's inferred by adding the suffix 'Set' to the objects simple class name

public void deleteEntity (MuleMessage message, Object entity, String entitySetName, String keyAttribute)

Deletes an entity represented by a pojo on the OData service To specify the entitie's id, your pojo can rather have an attribute of type Guid or to have a string attribute annotated with Guid

Parameters
message The current mule message
entity An object representing the entity
entitySetName The name of the set. If not specified then it's inferred by adding the suffix 'Set' to the objects simple class name
keyAttribute The name of the pojo's attribute that holds the entity's key. The attribute cannot hold a null value

public void disconnect ()

public String getConnectionIdentifier ()

public ODataConsumerFactory getConsumerFactory ()

public ODataVersion getConsumerVersion ()

public List<Object> getEntities (String returnClass, String entitySetName, String filter, String orderBy, String expand, Integer skip, Integer top, String select)

Reads entities from an specified set and returns it as a list of pojos. You can optionally provide a returnClass parameter which will allow you to get the result as a list of pojos (as long as that class is compliant with the Bean contract). If you don't specify it, you'll get a list of generic ${org.odata4j.core.OEntity} objects.

Parameters
returnClass The canonical class name for the pojo instances to be returned. If none especified then generic OEntity class will be returned. OEntity is a pojo which represents the set's metadata and allows for browsing
entitySetName The name of the set to be read
filter An OData filtering expression. If not provided, no filtering occurs (see http://www.odata.org/developers/protocols/uri-conventions#FilterSystemQueryOption)
orderBy The ordering expression. If not provided, no ordering occurs (see http://www.odata.org/developers/protocols/uri-conventions#OrderBySystemQueryOption(
expand Sets the expand expressions.
skip Number of items to skip, usefull for pagination. If not provided, no records are skept (see http://www.odata.org/developers/protocols/uri-conventions#SkipSystemQueryOption)
top Number of items to return (see http://www.odata.org/developers/protocols/uri-conventions#TopSystemQueryOption)
select The selection clauses. If not specified, all fields are returned (see http://www.odata.org/developers/protocols/uri-conventions#SelectSystemQueryOption)
Returns
  • a list of objects of class "returnClass" representing the obtained entities

public FormatType getFormatType ()

public PropertyNamingFormat getNamingFormat ()

public boolean isConnected ()

public void setConsumerFactory (ODataConsumerFactory consumerFactory)

Parameters
consumerFactory

public void setConsumerVersion (ODataVersion consumerVersion)

Parameters
consumerVersion

public void setFormatType (FormatType formatType)

Parameters
formatType

public void setNamingFormat (PropertyNamingFormat namingFormat)

Parameters
namingFormat

public void updateEntity (MuleMessage message, Object entity, String entitySetName, String keyAttribute)

Updates an entity represented by a pojo on the OData service To specify the entitie's id, your pojo can rather have an attribute of type Guid or to have a string attribute annotated with Guid

Parameters
message The current mule message
entity An object representing the entity
entitySetName The name of the set. If not specified then it's inferred by adding the suffix 'Set' to the objects simple class name
keyAttribute The name of the pojo's attribute that holds the entity's key. The attribute cannot hold a null value