You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/09/17 10:45:17 UTC

svn commit: r1703527 - /olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext

Author: chrish
Date: Thu Sep 17 08:45:16 2015
New Revision: 1703527

URL: http://svn.apache.org/r1703527
Log:
CMS commit to olingo by chrish

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

Modified: olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext
URL: http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext?rev=1703527&r1=1703526&r2=1703527&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext (original)
+++ olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext Thu Sep 17 08:45:16 2015
@@ -173,29 +173,42 @@ Here’s the full implementation of t
             return requestedEntity;
          }
 
-        /* HELPER */
-
-        private void initSampleData(){
-
-            // add some sample product entities
-            productList.add(new Entity()
-                 .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1))
-                 .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"))
-                 .addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB")));
-
-            productList.add(new Entity()
-                .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2))
-                .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"))
-                .addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network")));
-
-            productList.add(new Entity()
-                .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3))
-                .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"))
-                .addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960")));
-
-         }
-    }
+         /* HELPER */
+         private void initSampleData(){
 
+             // add some sample product entities
+             final Entity e1 = new Entity()
+                                   .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1))
+                                   .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"))
+                                   .addProperty(new Property(null, "Description", ValueType.PRIMITIVE,
+                                                "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB"));
+            e1.setId(createId("Products", 1));
+            productList.add(e1);
+
+            final Entity e2 = new Entity()
+                                  .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2))
+                                  .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"))
+                                  .addProperty(new Property(null, "Description", ValueType.PRIMITIVE,
+                                               "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network"));
+            e2.setId(createId("Products", 1));
+            productList.add(e2);
+
+            final Entity e3 = new Entity()
+                                  .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3))
+                                  .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"))
+                                  .addProperty(new Property(null, "Description", ValueType.PRIMITIVE,
+						"19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960"));
+            e3.setId(createId("Products", 1));
+            productList.add(e3);
+        }
+
+        private URI createId(String entitySetName, Object id) {
+            try {
+                return new URI(entitySetName + "(" + String.valueOf(id) + ")");
+            } catch (URISyntaxException e) {
+                throw new ODataRuntimeException("Unable to create id for entity: " + entitySetName, e);
+            }
+        }
 
 
 The *Public Façade* contains the methods that are called from outside.