You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2016/08/28 06:54:16 UTC

[1/5] olingo-odata2 git commit: [OLINGO-414] Fixed filter for to one navigation

Repository: olingo-odata2
Updated Branches:
  refs/heads/master 6bc60b47f -> cd4810b9b


[OLINGO-414] Fixed filter for to one navigation


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

Branch: refs/heads/master
Commit: 67d646dca0a4f1ebc82620ac09353ade329be7cd
Parents: 5974655
Author: mibo <mi...@apache.org>
Authored: Sat Jun 18 07:29:23 2016 +0200
Committer: mibo <mi...@apache.org>
Committed: Sat Jun 18 07:29:23 2016 +0200

----------------------------------------------------------------------
 .../annotation-processor-api/pom.xml            |  2 +-
 .../annotation-processor-core/pom.xml           |  2 +-
 .../annotation-processor-ref/pom.xml            |  2 +-
 .../annotation-processor-web/pom.xml            |  2 +-
 odata2-annotation-processor/pom.xml             |  2 +-
 odata2-dist/janos/pom.xml                       |  2 +-
 odata2-dist/javadoc/pom.xml                     |  2 +-
 odata2-dist/jpa/pom.xml                         |  2 +-
 odata2-dist/lib/pom.xml                         |  2 +-
 odata2-dist/pom.xml                             |  2 +-
 odata2-dist/ref/pom.xml                         |  2 +-
 odata2-jpa-processor/jpa-api/pom.xml            |  2 +-
 odata2-jpa-processor/jpa-core/pom.xml           |  2 +-
 .../processor/core/ODataExpressionParser.java   | 52 +++++++-------------
 odata2-jpa-processor/jpa-ref/pom.xml            |  2 +-
 odata2-jpa-processor/jpa-web/pom.xml            |  2 +-
 odata2-jpa-processor/pom.xml                    |  2 +-
 odata2-lib/odata-annotation/pom.xml             |  2 +-
 odata2-lib/odata-api/pom.xml                    |  2 +-
 odata2-lib/odata-core/pom.xml                   |  2 +-
 odata2-lib/odata-fit/pom.xml                    |  2 +-
 odata2-lib/odata-ref/pom.xml                    |  2 +-
 odata2-lib/odata-testutil/pom.xml               |  2 +-
 odata2-lib/odata-web/pom.xml                    |  2 +-
 odata2-lib/pom.xml                              |  2 +-
 odata2-sample/cars-annotation-archetype/pom.xml |  4 +-
 .../main/resources/archetype-resources/pom.xml  |  2 +-
 odata2-sample/cars-jpa-archetype/pom.xml        |  2 +-
 .../main/resources/archetype-resources/pom.xml  |  2 +-
 odata2-sample/cars-service-archetype/pom.xml    |  4 +-
 .../main/resources/archetype-resources/pom.xml  |  2 +-
 odata2-sample/pom.xml                           |  2 +-
 odata2-spring/pom.xml                           |  2 +-
 pom.xml                                         |  2 +-
 34 files changed, 52 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-annotation-processor/annotation-processor-api/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-api/pom.xml b/odata2-annotation-processor/annotation-processor-api/pom.xml
index 8e671ab..f181005 100644
--- a/odata2-annotation-processor/annotation-processor-api/pom.xml
+++ b/odata2-annotation-processor/annotation-processor-api/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.olingo</groupId>
     <artifactId>olingo-odata2-annotation-processor</artifactId>
-    <version>2.0.7-RC01</version>
+    <version>2.0.8-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-annotation-processor/annotation-processor-core/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-core/pom.xml b/odata2-annotation-processor/annotation-processor-core/pom.xml
index 9aa5e1e..3ea6fe1 100644
--- a/odata2-annotation-processor/annotation-processor-core/pom.xml
+++ b/odata2-annotation-processor/annotation-processor-core/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.olingo</groupId>
     <artifactId>olingo-odata2-annotation-processor</artifactId>
-    <version>2.0.7-RC01</version>
+    <version>2.0.8-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-annotation-processor/annotation-processor-ref/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-ref/pom.xml b/odata2-annotation-processor/annotation-processor-ref/pom.xml
index c81a6f7..92dc985 100644
--- a/odata2-annotation-processor/annotation-processor-ref/pom.xml
+++ b/odata2-annotation-processor/annotation-processor-ref/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.olingo</groupId>
     <artifactId>olingo-odata2-annotation-processor</artifactId>
-    <version>2.0.7-RC01</version>
+    <version>2.0.8-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-annotation-processor/annotation-processor-web/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-web/pom.xml b/odata2-annotation-processor/annotation-processor-web/pom.xml
index bf7eac7..d3ebeb7 100644
--- a/odata2-annotation-processor/annotation-processor-web/pom.xml
+++ b/odata2-annotation-processor/annotation-processor-web/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.olingo</groupId>
     <artifactId>olingo-odata2-annotation-processor</artifactId>
-    <version>2.0.7-RC01</version>
+    <version>2.0.8-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-annotation-processor/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/pom.xml b/odata2-annotation-processor/pom.xml
index 19a913f..21bf5d2 100644
--- a/odata2-annotation-processor/pom.xml
+++ b/odata2-annotation-processor/pom.xml
@@ -18,7 +18,7 @@
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-parent</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-dist/janos/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-dist/janos/pom.xml b/odata2-dist/janos/pom.xml
index afc43bc..f5630e2 100644
--- a/odata2-dist/janos/pom.xml
+++ b/odata2-dist/janos/pom.xml
@@ -17,7 +17,7 @@
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-dist</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-dist/javadoc/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-dist/javadoc/pom.xml b/odata2-dist/javadoc/pom.xml
index d727712..03ec5d6 100644
--- a/odata2-dist/javadoc/pom.xml
+++ b/odata2-dist/javadoc/pom.xml
@@ -17,7 +17,7 @@
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-dist</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-dist/jpa/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-dist/jpa/pom.xml b/odata2-dist/jpa/pom.xml
index c1d60a0..ad634cd 100644
--- a/odata2-dist/jpa/pom.xml
+++ b/odata2-dist/jpa/pom.xml
@@ -17,7 +17,7 @@
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-dist</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-dist/lib/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-dist/lib/pom.xml b/odata2-dist/lib/pom.xml
index d24df72..1d692a8 100644
--- a/odata2-dist/lib/pom.xml
+++ b/odata2-dist/lib/pom.xml
@@ -17,7 +17,7 @@
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-dist</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-dist/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-dist/pom.xml b/odata2-dist/pom.xml
index 19af37b..a4b9525 100644
--- a/odata2-dist/pom.xml
+++ b/odata2-dist/pom.xml
@@ -17,7 +17,7 @@
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-parent</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-dist/ref/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-dist/ref/pom.xml b/odata2-dist/ref/pom.xml
index 5b877e6..916fc47 100644
--- a/odata2-dist/ref/pom.xml
+++ b/odata2-dist/ref/pom.xml
@@ -17,7 +17,7 @@
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-dist</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-jpa-processor/jpa-api/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/pom.xml b/odata2-jpa-processor/jpa-api/pom.xml
index 7f791f5..e364f10 100644
--- a/odata2-jpa-processor/jpa-api/pom.xml
+++ b/odata2-jpa-processor/jpa-api/pom.xml
@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>org.apache.olingo</groupId>
 		<artifactId>olingo-odata2-jpa-processor</artifactId>
-		<version>2.0.7-RC01</version>
+		<version>2.0.8-SNAPSHOT</version>
 		<relativePath>../</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-jpa-processor/jpa-core/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/pom.xml b/odata2-jpa-processor/jpa-core/pom.xml
index 5daf3e1..663a631 100644
--- a/odata2-jpa-processor/jpa-core/pom.xml
+++ b/odata2-jpa-processor/jpa-core/pom.xml
@@ -24,7 +24,7 @@
 	<parent>
 		<groupId>org.apache.olingo</groupId>
 		<artifactId>olingo-odata2-jpa-processor</artifactId>
-		<version>2.0.7-RC01</version>
+		<version>2.0.8-SNAPSHOT</version>
 		<relativePath>../</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/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 79905ce..0f4b7ca 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
@@ -18,41 +18,19 @@
  ******************************************************************************/
 package org.apache.olingo.odata2.jpa.processor.core;
 
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmLiteral;
-import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
-import org.apache.olingo.odata2.api.edm.EdmMapping;
-import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleType;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.edm.EdmTyped;
+import org.apache.olingo.odata2.api.edm.*;
 import org.apache.olingo.odata2.api.exception.ODataException;
 import org.apache.olingo.odata2.api.exception.ODataNotImplementedException;
 import org.apache.olingo.odata2.api.uri.KeyPredicate;
-import org.apache.olingo.odata2.api.uri.expression.BinaryExpression;
-import org.apache.olingo.odata2.api.uri.expression.BinaryOperator;
-import org.apache.olingo.odata2.api.uri.expression.CommonExpression;
-import org.apache.olingo.odata2.api.uri.expression.ExpressionKind;
-import org.apache.olingo.odata2.api.uri.expression.FilterExpression;
-import org.apache.olingo.odata2.api.uri.expression.LiteralExpression;
-import org.apache.olingo.odata2.api.uri.expression.MemberExpression;
-import org.apache.olingo.odata2.api.uri.expression.MethodExpression;
-import org.apache.olingo.odata2.api.uri.expression.MethodOperator;
-import org.apache.olingo.odata2.api.uri.expression.OrderByExpression;
-import org.apache.olingo.odata2.api.uri.expression.OrderExpression;
-import org.apache.olingo.odata2.api.uri.expression.PropertyExpression;
-import org.apache.olingo.odata2.api.uri.expression.SortOrder;
-import org.apache.olingo.odata2.api.uri.expression.UnaryExpression;
+import org.apache.olingo.odata2.api.uri.expression.*;
 import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException;
 import org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement;
 
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  * This class contains utility methods for parsing the filter expressions built by core library from user OData Query.
  *
@@ -441,14 +419,18 @@ public class ODataExpressionParser {
 
   private static String getPropertyName(final CommonExpression whereExpression) throws EdmException,
       ODataJPARuntimeException {
-    EdmTyped edmProperty  = ((PropertyExpression) whereExpression).getEdmProperty();
+    EdmTyped edmProperty = ((PropertyExpression) whereExpression).getEdmProperty();
+    EdmMapping mapping;
     if (edmProperty instanceof EdmNavigationProperty) {
-      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.FILTER_ON_NAVIGATION_NOT_SUPPORTED, null);
+      EdmNavigationProperty edmNavigationProperty = (EdmNavigationProperty) edmProperty;
+      mapping = edmNavigationProperty.getMapping();
+    } else if(edmProperty instanceof EdmProperty) {
+      EdmProperty property = (EdmProperty) edmProperty;
+      mapping = property.getMapping();
+    } else {
+      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, null);
     }
 
-    EdmProperty property = ((EdmProperty) edmProperty);
-    EdmMapping mapping = property.getMapping();
-    String name = mapping != null ? mapping.getInternalName() : property.getName();
-    return name;
+    return mapping != null ? mapping.getInternalName() : edmProperty.getName();
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-jpa-processor/jpa-ref/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-ref/pom.xml b/odata2-jpa-processor/jpa-ref/pom.xml
index 1dbf32d..c94ce49 100644
--- a/odata2-jpa-processor/jpa-ref/pom.xml
+++ b/odata2-jpa-processor/jpa-ref/pom.xml
@@ -17,7 +17,7 @@
 	<parent>
 		<groupId>org.apache.olingo</groupId>
 		<artifactId>olingo-odata2-jpa-processor</artifactId>
-		<version>2.0.7-RC01</version>
+		<version>2.0.8-SNAPSHOT</version>
 		<relativePath>..</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-jpa-processor/jpa-web/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/pom.xml b/odata2-jpa-processor/jpa-web/pom.xml
index 342d3a3..3aa5e69 100644
--- a/odata2-jpa-processor/jpa-web/pom.xml
+++ b/odata2-jpa-processor/jpa-web/pom.xml
@@ -21,7 +21,7 @@
 	<parent>
 		<groupId>org.apache.olingo</groupId>
 		<artifactId>olingo-odata2-jpa-processor</artifactId>
-		<version>2.0.7-RC01</version>
+		<version>2.0.8-SNAPSHOT</version>
 		<relativePath>..</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-jpa-processor/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/pom.xml b/odata2-jpa-processor/pom.xml
index 92b1d24..2873e26 100644
--- a/odata2-jpa-processor/pom.xml
+++ b/odata2-jpa-processor/pom.xml
@@ -18,7 +18,7 @@
     <parent>
       <groupId>org.apache.olingo</groupId>
       <artifactId>olingo-odata2-parent</artifactId>
-      <version>2.0.7-RC01</version>
+      <version>2.0.8-SNAPSHOT</version>
       <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-lib/odata-annotation/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-annotation/pom.xml b/odata2-lib/odata-annotation/pom.xml
index 8ffd567..c8a65e6 100644
--- a/odata2-lib/odata-annotation/pom.xml
+++ b/odata2-lib/odata-annotation/pom.xml
@@ -17,7 +17,7 @@
   <parent>
     <groupId>org.apache.olingo</groupId>
     <artifactId>olingo-odata2-lib</artifactId>
-    <version>2.0.7-RC01</version>
+    <version>2.0.8-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-lib/odata-api/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-api/pom.xml b/odata2-lib/odata-api/pom.xml
index 4d07455..7993a75 100644
--- a/odata2-lib/odata-api/pom.xml
+++ b/odata2-lib/odata-api/pom.xml
@@ -28,7 +28,7 @@
 	<parent>
 		<groupId>org.apache.olingo</groupId>
 		<artifactId>olingo-odata2-lib</artifactId>
-    <version>2.0.7-RC01</version>
+    <version>2.0.8-SNAPSHOT</version>
 		<relativePath>..</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-lib/odata-core/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/pom.xml b/odata2-lib/odata-core/pom.xml
index f5470e7..aa22e95 100644
--- a/odata2-lib/odata-core/pom.xml
+++ b/odata2-lib/odata-core/pom.xml
@@ -28,7 +28,7 @@
 	<parent>
 		<groupId>org.apache.olingo</groupId>
 		<artifactId>olingo-odata2-lib</artifactId>
-		<version>2.0.7-RC01</version>
+		<version>2.0.8-SNAPSHOT</version>
 		<relativePath>..</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-lib/odata-fit/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-fit/pom.xml b/odata2-lib/odata-fit/pom.xml
index 5af96b8..f4174d1 100644
--- a/odata2-lib/odata-fit/pom.xml
+++ b/odata2-lib/odata-fit/pom.xml
@@ -28,7 +28,7 @@
 	<parent>
 		<groupId>org.apache.olingo</groupId>
 		<artifactId>olingo-odata2-lib</artifactId>
-		<version>2.0.7-RC01</version>
+		<version>2.0.8-SNAPSHOT</version>
 		<relativePath>..</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-lib/odata-ref/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-ref/pom.xml b/odata2-lib/odata-ref/pom.xml
index 75efa52..2442b7e 100644
--- a/odata2-lib/odata-ref/pom.xml
+++ b/odata2-lib/odata-ref/pom.xml
@@ -28,7 +28,7 @@
 	<parent>
 		<groupId>org.apache.olingo</groupId>
 		<artifactId>olingo-odata2-lib</artifactId>
-		<version>2.0.7-RC01</version>
+		<version>2.0.8-SNAPSHOT</version>
 		<relativePath>..</relativePath>
 	</parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-lib/odata-testutil/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-testutil/pom.xml b/odata2-lib/odata-testutil/pom.xml
index 7fef62b..49f4660 100644
--- a/odata2-lib/odata-testutil/pom.xml
+++ b/odata2-lib/odata-testutil/pom.xml
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.olingo</groupId>
     <artifactId>olingo-odata2-lib</artifactId>
-    <version>2.0.7-RC01</version>
+    <version>2.0.8-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-lib/odata-web/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-web/pom.xml b/odata2-lib/odata-web/pom.xml
index e2bc4f2..fb0bec1 100644
--- a/odata2-lib/odata-web/pom.xml
+++ b/odata2-lib/odata-web/pom.xml
@@ -17,7 +17,7 @@
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-lib</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-lib/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/pom.xml b/odata2-lib/pom.xml
index 01239d1..32161f5 100644
--- a/odata2-lib/pom.xml
+++ b/odata2-lib/pom.xml
@@ -18,7 +18,7 @@
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-parent</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-sample/cars-annotation-archetype/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-sample/cars-annotation-archetype/pom.xml b/odata2-sample/cars-annotation-archetype/pom.xml
index 3a72029..4c91fda 100644
--- a/odata2-sample/cars-annotation-archetype/pom.xml
+++ b/odata2-sample/cars-annotation-archetype/pom.xml
@@ -16,13 +16,13 @@
   <groupId>org.apache.olingo</groupId>
   <artifactId>olingo-odata2-sample-cars-annotation-archetype</artifactId>
   <name>${project.artifactId}</name>
-  <version>2.0.7-RC01</version>
+  <version>2.0.8-SNAPSHOT</version>
   <packaging>maven-archetype</packaging>
 
   <parent>
     <groupId>org.apache.olingo</groupId>
     <artifactId>olingo-odata2-sample</artifactId>
-    <version>2.0.7-RC01</version>
+    <version>2.0.8-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-sample/cars-annotation-archetype/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-sample/cars-annotation-archetype/src/main/resources/archetype-resources/pom.xml b/odata2-sample/cars-annotation-archetype/src/main/resources/archetype-resources/pom.xml
index 065fc19..541c03e 100644
--- a/odata2-sample/cars-annotation-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/odata2-sample/cars-annotation-archetype/src/main/resources/archetype-resources/pom.xml
@@ -32,7 +32,7 @@
     <version.servlet-api>2.5</version.servlet-api>
     <version.jaxrs-api>2.0-m10</version.jaxrs-api>
     <version.slf4j>1.7.1</version.slf4j>
-    <version.olingo>2.0.7-RC01</version.olingo>
+    <version.olingo>2.0.8-SNAPSHOT</version.olingo>
   </properties>
 
   <build>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-sample/cars-jpa-archetype/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-sample/cars-jpa-archetype/pom.xml b/odata2-sample/cars-jpa-archetype/pom.xml
index 1d2379c..9eb7644 100644
--- a/odata2-sample/cars-jpa-archetype/pom.xml
+++ b/odata2-sample/cars-jpa-archetype/pom.xml
@@ -23,7 +23,7 @@
 	<parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-sample</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 	

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-sample/cars-jpa-archetype/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-sample/cars-jpa-archetype/src/main/resources/archetype-resources/pom.xml b/odata2-sample/cars-jpa-archetype/src/main/resources/archetype-resources/pom.xml
index 66fe249..4f651df 100644
--- a/odata2-sample/cars-jpa-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/odata2-sample/cars-jpa-archetype/src/main/resources/archetype-resources/pom.xml
@@ -23,7 +23,7 @@
 		<version.eclipselink>2.5.1</version.eclipselink>
 		<version.javax.persistence>2.0.5</version.javax.persistence>
 		<version.hsqldb>2.3.2</version.hsqldb>
-		<version.olingo>2.0.7-RC01</version.olingo>
+		<version.olingo>2.0.8-SNAPSHOT</version.olingo>
 	</properties>
 
 	<dependencies>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-sample/cars-service-archetype/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-sample/cars-service-archetype/pom.xml b/odata2-sample/cars-service-archetype/pom.xml
index c154b49..05ee1ff 100644
--- a/odata2-sample/cars-service-archetype/pom.xml
+++ b/odata2-sample/cars-service-archetype/pom.xml
@@ -24,14 +24,14 @@
     <groupId>org.apache.olingo</groupId>
     <artifactId>olingo-odata2-sample-cars-service-archetype</artifactId>
     <name>${project.artifactId}</name>
-    <version>2.0.7-RC01</version>
+    <version>2.0.8-SNAPSHOT</version>
 
     <packaging>maven-archetype</packaging>
 
     <parent>
         <groupId>org.apache.olingo</groupId>
         <artifactId>olingo-odata2-sample</artifactId>
-        <version>2.0.7-RC01</version>
+        <version>2.0.8-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-sample/cars-service-archetype/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-sample/cars-service-archetype/src/main/resources/archetype-resources/pom.xml b/odata2-sample/cars-service-archetype/src/main/resources/archetype-resources/pom.xml
index 554ff43..afa621d 100644
--- a/odata2-sample/cars-service-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/odata2-sample/cars-service-archetype/src/main/resources/archetype-resources/pom.xml
@@ -20,7 +20,7 @@
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<version.cxf>2.7.6</version.cxf>
 		<version.slf4j>1.7.1</version.slf4j>
-		<version.olingo>2.0.7-RC01</version.olingo>
+		<version.olingo>2.0.8-SNAPSHOT</version.olingo>
 	</properties>
 
 	<build>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-sample/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-sample/pom.xml b/odata2-sample/pom.xml
index aca079a..db899a7 100644
--- a/odata2-sample/pom.xml
+++ b/odata2-sample/pom.xml
@@ -15,7 +15,7 @@
     <parent>
       <groupId>org.apache.olingo</groupId>
       <artifactId>olingo-odata2-parent</artifactId>
-      <version>2.0.7-RC01</version>
+      <version>2.0.8-SNAPSHOT</version>
       <relativePath>..</relativePath>
     </parent>
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/odata2-spring/pom.xml
----------------------------------------------------------------------
diff --git a/odata2-spring/pom.xml b/odata2-spring/pom.xml
index d0550b3..54bd4b1 100755
--- a/odata2-spring/pom.xml
+++ b/odata2-spring/pom.xml
@@ -18,7 +18,7 @@
 	<parent>
 		<groupId>org.apache.olingo</groupId>
 		<artifactId>olingo-odata2-parent</artifactId>
-		<version>2.0.7-SNAPSHOT</version>
+		<version>2.0.8-SNAPSHOT</version>
 	</parent>
 
 	<dependencies>

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/67d646dc/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0e39e39..dd58057 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
 
 	<groupId>org.apache.olingo</groupId>
 	<artifactId>olingo-odata2-parent</artifactId>
-	<version>2.0.7-RC01</version>
+	<version>2.0.8-SNAPSHOT</version>
 	<packaging>pom</packaging>
 
 	<name>${project.artifactId}</name>


[5/5] olingo-odata2 git commit: [OLINGO-1011] Added UUID generation to DataStore.KeyAccess.createKey.

Posted by mi...@apache.org.
[OLINGO-1011] Added UUID generation to DataStore.KeyAccess.createKey.

Signed-off-by: mibo <mi...@apache.org>


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

Branch: refs/heads/master
Commit: cd4810b9b8bcd542c4ece8656cab580421152404
Parents: 07984dc
Author: Michael Strasser <mi...@michaelstrasser.com>
Authored: Thu Aug 25 20:48:47 2016 +1000
Committer: mibo <mi...@apache.org>
Committed: Sun Aug 28 08:53:40 2016 +0200

----------------------------------------------------------------------
 .../processor/core/datasource/DataStore.java    |  3 ++
 .../datasource/AnnotationsInMemoryDsTest.java   | 35 ++++++++++++
 .../processor/core/model/GuidKeyEntity.java     | 56 ++++++++++++++++++++
 3 files changed, 94 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cd4810b9/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/annotation/processor/core/datasource/DataStore.java
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/annotation/processor/core/datasource/DataStore.java b/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/annotation/processor/core/datasource/DataStore.java
index c03a557..98f86f1 100644
--- a/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/annotation/processor/core/datasource/DataStore.java
+++ b/odata2-annotation-processor/annotation-processor-core/src/main/java/org/apache/olingo/odata2/annotation/processor/core/datasource/DataStore.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.olingo.odata2.annotation.processor.core.util.AnnotationHelper;
@@ -263,6 +264,8 @@ public class DataStore<T> {
         return Integer.valueOf(idCounter.getAndIncrement());
       } else if (type == Long.class || type == long.class) {
         return Long.valueOf(idCounter.getAndIncrement());
+      } else if (type == UUID.class) {
+        return UUID.randomUUID();
       }
 
       throw new UnsupportedOperationException("Automated key generation for type '" + type

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cd4810b9/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java b/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java
index 7b2ee4b..089b6d4 100644
--- a/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java
+++ b/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/datasource/AnnotationsInMemoryDsTest.java
@@ -24,6 +24,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -32,6 +33,7 @@ import org.apache.olingo.odata2.annotation.processor.core.edm.AnnotationEdmProvi
 import org.apache.olingo.odata2.annotation.processor.core.model.Building;
 import org.apache.olingo.odata2.annotation.processor.core.model.City;
 import org.apache.olingo.odata2.annotation.processor.core.model.Employee;
+import org.apache.olingo.odata2.annotation.processor.core.model.GuidKeyEntity;
 import org.apache.olingo.odata2.annotation.processor.core.model.Location;
 import org.apache.olingo.odata2.annotation.processor.core.model.Manager;
 import org.apache.olingo.odata2.annotation.processor.core.model.ModelSharedConstants;
@@ -686,6 +688,39 @@ public class AnnotationsInMemoryDsTest {
   }
 
   @Test
+  public void createGuidKeyEntity() throws Exception {
+    EdmEntitySet edmEntitySet = createMockedEdmEntitySet(GuidKeyEntity.GUID_KEY_ENTITIES);
+
+    final String entityName = "Entity name";
+    GuidKeyEntity testEntity = new GuidKeyEntity();
+    testEntity.setName(entityName);
+    datasource.createData(edmEntitySet, testEntity);
+
+    List entities = datasource.readData(edmEntitySet);
+    GuidKeyEntity readEntity = (GuidKeyEntity) entities.get(0);
+    Assert.assertEquals(entityName, readEntity.getName());
+  }
+
+  @Test
+  public void createGuidKeyEntityWithOwnKey() throws Exception {
+    EdmEntitySet edmEntitySet = createMockedEdmEntitySet(GuidKeyEntity.GUID_KEY_ENTITIES);
+
+    final UUID entityId = UUID.randomUUID();
+    final String entityName = "Entity name";
+    GuidKeyEntity testEntity = new GuidKeyEntity();
+    testEntity.setId(entityId);
+    testEntity.setName(entityName);
+    datasource.createData(edmEntitySet, testEntity);
+
+    Map<String, Object> keys = new HashMap<String, Object>();
+    keys.put("Id", entityId);
+
+    GuidKeyEntity readEntity = (GuidKeyEntity) datasource.readData(edmEntitySet, keys);
+    Assert.assertEquals(entityId, readEntity.getId());
+    Assert.assertEquals(entityName, readEntity.getName());
+  }
+
+  @Test
   public void deleteSimpleEntity() throws Exception {
     EdmEntitySet edmEntitySet = createMockedEdmEntitySet("Buildings");
     DataStore<Building> datastore = datasource.getDataStore(Building.class);

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/cd4810b9/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/model/GuidKeyEntity.java
----------------------------------------------------------------------
diff --git a/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/model/GuidKeyEntity.java b/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/model/GuidKeyEntity.java
new file mode 100644
index 0000000..36feabe
--- /dev/null
+++ b/odata2-annotation-processor/annotation-processor-core/src/test/java/org/apache/olingo/odata2/annotation/processor/core/model/GuidKeyEntity.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2013 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.olingo.odata2.annotation.processor.core.model;
+
+import org.apache.olingo.odata2.api.annotation.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.annotation.edm.EdmEntityType;
+import org.apache.olingo.odata2.api.annotation.edm.EdmFacets;
+import org.apache.olingo.odata2.api.annotation.edm.EdmKey;
+import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
+
+import java.util.AbstractMap;
+import java.util.UUID;
+
+@EdmEntityType(name = "GuidKeyEntity", namespace = ModelSharedConstants.NAMESPACE_1)
+@EdmEntitySet(name = GuidKeyEntity.GUID_KEY_ENTITIES)
+public class GuidKeyEntity {
+
+  public static final String GUID_KEY_ENTITIES = "GuidKeyEntities";
+  @EdmProperty(name = "Id", type = EdmType.GUID, facets = @EdmFacets(nullable = false))
+  @EdmKey
+  protected UUID id;
+
+  @EdmProperty(name = "Name")
+  protected String name;
+
+  public UUID getId() {
+    return id;
+  }
+
+  public void setId(UUID id) {
+    this.id = id;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+}


[4/5] olingo-odata2 git commit: [OLINGO-414] Merge branch 'master' into OLINGO-JPA-Fixes

Posted by mi...@apache.org.
[OLINGO-414] Merge branch 'master' into OLINGO-JPA-Fixes


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

Branch: refs/heads/master
Commit: 07984dc1ba40f14a8a92147d1eb9ec40290ed671
Parents: 3ed5889 6bc60b4
Author: mibo <mi...@apache.org>
Authored: Wed Aug 24 22:45:14 2016 +0200
Committer: mibo <mi...@apache.org>
Committed: Wed Aug 24 22:45:14 2016 +0200

----------------------------------------------------------------------
 .../odata2/api/edm/provider/DataServices.java   |  36 +++
 .../olingo/odata2/api/ep/EntityProvider.java    |  32 +++
 .../apache/olingo/odata2/api/uri/PathInfo.java  |   2 +-
 .../odata2/core/batch/BatchHandlerImpl.java     |   8 +-
 .../odata2/core/batch/v2/BatchParser.java       |  13 +-
 .../odata2/core/ep/BasicEntityProvider.java     |  23 +-
 .../odata2/core/ep/ProviderFacadeImpl.java      |   7 +
 .../ep/producer/AtomEntryEntityProducer.java    |   3 +-
 .../core/ep/producer/XmlMetadataProducer.java   |  50 ++--
 .../odata2/core/batch/BatchHandlerTest.java     | 248 +++++++++++++++++++
 .../odata2/core/ep/BasicProviderTest.java       |  73 +++++-
 .../ep/consumer/XmlMetadataConsumerTest.java    |  70 ++++--
 .../core/ep/producer/AtomEntryProducerTest.java |   1 +
 .../resources/batchContentIdReferencing.batch   |  27 ++
 .../odata2/fit/client/ClientBatchTest.java      |  12 +-
 .../apache/olingo/odata2/fit/ref/BatchTest.java |  27 +-
 pom.xml                                         |   3 +
 17 files changed, 561 insertions(+), 74 deletions(-)
----------------------------------------------------------------------



[3/5] olingo-odata2 git commit: [OLINGO-414] Merged fix for ManyTo with DISTINCT generation

Posted by mi...@apache.org.
[OLINGO-414] Merged fix for ManyTo with DISTINCT generation


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

Branch: refs/heads/master
Commit: 3ed58899d76c57ef8a26a3a02098c736f4740856
Parents: a1f6d1f
Author: mibo <mi...@apache.org>
Authored: Wed Aug 24 22:40:03 2016 +0200
Committer: mibo <mi...@apache.org>
Committed: Wed Aug 24 22:40:03 2016 +0200

----------------------------------------------------------------------
 .../jpa/processor/api/jpql/JPQLStatement.java   |   1 +
 .../core/access/data/JPAQueryBuilder.java       | 106 ++++++++++++++++---
 2 files changed, 93 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/3ed58899/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLStatement.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLStatement.java b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLStatement.java
index 56ea231..57660b0 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLStatement.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/jpql/JPQLStatement.java
@@ -120,6 +120,7 @@ public class JPQLStatement {
 
   public static final class KEYWORD {
     public static final String SELECT = "SELECT";
+    public static final String SELECT_DISTINCT = "SELECT DISTINCT";
     public static final String FROM = "FROM";
     public static final String WHERE = "WHERE";
     public static final String LEFT_OUTER_JOIN = "LEFT OUTER JOIN";

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/3ed58899/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java
index c5e61a8..bf20832 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAQueryBuilder.java
@@ -18,6 +18,11 @@
  ******************************************************************************/
 package org.apache.olingo.odata2.jpa.processor.core.access.data;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
 
@@ -41,14 +46,14 @@ import org.apache.olingo.odata2.jpa.processor.api.model.JPAEdmMapping;
 
 public class JPAQueryBuilder {
 
-  public enum UriInfoType {
+  enum UriInfoType {
     GetEntitySet,
     GetEntity,
     GetEntitySetCount,
     GetEntityCount,
     PutMergePatch,
     Delete
-  };
+  }
 
   private EntityManager em = null;
   private int pageSize = 0;
@@ -82,7 +87,7 @@ public class JPAQueryBuilder {
   public Query build(GetEntityUriInfo uriInfo) throws ODataJPARuntimeException {
     Query query = null;
     try {
-      ODataJPAQueryExtensionEntityListener listener = getODataJPAQuertEntityListener((UriInfo) uriInfo);
+      ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((UriInfo) uriInfo);
       if (listener != null) {
         query = listener.getQuery(uriInfo, em);
       }
@@ -99,7 +104,7 @@ public class JPAQueryBuilder {
   public Query build(GetEntitySetCountUriInfo uriInfo) throws ODataJPARuntimeException {
     Query query = null;
     try {
-      ODataJPAQueryExtensionEntityListener listener = getODataJPAQuertEntityListener((UriInfo) uriInfo);
+      ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((UriInfo) uriInfo);
       if (listener != null) {
         query = listener.getQuery(uriInfo, em);
       }
@@ -116,7 +121,7 @@ public class JPAQueryBuilder {
   public Query build(GetEntityCountUriInfo uriInfo) throws ODataJPARuntimeException {
     Query query = null;
     try {
-      ODataJPAQueryExtensionEntityListener listener = getODataJPAQuertEntityListener((UriInfo) uriInfo);
+      ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((UriInfo) uriInfo);
       if (listener != null) {
         query = listener.getQuery(uriInfo, em);
       }
@@ -133,7 +138,7 @@ public class JPAQueryBuilder {
   public Query build(DeleteUriInfo uriInfo) throws ODataJPARuntimeException {
     Query query = null;
     try {
-      ODataJPAQueryExtensionEntityListener listener = getODataJPAQuertEntityListener((UriInfo) uriInfo);
+      ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((UriInfo) uriInfo);
       if (listener != null) {
         query = listener.getQuery(uriInfo, em);
       }
@@ -150,7 +155,7 @@ public class JPAQueryBuilder {
   public Query build(PutMergePatchUriInfo uriInfo) throws ODataJPARuntimeException {
     Query query = null;
     try {
-      ODataJPAQueryExtensionEntityListener listener = getODataJPAQuertEntityListener((UriInfo) uriInfo);
+      ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((UriInfo) uriInfo);
       if (listener != null) {
         query = listener.getQuery(uriInfo, em);
       }
@@ -168,17 +173,16 @@ public class JPAQueryBuilder {
       throws EdmException,
       ODataJPAModelException, ODataJPARuntimeException {
 
-    Query query = null;
     JPQLContextType contextType = determineJPQLContextType(uriParserResultView, type);
     JPQLContext jpqlContext = buildJPQLContext(contextType, uriParserResultView);
-    JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
-        .build();
-    query = em.createQuery(jpqlStatement.toString());
+    JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext).build();
 
-    return query;
+    return em.createQuery(normalizeMembers(jpqlStatement.toString()));
   }
 
-  public ODataJPAQueryExtensionEntityListener getODataJPAQuertEntityListener(UriInfo uriInfo) throws EdmException,
+  
+
+  public ODataJPAQueryExtensionEntityListener getODataJPAQueryEntityListener(UriInfo uriInfo) throws EdmException,
       InstantiationException, IllegalAccessException {
     ODataJPAQueryExtensionEntityListener queryListener = null;
     ODataJPATombstoneEntityListener listener = getODataJPATombstoneEntityListener(uriInfo);
@@ -236,7 +240,81 @@ public class JPAQueryBuilder {
     return contextType;
   }
 
-  public final class JPAQueryInfo {
+  private static final Pattern NORMALIZATION_NEEDED_PATTERN = Pattern.compile(".*[\\s\\(](\\S+\\.\\S+\\.\\S+).*");
+  private static final Pattern JOIN_ALIAS_PATTERN = Pattern.compile(".*\\sJOIN\\s(\\S*\\s\\S*).*");
+
+  private static String normalizeMembers(String jpqlQuery) {
+    // check if normalization is needed (if query contains "x.y.z" elements
+    // starting with space or parenthesis)
+    Matcher normalizationNeededMatcher = NORMALIZATION_NEEDED_PATTERN.matcher(jpqlQuery);
+    if (!normalizationNeededMatcher.find()) {
+      return jpqlQuery;
+    }
+
+    String normalizedJpqlQuery = jpqlQuery;
+    Map<String, String> joinAliases = new HashMap<String, String>();
+
+    // collect information about existing joins/aliases
+    Matcher joinAliasMatcher = JOIN_ALIAS_PATTERN.matcher(normalizedJpqlQuery);
+    if (joinAliasMatcher.find()) {
+      for (int i = 1; i <= joinAliasMatcher.groupCount(); i++) {
+        String[] joinAlias = joinAliasMatcher.group(i).split(String.valueOf(JPQLStatement.DELIMITER.SPACE));
+        joinAliases.put(joinAlias[0], joinAlias[1]);
+      }
+    }
+
+    // normalize query
+    boolean normalizationNeeded = true;
+    while (normalizationNeeded) {
+      String membershipToNormalize = normalizationNeededMatcher.group(1);
+
+      // get member info
+      String memberInfo = membershipToNormalize.substring(0,
+          ordinalIndexOf(membershipToNormalize, JPQLStatement.DELIMITER.PERIOD, 1));
+
+      String alias;
+      if (joinAliases.containsKey(memberInfo)) {
+        // use existing alias
+        alias = joinAliases.get(memberInfo);
+      } else {
+        // create new join/alias
+        alias = "R" + (joinAliases.size() + 1);
+
+        int joinInsertPosition = normalizedJpqlQuery.indexOf(JPQLStatement.KEYWORD.WHERE);
+        if (joinInsertPosition == -1) {
+          joinInsertPosition = normalizedJpqlQuery.indexOf(JPQLStatement.KEYWORD.ORDERBY);
+        }
+        normalizedJpqlQuery = normalizedJpqlQuery.substring(0, joinInsertPosition) + JPQLStatement.KEYWORD.JOIN
+            + JPQLStatement.DELIMITER.SPACE + memberInfo + JPQLStatement.DELIMITER.SPACE + alias
+            + JPQLStatement.DELIMITER.SPACE + normalizedJpqlQuery.substring(joinInsertPosition);
+
+        joinAliases.put(memberInfo, alias);
+      }
+
+      // use alias
+      normalizedJpqlQuery = normalizedJpqlQuery.replaceAll(memberInfo + "\\" + JPQLStatement.DELIMITER.PERIOD,
+          alias + JPQLStatement.DELIMITER.PERIOD);
+
+      // check if further normalization is needed
+      normalizationNeededMatcher = NORMALIZATION_NEEDED_PATTERN.matcher(normalizedJpqlQuery);
+      normalizationNeeded = normalizationNeededMatcher.find();
+    }
+
+    // add distinct to avoid duplicates in result set
+    return normalizedJpqlQuery.replaceFirst(
+        JPQLStatement.KEYWORD.SELECT + JPQLStatement.DELIMITER.SPACE,
+        JPQLStatement.KEYWORD.SELECT_DISTINCT + JPQLStatement.DELIMITER.SPACE);
+  }
+
+  private static int ordinalIndexOf(String str, char s, int n) {
+    int pos = str.indexOf(s, 0);
+    while (n-- > 0 && pos != -1) {
+      pos = str.indexOf(s, pos + 1);
+    }
+    return pos;
+  }
+
+  final class JPAQueryInfo {
     private Query query = null;
     private boolean isTombstoneQuery = false;
 


[2/5] olingo-odata2 git commit: [OLINGO-976] Added default ODataJPATransaction for CMP

Posted by mi...@apache.org.
[OLINGO-976] Added default ODataJPATransaction for CMP


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

Branch: refs/heads/master
Commit: a1f6d1f5f76a85567577e32409219b13a30928b5
Parents: 67d646d
Author: mibo <mi...@apache.org>
Authored: Fri Jul 1 06:48:42 2016 +0200
Committer: mibo <mi...@apache.org>
Committed: Fri Jul 1 06:48:42 2016 +0200

----------------------------------------------------------------------
 .../jpa/processor/core/ODataJPAContextImpl.java |  9 +++-
 .../ODataJPATransactionContainerManaged.java    | 49 ++++++++++++++++++++
 2 files changed, 56 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a1f6d1f5/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImpl.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImpl.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImpl.java
index 75e5174..1fe8f9d 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImpl.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPAContextImpl.java
@@ -173,9 +173,14 @@ public class ODataJPAContextImpl implements ODataJPAContext {
   public ODataJPATransaction getODataJPATransaction() {
     if (transaction == null) {
       transaction = odataContext.getServiceFactory().getCallback(ODataJPATransaction.class);
-      // Fallback to RESOURCE_LOCAL based transaction
+      // fallback to default implementations
       if (transaction == null) {
-        transaction = new ODataJPATransactionLocalDefault(getEntityManager());
+        if(isContainerManaged()) {
+          transaction = new ODataJPATransactionContainerManaged();
+        } else {
+          // Fallback to RESOURCE_LOCAL based transaction
+          transaction = new ODataJPATransactionLocalDefault(getEntityManager());
+        }
       }
     }
     return transaction;

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/a1f6d1f5/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPATransactionContainerManaged.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPATransactionContainerManaged.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPATransactionContainerManaged.java
new file mode 100644
index 0000000..5a08c74
--- /dev/null
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataJPATransactionContainerManaged.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+package org.apache.olingo.odata2.jpa.processor.core;
+
+import org.apache.olingo.odata2.jpa.processor.api.ODataJPATransaction;
+
+/**
+ * <code>ODataJPATransactionContainerManaged</code> only implements the methods for
+ * <code>ODataJPATransaction</code> bot does nothing for all methods because the
+ * whole persistence is managed by the environment (CMP).
+ */
+public class ODataJPATransactionContainerManaged implements ODataJPATransaction {
+  @Override
+  public void begin() {
+    /** do nothing for CMP */
+  }
+
+  @Override
+  public void commit() {
+    /** do nothing for CMP */
+  }
+
+  @Override
+  public void rollback() {
+    /** do nothing for CMP */
+  }
+
+  @Override
+  public boolean isActive() {
+    /** do nothing for CMP */
+    return false;
+  }
+}