You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by bu...@apache.org on 2015/01/28 11:26:50 UTC

svn commit: r937987 - in /websites/staging/olingo/trunk/content: ./ doc/odata4/tutorials/od4_basic_read.html

Author: buildbot
Date: Wed Jan 28 10:26:50 2015
New Revision: 937987

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_read.html

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Jan 28 10:26:50 2015
@@ -1 +1 @@
-1655256
+1655258

Modified: websites/staging/olingo/trunk/content/doc/odata4/tutorials/od4_basic_read.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/odata4/tutorials/od4_basic_read.html (original)
+++ websites/staging/olingo/trunk/content/doc/odata4/tutorials/od4_basic_read.html Wed Jan 28 10:26:50 2015
@@ -165,7 +165,7 @@ Each of them is split into an implementa
 
 
 <h5 id="setting-up-the-web-project">Setting up the web project</h5>
-<p>Next, setup up the web project by replacing the web.xml.</p>
+<p>Next, setup up the web project by replacing the <code>web.xml</code>.</p>
 <div class="codehilite"><pre><span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
 
 <span class="nt">&lt;web-app</span> <span class="na">xmlns:xsi=</span><span class="s">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span>
@@ -206,7 +206,7 @@ The processor receives, validates and de
 <h5 id="edmprovider">EdmProvider</h5>
 <p><img alt="Figure 2: Data model" src="er.png" /></p>
 <p>OData services are described in terms of an Entity Data Model (EDM). To do so, the first step is to provide such an EDM. In this basic tutorial, we will define a class that provides an EDM instance. The EDM will be used to determine the types of the entities, properties and so on. In addition, the service can deliver a service meta-document. As we have a static model we define constants for all top level elements of the schema. The data model is shown in figure 2 as entity relationship diagram.</p>
-<p>Create a new class called CarsEdmProvider that inherits from EdmProvider</p>
+<p>Create a new class called <code>CarsEdmProvider</code> that inherits from <code>EdmProvider</code></p>
 <div class="codehilite"><pre><span class="n">package</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">odata2</span><span class="p">.</span><span class="n">server</span><span class="p">.</span><span class="n">sample</span><span class="p">.</span><span class="n">edmprovider</span><span class="p">;</span>
 
 <span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">olingo</span><span class="p">.</span><span class="n">server</span><span class="p">.</span><span class="n">api</span><span class="p">.</span><span class="n">edm</span><span class="p">.</span><span class="n">provider</span><span class="p">.</span><span class="n">EdmProvider</span><span class="p">;</span>
@@ -233,7 +233,7 @@ The processor receives, validates and de
 </pre></div>
 
 
-<p>Implement <em>CarsEdmProvider.getSchemas</em>. This method is used to retrieve the complete structural information in order to build the metadata document and the service document. The implementation makes use of other getter methods of this class for simplicity reasons. If a very performant way of building the whole structural information was required, other implementation strategies could be used.</p>
+<p>Implement <code>CarsEdmProvider.getSchemas(...)</code>. This method is used to retrieve the complete structural information in order to build the metadata document and the service document. The implementation makes use of other getter methods of this class for simplicity reasons. If a very performant way of building the whole structural information was required, other implementation strategies could be used.</p>
 <div class="codehilite"><pre><span class="p">@</span><span class="n">Override</span>
 <span class="n">public</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Schema</span><span class="o">&gt;</span> <span class="n">getSchemas</span><span class="p">()</span> <span class="n">throws</span> <span class="n">ODataException</span> <span class="p">{</span>
     <span class="n">List</span><span class="o">&lt;</span><span class="n">Schema</span><span class="o">&gt;</span> <span class="n">schemas</span> <span class="p">=</span> <span class="n">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">Schema</span><span class="o">&gt;</span><span class="p">();</span>
@@ -260,7 +260,7 @@ The processor receives, validates and de
 </pre></div>
 
 
-<p>For example the method <em>CarsEdmProvider.getComplexType</em> delivers the definition of a complex type, if there exists a complex type with the same full qualified name. The full qualified name was provided by the getSchemas method as mentioned above.</p>
+<p>For example the method <code>CarsEdmProvider.getComplexType(...)</code> delivers the definition of a complex type, if there exists a complex type with the same full qualified name. The full qualified name was provided by the getSchemas method as mentioned above.</p>
 <div class="codehilite"><pre><span class="n">public</span> <span class="n">ComplexType</span> <span class="n">getComplexType</span><span class="p">(</span><span class="n">final</span> <span class="n">FullQualifiedName</span> <span class="n">complexTypeName</span><span class="p">)</span> <span class="n">throws</span> <span class="n">ODataException</span> <span class="p">{</span>
     <span class="k">if</span> <span class="p">(</span><span class="n">CT_ADDRESS</span><span class="p">.</span><span class="n">equals</span><span class="p">(</span><span class="n">complexTypeName</span><span class="p">))</span> <span class="p">{</span>
         <span class="k">return</span> <span class="n">new</span> <span class="n">ComplexType</span><span class="p">()</span>
@@ -277,7 +277,7 @@ The processor receives, validates and de
 
 
 <p>The same principle is used for all other types.
-<em>CarsEdmProvider.getEntityType</em> returns an Entity Type according to the full qualified name specified. The Entity Type holds all information about its structure like simple properties, complex properties, navigation properties and the definition of its key property (or properties)</p>
+<code>CarsEdmProvider.getEntityType(...)</code> returns an Entity Type according to the full qualified name specified. The Entity Type holds all information about its structure like simple properties, complex properties, navigation properties and the definition of its key property (or properties)</p>
 <div class="codehilite"><pre><span class="p">@</span><span class="n">Override</span>
 <span class="n">public</span> <span class="n">EntityType</span> <span class="n">getEntityType</span><span class="p">(</span><span class="n">final</span> <span class="n">FullQualifiedName</span> <span class="n">entityTypeName</span><span class="p">)</span> <span class="n">throws</span> <span class="n">ODataException</span> <span class="p">{</span>
     <span class="k">if</span> <span class="p">(</span><span class="n">ET_CAR</span><span class="p">.</span><span class="n">equals</span><span class="p">(</span><span class="n">entityTypeName</span><span class="p">))</span> <span class="p">{</span>
@@ -354,7 +354,7 @@ The processor receives, validates and de
 
 
 <p>Entities are not visible by default. To make them visible, we have to define a so called “EntityContainer”.
-Override the method <em>getEntityContainer()</em> and add the following code:</p>
+Override the method <code>getEntityContainer(...)</code> and add the following code:</p>
 <div class="codehilite"><pre><span class="p">@</span><span class="n">Override</span>
 <span class="n">public</span> <span class="n">EntityContainer</span> <span class="n">getEntityContainer</span><span class="p">()</span> <span class="n">throws</span> <span class="n">ODataException</span> <span class="p">{</span>
     <span class="n">EntityContainer</span> <span class="n">container</span> <span class="p">=</span> <span class="n">new</span> <span class="n">EntityContainer</span><span class="p">();</span>
@@ -412,8 +412,8 @@ Override the method <em>getEntityContain
 <p>Conclusion
 After the implementation of the EDM Provider the web application can be executed to show the Service Document and the Metadata Document.</p>
 <ul>
-<li>Build your project mvn clean install</li>
-<li>Deploy the Web Application to the server. (e. g. mvn tomcat:run)</li>
+<li>Build your project: <code>mvn clean install</code></li>
+<li>Deploy the Web Application to the server (e. g. mvn tomcat:run)</li>
 <li>Show the Service Document: <a href="http://localhost:8080/odata-server-sample/cars.svc/">http://localhost:8080/odata-server-sample/cars.svc/</a></li>
 <li>Show the Metadata Document:  <a href="http://localhost:8080/odata-server-sample/cars.svc/$metadata">http://localhost:8080/odata-server-sample/cars.svc/$metadata</a></li>
 </ul>
@@ -421,7 +421,7 @@ After the implementation of the EDM Prov
 <h5 id="add-runtime-data">Add runtime data</h5>
 <p>In the next steps we will implement read access to the Car and Manufacturer entries and the read access to the Cars and Manufacturers feed. As we need some basis for sample data we create a very simple data store which contains the data as well as access methods to serve the required data.</p>
 <p>We will implement some helper methods to provide a bunch of sample data.</p>
-<p>Create a new class DataProvider.</p>
+<p>Create a new class <code>DataProvider</code>.</p>
 <div class="codehilite"><pre><span class="n">package</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">olingo</span><span class="p">.</span><span class="n">server</span><span class="p">.</span><span class="n">sample</span><span class="p">.</span><span class="n">data</span><span class="p">;</span>
 
 <span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">util</span><span class="p">.</span><span class="n">ArrayList</span><span class="p">;</span>
@@ -528,7 +528,7 @@ After the implementation of the EDM Prov
 </pre></div>
 
 
-<p>The argument edmEntitySet will be provided by the URI parser. Further details can found in the next chapter (See processor implementation).  It contains information about the requested entity set. (e. g. name, type, navigation properties, …).</p>
+<p>The argument <code>edmEntitySet</code> will be provided by the URI parser. Further details can found in the next chapter (See processor implementation).  It contains information about the requested entity set. (e. g. name, type, navigation properties, …).</p>
 <div class="codehilite"><pre><span class="n">public</span> <span class="n">Entity</span> <span class="n">read</span><span class="p">(</span><span class="n">final</span> <span class="n">EdmEntitySet</span> <span class="n">edmEntitySet</span><span class="p">,</span> <span class="n">final</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">UriParameter</span><span class="o">&gt;</span> <span class="n">keys</span><span class="p">)</span> <span class="n">throws</span> <span class="n">DataProviderException</span> <span class="p">{</span>
     <span class="n">final</span> <span class="n">EdmEntityType</span> <span class="n">entityType</span> <span class="p">=</span> <span class="n">edmEntitySet</span><span class="p">.</span><span class="n">getEntityType</span><span class="p">();</span>
     <span class="n">final</span> <span class="n">EntitySet</span> <span class="n">entitySet</span> <span class="p">=</span> <span class="n">readAll</span><span class="p">(</span><span class="n">edmEntitySet</span><span class="p">);</span>
@@ -676,21 +676,21 @@ After the implementation of the EDM Prov
 
 
 <ul>
-<li><em>CarsProcessor.getEdmEntitySet(..)</em> extracts the EntitySet from the URI-Parser result.</li>
-<li><em>CarsProcessor.getContextUrl(..)</em> uses the Context  URI Builder to create a context URI. Further information about context URI can be found in the OData specification. (Chapter 10)</li>
-<li><em>CarsProcessor.readEntityInternal(..)</em> will extract the key values and pass them to the date provider.</li>
-<li><em>CarsProcessor.readProperty(..)</em> is used to read all properties. It does not matter if the property is primitive or complex. If case of primitive properties the constaints defined by the EDM has to be passed to the primitive serializer.</li>
+<li><code>CarsProcessor.getEdmEntitySet(..)</code> extracts the EntitySet from the URI-Parser result.</li>
+<li><code>CarsProcessor.getContextUrl(..)</code> uses the Context  URI Builder to create a context URI. Further information about context URI can be found in the OData specification. (Chapter 10)</li>
+<li><code>CarsProcessor.readEntityInternal(..)</code> will extract the key values and pass them to the date provider.</li>
+<li><code>CarsProcessor.readProperty(..)</code> is used to read all properties. It does not matter if the property is primitive or complex. If case of primitive properties the constaints defined by the EDM has to be passed to the primitive serializer.</li>
 </ul>
 <p><strong>Not implemented methods:</strong></p>
 <p>In this tutorial, we will implement read methods only. So add to the following methods an <em>OdataApplicationException</em>:</p>
 <ul>
-<li>createEntity</li>
-<li>updateComplex</li>
-<li>deleteComplex</li>
-<li>updateEntity</li>
-<li>deleteEntity</li>
-<li>updatePrimitive</li>
-<li>deletePrimitive</li>
+<li><code>createEntity</code></li>
+<li><code>updateComplex</code></li>
+<li><code>deleteComplex</code></li>
+<li><code>updateEntity</code></li>
+<li><code>deleteEntity</code></li>
+<li><code>updatePrimitive</code></li>
+<li><code>deletePrimitive</code></li>
 </ul>
 <p>Example:</p>
 <div class="codehilite"><pre><span class="p">@</span><span class="n">Override</span>
@@ -716,7 +716,7 @@ After the implementation of the EDM Prov
 </pre></div>
 
 
-<p>In addition we have to implement the methods <em>readEntityCollection</em> and <em>readEntity</em>.</p>
+<p>In addition we have to implement the methods <code>readEntityCollection(...)</code> and <code>readEntity(...)</code>.</p>
 <div class="codehilite"><pre><span class="p">@</span><span class="n">Override</span>
 <span class="n">public</span> <span class="n">void</span> <span class="n">readEntity</span><span class="p">(</span><span class="n">ODataRequest</span> <span class="n">request</span><span class="p">,</span> <span class="n">ODataResponse</span> <span class="n">response</span><span class="p">,</span> <span class="n">UriInfo</span> <span class="n">uriInfo</span><span class="p">,</span>
         <span class="n">ContentType</span> <span class="n">requestedContentType</span><span class="p">)</span> <span class="n">throws</span> <span class="n">ODataApplicationException</span><span class="p">,</span> <span class="n">SerializerException</span> <span class="p">{</span>
@@ -790,7 +790,7 @@ After the implementation of the EDM Prov
 
 
 <h5 id="complete-servlet-implementation">Complete servlet implementation</h5>
-<p>Replace the <em>CarsServlet.service(..)</em> method with following snipped:</p>
+<p>Replace the <code>CarsServlet.service(..)</code> method with following snipped:</p>
 <div class="codehilite"><pre><span class="p">@</span><span class="n">Override</span>
 <span class="n">protected</span> <span class="n">void</span> <span class="n">service</span><span class="p">(</span><span class="n">final</span> <span class="n">HttpServletRequest</span> <span class="n">req</span><span class="p">,</span> <span class="n">final</span> <span class="n">HttpServletResponse</span> <span class="n">resp</span><span class="p">)</span>
     <span class="n">throws</span> <span class="n">ServletException</span><span class="p">,</span> <span class="n">IOException</span> <span class="p">{</span>
@@ -821,18 +821,18 @@ After the implementation of the EDM Prov
 
 <p>The difference to the previous implementation is that the data provider and the Cars Processor are been instantiated. The data provider is bound to the current HttpSession and reused in subsequent requests. The Cars Processor will be registered in the OData handler. At this point, any number of processors can be registered. The processor is determined by the ODataHandler implementation by using the type of the request.</p>
 <ul>
-<li>Recompile your sample service  (<em>mvn clean install</em>)</li>
+<li>Recompile your sample service  (<code>mvn clean install</code>)</li>
 <li>Deploy the war file on a web server</li>
 <li>Test the created service</li>
 </ul>
 <p>Test the following URIs</p>
 <ul>
-<li>Service document  <a href="http://localhost:8080/odata-server-sample/cars.svc/">http://localhost:8080/odata-server-sample/cars.svc/</a></li>
-<li>Metadata document <a href="http://localhost:8080/odata-server-sample/cars.svc/$metadata">http://localhost:8080/odata-server-sample/cars.svc/$metadata</a></li>
-<li>EntitySet <a href="http://localhost:8080/odata-server-sample/cars.svc/Cars">http://localhost:8080/odata-server-sample/cars.svc/Cars</a></li>
-<li>Entity    <a href="http://localhost:8080/odata-server-sample/cars.svc/Cars(1)">http://localhost:8080/odata-server-sample/cars.svc/Cars(1)</a></li>
-<li>Primitive property    <a href="http://localhost:8080/odata-server-sample/cars.svc/Cars(5)/Price">http://localhost:8080/odata-server-sample/cars.svc/Cars(5)/Price</a></li>
-<li>Complex property  <a href="http://localhost:8080/odata-server-sample/cars.svc/Manufacturers(1)/Address">http://localhost:8080/odata-server-sample/cars.svc/Manufacturers(1)/Address</a></li>
+<li>Service document: <a href="http://localhost:8080/odata-server-sample/cars.svc/">http://localhost:8080/odata-server-sample/cars.svc/</a></li>
+<li>Metadata document:    <a href="http://localhost:8080/odata-server-sample/cars.svc/$metadata">http://localhost:8080/odata-server-sample/cars.svc/$metadata</a></li>
+<li>EntitySet:    <a href="http://localhost:8080/odata-server-sample/cars.svc/Cars">http://localhost:8080/odata-server-sample/cars.svc/Cars</a></li>
+<li>Entity:   <a href="http://localhost:8080/odata-server-sample/cars.svc/Cars(1)">http://localhost:8080/odata-server-sample/cars.svc/Cars(1)</a></li>
+<li>Primitive property:   <a href="http://localhost:8080/odata-server-sample/cars.svc/Cars(5)/Price">http://localhost:8080/odata-server-sample/cars.svc/Cars(5)/Price</a></li>
+<li>Complex property: <a href="http://localhost:8080/odata-server-sample/cars.svc/Manufacturers(1)/Address">http://localhost:8080/odata-server-sample/cars.svc/Manufacturers(1)/Address</a></li>
 </ul>
 <h3 id="basis-read-scenario">Basis read scenario</h3>
 <h5 id="setup-maven-project">Setup Maven project</h5>
@@ -891,7 +891,7 @@ After the implementation of the EDM Prov
 <li>Create a request by using the <em>getRetrieveRequestFactory</em></li>
 <li>Use the data, as shown in the class Main</li>
 </ul>
-<p>Create a new class <em>SampleClient</em></p>
+<p>Create a new class <code>SampleClient</code></p>
 <div class="codehilite"><pre><span class="n">package</span> <span class="n">org</span><span class="p">.</span><span class="n">apache</span><span class="p">.</span><span class="n">olingo</span><span class="p">.</span><span class="n">client</span><span class="p">.</span><span class="n">sample</span><span class="p">;</span>
 
 <span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">net</span><span class="p">.</span><span class="n">URI</span><span class="p">;</span>