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.
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataService}, {@link com.sap.cloud.mobile.kotlin.odata.RequestBatch}.
- Example using proxy classes:
open fun applyChangesExample(): kotlin.Unit { val service = this.service; val suppliers = service.getSuppliers(DataQuery().top(2)); val products = service.getProducts(DataQuery().top(3)); val product1 = products[0].copy(); val product2 = products[1].copy(); val product3 = products[2].copy(); product1.productName = "Blueberry Muffins"; product2.productName = "Strawberry Yoghurt"; product3.productName = "Raspberry Pie"; val entityCreates = ChangeSet(); entityCreates.createEntity(product1); entityCreates.createEntity(product2); entityCreates.createEntity(product3); service.applyChanges(entityCreates); val entityChanges = ChangeSet(); product2.productName = "Blackberry Yoghurt"; entityChanges.updateEntity(product2); entityChanges.deleteEntity(product3); service.applyChanges(entityChanges); val linkChanges = ChangeSet(); val supplier1 = suppliers[0]; val supplier2 = suppliers[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:
open fun applyChangesExample(): kotlin.Unit { val service = this.service; val suppliersEntitySet = service.getEntitySet("Suppliers"); val productsEntitySet = service.getEntitySet("Products"); val productEntityType = productsEntitySet.entityType; val productNameProperty = productEntityType.getProperty("ProductName"); val supplierProperty = productEntityType.getProperty("Supplier"); val suppliers = service.executeQuery(DataQuery().from(suppliersEntitySet) .top(2)) .getEntityList(); val products = service.executeQuery(DataQuery().from(productsEntitySet) .top(3)) .getEntityList(); val product1 = products[0].copyEntity(); val product2 = products[1].copyEntity(); val product3 = products[1].copyEntity(); productNameProperty.setString(product1, "Blueberry Yoghurt"); productNameProperty.setString(product2, "Strawberry Yoghurt"); productNameProperty.setString(product3, "Raspberry Pie"); val entityCreates = ChangeSet(); entityCreates.createEntity(product1); entityCreates.createEntity(product2); entityCreates.createEntity(product3); service.applyChanges(entityCreates); val entityChanges = ChangeSet(); productNameProperty.setString(product2, "Blackberry Yoghurt"); entityChanges.updateEntity(product2); entityChanges.deleteEntity(product3); service.applyChanges(entityChanges); val linkChanges = ChangeSet(); val supplier1 = suppliers[0]; val supplier2 = suppliers[1]; linkChanges.createLink(product1, supplierProperty, supplier1); linkChanges.updateLink(product1, supplierProperty, supplier2); linkChanges.deleteLink(product1, supplierProperty); service.applyChanges(linkChanges); }
Functions
Add an action call to the change set.
Add {@link com.sap.cloud.mobile.kotlin.odata.QueryResult} for an action call to this change set.
Add a pending created entity to the change set. The entity will be created when this change set is submitted.
Add a pending created link to the change set. The link will be created when this change set is submitted.
Add a pending created media entity to the change set. The entity will be created when this change set is submitted.
Add a pending created entity to the change set, related to a parent entity via a parent navigation property. The entity will be created when this change set is submitted.
See createRelatedMedia(EntityValue, StreamBase, EntityValue, Property, HttpHeaders?, RequestOptions?).
Add a pending created media entity to the change set, related to a parent entity via a parent navigation property.
Add a pending deleted entity to the change set. The entity will be deleted when this change set is submitted.
Add a pending deleted link to the change set. The link will be deleted when this change set is submitted.
Add a stream delete request to the change set. The stream will be deleted when this change set is submitted.
Return the {@link com.sap.cloud.mobile.kotlin.odata.QueryResult} for an action call.
Return the changed entity, if isEntity(index) is true, otherwise throws undefined.
The {@link com.sap.cloud.mobile.kotlin.odata.EntityValue#isCreated EntityValue.isCreated}, {@link com.sap.cloud.mobile.kotlin.odata.EntityValue#isUpdated EntityValue.isUpdated} and {@link com.sap.cloud.mobile.kotlin.odata.EntityValue#isDeleted EntityValue.isDeleted} properties can be accessed on the resulting entity value to determine the type of change.
Return the HTTP headers for the change at index.
Return the changed link, if isLink(index) is true, otherwise throws undefined.
The {@link com.sap.cloud.mobile.kotlin.odata.ChangedLink#isCreated ChangedLink.isCreated}, {@link com.sap.cloud.mobile.kotlin.odata.ChangedLink#isUpdated ChangedLink.isUpdated} and {@link com.sap.cloud.mobile.kotlin.odata.ChangedLink#isDeleted ChangedLink.isDeleted} properties can be accessed on the resulting changed link to determine the type of change.
Return the request options for the change at index.
Add an action call to the change set. If the method is not an action throws a 'UsageException'.
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataQuery#bind(com.sap.cloud.mobile.kotlin.odata.BindingPath) DataQuery.bind} and {@link com.sap.cloud.mobile.kotlin.odata.DataQuery#from(com.sap.cloud.mobile.kotlin.odata.EntitySet) DataQuery.from}, for setting the binding parameter for a bound action (either can be applied to the returned query).
Replace the request headers for a previously added request.
Replace the request options for a previously added request.
Call {@link com.sap.cloud.mobile.kotlin.odata.ChangeSet#createEntity(com.sap.cloud.mobile.kotlin.odata.EntityValue, com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders?, com.sap.cloud.mobile.kotlin.odata.RequestOptions?) ChangeSet.createEntity}, if entity.isNew == true, otherwise call {@link com.sap.cloud.mobile.kotlin.odata.ChangeSet#updateEntity(com.sap.cloud.mobile.kotlin.odata.EntityValue, com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders?, com.sap.cloud.mobile.kotlin.odata.RequestOptions?) ChangeSet.updateEntity}.
Add an updated entity to the change set. The entity will be updated when this change set is submitted.
Add a pending updated link to the change set. The link will be updated when this change set is submitted.
Add a media upload request to the change set. The media will be uploaded when this change set is submitted.
Add a stream upload request to the change set. The stream will be uploaded when this change set is submitted.