java.lang.Object
org.apache.camel.component.salesforce.api.dto.composite.SObjectTree
All Implemented Interfaces:
Serializable

public final class SObjectTree extends Object implements Serializable
Payload and response for the SObject tree Composite API. The main interface for specifying what to include in the sumission to the API endpoint. To build the tree out use:
 
 Account account = ...
 Contact president = ...
 Contact marketing = ...

 Account anotherAccount = ...
 Contact sales = ...
 Asset someAsset = ...

 SObjectTree request = new SObjectTree();
 request.addObject(account).addChildren(president, marketing);
 request.addObject(anotherAccount).addChild(sales).addChild(someAsset);
 
 
This will generate a tree of SObjects resembling:
 .
 |-- account
 |   |-- president
 |   `-- marketing
 `-- anotherAccount
     `-- sales
         `-- someAsset
 
By default references that correlate between SObjects in the tree and returned identifiers and errors are handled automatically, if you wish to customize the generation of the reference implement ReferenceGenerator and supply it as constructor argument to SObjectTree(ReferenceGenerator).

Note that the tree can hold single object type at the root of the tree.

See Also:
  • Constructor Details

  • Method Details

    • addObject

      public SObjectNode addObject(AbstractSObjectBase object)
      Add SObject at the root of the tree.
      Parameters:
      object - SObject to add
      Returns:
      SObjectNode for the given SObject
    • allNodes

      public Stream<SObjectNode> allNodes()
      Returns a stream of all nodes in the tree.
      Returns:
    • allObjects

      public Stream<AbstractSObjectBase> allObjects()
      Returns a stream of all objects in the tree.
      Returns:
    • getObjectType

      public String getObjectType()
      Returns the type of the objects in the root of the tree.
      Returns:
      object type
    • objectTypes

      public Class[] objectTypes()
    • setErrorFor

      public void setErrorFor(String referenceId, List<RestError> errors)
      Sets errors for the given reference. Used when processing the response of API invocation.
      Parameters:
      referenceId - reference identifier
      errors - list of RestError
    • setIdFor

      public void setIdFor(String referenceId, String id)
      Sets identifier of SObject for the given reference. Used when processing the response of API invocation.
      Parameters:
      referenceId - reference identifier
      id - SObject identifier
    • size

      public int size()
      Returns the number of elements in the tree.
      Returns:
      number of elements in the tree