Author: ramyav
Date: Tue May 28 06:16:01 2019
New Revision: 1860173

URL: http://svn.apache.org/viewvc?rev=1860173&view=rev
Log:
Batch Client API

Modified:
    olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_batch_client.mdtext

Modified: 
olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_batch_client.mdtext
URL: 
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_batch_client.mdtext?rev=1860173&r1=1860172&r2=1860173&view=diff
==============================================================================
--- 
olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_batch_client.mdtext 
(original)
+++ 
olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_batch_client.mdtext 
Tue May 28 06:16:01 2019
@@ -16,4 +16,45 @@ Notice:    Licensed to the Apache Softwa
            specific language governing permissions and limitations
            under the License.
 
-#How to use the Batch Client API in OData V4
\ No newline at end of file
+#How to use the Batch Client API in OData V4
+
+### Construction of OData Client
+
+    ODataClient odata = ODataClientFactory.getClient();
+    odata.getConfiguration().setDefaultPubFormat(ContentType.APPLICATION_JSON);
+
+### Construction of a client entity and create request
+
+    ClientObjectFactory factory = getClient().getObjectFactory();
+    final ClientEntity entity = factory.newEntity("OData.Demo.Manufacturer");
+    entity.getProperties().add(factory.newPrimitiveProperty("Name", 
factory.newPrimitiveValueBuilder().buildString("MyCarManufacturer")));
+         
+    final URI targetURI = 
getClient().newURIBuilder(serviceUrl).appendEntitySetSegment("Manufacturers").build();
+    final ODataEntityCreateRequest<ClientEntity> createRequest = 
getClient().getCUDRequestFactory().getEntityCreateRequest(targetURI, entity);
+
+### Add a create request to a changeset
+
+    BatchManager payloadManager = 
getClient().getBatchRequestFactory().getBatchRequest(serviceUrl).payloadManager();
+    final ODataChangeset changeset = payloadManager.addChangeset();
+     
+    changeset.addRequest(createRequest);
+
+### Construction of a query request
+
+    final URI targetURI = 
getClient().newURIBuilder(serviceUrl).appendEntitySetSegment("Manufacturers").appendKeySegment(1).build();
+    final URI uri = isRelative ? 
URI.create(<ServiceUri>).relativize(targetURI) : targetURI;
+     
+    ODataEntityRequest<ClientEntity> queryReq = 
getClient().getRetrieveRequestFactory().getEntityRequest(uri);
+    queryReq.setAccept(ContentType.APPLICATION_JSON);
+
+### Add query request to payloadManager
+
+    payload.addRequest(queryReq);
+
+### Fetch the batch response
+
+    final ODataBatchResponse response = payload.getResponse();
+     
+    final Iterator<ODataBatchResponseItem> responseBodyIter = 
response.getBody();
+    final ODataBatchResponseItem changeSetResponse = responseBodyIter.next();
+


Reply via email to