Request Batch
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."); }Content copied to clipboard
- 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."); }Content copied to clipboard
Functions
Link copied to clipboard
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, @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, @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, @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
Call QueryResult.check on the com.sap.cloud.mobile.odata.QueryResult for an action call.
Link copied to clipboard
@NotNull
@NotNull
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
@NotNull
@NotNull
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
Return the com.sap.cloud.mobile.odata.QueryResult for an action call.
Link copied to clipboard
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
Return the data query, if
isDataQuery(index) is true; otherwise throws undefined.Link copied to clipboard
Return (nullable) Error if
status does not represent a successful response.Link copied to clipboard
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
@NotNull
Return the com.sap.cloud.mobile.odata.QueryResult for a function call.
Link copied to clipboard
Return the HTTP headers for the request at
index.Link copied to clipboard
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
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
Return the request options for the request at
index.Link copied to clipboard
@NotNull
Return the result of a data query within this batch.
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
@NotNull
@NotNull
Add a function call to the batch.
Link copied to clipboard
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
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
Return true if RequestBatch.size is zero.
Link copied to clipboard
Return
true if index is a valid change index, and the request at that index is for a function call.Link copied to clipboard
Return true if RequestBatch.size is non-zero.
Link copied to clipboard
Replace the request headers for a previously added request.
Link copied to clipboard
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
Set error if
status does not represent a successful response.Link copied to clipboard
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
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
Set true if
OnlineODataProvider.processBatch should just set RequestBatch.httpRequest (and RequestBatch.mimeStream for MIME multipart batch) but not process the response itself.