[OLINGO-576] Adapt ODataExpressionParser
Signed-off-by: Chandan V A <chandan.v.a@sap.com>
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 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 @@
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 @@
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;
- }
-
}