Class SObjectComposite
java.lang.Object
org.apache.camel.component.salesforce.api.dto.composite.SObjectComposite
- All Implemented Interfaces:
Serializable
Executes a series of REST API requests in a single call. You can use the output of one request as the input to a
subsequent request. The response bodies and HTTP statuses of the requests are returned in a single response body. The
entire request counts as a single call toward your API limits. The requests in a composite call are called
subrequests. All subrequests are executed in the context of the same user. In a subrequest’s body, you specify a
reference ID that maps to the subrequest’s response. You can then refer to the ID in the url or body fields of later
subrequests by using a JavaScript-like reference notation. 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, String)
or addGeneric(Method, String, Object, String)
methods. To build the batch use: This will build a composite of two insert operations.composite = new SObjectComposite("41.0", true); // insert operation via an external id final Invoice__c_Lookup invoiceLookup = new Invoice__c_Lookup(); invoiceLookup.setInvoice_External_Id__c("0116"); final Payment__c payment = new Payment__c(); payment.setInvoice__r(invoiceLookup); composite.addCreate(payment, "NewPayment1"); composite.addCreate(payment, "NewPayment2");
- See Also:
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSObjectComposite
(String apiVersion, boolean allOrNone) Create new composite request. -
Method Summary
Modifier and TypeMethodDescriptionaddCreate
(AbstractDescribedSObjectBase data, String referenceId) Add create SObject to the composite request.Add delete SObject with identifier to the composite request.addGeneric
(SObjectComposite.Method method, String url, Object richInput, String referenceId) Generic way to add requests to composite withrichInput
payload.addGeneric
(SObjectComposite.Method method, String url, String referenceId) Generic way to add requests to composite.Add field retrieval of an SObject by identifier to the composite request.addGetByExternalId
(String type, String fieldName, String fieldValue, String referenceId) Add field retrieval of an SObject by external identifier to the composite request.Add retrieval of related SObject fields by identifier.Add retrieval of SObject records by query to the composite.addQueryAll
(String query, String referenceId) Add retrieval of all SObject records by query to the composite.addUpdate
(String type, String id, AbstractSObjectBase data, String referenceId) Add update of SObject record to the composite.addUpdateByExternalId
(String type, String fieldName, String fieldValue, AbstractSObjectBase data, String referenceId) Add update of SObject record by external identifier to the composite.addUpsertByExternalId
(String type, String fieldName, String fieldValue, AbstractSObjectBase data, String referenceId) Add insert or update of SObject record by external identifier to the composite.boolean
List<org.apache.camel.component.salesforce.api.dto.composite.CompositeRequest>
Fetches compose requests contained in this compose request.Version of Salesforce API for this batch request.Class[]
Returns all object types nested within this composite request, needed for serialization.
-
Field Details
-
REQUIRED_PAYLOAD_FORMAT
-
-
Constructor Details
-
SObjectComposite
Create new composite 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 composite request.- Parameters:
data
- object to create- Returns:
- this batch builder
-
addDelete
Add delete SObject with identifier to the composite request.- Parameters:
type
- type of SObjectid
- identifier of the object- Returns:
- this batch builder
-
addGeneric
public SObjectComposite addGeneric(SObjectComposite.Method method, String url, Object richInput, String referenceId) Generic way to add requests to composite 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
-
addGeneric
Generic way to add requests to composite. 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
-
addGet
Add field retrieval of an SObject by identifier to the composite request.- Parameters:
type
- type of SObjectid
- identifier of SObjectfields
- to return- Returns:
- this batch builder
-
addGetByExternalId
public SObjectComposite addGetByExternalId(String type, String fieldName, String fieldValue, String referenceId) Add field retrieval of an SObject by external identifier to the composite request.- Parameters:
type
- type of SObjectfieldName
- external identifier field namefieldValue
- external identifier field value- Returns:
- this batch builder
-
addGetRelated
public SObjectComposite addGetRelated(String type, String id, String relation, String referenceId, String... fields) 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
-
addQuery
Add retrieval of SObject records by query to the composite.- Parameters:
query
- SOQL query to execute- Returns:
- this batch builder
-
addQueryAll
Add retrieval of all SObject records by query to the composite.- Parameters:
query
- SOQL query to execute- Returns:
- this batch builder
-
addUpdate
public SObjectComposite addUpdate(String type, String id, AbstractSObjectBase data, String referenceId) Add update of SObject record to the composite. 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 SObjectComposite addUpdateByExternalId(String type, String fieldName, String fieldValue, AbstractSObjectBase data, String referenceId) Add update of SObject record by external identifier to the composite. 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 field valuedata
- SObject with fields to change- Returns:
- this batch builder
-
addUpsertByExternalId
public SObjectComposite addUpsertByExternalId(String type, String fieldName, String fieldValue, AbstractSObjectBase data, String referenceId) Add insert or update of SObject record by external identifier to the composite. 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 field valuedata
- SObject with fields to change- Returns:
- this batch builder
-
getAllOrNone
public boolean getAllOrNone() -
getCompositeRequests
public List<org.apache.camel.component.salesforce.api.dto.composite.CompositeRequest> getCompositeRequests()Fetches compose requests contained in this compose request.- Returns:
- all requests
-
getVersion
Version of Salesforce API for this batch request.- Returns:
- the version
-
objectTypes
Returns all object types nested within this composite request, needed for serialization.- Returns:
- all object types in this composite request
-