OLINGO-483: Possible patch for mentioned Jira issue; needs review
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/599fbc3d Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/599fbc3d Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/599fbc3d Branch: refs/heads/Olingo-129_PocJpaDataStore Commit: 599fbc3db76e73a5b01ff2fd5d1df95f0856e034 Parents: 5b30979 Author: Giacomo Pati <[email protected]> Authored: Thu Nov 20 16:59:06 2014 +0100 Committer: Chandan V A <[email protected]> Committed: Sat Dec 6 13:17:33 2014 +0530 ---------------------------------------------------------------------- .../core/callback/JPAExpandCallBack.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/599fbc3d/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/callback/JPAExpandCallBack.java ---------------------------------------------------------------------- diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/callback/JPAExpandCallBack.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/callback/JPAExpandCallBack.java index 41cad61..861a399 100644 --- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/callback/JPAExpandCallBack.java +++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/callback/JPAExpandCallBack.java @@ -80,10 +80,10 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten navigationLinks = context.getCurrentExpandSelectTreeNode().getLinks(); if (navigationLinks.size() > 0) { currentNavPropertyList = new ArrayList<EdmNavigationProperty>(); - EdmNavigationProperty nextNavProperty = - getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty()); + List<EdmNavigationProperty> nextNavProperty = + getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty()); if (nextNavProperty != null) { - currentNavPropertyList.add(nextNavProperty); + currentNavPropertyList.addAll(nextNavProperty); } HashMap<String, Object> navigationMap = jpaResultParser.parse2EdmNavigationValueMap(inlinedEntry, currentNavPropertyList); @@ -160,10 +160,10 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten if (currentExpandTreeNode.getLinks().size() > 0) { currentNavPropertyList = new ArrayList<EdmNavigationProperty>(); - EdmNavigationProperty nextNavProperty = + List<EdmNavigationProperty> nextNavPropertyList = getNextNavigationProperty(context.getSourceEntitySet().getEntityType(), context.getNavigationProperty()); - if (nextNavProperty != null) { - currentNavPropertyList.add(nextNavProperty); + if (nextNavPropertyList != null) { + currentNavPropertyList.addAll(nextNavPropertyList); } int count = 0; for (Object object : listOfItems) { @@ -183,8 +183,9 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten return result; } - private EdmNavigationProperty getNextNavigationProperty(final EdmEntityType sourceEntityType, + private List<EdmNavigationProperty> getNextNavigationProperty(final EdmEntityType sourceEntityType, final EdmNavigationProperty navigationProperty) throws EdmException { + final List<EdmNavigationProperty> edmNavigationPropertyList = new ArrayList<EdmNavigationProperty>(); for (ArrayList<NavigationPropertySegment> navPropSegments : expandList) { int size = navPropSegments.size(); for (int i = 0; i < size; i++) { @@ -192,12 +193,12 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten if (navProperty.getFromRole().equalsIgnoreCase(sourceEntityType.getName()) && navProperty.getName().equals(navigationProperty.getName())) { if (i < size - 1) { - return navPropSegments.get(i + 1).getNavigationProperty(); + edmNavigationPropertyList.add(navPropSegments.get(i + 1).getNavigationProperty()); } } } } - return null; + return edmNavigationPropertyList; } public static <T> Map<String, ODataCallback> getCallbacks(final URI baseUri,
