Repository: olingo-odata2
Updated Branches:
  refs/heads/master 2638b8d92 -> 676aad45d


[OLINGO-576] Adapt ODataExpressionParser


Signed-off-by: Chandan V A <[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/676aad45
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/676aad45
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/676aad45

Branch: refs/heads/master
Commit: 676aad45dfab8382d332e1c9029fd2c7fd26574a
Parents: 2638b8d
Author: Chandan V A <[email protected]>
Authored: Thu Feb 19 12:54:12 2015 +0530
Committer: Chandan V A <[email protected]>
Committed: Thu Feb 19 12:54:12 2015 +0530

----------------------------------------------------------------------
 .../processor/core/ODataExpressionParser.java   | 41 ++++++++++----------
 1 file changed, 21 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/676aad45/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 3824fd1..e351843 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
@@ -342,6 +342,26 @@ public class ODataExpressionParser {
     }
   }
 
+  public static HashMap<String, String> 
parseKeyPropertiesToJPAOrderByExpression(
+      final List<EdmProperty> edmPropertylist, final String tableAlias) throws 
ODataJPARuntimeException {
+    LinkedHashMap<String, String> orderByMap = new LinkedHashMap<String, 
String>();
+    String propertyName = null;
+    for (EdmProperty edmProperty : edmPropertylist) {
+      try {
+        EdmMapping mapping = edmProperty.getMapping();
+        if (mapping != null && mapping.getInternalName() != null) {
+          propertyName = mapping.getInternalName();// For embedded/complex keys
+        } else {
+          propertyName = edmProperty.getName();
+        }
+      } catch (EdmException e) {
+        throw 
ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()),
 e);
+      }
+      orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + 
propertyName, EMPTY);
+    }
+    return orderByMap;
+  }
+
   /**
    * This method evaluates the expression based on the type instance. Used for 
adding escape characters where necessary.
    * 
@@ -355,6 +375,7 @@ public class ODataExpressionParser {
 
     if (edmSimpleType == EdmSimpleTypeKind.String.getEdmSimpleTypeInstance()
         || edmSimpleType == EdmSimpleTypeKind.Guid.getEdmSimpleTypeInstance()) 
{
+      value = value.replaceAll("'", "''");
       value = "\'" + value + "\'"; //$NON-NLS-1$       //$NON-NLS-2$
     } else if (edmSimpleType == 
EdmSimpleTypeKind.DateTime.getEdmSimpleTypeInstance()
         || edmSimpleType == 
EdmSimpleTypeKind.DateTimeOffset.getEdmSimpleTypeInstance()) {
@@ -402,24 +423,4 @@ public class ODataExpressionParser {
     return value;
   }
 
-  public static HashMap<String, String> 
parseKeyPropertiesToJPAOrderByExpression(
-      final List<EdmProperty> edmPropertylist, final String tableAlias) throws 
ODataJPARuntimeException {
-    LinkedHashMap<String, String> orderByMap = new LinkedHashMap<String, 
String>();
-    String propertyName = null;
-    for (EdmProperty edmProperty : edmPropertylist) {
-      try {
-        EdmMapping mapping = edmProperty.getMapping();
-        if (mapping != null && mapping.getInternalName() != null) {
-          propertyName = mapping.getInternalName();// For embedded/complex keys
-        } else {
-          propertyName = edmProperty.getName();
-        }
-      } catch (EdmException e) {
-        throw 
ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()),
 e);
-      }
-      orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + 
propertyName, EMPTY);
-    }
-    return orderByMap;
-  }
-
 }

Reply via email to