RequestBatch

open class RequestBatch

Encapsulates an OData batch request.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.ChangeSet}, {@link com.sap.cloud.mobile.kotlin.odata.DataQuery}, DataService.processBatch.

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

Constructors

Link copied to clipboard
constructor()

Properties

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

Functions

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

Add an action call to this request batch.

Link copied to clipboard
open fun addChanges(changes: ChangeSet)
open fun addChanges(changes: ChangeSet, headers: HttpHeaders?)
open fun addChanges(changes: ChangeSet, headers: HttpHeaders?, options: RequestOptions?)

Add a change set to this request batch.

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

Add a function call to this request batch.

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

Add a data query to this request batch.

Link copied to clipboard
open fun addQueryResult(query: DataQuery, result: QueryResult)
open fun addQueryResult(query: DataQuery, result: QueryResult, index: Int)

Add a query result to this request batch.

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

Call {@link com.sap.cloud.mobile.kotlin.odata.QueryResult#check(kotlin.Int) QueryResult.check} on the {@link com.sap.cloud.mobile.kotlin.odata.QueryResult} for an action call. Throws {@link com.sap.cloud.mobile.kotlin.odata.DataServiceException} if the action failed.

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

Add a "download media" query to the batch, to obtain a stream for downloading the content of a media entity from the target system. Caution: streams are often used for large content that may not fit (all at once) in available application memory. Having too many threads simultaneously downloading streams, or using {@link com.sap.cloud.mobile.kotlin.odata.ByteStream#readAndClose() ByteStream.readAndClose}, may result in out-of-memory conditions on memory-constrained devices.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.QueryResult#getByteStream() QueryResult.getByteStream}, {@link com.sap.cloud.mobile.kotlin.odata.QueryResult#getCharStream() QueryResult.getCharStream}.

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

Add a "download stream" query to the batch, to obtain a stream for downloading the content of a stream property from the target system. Caution: streams are often used for large content that may not fit (all at once) in available application memory. Having too many threads simultaneously downloading streams, or using {@link com.sap.cloud.mobile.kotlin.odata.ByteStream#readAndClose() ByteStream.readAndClose}, may result in out-of-memory conditions on memory-constrained devices.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.QueryResult#getByteStream() QueryResult.getByteStream}, {@link com.sap.cloud.mobile.kotlin.odata.QueryResult#getCharStream() QueryResult.getCharStream}.

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

Return the {@link com.sap.cloud.mobile.kotlin.odata.DataQuery} for an 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 getChangeSet(index: Int): ChangeSet

Return the change set, if isChangeSet(index) is true; otherwise throws undefined.

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

Return the data query, if isDataQuery(index) is true; otherwise throws undefined.

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

Return the {@link com.sap.cloud.mobile.kotlin.odata.DataQuery} for a function call, if isFunction(index) is true; otherwise throws undefined.

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

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

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

Return the HTTP headers for the request at index.

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

Return the request options for the request at index.

Link copied to clipboard
open fun getQueryResult(query: DataQuery, index: Int): QueryResult

Return the result of a data query within this batch.

See Also:

{@link com.sap.cloud.mobile.kotlin.odata.RequestBatch#addQuery(com.sap.cloud.mobile.kotlin.odata.DataQuery, com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders?, com.sap.cloud.mobile.kotlin.odata.RequestOptions?) RequestBatch.addQuery}.

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

Add a function call to the batch.

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 function (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 request at that index is for an action call.

Link copied to clipboard
open fun isChangeSet(index: Int): Boolean

Return true if index is a valid request index, and the request at that index is a {@link com.sap.cloud.mobile.kotlin.odata.ChangeSet}; otherwise false.

Link copied to clipboard
open fun isDataQuery(index: Int): Boolean

Return true if index is a valid request index, and the request at that index is a {@link com.sap.cloud.mobile.kotlin.odata.DataQuery}; otherwise false.

Link copied to clipboard
open fun isFunction(index: Int): Boolean

Return true if index is a valid change index, and the request at that index is for a function call.

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.