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/06/30 14:52:10 UTC

olingo-odata2 git commit: [OLINGO-719] Support complex types in $orderby expression

Repository: olingo-odata2
Updated Branches:
  refs/heads/master 0f08913bd -> dd0625e3f


[OLINGO-719] Support complex types in $orderby expression

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/dd0625e3
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/dd0625e3
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/dd0625e3

Branch: refs/heads/master
Commit: dd0625e3ff71d920987452bccb77190eb574c77a
Parents: 0f08913
Author: Chandan V A <ch...@sap.com>
Authored: Tue Jun 30 18:22:03 2015 +0530
Committer: Chandan V A <ch...@sap.com>
Committed: Tue Jun 30 18:22:03 2015 +0530

----------------------------------------------------------------------
 .../odata2/jpa/processor/core/ODataExpressionParser.java | 11 ++++++++---
 .../processor/core/jpql/JPQLSelectContextImplTest.java   |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd0625e3/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataExpressionParser.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataExpressionParser.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataExpressionParser.java
index 9b64333..e733337 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataExpressionParser.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataExpressionParser.java
@@ -277,13 +277,18 @@ public class ODataExpressionParser {
       for (OrderExpression orderBy : orderBys) {
 
         try {
-          orderByField = getPropertyName(orderBy.getExpression());
+          if (orderBy.getExpression().getKind() == ExpressionKind.MEMBER) {
+            orderByField = parseToJPAWhereExpression(orderBy.getExpression(), tableAlias);
+          } else {
+            orderByField = tableAlias + JPQLStatement.DELIMITER.PERIOD + getPropertyName(orderBy.getExpression());
+          }
           orderByDirection = (orderBy.getSortOrder() == SortOrder.asc) ? EMPTY :
               JPQLStatement.DELIMITER.SPACE + "DESC"; //$NON-NLS-1$
-          jpqlOrderByExpression +=
-              tableAlias + JPQLStatement.DELIMITER.PERIOD + orderByField + orderByDirection + " , ";
+          jpqlOrderByExpression += orderByField + orderByDirection + " , ";
         } catch (EdmException e) {
           throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
+        } catch (ODataException e) {
+          throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/dd0625e3/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/jpql/JPQLSelectContextImplTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/jpql/JPQLSelectContextImplTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/jpql/JPQLSelectContextImplTest.java
index 2f81bf4..7463feb 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/jpql/JPQLSelectContextImplTest.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/jpql/JPQLSelectContextImplTest.java
@@ -104,6 +104,7 @@ public class JPQLSelectContextImplTest {
       }
 
       PropertyExpression commonExpression = EasyMock.createMock(PropertyExpression.class);
+      EasyMock.expect(commonExpression.getKind()).andReturn(ExpressionKind.PROPERTY).anyTimes();
       EasyMock.expect(commonExpression.getEdmType()).andStubReturn(edmType);
 
       EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);