You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by de...@apache.org on 2014/01/31 06:02:45 UTC

svn commit: r1563060 - /incubator/olingo/site/trunk/content/doc/tutorials/ExtendingtheEDM.mdtext

Author: deepa
Date: Fri Jan 31 05:02:45 2014
New Revision: 1563060

URL: http://svn.apache.org/r1563060
Log:
CMS commit to olingo by deepa

Added:
    incubator/olingo/site/trunk/content/doc/tutorials/ExtendingtheEDM.mdtext   (with props)

Added: incubator/olingo/site/trunk/content/doc/tutorials/ExtendingtheEDM.mdtext
URL: http://svn.apache.org/viewvc/incubator/olingo/site/trunk/content/doc/tutorials/ExtendingtheEDM.mdtext?rev=1563060&view=auto
==============================================================================
--- incubator/olingo/site/trunk/content/doc/tutorials/ExtendingtheEDM.mdtext (added)
+++ incubator/olingo/site/trunk/content/doc/tutorials/ExtendingtheEDM.mdtext Fri Jan 31 05:02:45 2014
@@ -0,0 +1,83 @@
+Title:
+Notice:    Licensed to the Apache Software Foundation (ASF) under one
+           or more contributor license agreements.  See the NOTICE file
+           distributed with this work for additional information
+           regarding copyright ownership.  The ASF licenses this file
+           to you under the Apache License, Version 2.0 (the
+           "License"); you may not use this file except in compliance
+           with the License.  You may obtain a copy of the License at
+           .
+             http://www.apache.org/licenses/LICENSE-2.0
+           .
+           Unless required by applicable law or agreed to in writing,
+           software distributed under the License is distributed on an
+           "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+           KIND, either express or implied.  See the License for the
+           specific language governing permissions and limitations
+           under the License.
+
+# Extending the EDM Generated from the JPA Models 
+
+The Entity Data Model (EDM) generated from the JPA models can be extended with new Entity Types, Complex Types and also the existing EDM elements can be modified by implementing the interface method ***org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmExtension.extendJPAEdmSchemaP***.
+
+https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=ecdc476
+
+#### How to Add a Complex Type to an EDM
+
+Consider a scenario where we have a Plain Old Java Object (POJO) in the OrderValue Java class and let us try to transform this POJO into a Complex Type in the EDM <>. SalesOrderProcessingExtension implements the JPAEdmExtension 
+
+###### POJO in OrderValue Java Class
+
+public class OrderValue
+{
+
+private double amount;
+private String currency;
+
+public double getAmount() 
+
+{ return amount; } 
+public void setAmount(double amount) 
+
+{ this.amount = amount; } 
+public String getCurrency() 
+
+{ return currency; } 
+public void setCurrency(String currency) 
+
+{ this.currency = currency; } 
+
+}
+
+
+##### Sample Code
+                
+                @Override
+		public void extendJPAEdmSchema(final JPAEdmSchemaView view) {
+		  Schema edmSchema = view.getEdmSchema();
+		  edmSchema.getComplexTypes().add(getComplexType());
+		}
+ 
+		private ComplexType getComplexType() {
+		  ComplexType complexType = new ComplexType();
+     
+		  List<Property> properties = new ArrayList<Property>();
+		  SimpleProperty property = new SimpleProperty();
+     
+		  property.setName("Amount");
+		  property.setType(EdmSimpleTypeKind.Double);
+		  properties.add(property);
+     
+		  property = new SimpleProperty();
+		  property.setName("Currency");
+		  property.setType(EdmSimpleTypeKind.String);
+		  properties.add(property);
+    
+		  complexType.setName("OrderValue");
+		  complexType.setProperties(properties);
+    
+		  return complexType;
+     
+		}
+
+The Complex Type added to the EDM can be used as Function Imports Return Type. See <> for more information.
\ No newline at end of file

Propchange: incubator/olingo/site/trunk/content/doc/tutorials/ExtendingtheEDM.mdtext
------------------------------------------------------------------------------
    svn:eol-style = native