You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2013/09/30 16:31:43 UTC

svn commit: r1527595 - /incubator/olingo/site/trunk/content/doc/tutorials/read_media-resource.mdtext

Author: sklevenz
Date: Mon Sep 30 14:31:43 2013
New Revision: 1527595

URL: http://svn.apache.org/r1527595
Log:
CMS commit to olingo by sklevenz

Modified:
    incubator/olingo/site/trunk/content/doc/tutorials/read_media-resource.mdtext

Modified: incubator/olingo/site/trunk/content/doc/tutorials/read_media-resource.mdtext
URL: http://svn.apache.org/viewvc/incubator/olingo/site/trunk/content/doc/tutorials/read_media-resource.mdtext?rev=1527595&r1=1527594&r2=1527595&view=diff
==============================================================================
--- incubator/olingo/site/trunk/content/doc/tutorials/read_media-resource.mdtext (original)
+++ incubator/olingo/site/trunk/content/doc/tutorials/read_media-resource.mdtext Mon Sep 30 14:31:43 2013
@@ -78,6 +78,7 @@ As conclusion the `getEntityType(…)
 
 #### Sample Code
 
+    :::java
     …
       } else if (ENTITY_TYPE_1_3.getName().equals(edmFQName.getName())) {
         List<Property> properties = new ArrayList<Property>();
@@ -110,11 +111,13 @@ As conclusion the `getEntityType(…)
 
 In addition it is necessary to extend the `getSchemas(…)` method with the according `EntityType` and `EntitySet` of the new Driver.
 
+    :::java
     entityTypes.add(getEntityType(ENTITY_TYPE_1_3));
     entitySets.add(getEntitySet(ENTITY_CONTAINER, ENTITY_SET_NAME_DRIVERS));
 
 And at last following constants are added to the `MyEdmProvider` for cleaner code.
 
+    :::java
       static final String ENTITY_SET_NAME_DRIVERS = "Drivers";
       static final String ENTITY_NAME_DRIVER = "Driver";
       private static final FullQualifiedName ENTITY_TYPE_1_3 = new FullQualifiedName(NAMESPACE, ENTITY_NAME_DRIVER);
@@ -126,6 +129,7 @@ For our scenario we simply have to valid
 Seems a lot but in code this are only these few lines:
 
 
+    :::java
     @Override
     public ODataResponse readEntityMedia(final GetMediaResourceUriInfo uriInfo, final String contentType) throws ODataException {
     
@@ -153,6 +157,7 @@ But its quite the same procedure as in t
 
 The resulting extension for `readEntity(…)`:
 
+    :::java
       } else if (ENTITY_SET_NAME_DRIVERS.equals(entitySet.getName())) {
         int id = getKeyValue(uriInfo.getKeyPredicates().get(0));
         Map<String, Object> data = dataStore.getDriver(id);
@@ -180,6 +185,7 @@ For a more interesting sample we now cre
 ### Extend Driver and Car in MyEdmProvider with a navigation property
 At first we introduce the necessary constants:
 
+    :::java
       private static final FullQualifiedName ASSOCIATION_DRIVER_CAR = new FullQualifiedName(NAMESPACE, "Driver_Car-Car_Driver");
     
       private static final String ROLE_1_3 = "Car_Driver";
@@ -197,6 +203,7 @@ Next step is the extension of the entity
 
 For the Car:
 
+    :::java
       if (ENTITY_TYPE_1_1.getName().equals(edmFQName.getName())) {
     ...
         navigationProperties.add(new NavigationProperty().setName("Driver")
@@ -206,6 +213,7 @@ For the Car:
 
 And the Driver:
 
+    :::java
       if (ENTITY_TYPE_1_3.getName().equals(edmFQName.getName())) {
     ...
         properties.add(new SimpleProperty().setName("CarId").setType(EdmSimpleTypeKind.Int32));
@@ -216,6 +224,7 @@ And the Driver:
 
 At last the `getAssociation(…)` and `getAssociationSet(...)` has also to be extended and has to look like:
 
+    :::java
     @Override
     public Association getAssociation(FullQualifiedName edmFQName) throws ODataException {
       if (NAMESPACE.equals(edmFQName.getNamespace())) {
@@ -256,6 +265,7 @@ At last the `getAssociation(…)` and
 ### Extend existing `readreadEntitySet(...)` and `readEntity(...)` methods in `MyODataSingleProcessor`
 For cleaner code we introduce at first following method in the `MyODataSingleProcessor` which validate if the uri contains the expected association.
 
+    :::java
     private boolean isAssociation(GetEntityUriInfo uriInfo, String startName, String targetName) throws EdmException {
       if(startName == null || targetName == null) {
       return false;
@@ -268,6 +278,7 @@ For cleaner code we introduce at first f
 
 The procedure should be already familiar. At first it is checked for the correct association of the requested Entity, then the key for requesting the DataStore is get as well as the data and then result data is written via the `EntityProvider`.
 
+    :::java
     } else if (uriInfo.getNavigationSegments().size() == 1) {
       //navigation first level, simplified example for illustration purposes only
       EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
@@ -302,6 +313,7 @@ The procedure is similar to the Cars - M
 
 The resulting method extension is:
 
+    :::java
     ...
       if(isNavigationFromTo(context, ENTITY_SET_NAME_CARS, ENTITY_NAME_DRIVER)) {
         EntityProviderWriteProperties inlineProperties = EntityProviderWriteProperties.serviceRoot(serviceRoot)
@@ -330,6 +342,7 @@ After extension of `MyCallback` it is ne
 
 For the Driver we add the complete callback registration (code between the comments) which results in final code for the complete Driver Entity handling:
 
+    :::java
     ...
        } else if (ENTITY_SET_NAME_DRIVERS.equals(entitySet.getName())) {
         int id = getKeyValue(uriInfo.getKeyPredicates().get(0));
@@ -353,6 +366,7 @@ For the Driver we add the complete callb
 
 For the Car it is only necessary to add the single code line below to register the additional callback and enable the `$expand`:
 
+    :::java
       if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) {
     ...
           callbacks.put(ENTITY_NAME_DRIVER, new MyCallback(dataStore, serviceRoot));