Request Batch
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."); }
Properties
Functions
Add an action call to this request batch.
Add a change set to this request batch.
Add a function call to this request batch.
Add a data query to this request batch.
Add a query result to this request batch.
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.
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}.
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}.
Return the {@link com.sap.cloud.mobile.kotlin.odata.QueryResult} for an action call.
Return the change set, if isChangeSet(index) is true; otherwise throws undefined.
Return the data query, if isDataQuery(index) is true; otherwise throws undefined.
Return the {@link com.sap.cloud.mobile.kotlin.odata.DataQuery} for a function call, if isFunction(index) is true; otherwise throws undefined.
Return the {@link com.sap.cloud.mobile.kotlin.odata.QueryResult} for a function call.
Return the HTTP headers for the request at index.
Return the request options for the request at index.
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}.
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).
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.
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.
Return true if index is a valid change index, and the request at that index is for a function call.
Replace the request headers for a previously added request.
Replace the request options for a previously added request.