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 2014/09/20 11:02:39 UTC

git commit: [OLINGO-433] Enhance Mapping logic for Foreign Key Columns

Repository: olingo-odata2
Updated Branches:
  refs/heads/master fe1b1c97f -> fc8c4ff9e


[OLINGO-433] Enhance Mapping logic for Foreign Key Columns


Signed-off-by: Chandan V A <ch...@sap.com>

Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/fc8c4ff9
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/fc8c4ff9
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/fc8c4ff9

Branch: refs/heads/master
Commit: fc8c4ff9ed266a778f682065f87328b1f43a43c8
Parents: fe1b1c9
Author: Chandan V A <ch...@sap.com>
Authored: Sat Sep 20 14:32:31 2014 +0530
Committer: Chandan V A <ch...@sap.com>
Committed: Sat Sep 20 14:32:31 2014 +0530

----------------------------------------------------------------------
 .../jpa/processor/core/access/model/JPAEdmNameBuilder.java     | 6 +++++-
 .../jpa/processor/ref/extension/SalesOrderHeaderProcessor.java | 2 +-
 .../src/main/webapp/SalesOrderProcessingMappingModel.xml       | 3 ++-
 3 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fc8c4ff9/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmNameBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmNameBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmNameBuilder.java
index 75878e6..edd4bb9 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmNameBuilder.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/model/JPAEdmNameBuilder.java
@@ -148,7 +148,11 @@ public class JPAEdmNameBuilder {
       propertyName = jpaAttributeName;
       if (isForeignKey == true) {
         joinColumnNames = view.getJPAJoinColumns().get(view.getJPAJoinColumns().size() - 1);
-        propertyName = FK_PREFIX + UNDERSCORE + joinColumnNames[0];
+        propertyName = mappingModelAccess.mapJPAAttribute(view.getJPAEdmEntityTypeView().getJPAEntityType().getName(), 
+            joinColumnNames[0]);
+        if (propertyName == null) {
+          propertyName = FK_PREFIX + UNDERSCORE + joinColumnNames[0];
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fc8c4ff9/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
index 5dc9017..9a34473 100644
--- a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
+++ b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/extension/SalesOrderHeaderProcessor.java
@@ -71,7 +71,7 @@ public class SalesOrderHeaderProcessor {
     }
   }
 
-  @EdmFunctionImport(returnType = @ReturnType(type = Type.ENTITY, isCollection = true), entitySet = "SalesOrders")
+  @EdmFunctionImport(returnType = @ReturnType(type = Type.ENTITY, isCollection = false), entitySet = "SalesOrders")
   public SalesOrderHeader calculateNetAmount(
       @EdmFunctionImportParameter(name = "SoID", facets = @EdmFacets(nullable = false)) final Long soID)
       throws ODataException {

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/fc8c4ff9/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml b/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
index cba7813..2d7f7c7 100644
--- a/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
+++ b/odata2-jpa-processor/jpa-web/src/main/webapp/SalesOrderProcessingMappingModel.xml
@@ -32,7 +32,8 @@
 				<EDMEntitySet>SalesOrderLineItems</EDMEntitySet>
 				<JPAAttributes>
 					<JPAAttribute name="liId">ID</JPAAttribute>
-					<JPAAttribute name="soId">SalesOrderID</JPAAttribute>
+					<JPAAttribute name="soId">SalesOrderID</JPAAttribute>
+					<JPAAttribute name="Material_Id">mID</JPAAttribute>
 				</JPAAttributes>
 				<JPARelationships>
 					<JPARelationship name="salesOrderHeader">SalesOrderHeaderDetails</JPARelationship>