public class

ServiceSourceConnector

extends Object
java.lang.Object
   ↳ org.mule.module.servicesource.ServiceSourceConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

ServiceSource Cloud Connector. The ServiceSource Connector will allow to use the ServiceSource REST API. Almost every operation that can be done via the API can be done through this connector.

Summary

Fields
private WebResource analysisResource
private String analysisUrl The relative URL where the analysis API calls are made
private JerseyUtil apiClient
private WebResource apiResource
private String apiUrl The relative URL where the main API calls are made.
private Client client Jersey Client
private Integer connectTimeout The connect timeout interval, in milliseconds
private NewCookie coockie
private String csrfToken CSRF Token
private static final Logger logger
private String loginUrl The relative url of the endpoint that handles login
private Map<LookupRequest, String> lookupKeyCache
private List<Map<String, Object>> modelsMetadata
private String password Application password
private Integer readTimeout The read timeout interval, in milliseconds
private String server URL of the ServiceSource server API
private String tenantName Name of the tenant
private String username Application username
Public Constructors
ServiceSourceConnector()
Public Methods
AnalysisObject analysisSearch(AnalysisCollection collection, Map<String, Object> filters)
This method allows searching on the analysis API.
void completeDataLoad(DataLoadCompleteRequest request, String dataLoadJobId)
This processor must be invoked to indicatethat the data load job has completed.
void connect(String username, String password, String server, String tenantName)
Connect
String connectionId()
Connection Identifier
ServiceSourceEntity create(ServiceSourceCollection collection, ServiceSourceEntity entity)
Generic method to create entities in dynamic collections
Address createAddress(Address address)
Creates new address
Asset createAsset(Asset asset)
Creates a new Asset
Booking createBooking(Booking booking)
Creates a new Booking
Contact createContact(Contact contact)
Creates new contact
Forecast createForecast(Forecast forecast)
Creates a new forecast
Lookup createLookup(Lookup lookup)
Creates a new lookup
Note createNote(Note note)
Creates a new note
Offer createOffer(Offer offer)
Creates new offer
Opportunity createOpportunity(Opportunity opportunity)
Creates a new opportunity
Product createProduct(Product product)
Creates a new Product
Quote createQuote(Quote quote)
Creates a new Quote
Task createTask(Task task)
Creates a new Task
void delete(ServiceSourceCollection collection, String objectId)
Removes the object from the collection, permitting reference checks.
void disconnect()
Disconnect
Map<String, Object> dynamicCreate(String collection, Map<String, Object> entity)
Generic method to create entities dynamicly using DataSense.
void dynamicLoadData(String collection, List<Map<String, Object>> objects, String dataLoadJobId, boolean incremental)
Pushes data through the load API.
List<ServiceSourceEntity> export(ServiceSourceCollection collection, boolean streaming, List<String> columns)
Export a collection.
String getAnalysisUrl()
String getApiUrl()
Integer getConnectTimeout()
String getCsrfToken()
String getLoginUrl()
MetaData getMetaData(MetaDataKey key)
List<MetaDataKey> getMetaDataKeys()
List<Map<String, Object>> getModelsMetadata()
String getPassword()
Integer getReadTimeout()
String getServer()
String getTenantName()
String getUsername()
void init()
This method initiates the ServiceSource client and gson
List<Map<String, String>> invokeObjectMethod(ServiceSourceCollection collection, String objectId, String method, Map<String, Object> parameters)
Executes a method on the object of a collection.
List<Map<String, String>> invokeStaticMethod(ServiceSourceCollection collection, String method, Map<String, Object> parameters)
Invoke Static Method Executes a static method on the collection.
boolean isConnected()
Are we connected
List<ServiceSourceEntity> loadData(List<ServiceSourceEntity> objects, ServiceSourceCollection collection, String dataLoadJobId, boolean incremental)
Pushes data through the load API.
String lookupKey(String collectionName, String propertyPath, String displayName)
Consumes the lookups config API looking for a lookup for the given connection on the given propertyPath.
List<ServiceSourceEntity> query(ServiceSourceCollection collection, String query)
This method provides basic search capabilities through a collection by providing a mongo formatted query.
ServiceSourceEntity read(ServiceSourceCollection collection, String objectId)
Generic method to read entities from dynamic collections
Address readAddress(String objectId)
Fetches the address identified by the object id.
Asset readAsset(String objectId)
Fetches the Asset identified by the object id.
Booking readBooking(String objectId)
Fetches the Booking identified by the object id.
Contact readContact(String objectId)
Fetches the contact identified by the object id.
Forecast readForecast(String objectId)
Fetches the forecast identified by the object id.
Note readNote(String objectId)
Fetches the note identified by the object id.
Offer readOffer(String objectId)
Fetches the offer identified by the object id.
Opportunity readOpportunity(String objectId)
Fetches the opportunity identified by the object id.
Product readProduct(String objectId)
Fetches the Product identified by the object id.
Quote readQuote(String objectId)
Fetches the Quote identified by the object id.
Task readTask(String objectId)
Fetches the Task identified by the object id.
List<ServiceSourceEntity> search(ServiceSourceCollection collection, Map<String, Object> filters, boolean streaming, List<String> columns, int limit)
This method provides search capabilities by specifying filters through a map.
void setAnalysisUrl(String analysisUrl)
void setApiUrl(String apiUrl)
void setConnectTimeout(Integer connectTimeout)
void setCsrfToken(String csrfToken)
void setLoginUrl(String loginUrl)
void setPassword(String password)
void setReadTimeout(Integer readTimeout)
void setServer(String server)
void setTenantName(String tenantName)
void setUsername(String username)
DataLoad startDataLoad(String jobName, String dataLoadConfigId, String displayName)
Starts a Data Load by creating an entry in the data load collection.
ServiceSourceEntity update(ServiceSourceCollection collection, String objectId, ServiceSourceEntity entity)
Generic method to update entities from dynamic collections
Address updateAddress(String objectId, Address address)
Updates an address
Asset updateAsset(String objectId, Asset asset)
Updates an Asset
Booking updateBooking(String objectId, Booking booking)
Updates a Booking
Contact updateContact(String objectId, Contact contact)
Updates a given contact
Forecast updateForecast(String objectId, Forecast forecast)
Updates a forecast
Note updateNote(String objectId, Note note)
Updates a given note
Offer updateOffer(String objectId, Offer offer)
Updates an offer
Opportunity updateOpportunity(String objectId, Opportunity opportunity)
Updates an opportunity
Product updateProduct(String objectId, Product product)
Updates a Product
Quote updateQuote(String objectId, Quote quote)
Updates a Quote
Task updateTask(String objectId, Task task)
Updates a Task
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private WebResource analysisResource

private String analysisUrl

The relative URL where the analysis API calls are made

private JerseyUtil apiClient

private WebResource apiResource

private String apiUrl

The relative URL where the main API calls are made.

private Client client

Jersey Client

private Integer connectTimeout

The connect timeout interval, in milliseconds

private NewCookie coockie

private String csrfToken

CSRF Token

private static final Logger logger

private String loginUrl

The relative url of the endpoint that handles login

private Map<LookupRequest, String> lookupKeyCache

private List<Map<String, Object>> modelsMetadata

private String password

Application password

private Integer readTimeout

The read timeout interval, in milliseconds

private String server

URL of the ServiceSource server API

private String tenantName

Name of the tenant

private String username

Application username

Public Constructors

public ServiceSourceConnector ()

Public Methods

public AnalysisObject analysisSearch (AnalysisCollection collection, Map<String, Object> filters)

This method allows searching on the analysis API.

Parameters
collection The collection to query
filters Map that includes filters
Returns
  • the actual type of the return value depends on the provided collection, but it will be an implementation of AnalysisObject

public void completeDataLoad (DataLoadCompleteRequest request, String dataLoadJobId)

This processor must be invoked to indicatethat the data load job has completed. This call must be made after all the in-progress load calls complete. The done API can optionally contain summary statistics about the loaded data organized by input source.

Parameters
request An instance of DataLoadCompleteRequest with the comple data load request data
dataLoadJobId The id of the data load job.

public void connect (String username, String password, String server, String tenantName)

Connect

Parameters
username Application username
password Application password
server URL of the SRPS server API
tenantName Name of the tenant
Throws
ConnectionException .

public String connectionId ()

Connection Identifier

public ServiceSourceEntity create (ServiceSourceCollection collection, ServiceSourceEntity entity)

Generic method to create entities in dynamic collections

Parameters
collection A member of the ServiceSourceCollection enum representing the collection that owns the entity
entity A subclass instance of ServiceSourceEntity
Returns

public Address createAddress (Address address)

Creates new address

Parameters
address A Address
Returns
  • a Address representing the newly created address

public Asset createAsset (Asset asset)

Creates a new Asset

Parameters
asset A org.mule.module.servicesource.model.Asset
Returns
  • a org.mule.module.servicesource.model.Asset representing the newly created Asset

public Booking createBooking (Booking booking)

Creates a new Booking

Parameters
booking A org.mule.module.servicesource.model.Booking
Returns
  • a org.mule.module.servicesource.model.Booking representing the newly created Booking

public Contact createContact (Contact contact)

Creates new contact

Parameters
contact A Contact
Returns
  • a Contact representing the newly created contact

public Forecast createForecast (Forecast forecast)

Creates a new forecast

Parameters
forecast A Forecast
Returns
  • a Forecast representing the newly created contact

public Lookup createLookup (Lookup lookup)

Creates a new lookup

Parameters
lookup A Lookup
Returns
  • a Lookup representing the newly created lookup

public Note createNote (Note note)

Creates a new note

Parameters
note A Note
Returns
  • a Contact representing the newly created note

public Offer createOffer (Offer offer)

Creates new offer

Parameters
offer A Offer
Returns
  • a Offer representing the newly created offer

public Opportunity createOpportunity (Opportunity opportunity)

Creates a new opportunity

Parameters
opportunity A Opportunity
Returns
  • a Opportunity representing the newly created opportunity

public Product createProduct (Product product)

Creates a new Product

Parameters
product A org.mule.module.servicesource.model.Product
Returns
  • a org.mule.module.servicesource.model.Product representing the newly created Product

public Quote createQuote (Quote quote)

Creates a new Quote

Parameters
quote A org.mule.module.servicesource.model.Quote
Returns
  • a org.mule.module.servicesource.model.Quote representing the newly created Quote

public Task createTask (Task task)

Creates a new Task

Parameters
task A org.mule.module.servicesource.model.Task
Returns
  • a org.mule.module.servicesource.model.Task representing the newly created task

public void delete (ServiceSourceCollection collection, String objectId)

Removes the object from the collection, permitting reference checks.

Parameters
collection The name of the collection
objectId Id of the object to delete.

public void disconnect ()

Disconnect

public Map<String, Object> dynamicCreate (String collection, Map<String, Object> entity)

Generic method to create entities dynamicly using DataSense. This method used a Map to represent entities instead of pojos.

Parameters
collection A String representation of a ServiceSource collection. For example: app.offers
entity A Map representing the entity
Returns
  • a Map with a representation of the created entity

public void dynamicLoadData (String collection, List<Map<String, Object>> objects, String dataLoadJobId, boolean incremental)

Pushes data through the load API. The ID of the data load job must be included as input. Each invocation of the load API provides data for a single collection and parallel calls can be made to push data to multiple collections. The object content can be deduced from the data dictionary, metadata API or by fetching a pre-existing object using the object fetch API. Unlike its load-data counterpart, this version of the processor takes maps instead of pojos and includes support for DataSense.

Parameters
collection A member of the ServiceSourceCollection enum representing the collection that owns the entities
objects A list with instances of ServiceSourceEntity all belonging to the same collection
dataLoadJobId The id of the data load job.
incremental If true performs an incremental load and the data may already exist and should be updated if it does rather than just added

public List<ServiceSourceEntity> export (ServiceSourceCollection collection, boolean streaming, List<String> columns)

Export a collection. You can optionally specify the columns you want to export and whether or not to use streaming

Parameters
collection The collection to query
streaming Wether or not use streaming
columns List of string specifying the columns to return
Returns
  • A List of objects that matched the criteria. The actual type of those objects depends on the provided collection but will be a subclass of ServiceSourceEntity

public String getAnalysisUrl ()

public String getApiUrl ()

public Integer getConnectTimeout ()

public String getCsrfToken ()

public String getLoginUrl ()

public MetaData getMetaData (MetaDataKey key)

Parameters
key
Throws
Exception

public List<MetaDataKey> getMetaDataKeys ()

Throws
Exception

public List<Map<String, Object>> getModelsMetadata ()

public String getPassword ()

public Integer getReadTimeout ()

public String getServer ()

public String getTenantName ()

public String getUsername ()

public void init ()

This method initiates the ServiceSource client and gson

Throws
MuleException

public List<Map<String, String>> invokeObjectMethod (ServiceSourceCollection collection, String objectId, String method, Map<String, Object> parameters)

Executes a method on the object of a collection.

Parameters
collection The collection the object belongs to
objectId Id of the object.
method The object method to be invoked.
parameters The parameters for the specified method.
Returns
  • a list of maps representing the output of the invokation

public List<Map<String, String>> invokeStaticMethod (ServiceSourceCollection collection, String method, Map<String, Object> parameters)

Invoke Static Method Executes a static method on the collection. These methods can perform actions across multiple objects.

Parameters
collection The name of the collection
method The static method to be invoked.
parameters The parameters for the specified method.
Returns
  • a list of maps representing the output object

public boolean isConnected ()

Are we connected

public List<ServiceSourceEntity> loadData (List<ServiceSourceEntity> objects, ServiceSourceCollection collection, String dataLoadJobId, boolean incremental)

Pushes data through the load API. The ID of the data load job must be included as input. Each invocation of the load API provides data for a single collection and parallel calls can be made to push data to multiple collections. The object content can be deduced from the data dictionary, metadata API or by fetching a pre-existing object using the object fetch API.

Parameters
objects A list with instances of ServiceSourceEntity all belonging to the same collection
collection A member of the ServiceSourceCollection enum representing the collection that owns the entities
dataLoadJobId The id of the data load job.
incremental If true performs an incremental load and the data may already exist and should be updated if it does rather than just added
Returns

public String lookupKey (String collectionName, String propertyPath, String displayName)

Consumes the lookups config API looking for a lookup for the given connection on the given propertyPath. If found, then the name of a lookup matching the displayName is returned

Parameters
collectionName The name of collection that the lookup referes to
propertyPath The property path of the lookup vlaue
displayName The displayName being looked up
Returns
  • a String if the value was found, null otherwise

public List<ServiceSourceEntity> query (ServiceSourceCollection collection, String query)

This method provides basic search capabilities through a collection by providing a mongo formatted query. Take in count that the query is sent as a query param so per http protocol limitations there's a limit on the amount of characters that it can have. To post large filters use search instead.

Parameters
collection The collection to query
query A mongo formatted query
Returns
  • A List of objects that matched the query. The actual type of those objects depends on the provided collection but will be a subclass of ServiceSourceEntity

public ServiceSourceEntity read (ServiceSourceCollection collection, String objectId)

Generic method to read entities from dynamic collections

Parameters
collection A member of the ServiceSourceCollection enum representing the collection that owns the entity
objectId The id of the entity you want to get
Returns

public Address readAddress (String objectId)

Fetches the address identified by the object id.

Parameters
objectId Id of the object to read.
Returns

public Asset readAsset (String objectId)

Fetches the Asset identified by the object id.

Parameters
objectId Id of the object to read.
Returns
  • an instance of org.mule.module.servicesource.model.forecast.Asset

public Booking readBooking (String objectId)

Fetches the Booking identified by the object id.

Parameters
objectId Id of the object to read.
Returns
  • an instance of org.mule.module.servicesource.model.forecast.Booking

public Contact readContact (String objectId)

Fetches the contact identified by the object id.

Parameters
objectId Id of the object to read.
Returns

public Forecast readForecast (String objectId)

Fetches the forecast identified by the object id.

Parameters
objectId Id of the object to read.
Returns

public Note readNote (String objectId)

Fetches the note identified by the object id.

Parameters
objectId Id of the object to read.
Returns
  • an instance of Note

public Offer readOffer (String objectId)

Fetches the offer identified by the object id.

Parameters
objectId Id of the object to read.
Returns

public Opportunity readOpportunity (String objectId)

Fetches the opportunity identified by the object id.

Parameters
objectId Id of the object to read.
Returns

public Product readProduct (String objectId)

Fetches the Product identified by the object id.

Parameters
objectId Id of the object to read.
Returns
  • an instance of org.mule.module.servicesource.model.forecast.Product

public Quote readQuote (String objectId)

Fetches the Quote identified by the object id.

Parameters
objectId Id of the object to read.
Returns
  • an instance of org.mule.module.servicesource.model.forecast.Quote

public Task readTask (String objectId)

Fetches the Task identified by the object id.

Parameters
objectId Id of the object to read.
Returns
  • an instance of org.mule.module.servicesource.model.forecast.Task

public List<ServiceSourceEntity> search (ServiceSourceCollection collection, Map<String, Object> filters, boolean streaming, List<String> columns, int limit)

This method provides search capabilities by specifying filters through a map. The advantage of using this processor over query is that you can now use a map to visually add the filters and you don't risk exceeding the max length of the query params since the filters are sent as a post.

Parameters
collection The collection to query
filters Map that includes filters
streaming Wheter or not to do streaming
columns An optional list of columns to return. Use this to only return the fields you're interested while reducing network traffic
limit The max number of results to return. If you want to have no limit then pass -1
Returns
  • A List of objects that matched the criteria. The actual type of those objects depends on the provided collection but will be a subclass of ServiceSourceEntity

public void setAnalysisUrl (String analysisUrl)

Parameters
analysisUrl

public void setApiUrl (String apiUrl)

Parameters
apiUrl

public void setConnectTimeout (Integer connectTimeout)

Parameters
connectTimeout

public void setCsrfToken (String csrfToken)

Parameters
csrfToken

public void setLoginUrl (String loginUrl)

Parameters
loginUrl

public void setPassword (String password)

Parameters
password

public void setReadTimeout (Integer readTimeout)

Parameters
readTimeout

public void setServer (String server)

Parameters
server

public void setTenantName (String tenantName)

Parameters
tenantName

public void setUsername (String username)

Parameters
username

public DataLoad startDataLoad (String jobName, String dataLoadConfigId, String displayName)

Starts a Data Load by creating an entry in the data load collection. The returned data load object contains an id field and the content of this field must be used in the load and done API call URLs.

Parameters
jobName The name of the data load job you want to start
dataLoadConfigId The id of the data load configuration that this job references to
displayName A friendly name for the generated job
Returns
  • another instance of DataLoad which represents the created DataLoad object. It also includes the id you need to provide later on.

public ServiceSourceEntity update (ServiceSourceCollection collection, String objectId, ServiceSourceEntity entity)

Generic method to update entities from dynamic collections

Parameters
collection A member of the ServiceSourceCollection enum representing the collection that owns the entity
objectId The id of the entity you want to get
entity A subclass instance of ServiceSourceEntity with the entitie's new state
Returns

public Address updateAddress (String objectId, Address address)

Updates an address

Parameters
objectId Id of the object to update.
address The new state of the note as an instance of Address
Returns
  • The updated address as an instance of Address.

public Asset updateAsset (String objectId, Asset asset)

Updates an Asset

Parameters
objectId Id of the object to update.
asset The new state of the asset as an instance of Asset
Returns
  • The updated asset as an instance of Asset

public Booking updateBooking (String objectId, Booking booking)

Updates a Booking

Parameters
objectId Id of the object to update.
booking The new state of the booking as an instance of Booking
Returns
  • The updated booking as an instance of Booking

public Contact updateContact (String objectId, Contact contact)

Updates a given contact

Parameters
objectId Id of the object to update.
contact The new state of the contact as an instance of Contact
Returns
  • The updated contact as an instance of Contact

public Forecast updateForecast (String objectId, Forecast forecast)

Updates a forecast

Parameters
objectId Id of the object to update.
forecast The new state of the forecast as an instance of Forecast
Returns
  • The updated forecast as an instance of Forecast

public Note updateNote (String objectId, Note note)

Updates a given note

Parameters
objectId Id of the no to update.
note The new state of the note as an instance of Note
Returns
  • The updated note as an instance of Note.

public Offer updateOffer (String objectId, Offer offer)

Updates an offer

Parameters
objectId Id of the object to update.
offer The new state of the offer as an instance of Offer
Returns
  • The updated offer as an instance of Offer

public Opportunity updateOpportunity (String objectId, Opportunity opportunity)

Updates an opportunity

Parameters
objectId Id of the object to update.
opportunity The new state of the note as an instance of Opportunity
Returns

public Product updateProduct (String objectId, Product product)

Updates a Product

Parameters
objectId Id of the object to update.
product The new state of the product as an instance of Product
Returns
  • The updated product as an instance of Product

public Quote updateQuote (String objectId, Quote quote)

Updates a Quote

Parameters
objectId Id of the object to update.
quote The new state of the quote as an instance of Quote
Returns
  • The updated quote as an instance of Quote

public Task updateTask (String objectId, Task task)

Updates a Task

Parameters
objectId Id of the object to update.
task The new state of the task as an instance of Task
Returns
  • The updated task as an instance of Task