ChangeSet

open class ChangeSet

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);
}

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
open val isEmpty: Boolean
Link copied to clipboard
Link copied to clipboard
open val size: Int
Link copied to clipboard
var status: Int

Functions

Link copied to clipboard
open fun addAction(action: DataQuery)
open fun addAction(action: DataQuery, headers: HttpHeaders?)
open fun addAction(action: DataQuery, headers: HttpHeaders?, options: RequestOptions?)

Add an action call to the change set.

Link copied to clipboard
open fun addActionResult(call: DataQuery, result: QueryResult)
open fun addActionResult(call: DataQuery, result: QueryResult, index: Int)

Add {@link com.sap.cloud.mobile.kotlin.odata.QueryResult} for an action call to this change set.

Link copied to clipboard
open fun createEntity(entity: EntityValue)
open fun createEntity(entity: EntityValue, headers: HttpHeaders?)
open fun createEntity(entity: EntityValue, headers: HttpHeaders?, options: RequestOptions?)

Add a pending created entity to the change set. The entity will be created when this change set is submitted.

Link copied to clipboard
open fun createLink(from: EntityValue, property: Property, to: EntityValue)
open fun createLink(from: EntityValue, property: Property, to: EntityValue, headers: HttpHeaders?)
open fun createLink(from: EntityValue, property: Property, to: EntityValue, headers: HttpHeaders?, options: RequestOptions?)

Add a pending created link to the change set. The link will be created when this change set is submitted.

Link copied to clipboard
open fun createMedia(entity: EntityValue, content: StreamBase)
open fun createMedia(entity: EntityValue, content: StreamBase, headers: HttpHeaders?)
open fun createMedia(entity: EntityValue, content: StreamBase, headers: HttpHeaders?, options: RequestOptions?)

Add a pending created media entity to the change set. The entity will be created when this change set is submitted.

Link copied to clipboard
open fun createRelatedEntity(entity: EntityValue, parent: EntityValue, property: Property)
open fun createRelatedEntity(entity: EntityValue, parent: EntityValue, property: Property, headers: HttpHeaders?)
open fun createRelatedEntity(entity: EntityValue, parent: EntityValue, property: Property, headers: HttpHeaders?, options: RequestOptions?)

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.

Link copied to clipboard
open fun createRelatedMedia(entity: EntityValue, content: StreamBase, parent: EntityValue, property: Property)
open fun createRelatedMedia(entity: EntityValue, content: StreamBase, parent: EntityValue, property: Property, headers: HttpHeaders?)
open fun createRelatedMedia(entity: EntityValue, content: StreamBase, parent: EntityValue, property: Property, headers: HttpHeaders?, options: 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(entity: EntityValue)
open fun deleteEntity(entity: EntityValue, headers: HttpHeaders?)
open fun deleteEntity(entity: EntityValue, headers: HttpHeaders?, options: RequestOptions?)

Add a pending deleted entity to the change set. The entity will be deleted when this change set is submitted.

Link copied to clipboard
open fun deleteLink(from: EntityValue, property: Property)
open fun deleteLink(from: EntityValue, property: Property, to: EntityValue)
open fun deleteLink(from: EntityValue, property: Property, to: EntityValue, headers: HttpHeaders?)
open fun deleteLink(from: EntityValue, property: Property, to: EntityValue, headers: HttpHeaders?, options: RequestOptions?)

Add a pending deleted link to the change set. The link will be deleted when this change set is submitted.

Link copied to clipboard
open fun deleteStream(entity: EntityValue, link: StreamLink)
open fun deleteStream(entity: EntityValue, link: StreamLink, headers: HttpHeaders?)
open fun deleteStream(entity: EntityValue, link: StreamLink, headers: HttpHeaders?, options: RequestOptions?)

Add a stream delete request to the change set. The stream will be deleted when this change set is submitted.

Link copied to clipboard
open fun getAction(index: Int): DataQuery

Return the DataQuery for the action call, if isAction(index) is true, otherwise throws undefined

Link copied to clipboard
open fun getActionResult(call: DataQuery, index: Int): QueryResult

Return the {@link com.sap.cloud.mobile.kotlin.odata.QueryResult} for an action call.

Link copied to clipboard
open fun getEntity(index: Int): EntityValue

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.

Link copied to clipboard
open fun getHeaders(index: Int): HttpHeaders

Return the HTTP headers for the change at index.

Link copied to clipboard
open fun getLink(index: Int): ChangedLink

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.

Link copied to clipboard
open fun getOptions(index: Int): RequestOptions

Return the request options for the change at index.

Link copied to clipboard
open fun invokeAction(method: DataMethod): DataQuery
open fun invokeAction(method: DataMethod, parameters: ParameterList): DataQuery
open fun invokeAction(method: DataMethod, parameters: ParameterList, headers: HttpHeaders?): DataQuery
open fun invokeAction(method: DataMethod, parameters: ParameterList, headers: HttpHeaders?, options: RequestOptions?): DataQuery

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).

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 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 replaceHeaders(index: Int, headers: HttpHeaders)

Replace the request headers for a previously added request.

Link copied to clipboard
open fun replaceOptions(index: Int, options: RequestOptions)

Replace the request options for a previously added request.

Link copied to clipboard
open fun saveEntity(entity: EntityValue)
open fun saveEntity(entity: EntityValue, headers: HttpHeaders?)
open fun saveEntity(entity: EntityValue, headers: HttpHeaders?, options: RequestOptions?)

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}.

Link copied to clipboard
open fun updateEntity(entity: EntityValue)
open fun updateEntity(entity: EntityValue, headers: HttpHeaders?)
open fun updateEntity(entity: EntityValue, headers: HttpHeaders?, options: RequestOptions?)

Add an updated entity to the change set. The entity will be updated when this change set is submitted.

Link copied to clipboard
open fun updateLink(from: EntityValue, property: Property, to: EntityValue)
open fun updateLink(from: EntityValue, property: Property, to: EntityValue, headers: HttpHeaders?)
open fun updateLink(from: EntityValue, property: Property, to: EntityValue, headers: HttpHeaders?, options: RequestOptions?)

Add a pending updated link to the change set. The link will be updated when this change set is submitted.

Link copied to clipboard
open fun uploadMedia(entity: EntityValue, content: StreamBase)
open fun uploadMedia(entity: EntityValue, content: StreamBase, headers: HttpHeaders?)
open fun uploadMedia(entity: EntityValue, content: StreamBase, headers: HttpHeaders?, options: RequestOptions?)

Add a media upload request to the change set. The media will be uploaded when this change set is submitted.

Link copied to clipboard
open fun uploadStream(entity: EntityValue, link: StreamLink, content: StreamBase)
open fun uploadStream(entity: EntityValue, link: StreamLink, content: StreamBase, headers: HttpHeaders?)
open fun uploadStream(entity: EntityValue, link: StreamLink, content: StreamBase, headers: HttpHeaders?, options: RequestOptions?)

Add a stream upload request to the change set. The stream will be uploaded when this change set is submitted.