olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r1045621 - in /websites/staging/olingo/trunk/content: ./ doc/odata4/tutorials/od4_basic_client_read.html
Date Tue, 28 May 2019 07:32:08 GMT
Author: buildbot
Date: Tue May 28 07:32:08 2019
New Revision: 1045621

Log:
Staging update by buildbot for olingo

Modified:
    websites/staging/olingo/trunk/content/   (props changed)
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/od4_basic_client_read.html

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue May 28 07:32:08 2019
@@ -1 +1 @@
-1860185
+1860189

Modified: websites/staging/olingo/trunk/content/doc/odata4/tutorials/od4_basic_client_read.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/odata4/tutorials/od4_basic_client_read.html
(original)
+++ websites/staging/olingo/trunk/content/doc/odata4/tutorials/od4_basic_client_read.html
Tue May 28 07:32:08 2019
@@ -126,7 +126,7 @@ For creating a simple odata service refe
 
 
 <h3 id="read-edm">Read EDM<a class="headerlink" href="#read-edm" title="Permanent
link">&para;</a></h3>
-<p>For an OData Service the Entity Data Model (EDM) defines all metadata information
about the provided data of the service. This includes all entities with their type, properties
and relations, which entities are provided as entity sets and additional functions and operations
provided by the OData Service. The EDM also have to be provided by the OData Service via a
unique URI (e.g. http://localhost:8080/DemoService/DemoService.svc/$metadata) in the EDMX
format.
+<p>For an OData Service the Entity Data Model (EDM) defines all metadata information
about the provided data of the service. This includes all entities with their type, properties
and relations, which entities are provided as entity sets and additional functions and operations
provided by the OData Service. The EDM also have to be provided by the OData Service via a
unique URI (e.g. http://localhost:8080/cars.svc/$metadata) in the EDMX format.
 This fact is important because the Apache Olingo library requires the metadata for serialization
and de-serialization of the data of an entity (e.g. the validation of the data is done against
the EDM provided metadata). Hence the first step in this sample is to read the whole EDM of
an OData Service.</p>
 <h3 id="code-sample-read-edm-metadata">Code sample: Read EDM ($metadata)<a class="headerlink"
href="#code-sample-read-edm-metadata" title="Permanent link">&para;</a></h3>
 <div class="codehilite"><pre><span class="n">final</span> <span
class="n">Edm</span> <span class="n">edm</span> <span class="p">=</span>
<span class="n">getClient</span><span class="p">().</span><span
class="n">getRetrieveRequestFactory</span><span class="p">().</span><span
class="n">getMetadataRequest</span><span class="p">(</span><span class="n">serviceUrl</span><span
class="p">).</span><span class="n">execute</span><span class="p">().</span><span
class="n">getBody</span><span class="p">();</span>
@@ -136,9 +136,16 @@ This fact is important because the Apach
 
 <p>If annotations defined in external vocabulary file has to be loaded then the below
code has to be used</p>
 <div class="codehilite"><pre><span class="n">List</span><span
class="o">&lt;</span><span class="n">InputStream</span><span class="o">&gt;</span>
<span class="n">streams</span> <span class="p">=</span> <span class="n">new</span>
<span class="n">ArrayList</span><span class="o">&lt;</span><span
class="n">InputStream</span><span class="o">&gt;</span><span class="p">();</span>
+<span class="o">//</span><span class="n">If</span> <span class="n">file</span>
<span class="n">is</span> <span class="n">locally</span> <span
class="n">available</span>    
 <span class="n">streams</span><span class="p">.</span><span class="n">add</span><span
class="p">(</span><span class="n">getClass</span><span class="p">().</span><span
class="n">getResourceAsStream</span><span class="p">(</span>&quot;<span
class="n">annotations</span><span class="p">.</span><span class="n">xml</span>&quot;<span
class="p">));</span>
 <span class="n">XMLMetadata</span> <span class="n">xmlMetadata</span>
<span class="p">=</span> <span class="n">getClient</span><span
class="p">().</span><span class="n">getRetrieveRequestFactory</span><span
class="p">().</span><span class="n">getXMLMetadataRequest</span><span
class="p">(</span><span class="n">serviceUrl</span><span class="p">).</span><span
class="n">execute</span><span class="p">().</span><span class="n">getBody</span><span
class="p">();</span>
-<span class="n">final</span> <span class="n">Edm</span> <span
class="n">edm</span> <span class="p">=</span> <span class="n">getClient</span><span
class="p">().</span><span class="n">getReader</span><span class="p">().</span><span
class="n">readMetadata</span><span class="p">(</span><span class="n">xmlMetadata</span><span
class="p">,</span> <span class="n">terms</span><span class="p">);</span>
+<span class="o">//</span><span class="n">If</span> <span class="n">the</span>
<span class="n">reference</span> <span class="n">uri</span><span
class="o">&#39;</span><span class="n">s</span> <span class="n">have</span>
<span class="n">to</span> <span class="n">be</span> <span class="n">loaded</span>

+<span class="n">String</span> <span class="n">vocabUrl</span> <span
class="p">=</span> <span class="n">metadata</span><span class="p">.</span><span
class="n">getReferences</span><span class="p">().</span><span class="n">get</span><span
class="p">(</span>0<span class="p">).</span><span class="n">getUri</span><span
class="p">().</span><span class="n">toString</span><span class="p">();</span>
+<span class="n">URI</span> <span class="n">uri</span> <span class="p">=</span>
<span class="n">new</span> <span class="n">URI</span><span class="p">(</span><span
class="n">vocabUrl</span><span class="p">);</span>
+<span class="n">ODataRawRequest</span> <span class="n">request</span>
<span class="p">=</span> <span class="n">getClient</span><span
class="p">().</span><span class="n">getRetrieveRequestFactory</span><span
class="p">().</span><span class="n">getRawRequest</span><span class="p">(</span><span
class="n">uri</span><span class="p">);</span>
+<span class="n">ODataRawResponse</span> <span class="n">response</span>
<span class="p">=</span> <span class="n">request</span><span class="p">.</span><span
class="n">execute</span><span class="p">();</span>
+<span class="n">streams</span><span class="p">.</span><span class="n">add</span><span
class="p">(</span><span class="n">response</span><span class="p">.</span><span
class="n">getRawResponse</span><span class="p">());</span>
+<span class="n">final</span> <span class="n">Edm</span> <span
class="n">edm</span> <span class="p">=</span> <span class="n">getClient</span><span
class="p">().</span><span class="n">getReader</span><span class="p">().</span><span
class="n">readMetadata</span><span class="p">(</span><span class="n">xmlMetadata</span><span
class="p">,</span> <span class="n">streams</span><span class="p">);</span>
 <span class="k">return</span> <span class="n">edm</span><span
class="p">;</span>
 </pre></div>
 
@@ -146,7 +153,7 @@ This fact is important because the Apach
 <p>Here the serviceUrl is the root Url of the odata service.
 For read and de-serialize of the EDM this is all what have to be done and the resulting EDM
instance than can be used for necessary serialization and de-serialization in combination
of CRUD operations supported by Apache Olingo library.</p>
 <h3 id="read-entity">Read Entity<a class="headerlink" href="#read-entity" title="Permanent
link">&para;</a></h3>
-<p>For reading entities this sample provides two methods. First is read of a complete
OData Feed / Entity Set and second is read os a single Entity. In general, for both first
create the request and execute the request.</p>
+<p>For reading entities this sample provides two methods. First is read of a complete
collection / Entity Set and second is read of a single Entity. In general, for both first
create the request and execute the request.</p>
 <h3 id="read-entitycollection">Read entityCollection<a class="headerlink" href="#read-entitycollection"
title="Permanent link">&para;</a></h3>
 <div class="codehilite"><pre><span class="n">ODataEntitySetRequest</span><span
class="o">&lt;</span><span class="n">ClientEntitySet</span><span
class="o">&gt;</span> <span class="n">request</span> <span class="p">=</span>
<span class="n">getClient</span><span class="p">().</span><span
class="n">getRetrieveRequestFactory</span><span class="p">()</span>
         <span class="p">.</span><span class="n">getEntitySetRequest</span><span
class="p">(</span><span class="n">getClient</span><span class="p">().</span><span
class="n">newURIBuilder</span><span class="p">(</span><span class="n">serviceUrl</span><span
class="p">)</span>
@@ -174,16 +181,13 @@ For read and de-serialize of the EDM thi
         <span class="p">.</span><span class="n">appendPropertySegment</span><span
class="p">(</span>“<span class="n">Name</span>”<span class="p">).</span><span
class="n">build</span><span class="p">());</span>
 <span class="n">final</span> <span class="n">ODataRetrieveResponse</span><span
class="o">&lt;</span><span class="n">ClientProperty</span><span
class="o">&gt;</span> <span class="n">response</span> <span class="p">=</span>
<span class="n">request</span><span class="p">.</span><span class="n">execute</span><span
class="p">();</span>
 <span class="n">final</span> <span class="n">ClientProperty</span>
<span class="n">property</span> <span class="p">=</span> <span
class="n">response</span><span class="p">.</span><span class="n">getBody</span><span
class="p">();</span>
-</pre></div>
-
-
-<p>If the property is a Complex Type and if value has to be fetched
-    // Here Address is a complex property
-    final ClientComplexValue complexValue = prop.getComplexValue();
-    final ClientValue propertyComp = complexValue.get("Street").getValue();</p>
-<p>If property is a primitive type and if value has to be fetched</p>
-<div class="codehilite"><pre><span class="n">final</span> <span
class="n">ClientProperty</span> <span class="n">property</span> <span
class="p">=</span> <span class="n">property</span><span class="p">.</span><span
class="n">get</span><span class="p">(</span>&quot;<span class="n">Name</span>&quot;<span
class="p">);</span>
+<span class="o">//</span><span class="n">If</span> <span class="n">property</span>
<span class="n">is</span> <span class="n">a</span> <span class="n">primitive</span>
<span class="n">type</span> <span class="n">and</span> <span class="k">if</span>
<span class="n">value</span> <span class="n">has</span> <span class="n">to</span>
<span class="n">be</span> <span class="n">fetched</span>
+<span class="n">final</span> <span class="n">ClientProperty</span>
<span class="n">property</span> <span class="p">=</span> <span
class="n">property</span><span class="p">.</span><span class="n">get</span><span
class="p">(</span>&quot;<span class="n">Name</span>&quot;<span
class="p">);</span>
 <span class="n">final</span> <span class="n">ClientPrimitiveValue</span>
<span class="n">clientValue</span> <span class="p">=</span> <span
class="n">property</span><span class="p">.</span><span class="n">getPrimitiveValue</span><span
class="p">();</span>
+<span class="o">//</span><span class="n">If</span> <span class="n">the</span>
<span class="n">property</span> <span class="n">is</span> <span
class="n">a</span> <span class="n">Complex</span> <span class="n">Type</span>
<span class="n">and</span> <span class="k">if</span> <span class="n">value</span>
<span class="n">has</span> <span class="n">to</span> <span class="n">be</span>
<span class="n">fetched</span>
+<span class="o">//</span> <span class="n">Here</span> <span class="n">Address</span>
<span class="n">is</span> <span class="n">a</span> <span class="nb">complex</span>
<span class="n">property</span>
+<span class="n">final</span> <span class="n">ClientComplexValue</span>
<span class="n">complexValue</span> <span class="p">=</span> <span
class="n">prop</span><span class="p">.</span><span class="n">getComplexValue</span><span
class="p">();</span>
+<span class="n">final</span> <span class="n">ClientValue</span> <span
class="n">propertyComp</span> <span class="p">=</span> <span class="n">complexValue</span><span
class="p">.</span><span class="n">get</span><span class="p">(</span>&quot;<span
class="n">Street</span>&quot;<span class="p">).</span><span class="n">getValue</span><span
class="p">();</span>
 </pre></div>
 
 
@@ -196,7 +200,7 @@ For simplicity in the code sample below
 <span class="n">newEntity</span><span class="p">.</span><span
class="n">getProperties</span><span class="p">().</span><span class="n">add</span><span
class="p">(</span><span class="n">getClient</span><span class="p">().</span><span
class="n">getObjectFactory</span><span class="p">().</span><span class="n">newPrimitiveProperty</span><span
class="p">(</span>“<span class="n">Name</span>”<span class="p">,</span>
         <span class="n">getFactory</span><span class="p">().</span><span
class="n">newPrimitiveValueBuilder</span><span class="p">().</span><span
class="n">buildString</span><span class="p">(</span>“<span class="n">MyCarManufacturer</span>”<span
class="p">)));</span>
 <span class="n">newEntity</span><span class="p">.</span><span
class="n">addLink</span><span class="p">(</span><span class="n">getClient</span><span
class="p">().</span><span class="n">getObjectFactory</span><span class="p">().</span><span
class="n">newEntityNavigationLink</span><span class="p">(</span>“<span
class="n">Cars</span>”<span class="p">,</span>
-        <span class="n">client</span><span class="p">.</span><span
class="n">newURIBuilder</span><span class="p">(</span><span class="n">SERVICE_URI</span><span
class="p">)</span>
+        <span class="n">client</span><span class="p">.</span><span
class="n">newURIBuilder</span><span class="p">(</span><span class="n">serviceUrl</span><span
class="p">)</span>
             <span class="p">.</span><span class="n">appendEntitySetSegment</span><span
class="p">(</span>“<span class="n">Cars</span>”<span class="p">)</span>
             <span class="p">.</span><span class="n">appendKeySegment</span><span
class="p">(</span>1<span class="p">)</span>
             <span class="p">.</span><span class="n">build</span><span
class="p">()));</span>



Mime
View raw message