diff --git a/src/main/java/org/reso/service/data/GenericEntityCollectionProcessor.java b/src/main/java/org/reso/service/data/GenericEntityCollectionProcessor.java index be81fa8..db90eba 100644 --- a/src/main/java/org/reso/service/data/GenericEntityCollectionProcessor.java +++ b/src/main/java/org/reso/service/data/GenericEntityCollectionProcessor.java @@ -251,7 +251,7 @@ public class GenericEntityCollectionProcessor implements EntityCollectionProcess if (uriResource instanceof UriResourcePrimitiveProperty) { EdmProperty edmProperty = ((UriResourcePrimitiveProperty) uriResource).getProperty(); - final String sortPropertyName = edmProperty.getName(); + final String sortPropertyName = edmProperty.getName().toLowerCase(); queryString = queryString + " ORDER BY "+sortPropertyName; if(orderByItem.isDescending()) { @@ -260,7 +260,7 @@ public class GenericEntityCollectionProcessor implements EntityCollectionProcess } } } - LOG.debug("SQL Query: "+queryString); + LOG.info("SQL Query: "+queryString); ResultSet resultSet = statement.executeQuery(queryString); // special return logic for $count diff --git a/src/main/java/org/reso/service/data/GenericEntityProcessor.java b/src/main/java/org/reso/service/data/GenericEntityProcessor.java index 42133fa..f46a90b 100644 --- a/src/main/java/org/reso/service/data/GenericEntityProcessor.java +++ b/src/main/java/org/reso/service/data/GenericEntityProcessor.java @@ -103,7 +103,7 @@ public class GenericEntityProcessor implements EntityProcessor for (final UriParameter key : keyPredicates) { // key - String keyName = key.getName(); + String keyName = key.getName().toLowerCase(); String keyValue = key.getText(); if (sqlCriteria==null) { @@ -122,7 +122,7 @@ public class GenericEntityProcessor implements EntityProcessor queryString = queryString + " WHERE " + sqlCriteria; } - LOG.debug("SQL Query: "+queryString); + LOG.info("SQL Query: "+queryString); ResultSet resultSet = statement.executeQuery(queryString); String primaryFieldName = resource.getPrimaryKeyName(); diff --git a/src/main/java/org/reso/service/data/common/CommonDataProcessing.java b/src/main/java/org/reso/service/data/common/CommonDataProcessing.java index 8a43c2f..7dcc6a4 100644 --- a/src/main/java/org/reso/service/data/common/CommonDataProcessing.java +++ b/src/main/java/org/reso/service/data/common/CommonDataProcessing.java @@ -1,13 +1,11 @@ package org.reso.service.data.common; -import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.Property; import org.apache.olingo.commons.api.data.ValueType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.ex.ODataRuntimeException; -import org.reso.service.data.GenericEntityCollectionProcessor; import org.reso.service.data.meta.FieldInfo; import org.reso.service.data.meta.ResourceInfo; import org.slf4j.Logger; @@ -15,12 +13,10 @@ import org.slf4j.LoggerFactory; import java.net.URI; import java.net.URISyntaxException; -import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; -import java.util.List; public class CommonDataProcessing { @@ -38,7 +34,7 @@ public class CommonDataProcessing { value = resultSet.getTimestamp(fieldName); } - else if (field.getFieldName().equals("EnumTest")) // @TEST CODE + else if (field.getODATAFieldName().equals("EnumTest")) // @TEST CODE { ArrayList responses = new ArrayList(); responses.add(1); @@ -65,7 +61,7 @@ public class CommonDataProcessing Entity ent = new Entity(); for (FieldInfo field : fields) { - String fieldName = field.getFieldName(); + String fieldName = field.getODATAFieldName(); Object value = null; if (selectLookup==null || selectLookup.containsKey(fieldName) ) { diff --git a/src/main/java/org/reso/service/data/meta/FieldInfo.java b/src/main/java/org/reso/service/data/meta/FieldInfo.java index c76f6b7..c3dceac 100644 --- a/src/main/java/org/reso/service/data/meta/FieldInfo.java +++ b/src/main/java/org/reso/service/data/meta/FieldInfo.java @@ -40,6 +40,10 @@ public class FieldInfo */ public String getFieldName() + { + return fieldName.toLowerCase(); + } + public String getODATAFieldName() { return fieldName; } diff --git a/src/main/java/org/reso/service/data/meta/MySQLFilterExpressionVisitor.java b/src/main/java/org/reso/service/data/meta/MySQLFilterExpressionVisitor.java index 94f9588..c38a91e 100644 --- a/src/main/java/org/reso/service/data/meta/MySQLFilterExpressionVisitor.java +++ b/src/main/java/org/reso/service/data/meta/MySQLFilterExpressionVisitor.java @@ -23,7 +23,8 @@ import java.util.*; /** * $filter */ -public class MySQLFilterExpressionVisitor implements ExpressionVisitor { +public class MySQLFilterExpressionVisitor implements ExpressionVisitor +{ private static final Logger LOG = LoggerFactory.getLogger(MySQLFilterExpressionVisitor.class); private static final Map BINARY_OPERATORS = new HashMap() {{ put(BinaryOperatorKind.ADD, " + "); @@ -63,6 +64,17 @@ public class MySQLFilterExpressionVisitor implements ExpressionVisitor { return left + strOperator + right; } + // @TODO I'm unsure where this would be called. + @Override public String visitBinaryOperator(BinaryOperatorKind operator, String s, List list) + throws ExpressionVisitException, ODataApplicationException + { + String strOperator = BINARY_OPERATORS.get(operator); + throw new ODataApplicationException("Unsupported binary operation: " + operator.name(), + operator == BinaryOperatorKind.HAS ? + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode() : + HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ENGLISH); + } + @Override public String visitUnaryOperator(UnaryOperatorKind operator, String operand) throws ExpressionVisitException, ODataApplicationException { diff --git a/src/main/java/org/reso/service/data/meta/PostgreSQLFilterExpressionVisitor.java b/src/main/java/org/reso/service/data/meta/PostgreSQLFilterExpressionVisitor.java index c523f10..981dada 100644 --- a/src/main/java/org/reso/service/data/meta/PostgreSQLFilterExpressionVisitor.java +++ b/src/main/java/org/reso/service/data/meta/PostgreSQLFilterExpressionVisitor.java @@ -60,6 +60,17 @@ public class PostgreSQLFilterExpressionVisitor implements ExpressionVisitor list) + throws ExpressionVisitException, ODataApplicationException + { + String strOperator = BINARY_OPERATORS.get(operator); + throw new ODataApplicationException("Unsupported binary operation: " + operator.name(), + operator == BinaryOperatorKind.HAS ? + HttpStatusCode.NOT_IMPLEMENTED.getStatusCode() : + HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ENGLISH); + } + @Override public String visitUnaryOperator(UnaryOperatorKind operator, String operand) throws ExpressionVisitException, ODataApplicationException { diff --git a/src/main/java/org/reso/service/data/meta/ResourceInfo.java b/src/main/java/org/reso/service/data/meta/ResourceInfo.java index d5e398d..b5c6f5e 100644 --- a/src/main/java/org/reso/service/data/meta/ResourceInfo.java +++ b/src/main/java/org/reso/service/data/meta/ResourceInfo.java @@ -71,13 +71,21 @@ public class ResourceInfo String pkColumnName = pkColumns.getString("COLUMN_NAME"); Integer pkPosition = pkColumns.getInt("KEY_SEQ"); LOG.debug(""+pkColumnName+" is the "+pkPosition+". column of the primary key of the table "+tableName); - primaryKey = pkColumnName; + primaryKey = pkColumnName.toLowerCase(); } - String[] splitKey = primaryKey.split("Numeric"); + String[] splitKey = primaryKey.split("numeric"); if (splitKey.length>=1) primaryKey = splitKey[0]; + ArrayList fields = this.getFieldList(); + for (FieldInfo field : fields) + { + String fieldName = field.getFieldName(); + if (primaryKey.equals(fieldName)) + primaryKey = field.getODATAFieldName(); + } + this.primaryKeyName = primaryKey; } diff --git a/src/main/java/org/reso/service/edmprovider/RESOedmProvider.java b/src/main/java/org/reso/service/edmprovider/RESOedmProvider.java index 47c2a15..3aa1ebf 100644 --- a/src/main/java/org/reso/service/edmprovider/RESOedmProvider.java +++ b/src/main/java/org/reso/service/edmprovider/RESOedmProvider.java @@ -61,7 +61,7 @@ public class RESOedmProvider extends CsdlAbstractEdmProvider for (FieldInfo field : fields) if (field.isComplex()) { - String fieldName = field.getFieldName(); + String fieldName = field.getODATAFieldName(); CsdlProperty property = new CsdlProperty().setName(fieldName).setType(field.getType()).setCollection(field.isCollection()); Integer maxLength = field.getMaxLength(); @@ -124,7 +124,7 @@ public class RESOedmProvider extends CsdlAbstractEdmProvider for (FieldInfo field : fields) if (!field.isComplex()) { - String fieldName = field.getFieldName(); + String fieldName = field.getODATAFieldName(); CsdlProperty property = new CsdlProperty().setName(fieldName).setType(field.getType()).setCollection(field.isCollection()); Integer maxLength = field.getMaxLength();