Class SObjectBatch
java.lang.Object
org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch
- All Implemented Interfaces:
Serializable
Builder for Composite API batch request. Composite API is available from Salesforce API version 34.0 onwards its a
way to combine multiple requests in a batch and submit them in one HTTP request. This object help to build the
payload of the batch request. Most requests that are supported in the Composite batch API the helper builder methods
are provided. For batch requests that do not have their corresponding helper builder method, use
addGeneric(Method, String)
or addGeneric(Method, String, Object)
methods. To build the batch use:
This will build a batch of three operations, one to create new Account, one to delete an Account, and one to get two fields from an Account.{ @code SObjectBatch batch = new SObjectBatch("37.0"); final Account account = new Account(); account.setName("NewAccountName"); account.setIndustry(Account_IndustryEnum.ENVIRONMENTAL); batch.addCreate(account); batch.addDelete("Account", "001D000000K0fXOIAZ"); batch.addGet("Account", "0010Y00000Arwt6QAB", "Name", "BillingPostalCode"); }
- See Also:
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdd create SObject to the batch request.Add delete SObject with identifier to the batch request.addGeneric
(SObjectBatch.Method method, String url) Generic way to add requests to batch.addGeneric
(SObjectBatch.Method method, String url, Object richInput) Generic way to add requests to batch withrichInput
payload.Add field retrieval of an SObject by identifier to the batch request.addGetByExternalId
(String type, String fieldName, String fieldValue) Add field retrieval of an SObject by external identifier to the batch request.addGetRelated
(String type, String id, String relation, String... fields) Add retrieval of related SObject fields by identifier.Add retrieval of limits to the batch.Add retrieval of SObject records by query to the batch.addQueryAll
(String query) Add retrieval of all SObject records by query to the batch.Add retrieval of SObject records by search to the batch.addUpdate
(String type, String id, AbstractSObjectBase data) Add update of SObject record to the batch.addUpdateByExternalId
(String type, String fieldName, String fieldValue, AbstractSObjectBase data) Add update of SObject record by external identifier to the batch.addUpsertByExternalId
(String type, String fieldName, String fieldValue, AbstractSObjectBase data) Add insert or update of SObject record by external identifier to the batch.List<org.apache.camel.component.salesforce.api.dto.composite.BatchRequest>
Fetches batch requests contained in this batch.Version of Salesforce API for this batch request.Class[]
Returns all object types nested within this batch, needed for serialization.
-
Constructor Details
-
SObjectBatch
Create new batch request. You must specify the API version of the batch request. The API version cannot be newer than the version configured in the Salesforce Camel component. Some of the batched requests are available only from certain Salesforce API versions, when this is the case it is noted in the documentation of the builder method, if uncertain consult the Salesforce API documentation.- Parameters:
apiVersion
- API version for the batch request
-
-
Method Details
-
addCreate
Add create SObject to the batch request.- Parameters:
data
- object to create- Returns:
- this batch builder
-
addDelete
Add delete SObject with identifier to the batch request.- Parameters:
type
- type of SObjectid
- identifier of the object- Returns:
- this batch builder
-
addGeneric
Generic way to add requests to batch. Given URL starts from the version, so in order to retrieve SObject specify just/sobjects/Account/identifier
which results in/services/data/v37.0/sobjects/Account/identifier
. Note the leading slash.- Parameters:
method
- HTTP methodurl
- URL starting from the version- Returns:
- this batch builder
-
addGeneric
Generic way to add requests to batch withrichInput
payload. Given URL starts from the version, so in order to update SObject specify just/sobjects/Account/identifier
which results in/services/data/v37.0/sobjects/Account/identifier
. Note the leading slash.- Parameters:
method
- HTTP methodurl
- URL starting from the versionrichInput
- body of the request, to be placed in richInput- Returns:
- this batch builder
-
addGet
Add field retrieval of an SObject by identifier to the batch request.- Parameters:
type
- type of SObjectid
- identifier of SObjectfields
- to return- Returns:
- this batch builder
-
addGetByExternalId
Add field retrieval of an SObject by external identifier to the batch request.- Parameters:
type
- type of SObjectfieldName
- external identifier field namefieldValue
- external identifier field value- Returns:
- this batch builder
-
addGetRelated
Add retrieval of related SObject fields by identifier. For exampleAccount
has a relation toCreatedBy
. To fetch fields from that related object (User
SObject) use:batch.addGetRelated("Account", identifier, "CreatedBy", "Name", "Id")
- Parameters:
type
- type of SObjectid
- identifier of SObjectrelation
- name of the related SObject fieldfields
- to return- Returns:
- this batch builder
-
addLimits
Add retrieval of limits to the batch.- Returns:
- this batch builder
-
addQuery
Add retrieval of SObject records by query to the batch.- Parameters:
query
- SOQL query to execute- Returns:
- this batch builder
-
addQueryAll
Add retrieval of all SObject records by query to the batch.- Parameters:
query
- SOQL query to execute- Returns:
- this batch builder
-
addSearch
Add retrieval of SObject records by search to the batch.- Parameters:
searchString
- SOSL search to execute- Returns:
- this batch builder
-
addUpdate
Add update of SObject record to the batch. The givendata
parameter must contain only the fields that need updating and must not contain theId
field. So set any fields tonull
that you do not want changed along withId
field.- Parameters:
type
- type of SObjectid
- identifier of SObjectdata
- SObject with fields to change- Returns:
- this batch builder
-
addUpdateByExternalId
public SObjectBatch addUpdateByExternalId(String type, String fieldName, String fieldValue, AbstractSObjectBase data) Add update of SObject record by external identifier to the batch. The givendata
parameter must contain only the fields that need updating and must not contain theId
field. So set any fields tonull
that you do not want changed along withId
field.- Parameters:
type
- type of SObjectfieldName
- name of the field holding the external identifierfieldValue
- external identifier valuedata
- SObject with fields to change- Returns:
- this batch builder
-
addUpsertByExternalId
public SObjectBatch addUpsertByExternalId(String type, String fieldName, String fieldValue, AbstractSObjectBase data) Add insert or update of SObject record by external identifier to the batch. The givendata
parameter must contain only the fields that need updating and must not contain theId
field. So set any fields tonull
that you do not want changed along withId
field.- Parameters:
type
- type of SObjectfieldName
- name of the field holding the external identifierfieldValue
- external identifier valuedata
- SObject with fields to change- Returns:
- this batch builder
-
getBatchRequests
public List<org.apache.camel.component.salesforce.api.dto.composite.BatchRequest> getBatchRequests()Fetches batch requests contained in this batch.- Returns:
- all requests
-
getVersion
Version of Salesforce API for this batch request.- Returns:
- the version
-
objectTypes
Returns all object types nested within this batch, needed for serialization.- Returns:
- all object types in this batch
-