public final class SObjectBatch extends Object implements Serializable
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.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");
Modifier and Type | Class and Description |
---|---|
static class |
SObjectBatch.Method |
Constructor and Description |
---|
SObjectBatch(String apiVersion)
Create new batch request.
|
Modifier and Type | Method and Description |
---|---|
SObjectBatch |
addCreate(AbstractDescribedSObjectBase data)
Add create SObject to the batch request.
|
SObjectBatch |
addDelete(String type,
String id)
Add delete SObject with identifier to the batch request.
|
SObjectBatch |
addGeneric(SObjectBatch.Method method,
String url)
Generic way to add requests to batch.
|
SObjectBatch |
addGeneric(SObjectBatch.Method method,
String url,
Object richInput)
Generic way to add requests to batch with
richInput payload. |
SObjectBatch |
addGet(String type,
String id,
String... fields)
Add field retrieval of an SObject by identifier to the batch request.
|
SObjectBatch |
addGetByExternalId(String type,
String fieldName,
String fieldValue)
Add field retrieval of an SObject by external identifier to the batch request.
|
SObjectBatch |
addGetRelated(String type,
String id,
String relation,
String... fields)
Add retrieval of related SObject fields by identifier.
|
SObjectBatch |
addLimits()
Add retrieval of limits to the batch.
|
SObjectBatch |
addQuery(String query)
Add retrieval of SObject records by query to the batch.
|
SObjectBatch |
addQueryAll(String query)
Add retrieval of all SObject records by query to the batch.
|
SObjectBatch |
addSearch(String searchString)
Add retrieval of SObject records by search to the batch.
|
SObjectBatch |
addUpdate(String type,
String id,
AbstractSObjectBase data)
Add update of SObject record to the batch.
|
SObjectBatch |
addUpdateByExternalId(String type,
String fieldName,
String fieldValue,
AbstractSObjectBase data)
Add update of SObject record by external identifier to the batch.
|
SObjectBatch |
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> |
getBatchRequests()
Fetches batch requests contained in this batch.
|
Version |
getVersion()
Version of Salesforce API for this batch request.
|
static String |
notEmpty(String value,
String name) |
Class[] |
objectTypes()
Returns all object types nested within this batch, needed for serialization.
|
public SObjectBatch(String apiVersion)
apiVersion
- API version for the batch requestpublic SObjectBatch addCreate(AbstractDescribedSObjectBase data)
data
- object to createpublic SObjectBatch addDelete(String type, String id)
type
- type of SObjectid
- identifier of the objectpublic SObjectBatch addGeneric(SObjectBatch.Method method, String url)
/sobjects/Account/identifier
which results in
/services/data/v37.0/sobjects/Account/identifier
. Note the leading slash.method
- HTTP methodurl
- URL starting from the versionpublic SObjectBatch addGeneric(SObjectBatch.Method method, String url, Object richInput)
richInput
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.method
- HTTP methodurl
- URL starting from the versionrichInput
- body of the request, to be placed in richInputpublic SObjectBatch addGet(String type, String id, String... fields)
type
- type of SObjectid
- identifier of SObjectfields
- to returnpublic SObjectBatch addGetByExternalId(String type, String fieldName, String fieldValue)
type
- type of SObjectfieldName
- external identifier field namefieldValue
- external identifier field valuefields
- to returnpublic SObjectBatch addGetRelated(String type, String id, String relation, String... fields)
Account
has a relation to
CreatedBy
. To fetch fields from that related object (User
SObject) use: batch.addGetRelated("Account", identifier, "CreatedBy", "Name", "Id")
type
- type of SObjectid
- identifier of SObjectrelation
- name of the related SObject fieldfields
- to returnpublic SObjectBatch addLimits()
public SObjectBatch addQuery(String query)
query
- SOQL query to executepublic SObjectBatch addQueryAll(String query)
query
- SOQL query to executepublic SObjectBatch addSearch(String searchString)
query
- SOSL search to executepublic SObjectBatch addUpdate(String type, String id, AbstractSObjectBase data)
data
parameter must contain only the fields that
need updating and must not contain the Id
field. So set any fields to null
that you do not want
changed along with Id
field.type
- type of SObjectid
- identifier of SObjectdata
- SObject with fields to changepublic SObjectBatch addUpdateByExternalId(String type, String fieldName, String fieldValue, AbstractSObjectBase data)
data
parameter must contain
only the fields that need updating and must not contain the Id
field. So set any fields to null
that you do not want changed along with Id
field.type
- type of SObjectfieldName
- name of the field holding the external identifierid
- external identifier valuedata
- SObject with fields to changepublic SObjectBatch addUpsertByExternalId(String type, String fieldName, String fieldValue, AbstractSObjectBase data)
data
parameter must
contain only the fields that need updating and must not contain the Id
field. So set any fields to
null
that you do not want changed along with Id
field.type
- type of SObjectfieldName
- name of the field holding the external identifierid
- external identifier valuedata
- SObject with fields to changepublic List<org.apache.camel.component.salesforce.api.dto.composite.BatchRequest> getBatchRequests()
public Version getVersion()
public Class[] objectTypes()
Apache Camel