Change Set
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.
- 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); }Content copied to clipboard
- 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); }Content copied to clipboard
Functions
Link copied to clipboard
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, @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)
See createRelatedMedia(EntityValue, StreamBase, EntityValue, Property, HttpHeaders, RequestOptions).
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, @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
Return the com.sap.cloud.mobile.odata.QueryResult for an action call.
Link copied to clipboard
Return the changed entity, if
isEntity(index) is true, otherwise throws undefined.Link copied to clipboard
Return (nullable) Error if
status does not represent a successful response.Link copied to clipboard
Return the HTTP headers for the change at
index.Link copied to clipboard
Return the changed link, if
isLink(index) is true, otherwise throws undefined.Link copied to clipboard
Return the request options for the change at
index.Link copied to clipboard
@NotNull
@NotNull
@NotNull
Add an action call to the change set.
Link copied to clipboard
Return true if ChangeSet.size is zero.
Link copied to clipboard
Return true if ChangeSet.size is non-zero.
Link copied to clipboard
Replace the request headers for a previously added request.
Link copied to clipboard
Replace the request options for a previously added request.
Link copied to clipboard
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)
Link copied to clipboard
Set error if
status does not represent a successful response.Link copied to clipboard
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.