processBatch

open suspend fun processBatch(batch: RequestBatch)

See processBatch_(RequestBatch, HttpHeaders?, RequestOptions?).

Parameters

batch

Batch parameter.


open suspend fun processBatch(batch: RequestBatch, headers: HttpHeaders?)

See processBatch_(RequestBatch, HttpHeaders?, RequestOptions?).

Parameters

batch

Batch parameter.

headers

Headers parameter.


open suspend fun processBatch(batch: RequestBatch, headers: HttpHeaders?, options: RequestOptions?)

Execute a request batch in the target system. Note: If the request batch contains just one item, that item being a change set, the {@link com.sap.cloud.mobile.kotlin.odata.DataServiceAsync#applyChanges_(com.sap.cloud.mobile.kotlin.odata.ChangeSet, com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders?, com.sap.cloud.mobile.kotlin.odata.RequestOptions?) DataServiceAsync.applyChanges} function is recommended for conciseness.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.RequestBatch}, {@link com.sap.cloud.mobile.kotlin.odata.DataServiceAsync#applyChanges_(com.sap.cloud.mobile.kotlin.odata.ChangeSet, com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders?, com.sap.cloud.mobile.kotlin.odata.RequestOptions?) DataServiceAsync.applyChanges}.

Example using proxy classes:
open fun processBatchExample(): kotlin.Unit
{
    val service = this.service;
    val supplier1 = service.getSupplier(DataQuery().top(1));
    val supplier2 = supplier1.copy();
    val supplier3 = supplier1.copy();
    val supplier4 = supplier1.copy();
    supplier2.companyName = "Alpha Inc.";
    supplier3.companyName = "Beta Inc.";
    service.createEntity(supplier2);
    service.createEntity(supplier3);
    supplier3.companyName = "Gamma Inc.";
    val product1 = service.getProduct(DataQuery().top(1));
    val product2 = product1.copy();
    product2.productName = "Delta Cake";
    val batch = RequestBatch();
    val changes = ChangeSet();
    changes.createEntity(supplier4);
    changes.updateEntity(supplier3);
    changes.deleteEntity(supplier2);
    changes.createEntity(product2);
    changes.createLink(product2, Product.supplier, supplier4);
    changes.updateLink(product2, Product.supplier, supplier3);
    changes.deleteLink(product2, Product.supplier, supplier3);
    val query = DataQuery().from(NorthwindServiceMetadata.EntitySets.suppliers);
    batch.addChanges(changes);
    batch.addQuery(query);
    service.processBatch(batch);
    val suppliers = Supplier.list(batch.getQueryResult(query).getEntityList());
    Example.show("There are now ", Example.formatInt(suppliers.size),
        " suppliers.");
}
Example using dynamic API:
open fun processBatchExample(): kotlin.Unit
{
    val service = this.service;
    val suppliersEntitySet = service.getEntitySet("Suppliers");
    val productsEntitySet = service.getEntitySet("Products");
    val supplierEntityType = suppliersEntitySet.entityType;
    val companyNameProperty = supplierEntityType.getProperty("CompanyName");
    val productEntityType = productsEntitySet.entityType;
    val productNameProperty = productEntityType.getProperty("ProductName");
    val supplierProperty = productEntityType.getProperty("Supplier");
    val supplier1 = service.executeQuery(DataQuery().from(suppliersEntitySet)
        .top(1))
        .getRequiredEntity();
    val supplier2 = supplier1.copyEntity();
    val supplier3 = supplier1.copyEntity();
    val supplier4 = supplier1.copyEntity();
    companyNameProperty.setString(supplier2, "Alpha Inc.");
    companyNameProperty.setString(supplier3, "Beta Inc.");
    service.createEntity(supplier2);
    service.createEntity(supplier3);
    companyNameProperty.setString(supplier3, "Gamma Inc.");
    val product1 = service.executeQuery(DataQuery().from(productsEntitySet)
        .top(1))
        .getRequiredEntity();
    val product2 = product1.copyEntity();
    productNameProperty.setString(product2, "Delta Cake");
    val batch = RequestBatch();
    val changes = ChangeSet();
    changes.createEntity(supplier4);
    changes.updateEntity(supplier3);
    changes.deleteEntity(supplier2);
    changes.createEntity(product2);
    changes.createLink(product2, supplierProperty, supplier4);
    val query = DataQuery().from(suppliersEntitySet);
    batch.addChanges(changes);
    batch.addQuery(query);
    service.processBatch(batch);
    val suppliers = batch.getQueryResult(query).getEntityList();
    Example.show("There are now ", Example.formatInt(suppliers.length),
        " suppliers.");
}

Parameters

batch

The request batch.

headers

(nullable) Optional request-specific headers.

options

(nullable) Optional request-specific options.