olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chri...@apache.org
Subject olingo-odata2 git commit: [OLINGO-930] New error message: Filter on navigation not supported
Date Wed, 13 Apr 2016 09:18:21 GMT
Repository: olingo-odata2
Updated Branches:
  refs/heads/master b081eed85 -> 910d3bc28


[OLINGO-930] New error message: Filter on navigation not supported


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

Branch: refs/heads/master
Commit: 910d3bc286c218e923a70cb569c03a1c6093b761
Parents: b081eed
Author: Christian Amend <christian.amend@sap.com>
Authored: Wed Apr 13 11:17:01 2016 +0200
Committer: Christian Amend <christian.amend@sap.com>
Committed: Wed Apr 13 11:17:01 2016 +0200

----------------------------------------------------------------------
 .../api/exception/ODataJPARuntimeException.java   |  2 ++
 .../jpa/processor/core/ODataExpressionParser.java | 18 +++++++++++++-----
 .../main/resources/jpaprocessor_msg.properties    |  1 +
 .../ref/web/JPAReferenceServiceFactory.java       | 16 ++++++++++++++++
 4 files changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/910d3bc2/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPARuntimeException.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPARuntimeException.java
b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPARuntimeException.java
index 0b9c3b2..dd70e8d 100644
--- a/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPARuntimeException.java
+++ b/odata2-jpa-processor/jpa-api/src/main/java/org/apache/olingo/odata2/jpa/processor/api/exception/ODataJPARuntimeException.java
@@ -72,6 +72,8 @@ public class ODataJPARuntimeException extends ODataJPAException {
       "ERROR_JPA_CLOB_NULL");
   public static final MessageReference OPERATOR_EQ_NE_MISSING = createMessageReference(ODataJPARuntimeException.class,
       "OPERATOR_EQ_NE_MISSING");
+  public static final MessageReference FILTER_ON_NAVIGATION_NOT_SUPPORTED =
+      createMessageReference(ODataJPARuntimeException.class, "FILTER_ON_NAVIGATION_NOT_SUPPORTED");
 
   private ODataJPARuntimeException(final String localizedMessage, final Throwable e, final
MessageReference msgRef) {
     super(localizedMessage, e, msgRef);

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/910d3bc2/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 1141831..79905ce 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
@@ -27,10 +27,12 @@ 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.exception.ODataException;
 import org.apache.olingo.odata2.api.exception.ODataNotImplementedException;
 import org.apache.olingo.odata2.api.uri.KeyPredicate;
@@ -139,9 +141,9 @@ public class ODataExpressionParser {
             + JPQLStatement.DELIMITER.PARENTHESIS_RIGHT;
       case NE:
         return JPQLStatement.DELIMITER.PARENTHESIS_LEFT + left + JPQLStatement.DELIMITER.SPACE
-            + (!"null".equals(right) ? 
-            	  JPQLStatement.Operator.NE :
-            	  "IS" + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.NOT)
+            + (!"null".equals(right) ?
+                JPQLStatement.Operator.NE :
+                "IS" + JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.NOT)
             + JPQLStatement.DELIMITER.SPACE + right
             + JPQLStatement.DELIMITER.PARENTHESIS_RIGHT;
       case LT:
@@ -437,8 +439,14 @@ public class ODataExpressionParser {
     return uriLiteral;
   }
 
-  private static String getPropertyName(final CommonExpression whereExpression) throws EdmException
{
-    EdmProperty property = ((EdmProperty) ((PropertyExpression) whereExpression).getEdmProperty());
+  private static String getPropertyName(final CommonExpression whereExpression) throws EdmException,
+      ODataJPARuntimeException {
+    EdmTyped edmProperty  = ((PropertyExpression) whereExpression).getEdmProperty();
+    if (edmProperty instanceof EdmNavigationProperty) {
+      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.FILTER_ON_NAVIGATION_NOT_SUPPORTED,
null);
+    }
+
+    EdmProperty property = ((EdmProperty) edmProperty);
     EdmMapping mapping = property.getMapping();
     String name = mapping != null ? mapping.getInternalName() : property.getName();
     return name;

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/910d3bc2/odata2-jpa-processor/jpa-core/src/main/resources/jpaprocessor_msg.properties
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/resources/jpaprocessor_msg.properties
b/odata2-jpa-processor/jpa-core/src/main/resources/jpaprocessor_msg.properties
index 7b4bb95..a5a115c 100644
--- a/odata2-jpa-processor/jpa-core/src/main/resources/jpaprocessor_msg.properties
+++ b/odata2-jpa-processor/jpa-core/src/main/resources/jpaprocessor_msg.properties
@@ -58,6 +58,7 @@ org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException.RE
 org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException.ERROR_JPA_BLOB_NULL="OData
- JPA Runtime: Blob data type is null. Initialize Blob type by implementing callback interface
org.apache.olingo.odata2.jpa.processor.api.OnJPAWriteContent.
 org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException.ERROR_JPA_CLOB_NULL="OData
- JPA Runtime: Clob data type is null. Initialize Clob type by implementing callback interface
org.apache.olingo.odata2.jpa.processor.api.OnJPAWriteContent.
 org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException.OPERATOR_EQ_NE_MISSING="OData
- JPA Runtime: OData Expression parser - Operator EQ or NE missing"
+org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException.FILTER_ON_NAVIGATION_NOT_SUPPORTED="OData
- JPA Runtime: OData Expression parser - Filter expressions with navigation are currently
not supported"
 
 #JPA Common Errors
 org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAException.ODATA_JPACTX_NULL="OData
JPA: OData JPA Context cannot be null"

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/910d3bc2/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
index fa499c8..6e59903 100644
--- a/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
+++ b/odata2-jpa-processor/jpa-web/src/main/java/org/apache/olingo/odata2/jpa/processor/ref/web/JPAReferenceServiceFactory.java
@@ -20,6 +20,8 @@ package org.apache.olingo.odata2.jpa.processor.ref.web;
 
 import java.util.ResourceBundle;
 
+import org.apache.olingo.odata2.api.ODataCallback;
+import org.apache.olingo.odata2.api.ODataDebugCallback;
 import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext;
 import org.apache.olingo.odata2.jpa.processor.api.ODataJPAServiceFactory;
 import org.apache.olingo.odata2.jpa.processor.api.OnJPAWriteContent;
@@ -57,4 +59,18 @@ public class JPAReferenceServiceFactory extends ODataJPAServiceFactory
{
     boolean error = Boolean.parseBoolean(config.getString(SHOW_DETAIL_ERROR));
     setDetailErrors(error);
   }
+
+  @SuppressWarnings("unchecked")
+  @Override
+  public <T extends ODataCallback> T getCallback(final Class<T> callbackInterface)
{
+    return (T) (callbackInterface.isAssignableFrom(ODataDebugCallback.class) ?
+        new ScenarioDebugCallback() : super.getCallback(callbackInterface));
+  }
+
+  private final class ScenarioDebugCallback implements ODataDebugCallback {
+    @Override
+    public boolean isDebugEnabled() {
+      return true;
+    }
+  }
 }


Mime
View raw message