cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5806] Adding a patch from Romain Castan, and a temp disabled test
Date Wed, 18 Jun 2014 20:32:21 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 442972837 -> 507b03b8e


[CXF-5806] Adding a patch from Romain Castan, and a temp disabled test


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/507b03b8
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/507b03b8
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/507b03b8

Branch: refs/heads/master
Commit: 507b03b8e4def1d3da3d5f81e0c105eda1413058
Parents: 4429728
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Jun 18 21:31:56 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Jun 18 21:31:56 2014 +0100

----------------------------------------------------------------------
 .../jpa/AbstractJPATypedQueryVisitor.java       | 32 ++++++++++++++------
 .../jpa/AbstractJPATypedQueryVisitorTest.java   |  7 +++--
 .../jpa/JPATypedQueryVisitorFiqlTest.java       | 11 +++++++
 .../cxf/jaxrs/ext/search/jpa/Library.java       | 14 +++++++++
 4 files changed, 51 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/507b03b8/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitor.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitor.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitor.java
index 084cd93..6872dd8 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitor.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitor.java
@@ -283,19 +283,19 @@ public abstract class AbstractJPATypedQueryVisitor<T, T1, E>
         if (name.contains(".")) {
             String pre = name.substring(0, name.indexOf('.'));
             String post = name.substring(name.indexOf('.') + 1);
-            return getPath(getNextPath(element, pre, cv, null), 
-                           post, 
-                           cv,
-                           collSize);
+            final Path<?> nextPath = getNextPath(element, pre, post, cv, null);
+            return getPath(nextPath, post, cv, collSize);
         } else {
-            return getNextPath(element, name, cv, collSize);
+            return getNextPath(element, name, null, cv, collSize);
         }
     }
 
-    private Path<?> getNextPath(Path<?> element, String name, ClassValue cv,
CollectionCheckInfo collSize) {
-        if (collSize == null
-            && (cv.isCollection(name) || isJoinProperty(name)) && (element
== root || element instanceof Join)) {
-            
+    private Path<?> getNextPath(Path<?> element, String name, String postName,

+        ClassValue cv, CollectionCheckInfo collSize) {
+        final boolean isCollectionOrJoin = collSize == null
+            && (cv.isCollection(name) || isJoinProperty(name) || existingCollectionInPostName(cv,
postName)) 
+            && (element == root || element instanceof Join);
+        if (isCollectionOrJoin) {
             final Path<?> path = getExistingJoinProperty((From<?, ?>)element,
name);
             if (path != null) {
                 return path;
@@ -303,7 +303,7 @@ public abstract class AbstractJPATypedQueryVisitor<T, T1, E>
                 return element == root ? root.join(name) : ((Join<?, ?>)element).join(name);
             }
         } else {
-            return element.get(name);
+            return element.get(name);                
         }
     }
     
@@ -321,4 +321,16 @@ public abstract class AbstractJPATypedQueryVisitor<T, T1, E>
         }
         return null;
     }
+    
+    private boolean existingCollectionInPostName(ClassValue cv, String postName) {
+        if (postName != null) {
+            final String[] splitName = postName.split("\\.");
+            for (String name : splitName) {
+                if (cv.isCollection(name)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/507b03b8/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java
b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java
index 35bf72d..a53db1b 100644
--- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java
+++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java
@@ -98,7 +98,6 @@ public abstract class AbstractJPATypedQueryVisitorTest extends Assert {
             b1.setLibrary(lib);
             b1.getAuthors().add("John");
             em.persist(b1);
-            assertTrue(em.contains(b1));
             
             BookReview br2 = new BookReview();
             br2.setId(2);
@@ -120,7 +119,6 @@ public abstract class AbstractJPATypedQueryVisitorTest extends Assert
{
             b2.setLibrary(lib);
             b2.getAuthors().add("John");
             em.persist(b2);
-            assertTrue(em.contains(b2));
             
             BookReview br3 = new BookReview();
             br3.setId(3);
@@ -141,7 +139,10 @@ public abstract class AbstractJPATypedQueryVisitorTest extends Assert
{
             b3.setOwnerInfo(info3);
             b3.setLibrary(lib);
             em.persist(b3);
-            assertTrue(em.contains(b3));
+            
+            lib.getBooks().add(b1);
+            lib.getBooks().add(b2);
+            lib.getBooks().add(b3);
             
             em.getTransaction().commit();
         } catch (Exception ex) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/507b03b8/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java
b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java
index acfdb5d..a111e1c 100644
--- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java
+++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java
@@ -28,6 +28,8 @@ import javax.persistence.Tuple;
 
 import org.apache.cxf.jaxrs.ext.search.SearchConditionParser;
 import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
+
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class JPATypedQueryVisitorFiqlTest extends AbstractJPATypedQueryVisitorTest {
@@ -53,6 +55,15 @@ public class JPATypedQueryVisitorFiqlTest extends AbstractJPATypedQueryVisitorTe
         assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle()));
     }
     
+
+    @Test
+    @Ignore
+    public void testGetLibraryBook() throws Exception {
+        List<Book> books = queryBooks("library.books.bookTitle==num10");
+        assertEquals(1, books.size());
+        assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle()));
+    }
+    
     @Test
     public void testQueryCollection() throws Exception {
         List<Book> books = 

http://git-wip-us.apache.org/repos/asf/cxf/blob/507b03b8/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
index 1c24625..c5879a2 100644
--- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
+++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
@@ -18,14 +18,20 @@
  */
 package org.apache.cxf.jaxrs.ext.search.jpa;
 
+import java.util.LinkedList;
+import java.util.List;
+
 import javax.persistence.Entity;
 import javax.persistence.Id;
+import javax.persistence.OneToMany;
 
 @Entity
 public class Library {
     @Id
     private int id;
     private String address;
+    @OneToMany
+    private List<Book> books = new LinkedList<Book>(); 
     
     public int getId() {
         return id;
@@ -42,4 +48,12 @@ public class Library {
     public void setAddress(String address) {
         this.address = address;
     }
+
+    public List<Book> getBooks() {
+        return books;
+    }
+
+    public void setBooks(List<Book> books) {
+        this.books = books;
+    }
 }


Mime
View raw message