jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r718217 - in /jackrabbit/branches/1.5: ./ jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/ jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/impl/ jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/
Date Mon, 17 Nov 2008 10:48:24 GMT
Author: jukka
Date: Mon Nov 17 02:48:22 2008
New Revision: 718217

URL: http://svn.apache.org/viewvc?rev=718217&view=rev
Log:
1.5: Merged revision 713214 (JCR-1844). Ignored revisions 713956, 713958 and 713964.

Modified:
    jackrabbit/branches/1.5/   (props changed)
    jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/Filter.java
    jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/impl/FilterImpl.java
    jackrabbit/branches/1.5/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java

Propchange: jackrabbit/branches/1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 17 02:48:22 2008
@@ -1,2 +1,2 @@
 /jackrabbit/branches/1.3:631261
-/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162
+/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162,713214,713956,713958,713964

Modified: jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/Filter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/Filter.java?rev=718217&r1=718216&r2=718217&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/Filter.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/Filter.java
Mon Nov 17 02:48:22 2008
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.ocm.query;
 
 
-
 /**
  *
  * JCR Filter interface.
@@ -79,7 +78,7 @@
 	Filter addGreaterThan(String arg0, Object arg1);
 
 	Filter addLessOrEqualThan(String arg0, Object arg1);
-	
+
 	Filter addLessThan(String arg0, Object arg1);
 
 	Filter addLike(String arg0, Object arg1);
@@ -89,14 +88,16 @@
 	Filter addNotNull(String arg0);
 
 	Filter addIsNull(String arg0);
-	
+
+	Filter addOrFilter(String fieldAttributeName, String[] valueList);
+
 	Filter addOrFilter(Filter arg0);
 
 	Filter addAndFilter(Filter filter);
-	
+
 	Filter addJCRExpression(String jcrExpression);
-	
+
     Class getFilterClass();
-	
+
 
 }

Modified: jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/impl/FilterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/impl/FilterImpl.java?rev=718217&r1=718216&r2=718217&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/impl/FilterImpl.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/query/impl/FilterImpl.java
Mon Nov 17 02:48:22 2008
@@ -18,6 +18,7 @@
 package org.apache.jackrabbit.ocm.query.impl;
 
 
+
 import java.util.Map;
 
 import javax.jcr.ValueFactory;
@@ -221,6 +222,18 @@
         return this;
     }
 
+    public Filter addOrFilter(String fieldAttributeName, String[] valueList) {
+        String jcrExpression = "";
+        for(Object object: valueList){
+        jcrExpression =	"@" + this.getJcrFieldName(fieldAttributeName) + " = "
+        + this.getStringValue(fieldAttributeName, object);
+        orExpression(jcrExpression);
+        }
+        addExpression(jcrExpression);
+        return this;
+    }
+    
+    
     /**
      * @see org.apache.jackrabbit.ocm.query.Filter#addOrFilter(org.apache.jackrabbit.ocm.query.Filter)
      */
@@ -266,6 +279,13 @@
         return this;
     }
 
+    public Filter orJCRExpression(String jcrExpression) {
+        orExpression(jcrExpression);
+
+         return this;
+     }
+   
+    
     private String getJcrFieldName(String fieldAttribute) {
         String jcrFieldName = classDescriptor.getJcrName(fieldAttribute);
         if (jcrFieldName == null) {
@@ -315,6 +335,15 @@
         this.jcrExpression += jcrExpression ;
     }
 
+    private void orExpression(String jcrExpression) {
+
+	     if (this.jcrExpression.length() >0) {
+         	this.jcrExpression += " or ";
+	     }
+	     this.jcrExpression += jcrExpression ;
+    }
+    
+    
 	public String toString() {
 		return getJcrExpression();
 	}

Modified: jackrabbit/branches/1.5/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java?rev=718217&r1=718216&r2=718217&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java
Mon Nov 17 02:48:22 2008
@@ -195,6 +195,69 @@
 
     }
 
+    /**
+     * Build an or expression within a single filter
+     * @author Shrirang Edgaonkar
+     */
+    public void testGetObjectsOrForSingleFilter() {
+
+        try {
+
+            // Build the Query Object
+            QueryManager queryManager = this.getQueryManager();
+            Filter filter1 = queryManager.createFilter(Paragraph.class);
+            filter1.addOrFilter("text", new String[]{"Para 1","Para 2"});
+            filter1.setScope("/test/");
+
+            Query query = queryManager.createQuery(filter1);
+
+            ObjectContentManager ocm = this.getObjectContentManager();
+            Collection result = ocm.getObjects(query);
+            assertEquals("Invalid number of objects - should be = 2", 2, result.size());
+
+            Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 1"));
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 2"));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+
+    }
+
+    /**
+     * Build an or expression within a single filter
+     * @author Shrirang Edgaonkar
+     */
+    public void testGetObjectsOrWithAndForSingleFilter() {
+
+        try {
+
+            // Build the Query Object
+            QueryManager queryManager = this.getQueryManager();
+            Filter filter1 = queryManager.createFilter(Paragraph.class);
+            filter1.addOrFilter("text", new String[]{"Para 1","Another Para "}).addLike("text",
"Para%");
+            filter1.setScope("/test/");
+
+            Query query = queryManager.createQuery(filter1);
+
+            ObjectContentManager ocm = this.getObjectContentManager();
+            Collection result = ocm.getObjects(query);
+            assertEquals("Invalid number of objects - should be = 1", 1, result.size());
+
+            Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 1"));
+            //assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 2"));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+
+    }
+   
+    
     public void testGetObjectOrderBy() {
 
         try {



Mime
View raw message