apply Changes
See applyChanges_(ChangeSet, HttpHeaders?, RequestOptions?).
Parameters
changes
Changes parameter.
See applyChanges_(ChangeSet, HttpHeaders?, RequestOptions?).
Parameters
changes
Changes parameter.
headers
Headers parameter.
Apply the changes from a change set to the target system.
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataServiceAsync#processBatch_(com.sap.cloud.mobile.kotlin.odata.RequestBatch, com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders?, com.sap.cloud.mobile.kotlin.odata.RequestOptions?) DataServiceAsync.processBatch}.
- 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); }
- Example using proxy classes:
open fun joinTransactionExample(patient: Patient): kotlin.Unit { val service = this.healthService; val changes = ChangeSet(); val appointment1 = Appointment(); changes.createEntity(patient); changes.createRelatedEntity(appointment1, patient, Patient.appointments); service.applyChanges(changes); // Some time later... Attach another appointment to the same transaction as the patient. val appointment2 = Appointment(); changes.createRelatedEntity(appointment2, patient, Patient.appointments, com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders.empty, RequestOptions() .joinTransaction(patient)); // Some time later... Upload the patient and both appointments in the same backend transaction. service.upload(); }
Parameters
changes
The change set.
headers
(nullable) Optional request-specific headers.
options
(nullable) Optional request-specific options.