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

svn commit: r1655258 - /olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_read.mdtext

Author: mibo
Date: Wed Jan 28 10:26:43 2015
New Revision: 1655258

URL: http://svn.apache.org/r1655258
Log:
CMS commit to olingo by mibo

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

Modified: olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_read.mdtext
URL: http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_read.mdtext?rev=1655258&r1=1655257&r2=1655258&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_read.mdtext (original)
+++ olingo/site/trunk/content/doc/odata4/tutorials/od4_basic_read.mdtext Wed Jan 28 10:26:43 2015
@@ -100,7 +100,7 @@ Replace the pom.xml by the following lis
 
 ##### Setting up the web project
 
-Next, setup up the web project by replacing the web.xml.
+Next, setup up the web project by replacing the `web.xml`.
 
 
     <?xml version="1.0" encoding="UTF-8"?>
@@ -134,7 +134,7 @@ As you can see we define a servlet, whic
 
 Each Olingo OData service consists of several parts.
 
-* **EdmProvider**
+ * **EdmProvider**
 Delivers an abstract definition of the service.
 * **DataProvider**
 The data provider connects the Olingo library with the data source. In this basic tutorial, we will use static data. In real world application, the data provider will may establish a connection to a database. There a no constraints how a DataProvider has to be build.
@@ -147,7 +147,7 @@ The processor receives, validates and de
 
 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.
 
-Create a new class called CarsEdmProvider that inherits from EdmProvider
+Create a new class called `CarsEdmProvider` that inherits from `EdmProvider`
 
 	package org.apache.odata2.server.sample.edmprovider;
 
@@ -174,7 +174,7 @@ Create a new class called CarsEdmProvide
 	public static final String ES_MANUFACTURER_NAME = "Manufacturers";
 
 
-Implement *CarsEdmProvider.getSchemas*. 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.
+Implement `CarsEdmProvider.getSchemas(...)`. 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.
 
 	@Override
 	public List<Schema> getSchemas() throws ODataException {
@@ -200,7 +200,7 @@ Implement *CarsEdmProvider.getSchemas*.
 		return schemas;
 	}
 
-For example the method *CarsEdmProvider.getComplexType* 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.
+For example the method `CarsEdmProvider.getComplexType(...)` 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.
 
 	public ComplexType getComplexType(final FullQualifiedName complexTypeName) throws ODataException {
 		if (CT_ADDRESS.equals(complexTypeName)) {
@@ -216,7 +216,7 @@ For example the method *CarsEdmProvider.
 	}
 
 The same principle is used for all other types.
-*CarsEdmProvider.getEntityType* 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)
+`CarsEdmProvider.getEntityType(...)` 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)
 
 
 	@Override
@@ -293,7 +293,7 @@ The same principle is used for all other
 	  }
 
 Entities are not visible by default. To make them visible, we have to define a so called “EntityContainer”.
-Override the method *getEntityContainer()* and add the following code:
+Override the method `getEntityContainer(...)` and add the following code:
 
 
 	@Override
@@ -354,8 +354,8 @@ Insert the following code.
 Conclusion
 After the implementation of the EDM Provider the web application can be executed to show the Service Document and the Metadata Document.
 
-* Build your project mvn clean install
-* Deploy the Web Application to the server. (e. g. mvn tomcat:run)
+* Build your project: `mvn clean install`
+* Deploy the Web Application to the server (e. g. mvn tomcat:run)
 * Show the Service Document: [http://localhost:8080/odata-server-sample/cars.svc/](http://localhost:8080/odata-server-sample/cars.svc/)
 * Show the Metadata Document:  [http://localhost:8080/odata-server-sample/cars.svc/$metadata](http://localhost:8080/odata-server-sample/cars.svc/$metadata)
 
@@ -363,12 +363,11 @@ The Service Document and the Meta Docume
 
 ##### Add runtime data
 
-
 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.
 
 We will implement some helper methods to provide a bunch of sample data.
 
-Create a new class DataProvider.
+Create a new class `DataProvider`.
 
 	package org.apache.olingo.server.sample.data;
 
@@ -474,7 +473,7 @@ To access the data, we implement two hel
 	    return data.get(edmEntitySet.getName());
 	}
 
-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, …).
+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, …).
 
 	public Entity read(final EdmEntitySet edmEntitySet, final List<UriParameter> keys) throws DataProviderException {
 		final EdmEntityType entityType = edmEntitySet.getEntityType();
@@ -624,22 +623,22 @@ The design of the processor interface is
 	}
 
 
-  * *CarsProcessor.getEdmEntitySet(..)* extracts the EntitySet from the URI-Parser result.
-  * *CarsProcessor.getContextUrl(..)* uses the Context  URI Builder to create a context URI. Further information about context URI can be found in the OData specification. (Chapter 10)
-  * *CarsProcessor.readEntityInternal(..)* will extract the key values and pass them to the date provider.
-  * *CarsProcessor.readProperty(..)* 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.
+  * `CarsProcessor.getEdmEntitySet(..)` extracts the EntitySet from the URI-Parser result.
+  * `CarsProcessor.getContextUrl(..)` uses the Context  URI Builder to create a context URI. Further information about context URI can be found in the OData specification. (Chapter 10)
+  * `CarsProcessor.readEntityInternal(..)` will extract the key values and pass them to the date provider.
+  * `CarsProcessor.readProperty(..)` 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.
 
 **Not implemented methods:**
 
 In this tutorial, we will implement read methods only. So add to the following methods an *OdataApplicationException*:
 
-  * createEntity
-  * updateComplex
-  * deleteComplex
-  * updateEntity
-  * deleteEntity
-  * updatePrimitive
-  * deletePrimitive
+  * `createEntity`
+  * `updateComplex`
+  * `deleteComplex`
+  * `updateEntity`
+  * `deleteEntity`
+  * `updatePrimitive`
+  * `deletePrimitive`
 
 Example:
 
@@ -666,7 +665,7 @@ There are two different interfaces to re
 	}
 
 
-In addition we have to implement the methods *readEntityCollection* and *readEntity*.
+In addition we have to implement the methods `readEntityCollection(...)` and `readEntity(...)`.
 
 	@Override
 	public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
@@ -740,7 +739,7 @@ In addition we have to implement the met
 
 ##### Complete servlet implementation
 
-Replace the *CarsServlet.service(..)* method with following snipped:
+Replace the `CarsServlet.service(..)` method with following snipped:
 
 	@Override
 	protected void service(final HttpServletRequest req, final HttpServletResponse resp)
@@ -770,18 +769,18 @@ Replace the *CarsServlet.service(..)* me
 
 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.
 
-* Recompile your sample service  (*mvn clean install*)
+* Recompile your sample service  (`mvn clean install`)
 * Deploy the war file on a web server
 * Test the created service
 
 Test the following URIs
 
-* Service document	[http://localhost:8080/odata-server-sample/cars.svc/](http://localhost:8080/odata-server-sample/cars.svc/)
-* Metadata document	[http://localhost:8080/odata-server-sample/cars.svc/$metadata](http://localhost:8080/odata-server-sample/cars.svc/$metadata)
-* EntitySet	[http://localhost:8080/odata-server-sample/cars.svc/Cars](http://localhost:8080/odata-server-sample/cars.svc/Cars)
-* Entity	[http://localhost:8080/odata-server-sample/cars.svc/Cars(1)](http://localhost:8080/odata-server-sample/cars.svc/Cars(1))
-* Primitive property	[http://localhost:8080/odata-server-sample/cars.svc/Cars(5)/Price](http://localhost:8080/odata-server-sample/cars.svc/Cars(5)/Price)
-* Complex property	[http://localhost:8080/odata-server-sample/cars.svc/Manufacturers(1)/Address](http://localhost:8080/odata-server-sample/cars.svc/Manufacturers(1)/Address)
+* Service document: [http://localhost:8080/odata-server-sample/cars.svc/](http://localhost:8080/odata-server-sample/cars.svc/)
+* Metadata document:	[http://localhost:8080/odata-server-sample/cars.svc/$metadata](http://localhost:8080/odata-server-sample/cars.svc/$metadata)
+* EntitySet:	[http://localhost:8080/odata-server-sample/cars.svc/Cars](http://localhost:8080/odata-server-sample/cars.svc/Cars)
+* Entity:	[http://localhost:8080/odata-server-sample/cars.svc/Cars(1)](http://localhost:8080/odata-server-sample/cars.svc/Cars(1))
+* Primitive property:	[http://localhost:8080/odata-server-sample/cars.svc/Cars(5)/Price](http://localhost:8080/odata-server-sample/cars.svc/Cars(5)/Price)
+* Complex property:	[http://localhost:8080/odata-server-sample/cars.svc/Manufacturers(1)/Address](http://localhost:8080/odata-server-sample/cars.svc/Manufacturers(1)/Address)
 
 
 ### Basis read scenario
@@ -848,7 +847,7 @@ To request some data the following steps
   * Use the data, as shown in the class Main
 
 
-Create a new class *SampleClient*
+Create a new class `SampleClient`
 
 	package org.apache.olingo.client.sample;