ChangeSet

open class ChangeSet(source)

Encapsulates an OData change set. A change set is used to group a set of entity or link changes into a single unit of work, like an atomic database transaction.

See Also:

com.sap.cloud.mobile.odata.DataService, com.sap.cloud.mobile.odata.RequestBatch.

Example using proxy classes:
public void applyChangesExample() {
    NorthwindService service = this.getService();
    List<Supplier> suppliers = service.getSuppliers(new DataQuery().top(2));
    List<Product> products = service.getProducts(new DataQuery().top(3));
    Product product1 = products.get(0).copy();
    Product product2 = products.get(1).copy();
    Product product3 = products.get(2).copy();
    product1.setProductName("Blueberry Muffins");
    product2.setProductName("Strawberry Yoghurt");
    product3.setProductName("Raspberry Pie");
    ChangeSet entityCreates = new ChangeSet();
    entityCreates.createEntity(product1);
    entityCreates.createEntity(product2);
    entityCreates.createEntity(product3);
    service.applyChanges(entityCreates);
    ChangeSet entityChanges = new ChangeSet();
    product2.setProductName("Blackberry Yoghurt");
    entityChanges.updateEntity(product2);
    entityChanges.deleteEntity(product3);
    service.applyChanges(entityChanges);
    ChangeSet linkChanges = new ChangeSet();
    Supplier supplier1 = suppliers.get(0);
    Supplier supplier2 = suppliers.get(1);
    linkChanges.createLink(product1, Product.supplier, supplier1);
    linkChanges.updateLink(product1, Product.supplier, supplier2);
    linkChanges.deleteLink(product1, Product.supplier);
    service.applyChanges(linkChanges);
}
Example using dynamic API:
public void applyChangesExample() {
    DataService service = this.getService();
    EntitySet suppliersEntitySet = service.getEntitySet("Suppliers");
    EntitySet productsEntitySet = service.getEntitySet("Products");
    EntityType productEntityType = productsEntitySet.getEntityType();
    Property productNameProperty = productEntityType.getProperty("ProductName");
    Property supplierProperty = productEntityType.getProperty("Supplier");
    EntityValueList suppliers = service.executeQuery(new DataQuery()
        .from(suppliersEntitySet).top(2))
        .getEntityList();
    EntityValueList products = service.executeQuery(new DataQuery()
        .from(productsEntitySet).top(3))
        .getEntityList();
    EntityValue product1 = products.get(0).copyEntity();
    EntityValue product2 = products.get(1).copyEntity();
    EntityValue product3 = products.get(1).copyEntity();
    productNameProperty.setString(product1, "Blueberry Yoghurt");
    productNameProperty.setString(product2, "Strawberry Yoghurt");
    productNameProperty.setString(product3, "Raspberry Pie");
    ChangeSet entityCreates = new ChangeSet();
    entityCreates.createEntity(product1);
    entityCreates.createEntity(product2);
    entityCreates.createEntity(product3);
    service.applyChanges(entityCreates);
    ChangeSet entityChanges = new ChangeSet();
    productNameProperty.setString(product2, "Blackberry Yoghurt");
    entityChanges.updateEntity(product2);
    entityChanges.deleteEntity(product3);
    service.applyChanges(entityChanges);
    ChangeSet linkChanges = new ChangeSet();
    EntityValue supplier1 = suppliers.get(0);
    EntityValue supplier2 = suppliers.get(1);
    linkChanges.createLink(product1, supplierProperty, supplier1);
    linkChanges.updateLink(product1, supplierProperty, supplier2);
    linkChanges.deleteLink(product1, supplierProperty);
    service.applyChanges(linkChanges);
}

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open fun addAction(@NonNull @NotNull action: @NotNull DataQuery)
open fun addAction(@NonNull @NotNull action: @NotNull DataQuery, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun addAction(@NonNull @NotNull action: @NotNull DataQuery, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add an action call to the change set.
Link copied to clipboard
open fun addActionResult(@NonNull @NotNull call: @NotNull DataQuery, @NonNull @NotNull result: @NotNull QueryResult)
open fun addActionResult(@NonNull @NotNull call: @NotNull DataQuery, @NonNull @NotNull result: @NotNull QueryResult, index: Int)
Add com.sap.cloud.mobile.odata.QueryResult for an action call to this change set.
Link copied to clipboard
open fun createEntity(@NonNull @NotNull entity: @NotNull EntityValue)
open fun createEntity(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun createEntity(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a pending created entity to the change set.
Link copied to clipboard
open fun createLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @NonNull @NotNull to: @NotNull EntityValue)
open fun createLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @NonNull @NotNull to: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun createLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @NonNull @NotNull to: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a pending created link to the change set.
Link copied to clipboard
open fun createMedia(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull content: @NotNull StreamBase)
open fun createMedia(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull content: @NotNull StreamBase, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun createMedia(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull content: @NotNull StreamBase, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a pending created media entity to the change set.
Link copied to clipboard
open fun createRelatedEntity(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull parent: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property)
open fun createRelatedEntity(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull parent: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun createRelatedEntity(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull parent: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a pending created entity to the change set, related to a parent entity via a parent navigation property.
Link copied to clipboard
open fun createRelatedMedia(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull content: @NotNull StreamBase, @NonNull @NotNull parent: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property)
open fun createRelatedMedia(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull content: @NotNull StreamBase, @NonNull @NotNull parent: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun createRelatedMedia(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull content: @NotNull StreamBase, @NonNull @NotNull parent: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a pending created media entity to the change set, related to a parent entity via a parent navigation property.
Link copied to clipboard
open fun deleteEntity(@NonNull @NotNull entity: @NotNull EntityValue)
open fun deleteEntity(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun deleteEntity(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a pending deleted entity to the change set.
Link copied to clipboard
open fun deleteLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property)
open fun deleteLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @NonNull @NotNull to: @NotNull EntityValue)
open fun deleteLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @NonNull @NotNull to: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun deleteLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @NonNull @NotNull to: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a pending deleted link to the change set.
Link copied to clipboard
open fun deleteStream(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull link: @NotNull StreamLink)
open fun deleteStream(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull link: @NotNull StreamLink, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun deleteStream(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull link: @NotNull StreamLink, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a stream delete request to the change set.
Link copied to clipboard
@NotNull
open fun getAction(index: Int): @NotNull DataQuery
Return the DataQuery for the action call, if isAction(index) is true, otherwise throws undefined
Link copied to clipboard
@NotNull
open fun getActionResult(@NonNull @NotNull call: @NotNull DataQuery): @NotNull QueryResult
@NotNull
open fun getActionResult(@NonNull @NotNull call: @NotNull DataQuery, index: Int): @NotNull QueryResult
Return the com.sap.cloud.mobile.odata.QueryResult for an action call.
Link copied to clipboard
@NotNull
open fun getEntity(index: Int): @NotNull EntityValue
Return the changed entity, if isEntity(index) is true, otherwise throws undefined.
Link copied to clipboard
@Nullable
fun getError(): @Nullable DataServiceException
Return (nullable) Error if status does not represent a successful response.
Link copied to clipboard
@NotNull
open fun getHeaders(index: Int): @NotNull HttpHeaders
Return the HTTP headers for the change at index.
Link copied to clipboard
@NotNull
open fun getLink(index: Int): @NotNull ChangedLink
Return the changed link, if isLink(index) is true, otherwise throws undefined.
Link copied to clipboard
@NotNull
open fun getOptions(index: Int): @NotNull RequestOptions
Return the request options for the change at index.
Link copied to clipboard
fun getStatus(): Int
Return response status (e.g.
Link copied to clipboard
@NotNull
open fun invokeAction(@NonNull @NotNull method: @NotNull DataMethod): @NotNull DataQuery
@NotNull
open fun invokeAction(@NonNull @NotNull method: @NotNull DataMethod, @NonNull @NotNull parameters: @NotNull ParameterList): @NotNull DataQuery
@NotNull
open fun invokeAction(@NonNull @NotNull method: @NotNull DataMethod, @NonNull @NotNull parameters: @NotNull ParameterList, @Nullable @Nullable headers: @Nullable HttpHeaders): @NotNull DataQuery
@NotNull
open fun invokeAction(@NonNull @NotNull method: @NotNull DataMethod, @NonNull @NotNull parameters: @NotNull ParameterList, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions): @NotNull DataQuery
Add an action call to the change set.
Link copied to clipboard
open fun isAction(index: Int): Boolean
Return true if index is a valid change index, and the change is for an action call; otherwise false.
Link copied to clipboard
open fun isEmpty(): Boolean
Return true if ChangeSet.size is zero.
Link copied to clipboard
open fun isEntity(index: Int): Boolean
Return true if index is a valid change index, and the change is for a created, updated or deleted entity; otherwise false.
Link copied to clipboard
open fun isLink(index: Int): Boolean
Return true if index is a valid change index, and the change is for a created, updated or deleted link; otherwise false.
Link copied to clipboard
open fun isNotEmpty(): Boolean
Return true if ChangeSet.size is non-zero.
Link copied to clipboard
open fun replaceHeaders(index: Int, @NonNull @NotNull headers: @NotNull HttpHeaders)
Replace the request headers for a previously added request.
Link copied to clipboard
open fun replaceOptions(index: Int, @NonNull @NotNull options: @NotNull RequestOptions)
Replace the request options for a previously added request.
Link copied to clipboard
open fun saveEntity(@NonNull @NotNull entity: @NotNull EntityValue)
open fun saveEntity(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun saveEntity(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Call ChangeSet.createEntity, if entity.isNew == true, otherwise call ChangeSet.updateEntity.
Link copied to clipboard
fun setError(@Nullable @Nullable value: @Nullable DataServiceException)
Set error if status does not represent a successful response.
Link copied to clipboard
fun setStatus(value: Int)
Set response status (e.g.
Link copied to clipboard
open fun size(): Int
Return the number of changes in this change set.
Link copied to clipboard
open fun updateEntity(@NonNull @NotNull entity: @NotNull EntityValue)
open fun updateEntity(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun updateEntity(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add an updated entity to the change set.
Link copied to clipboard
open fun updateLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @NonNull @NotNull to: @NotNull EntityValue)
open fun updateLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @NonNull @NotNull to: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun updateLink(@NonNull @NotNull from: @NotNull EntityValue, @NonNull @NotNull property: @NotNull Property, @NonNull @NotNull to: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a pending updated link to the change set.
Link copied to clipboard
open fun uploadMedia(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull content: @NotNull StreamBase)
open fun uploadMedia(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull content: @NotNull StreamBase, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun uploadMedia(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull content: @NotNull StreamBase, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a media upload request to the change set.
Link copied to clipboard
open fun uploadStream(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull link: @NotNull StreamLink, @NonNull @NotNull content: @NotNull StreamBase)
open fun uploadStream(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull link: @NotNull StreamLink, @NonNull @NotNull content: @NotNull StreamBase, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun uploadStream(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull link: @NotNull StreamLink, @NonNull @NotNull content: @NotNull StreamBase, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a stream upload request to the change set.