olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r964140 - in /websites/staging/olingo/trunk/content: ./ doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html
Date Thu, 03 Sep 2015 08:11:56 GMT
Author: buildbot
Date: Thu Sep  3 08:11:56 2015
New Revision: 964140

Log:
Staging update by buildbot for olingo

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

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu Sep  3 08:11:56 2015
@@ -1 +1 @@
-1700945
+1700946

Modified: websites/staging/olingo/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html (original)
+++ websites/staging/olingo/trunk/content/doc/odata4/tutorials/sqo_f/tutorial_sqo_f.html Thu
Sep  3 08:11:56 2015
@@ -103,7 +103,7 @@ h2:hover > .headerlink, h3:hover > .head
 <p>In the present tutorial, we’ll continue implementing OData system query options,
this time focusing on <strong>$filter</strong></p>
 <p><strong>Note:</strong>
 The full implementation of the OData service as described in the present tutorial can be
found in the attached zip file that contains an Eclipse project that can be imported into
your Eclipse workspace.</p>
-<p>Table of Contents</p>
+<p><strong>Table of Contents</strong></p>
 <ol>
 <li>Preparation</li>
 <li>Implementation</li>
@@ -129,8 +129,8 @@ implementation for the $filter query opt
 </ol>
 <h3 id="21-implement-filter">2.1 Implement $filter<a class="headerlink" href="#21-implement-filter"
title="Permanent link">&para;</a></h3>
 <h4 id="background">Background<a class="headerlink" href="#background" title="Permanent
link">&para;</a></h4>
-<p>When requesting a list of entities from a service, the default behavior is to return
all entities on the list. The consumer of an OData service might want to be able to receive
a sub set by specifying certain criteria which each of the returned entities have to fulfill.<br
/>
-For example, a usual case would be to request all products with a specified minimum and maximum
price.
+<p>When requesting a list of entities from a service, the default behavior is to return
all entities on the list. The consumer of an OData service might want to be able to receive
a subset by specifying certain criteria which each of the returned entities have to fulfill.<br
/>
+For example, a common use case would be to request all products with a specified minimum
and maximum price.
 OData supports this requirement with the system query option <strong>$filter</strong></p>
 <p>It is specified as follows:</p>
 <div class="codehilite"><pre>$<span class="n">filter</span><span
class="p">=</span><span class="o">&lt;</span><span class="n">BooleanExpression</span><span
class="o">&gt;</span>
@@ -150,7 +150,7 @@ OData supports this requirement with the
 <p>The $filter system query option has been applied to the Products Entity Collection.
The client requests all products which fulfills the following condition: ID equals to one
or the Description should contain the string ‘1280’</p>
 <p><img alt="ProductsWithFilter" src="filter_applied.png" title="Products with applied
$filter" /></p>
 <p><strong>Visitor pattern</strong></p>
-<p>First things first, the Uri parser creates an <em>abstract syntax tree</em>
(AST).  An abstract syntax tree describes the expression in a hierarchical way. For example
to calculate the root node, all nodes below have to be calculated first. The idea is to traverse
the tree in pre order (depth-first).</p>
+<p>First things first, the Uri parser creates an <em>abstract syntax tree</em>
(AST).  An abstract syntax tree describes the expression in a hierarchical way. (see figure
1) For example to calculate the root node, all nodes below have to be calculated first. The
idea is to traverse the tree in pre order (depth-first).</p>
 <p>Consider the following Uri </p>
 <div class="codehilite"><pre>“<span class="o">/</span><span
class="n">Products</span>?$<span class="n">format</span><span class="p">=(</span><span
class="n">Price</span> <span class="n">lt</span> 2000<span class="p">)</span>
<span class="n">and</span> <span class="n">contains</span><span
class="p">(</span><span class="n">Description</span><span class="p">,</span>’<span
class="n">Notebook</span>’<span class="p">)</span>”<span
class="p">.</span>
 </pre></div>
@@ -160,7 +160,7 @@ OData supports this requirement with the
 <p><img alt="AbstractSyntaxTree" src="ast.png" title="Abstract syntax tree of the
filter expression “Price lt 2000 and contains(Description,’Notebook’)" /></p>
 <p>Key<br />
 <img alt="AbstractSyntaxTree" src="keyAST.png" title="Key abstract syntax tree" /></p>
-<p>So the following actions have to be done:</p>
+<p>So the following actions have to be done (The values of the properties are fictitious):</p>
 <table class="table">
 <thead>
 <tr>
@@ -215,14 +215,14 @@ OData supports this requirement with the
 </tr>
 </tbody>
 </table>
-<p>Olingo uses the vistor pattern to traverse the AST. Each of these actions is mapped
to one method of the ExpressionVistor. You can see the name of the methods in last column
of table 1. As service developers we have to implement this methods but we don`t have to take
care about calling them. The libaray will call the proper method and we have only to calculate
the result. </p>
+<p>Olingo uses the vistor pattern to traverse the AST. Each of these actions is mapped
to one method of the ExpressionVistor interface. You can see the name of the methods in last
column of table 1. As service developers we have to implement this methods but we don`t have
to take care about calling them. The libaray will call the proper method and we have only
to calculate the result. </p>
 <h4 id="implementation">Implementation<a class="headerlink" href="#implementation"
title="Permanent link">&para;</a></h4>
 <p>First we will create the <em>Filter Expression Visitor</em> and after
that, we`ll integrate the just created Visitor in <em>EntityCollectionProcessor</em>.</p>
 <p><strong>1.1 Create our FilterExpressionVisitor</strong></p>
 <p>Create a new class <em>FilterExpressionVisitor</em> in package <em>myservice.mynamespace.service</em>
and<br />
 implement the Interface <em>org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor</em>.
</p>
 <p>As you mentioned the interface needs a generic parameter. 
-This type is used as (return) parameter for the visitXXX methods (e.g. <em>visitLiteral</em>
). It`s up to your implementation to
+This generic type is used as (return) parameter for the visitXXX methods (e.g. <em>visitLiteral</em>
). It`s up to your implementation to
 choose a proper type for your use case. The main task is to keep track of the type and also
the return value of a node in the abstract syntax tree. 
 In real world scenarios it is common to build a statement to query a database or backend
instead modifying the preloaded data. </p>
 <p>In this tutorial we will use just <em>Object</em> and pass the native
Java values around.</p>
@@ -292,7 +292,7 @@ This method is been called if the curren
 <p><strong>Example</strong>  </p>
 <ul>
 <li>"‘1’" is a string with the value "1"</li>
-<li>"1"   could be an Byte, SByte, Edm.Int16, EdmInt32, EdmInt64, Edm.Single, Edm.Double,
Edm.Decimal with value 1</li>
+<li>"1"   could be an Edm.Byte, Edm.SByte, Edm.Int16, Edm.Int32, Edm.Int64, Edm.Single,
Edm.Double, Edm.Decimal with value 1</li>
 </ul>
 <p>As you can see in this little example, it can be difficult to guess the right type.
In this tutorial we will focus on Edm.Int32. </p>
 <p>In real world scenarios, there is something called “numeric promotion”,
which converts numbers to the next higher type. <a href="http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part2-url-conventions/odata-v4.0-errata02-os-part2-url-conventions-complete.html#_Toc406398161">OData
Version 4.0 Part 2: URL Conventions Plus Errata 02</a></p>
@@ -557,8 +557,8 @@ This method is been called if the curren
 <p><strong>2.4 Modify the collection</strong>   </p>
 <div class="codehilite"><pre>     <span class="c1">// The result of the
filter expression must be of type Edm.Boolean</span>
      <span class="k">if</span><span class="o">(</span><span class="n">visitorResult</span>
<span class="k">instanceof</span> <span class="n">Boolean</span><span
class="o">)</span> <span class="o">{</span>
-        <span class="k">if</span><span class="o">(</span><span
class="n">visitorResult</span> <span class="o">!=</span> <span class="kc">null</span>
<span class="o">&amp;&amp;</span> <span class="n">Boolean</span><span
class="o">.</span><span class="na">FALSE</span><span class="o">.</span><span
class="na">equals</span><span class="o">(</span><span class="n">visitorResult</span><span
class="o">))</span> <span class="o">{</span>
-          <span class="c1">// The expression evaluated to false, so we have to remove
the </span>
+        <span class="k">if</span><span class="o">(!</span><span
class="n">Boolean</span><span class="o">.</span><span class="na">TRUE</span><span
class="o">.</span><span class="na">equals</span><span class="o">(</span><span
class="n">visitorResult</span><span class="o">))</span> <span class="o">{</span>
+          <span class="c1">// The expression evaluated to false (or null), so we have
to remove the </span>
           <span class="c1">// currentEntity from entityList</span>
           <span class="n">entityIterator</span><span class="o">.</span><span
class="na">remove</span><span class="o">();</span>
         <span class="o">}</span>



Mime
View raw message