RequestBatch

open class RequestBatch(source)

Encapsulates an OData batch request.

See Also:

com.sap.cloud.mobile.odata.ChangeSet, com.sap.cloud.mobile.odata.DataQuery, DataService.processBatch.

Example using proxy classes:
public void processBatchExample() {
    NorthwindService service = this.getService();
    Supplier supplier1 = service.getSupplier(new DataQuery().top(1));
    Supplier supplier2 = supplier1.copy();
    Supplier supplier3 = supplier1.copy();
    Supplier supplier4 = supplier1.copy();
    supplier2.setCompanyName("Alpha Inc.");
    supplier3.setCompanyName("Beta Inc.");
    service.createEntity(supplier2);
    service.createEntity(supplier3);
    supplier3.setCompanyName("Gamma Inc.");
    Product product1 = service.getProduct(new DataQuery().top(1));
    Product product2 = product1.copy();
    product2.setProductName("Delta Cake");
    RequestBatch batch = new RequestBatch();
    ChangeSet changes = new 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);
    DataQuery query = new DataQuery()
        .from(NorthwindServiceMetadata.EntitySets.suppliers);
    batch.addChanges(changes);
    batch.addQuery(query);
    service.processBatch(batch);
    List<Supplier> suppliers = Supplier.list(batch.getQueryResult(query)
        .getEntityList());
    Example.show("There are now ", Example.formatInt(suppliers.size()),
        " suppliers.");
}
Example using dynamic API:
public void processBatchExample() {
    DataService service = this.getService();
    EntitySet suppliersEntitySet = service.getEntitySet("Suppliers");
    EntitySet productsEntitySet = service.getEntitySet("Products");
    EntityType supplierEntityType = suppliersEntitySet.getEntityType();
    Property companyNameProperty = supplierEntityType.getProperty("CompanyName");
    EntityType productEntityType = productsEntitySet.getEntityType();
    Property productNameProperty = productEntityType.getProperty("ProductName");
    Property supplierProperty = productEntityType.getProperty("Supplier");
    EntityValue supplier1 = service.executeQuery(new DataQuery()
        .from(suppliersEntitySet).top(1))
        .getRequiredEntity();
    EntityValue supplier2 = supplier1.copyEntity();
    EntityValue supplier3 = supplier1.copyEntity();
    EntityValue supplier4 = supplier1.copyEntity();
    companyNameProperty.setString(supplier2, "Alpha Inc.");
    companyNameProperty.setString(supplier3, "Beta Inc.");
    service.createEntity(supplier2);
    service.createEntity(supplier3);
    companyNameProperty.setString(supplier3, "Gamma Inc.");
    EntityValue product1 = service.executeQuery(new DataQuery()
        .from(productsEntitySet).top(1))
        .getRequiredEntity();
    EntityValue product2 = product1.copyEntity();
    productNameProperty.setString(product2, "Delta Cake");
    RequestBatch batch = new RequestBatch();
    ChangeSet changes = new ChangeSet();
    changes.createEntity(supplier4);
    changes.updateEntity(supplier3);
    changes.deleteEntity(supplier2);
    changes.createEntity(product2);
    changes.createLink(product2, supplierProperty, supplier4);
    DataQuery query = new DataQuery().from(suppliersEntitySet);
    batch.addChanges(changes);
    batch.addQuery(query);
    service.processBatch(batch);
    EntityValueList suppliers = batch.getQueryResult(query).getEntityList();
    Example.show("There are now ", Example.formatInt(suppliers.length()),
        " suppliers.");
}

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open fun addAction(@NonNull @NotNull call: @NotNull DataQuery)
open fun addAction(@NonNull @NotNull call: @NotNull DataQuery, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun addAction(@NonNull @NotNull call: @NotNull DataQuery, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add an action call to this request batch.
Link copied to clipboard
open fun addChanges(@NonNull @NotNull changes: @NotNull ChangeSet)
open fun addChanges(@NonNull @NotNull changes: @NotNull ChangeSet, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun addChanges(@NonNull @NotNull changes: @NotNull ChangeSet, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a change set to this request batch.
Link copied to clipboard
open fun addFunction(@NonNull @NotNull call: @NotNull DataQuery)
open fun addFunction(@NonNull @NotNull call: @NotNull DataQuery, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun addFunction(@NonNull @NotNull call: @NotNull DataQuery, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a function call to this request batch.
Link copied to clipboard
open fun addQuery(@NonNull @NotNull query: @NotNull DataQuery)
open fun addQuery(@NonNull @NotNull query: @NotNull DataQuery, @Nullable @Nullable headers: @Nullable HttpHeaders)
open fun addQuery(@NonNull @NotNull query: @NotNull DataQuery, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions)
Add a data query to this request batch.
Link copied to clipboard
open fun addQueryResult(@NonNull @NotNull query: @NotNull DataQuery, @NonNull @NotNull result: @NotNull QueryResult)
open fun addQueryResult(@NonNull @NotNull query: @NotNull DataQuery, @NonNull @NotNull result: @NotNull QueryResult, index: Int)
Add a query result to this request batch.
Link copied to clipboard
open fun checkActionResult(@NonNull @NotNull call: @NotNull DataQuery)
open fun checkActionResult(@NonNull @NotNull call: @NotNull DataQuery, index: Int)
Link copied to clipboard
@NotNull
open fun downloadMedia(@NonNull @NotNull entity: @NotNull EntityValue): @NotNull DataQuery
@NotNull
open fun downloadMedia(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders): @NotNull DataQuery
@NotNull
open fun downloadMedia(@NonNull @NotNull entity: @NotNull EntityValue, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions): @NotNull 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.
Link copied to clipboard
@NotNull
open fun downloadStream(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull link: @NotNull StreamLink): @NotNull DataQuery
@NotNull
open fun downloadStream(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull link: @NotNull StreamLink, @Nullable @Nullable headers: @Nullable HttpHeaders): @NotNull DataQuery
@NotNull
open fun downloadStream(@NonNull @NotNull entity: @NotNull EntityValue, @NonNull @NotNull link: @NotNull StreamLink, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions): @NotNull 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.
Link copied to clipboard
@NotNull
open fun getAction(index: Int): @NotNull DataQuery
Return the com.sap.cloud.mobile.odata.DataQuery for an action call, if isAction(index) is true; otherwise throws undefined.
Link copied to clipboard
@NotNull
open fun getActionResult(@NonNull @NotNull call: @NotNull DataQuery): @NotNull QueryResult
@NotNull
open fun getActionResult(@NonNull @NotNull call: @NotNull DataQuery, index: Int): @NotNull QueryResult
Return the com.sap.cloud.mobile.odata.QueryResult for an action call.
Link copied to clipboard
@NotNull
open fun getChangeSet(index: Int): @NotNull ChangeSet
Return the change set, if isChangeSet(index) is true; otherwise throws undefined.
Link copied to clipboard
Return should the server continue executing all requests in a batch if one or more of the requests returns an error status.
Link copied to clipboard
@NotNull
open fun getDataQuery(index: Int): @NotNull DataQuery
Return the data query, if isDataQuery(index) is true; otherwise throws undefined.
Link copied to clipboard
@Nullable
fun getError(): @Nullable DataServiceException
Return (nullable) Error if status does not represent a successful response.
Link copied to clipboard
@NotNull
open fun getFunction(index: Int): @NotNull DataQuery
Return the com.sap.cloud.mobile.odata.DataQuery for a function call, if isFunction(index) is true; otherwise throws undefined.
Link copied to clipboard
@NotNull
open fun getFunctionResult(@NonNull @NotNull call: @NotNull DataQuery): @NotNull QueryResult
@NotNull
open fun getFunctionResult(@NonNull @NotNull call: @NotNull DataQuery, index: Int): @NotNull QueryResult
Return the com.sap.cloud.mobile.odata.QueryResult for a function call.
Link copied to clipboard
@NotNull
open fun getHeaders(index: Int): @NotNull HttpHeaders
Return the HTTP headers for the request at index.
Link copied to clipboard
@NotNull
fun getHttpRequest(): @NotNull HttpRequest
Return set by OnlineODataProvider.processBatch if RequestBatch.streamResponse is true'. For MIME multipart batch, also see RequestBatch.mimeStream. @return Set by OnlineODataProvider.
Link copied to clipboard
@NotNull
fun getMimeStream(): @NotNull MimeStreamReader
Return set by OnlineODataProvider.processBatch if RequestBatch.streamResponse is true' and MIME multipart batch format is used. @return Set by OnlineODataProvider.
Link copied to clipboard
@NotNull
open fun getOptions(index: Int): @NotNull RequestOptions
Return the request options for the request at index.
Link copied to clipboard
@NotNull
open fun getQueryResult(@NonNull @NotNull query: @NotNull DataQuery): @NotNull QueryResult
@NotNull
open fun getQueryResult(@NonNull @NotNull query: @NotNull DataQuery, index: Int): @NotNull QueryResult
Return the result of a data query within this batch.
Link copied to clipboard
fun getStatus(): Int
Return response status (e.g.
Link copied to clipboard
Return true if OnlineODataProvider.processBatch should just set RequestBatch.httpRequest (and RequestBatch.mimeStream for MIME multipart batch) but not process the response itself.
Link copied to clipboard
@NotNull
open fun invokeFunction(@NonNull @NotNull method: @NotNull DataMethod): @NotNull DataQuery
@NotNull
open fun invokeFunction(@NonNull @NotNull method: @NotNull DataMethod, @NonNull @NotNull parameters: @NotNull ParameterList): @NotNull DataQuery
@NotNull
open fun invokeFunction(@NonNull @NotNull method: @NotNull DataMethod, @NonNull @NotNull parameters: @NotNull ParameterList, @Nullable @Nullable headers: @Nullable HttpHeaders): @NotNull DataQuery
@NotNull
open fun invokeFunction(@NonNull @NotNull method: @NotNull DataMethod, @NonNull @NotNull parameters: @NotNull ParameterList, @Nullable @Nullable headers: @Nullable HttpHeaders, @Nullable @Nullable options: @Nullable RequestOptions): @NotNull DataQuery
Add a function call to the batch.
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 com.sap.cloud.mobile.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 com.sap.cloud.mobile.odata.DataQuery; otherwise false.
Link copied to clipboard
open fun isEmpty(): Boolean
Return true if RequestBatch.size is zero.
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 isNotEmpty(): Boolean
Return true if RequestBatch.size is non-zero.
Link copied to clipboard
open fun replaceHeaders(index: Int, @NonNull @NotNull headers: @NotNull HttpHeaders)
Replace the request headers for a previously added request.
Link copied to clipboard
open fun replaceOptions(index: Int, @NonNull @NotNull options: @NotNull RequestOptions)
Replace the request options for a previously added request.
Link copied to clipboard
Set should the server continue executing all requests in a batch if one or more of the requests returns an error status.
Link copied to clipboard
fun setError(@Nullable @Nullable value: @Nullable DataServiceException)
Set error if status does not represent a successful response.
Link copied to clipboard
fun setHttpRequest(@NonNull @NotNull value: @NotNull HttpRequest)
Set set by OnlineODataProvider.processBatch if RequestBatch.streamResponse is true'. For MIME multipart batch, also see RequestBatch.mimeStream. @param value Set by OnlineODataProvider.
Link copied to clipboard
fun setMimeStream(@NonNull @NotNull value: @NotNull MimeStreamReader)
Set set by OnlineODataProvider.processBatch if RequestBatch.streamResponse is true' and MIME multipart batch format is used. @param value Set by OnlineODataProvider.
Link copied to clipboard
fun setStatus(value: Int)
Set response status (e.g.
Link copied to clipboard
Set true if OnlineODataProvider.processBatch should just set RequestBatch.httpRequest (and RequestBatch.mimeStream for MIME multipart batch) but not process the response itself.
Link copied to clipboard
open fun size(): Int
Return the number of requests in this request batch.