cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1552359 - in /cxf/trunk/rt/rs/extensions/search/src: main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
Date Thu, 19 Dec 2013 17:17:05 GMT
Author: sergeyb
Date: Thu Dec 19 17:17:05 2013
New Revision: 1552359

URL: http://svn.apache.org/r1552359
Log:
[CXF-5449] Updating FiqlParser to better deal with the deeply nested queries

Modified:
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java?rev=1552359&r1=1552358&r2=1552359&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
Thu Dec 19 17:17:05 2013
@@ -383,7 +383,7 @@ public class FiqlParser<T> implements Se
                 boolean lastTry = names.length == 2 
                     && (isPrimitive || returnType == Date.class || returnCollection);
                 
-                Object valueObject = lastTry && ownerBean != null ? ownerBean 
+                Object valueObject = ownerBean != null ? ownerBean 
                     : actualType.isInterface() 
                     ? Proxy.newProxyInstance(this.getClass().getClassLoader(), 
                                              new Class[]{actualType}, 
@@ -411,18 +411,25 @@ public class FiqlParser<T> implements Se
                 Method setterM = actualType.getMethod("set" + nextPart, new Class[]{returnType});
                 setterM.invoke(valueObject, new Object[]{nextObject});
                 
-                lastCastedValue = lastCastedValue == null ? valueObject : lastCastedValue;
                 if (lastTry) {
+                    lastCastedValue = lastCastedValue == null ? valueObject : lastCastedValue;
                     return isCollection ? getCollectionSingleton(valueType, lastCastedValue)
: lastCastedValue;
-                } 
+                } else {
+                    lastCastedValue = valueObject;
+                }
                 
                 TypeInfo nextTypeInfo = new TypeInfo(nextObject.getClass(), getterM.getGenericReturnType());

-                return parseType(originalPropName,
+                Object response = parseType(originalPropName,
                                  nextObject, 
                                  lastCastedValue, 
                                  setter.substring(index + 1), 
                                  nextTypeInfo, 
                                  value);
+                if (ownerBean == null) {
+                    return isCollection ? getCollectionSingleton(valueType, lastCastedValue)
: lastCastedValue;
+                } else {
+                    return response;
+                }
             } catch (Throwable e) {
                 throw new SearchParseException("Cannot convert String value \"" + value
                                                + "\" to a value of class " + valueType.getName(),
e);

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java?rev=1552359&r1=1552358&r2=1552359&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
Thu Dec 19 17:17:05 2013
@@ -199,6 +199,20 @@ public class JPATypedQueryVisitorTest ex
     }
     
     @Test
+    public void testQueryCollection2() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.book.id==10");
+        assertEquals(1, books.size());
+    }
+    
+    @Test
+    public void testQueryCollection3() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.book.ownerInfo.name==Barry");
+        assertEquals(1, books.size());
+    }
+    
+    @Test
     public void testQueryElementCollection() throws Exception {
         List<Book> books = 
             queryBooks("authors==John");



Mime
View raw message