Repository: olingo-odata2 Updated Branches: refs/heads/master 13cfd0a50 -> 09c0c743a
[OLINGO-837] getNextNavigationProperty fix Signed-off-by: mibo <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/1dd8850a Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/1dd8850a Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/1dd8850a Branch: refs/heads/master Commit: 1dd8850ae21723e10bf8377373d8df40f026f434 Parents: 13cfd0a Author: tothgya <[email protected]> Authored: Tue Dec 15 14:31:04 2015 +0100 Committer: mibo <[email protected]> Committed: Fri Jan 22 07:31:22 2016 +0100 ---------------------------------------------------------------------- .../core/callback/JPAExpandCallBack.java | 23 ++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/1dd8850a/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 0ebc5eb..9940281 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 @@ -19,6 +19,8 @@ package org.apache.olingo.odata2.jpa.processor.core.callback; import java.net.URI; +import java.text.NumberFormat; +import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -190,8 +192,7 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten int size = navPropSegments.size(); for (int i = 0; i < size; i++) { EdmNavigationProperty navProperty = navPropSegments.get(i).getNavigationProperty(); - if (navProperty.getFromRole().equalsIgnoreCase(sourceEntityType.getName()) - && navProperty.getName().equals(navigationProperty.getName())) { + if (testNavPropertySegment(navProperty, sourceEntityType, navigationProperty)) { if (i < size - 1) { edmNavigationPropertyList.add(navPropSegments.get(i + 1).getNavigationProperty()); } @@ -201,6 +202,24 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten return edmNavigationPropertyList; } + private static boolean testNavPropertySegment( + final EdmNavigationProperty navProperty, + final EdmEntityType sourceEntityType, + final EdmNavigationProperty navigationProperty) throws EdmException { + if(navigationProperty.getFromRole().toLowerCase().startsWith(sourceEntityType.getName().toLowerCase())) { + final String roleNum = + navigationProperty.getFromRole().substring(sourceEntityType.getName().length()); + if(roleNum.length() > 0) { + try { + NumberFormat.getInstance().parse(roleNum); + } catch (ParseException e) { + return false; + } + } + } + return navProperty.getName().equals(navigationProperty.getName()); + } + public static <T> Map<String, ODataCallback> getCallbacks(final URI baseUri, final ExpandSelectTreeNode expandSelectTreeNode, final List<ArrayList<NavigationPropertySegment>> expandList) throws EdmException {
