cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1419334 - in /cxf/branches/2.6.x-fixes: ./ rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/ rt/rs/extensions/search/src/main/java/org/apach...
Date Mon, 10 Dec 2012 10:54:20 GMT
Author: sergeyb
Date: Mon Dec 10 10:54:19 2012
New Revision: 1419334

URL: http://svn.apache.org/viewvc?rev=1419334&view=rev
Log:
Merged revisions 1419330 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1419330 | sergeyb | 2012-12-10 10:44:37 +0000 (Mon, 10 Dec 2012) | 1 line
  
  Adding comparesTo method to search builder - can make it simpler to capture the ui-level
selections, etc
........

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ConditionType.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/Property.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/SearchConditionBuilder.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1419330

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ConditionType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ConditionType.java?rev=1419334&r1=1419333&r2=1419334&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ConditionType.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/ConditionType.java
Mon Dec 10 10:54:19 2012
@@ -31,6 +31,5 @@ public enum ConditionType {
     LESS_OR_EQUALS,
     GREATER_OR_EQUALS,
     OR,
-    AND,
-    CUSTOM
+    AND
 }

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java?rev=1419334&r1=1419333&r2=1419334&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilder.java
Mon Dec 10 10:54:19 2012
@@ -25,6 +25,7 @@ import java.util.Map;
 
 import javax.xml.datatype.Duration;
 
+import org.apache.cxf.jaxrs.ext.search.ConditionType;
 import org.apache.cxf.jaxrs.ext.search.SearchUtils;
 import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 
@@ -129,6 +130,36 @@ public class FiqlSearchConditionBuilder 
             return condition(FiqlParser.LT, toString(date));
         }
 
+        public CompleteCondition comparesTo(ConditionType type, String value) {
+            
+            return condition(toFiqlPrimitiveCondition(type), value);
+        }
+        
+        public CompleteCondition comparesTo(ConditionType type, Double value) {
+            
+            return condition(toFiqlPrimitiveCondition(type), value);
+        }
+        
+        public CompleteCondition comparesTo(ConditionType type, Integer value) {
+            
+            return condition(toFiqlPrimitiveCondition(type), value);
+        }
+        
+        public CompleteCondition comparesTo(ConditionType type, Long value) {
+            
+            return condition(toFiqlPrimitiveCondition(type), value);
+        }
+        
+        public CompleteCondition comparesTo(ConditionType type, Date value) {
+            
+            return condition(toFiqlPrimitiveCondition(type), value);
+        }
+        
+        public CompleteCondition comparesTo(ConditionType type, Duration value) {
+            
+            return condition(toFiqlPrimitiveCondition(type), value);
+        }
+        
         public CompleteCondition equalTo(String value, String...moreValues) {
             return condition(FiqlParser.EQ, value, (Object[])moreValues);
         }
@@ -154,35 +185,51 @@ public class FiqlSearchConditionBuilder 
         }
 
         
-        public CompleteCondition greaterOrEqualTo(double number) {
+        public CompleteCondition greaterOrEqualTo(Double number) {
+            return condition(FiqlParser.GE, number);
+        }
+        
+        public CompleteCondition greaterOrEqualTo(Long number) {
             return condition(FiqlParser.GE, number);
         }
         
-        public CompleteCondition greaterOrEqualTo(long number) {
+        public CompleteCondition greaterOrEqualTo(Integer number) {
             return condition(FiqlParser.GE, number);
         }
 
-        public CompleteCondition greaterThan(double number) {
+        public CompleteCondition greaterThan(Double number) {
             return condition(FiqlParser.GT, number);
         }
         
-        public CompleteCondition greaterThan(long number) {
+        public CompleteCondition greaterThan(Long number) {
+            return condition(FiqlParser.GT, number);
+        }
+        
+        public CompleteCondition greaterThan(Integer number) {
             return condition(FiqlParser.GT, number);
         }
 
-        public CompleteCondition lessOrEqualTo(double number) {
+        public CompleteCondition lessOrEqualTo(Double number) {
+            return condition(FiqlParser.LE, number);
+        }
+        
+        public CompleteCondition lessOrEqualTo(Long number) {
             return condition(FiqlParser.LE, number);
         }
         
-        public CompleteCondition lessOrEqualTo(long number) {
+        public CompleteCondition lessOrEqualTo(Integer number) {
             return condition(FiqlParser.LE, number);
         }
 
-        public CompleteCondition lessThan(double number) {
+        public CompleteCondition lessThan(Double number) {
             return condition(FiqlParser.LT, number);
         }
         
-        public CompleteCondition lessThan(long number) {
+        public CompleteCondition lessThan(Long number) {
+            return condition(FiqlParser.LT, number);
+        }
+        
+        public CompleteCondition lessThan(Integer number) {
             return condition(FiqlParser.LT, number);
         }
 
@@ -214,11 +261,15 @@ public class FiqlSearchConditionBuilder 
             return condition(FiqlParser.NEQ, literalOrPattern);
         }
 
-        public CompleteCondition notEqualTo(double number) {
+        public CompleteCondition notEqualTo(Double number) {
+            return condition(FiqlParser.NEQ, number);
+        }
+        
+        public CompleteCondition notEqualTo(Long number) {
             return condition(FiqlParser.NEQ, number);
         }
         
-        public CompleteCondition notEqualTo(long number) {
+        public CompleteCondition notEqualTo(Integer number) {
             return condition(FiqlParser.NEQ, number);
         }
 
@@ -345,6 +396,14 @@ public class FiqlSearchConditionBuilder 
                 return value.toString();
             }
         }
+        
+        private String toFiqlPrimitiveCondition(ConditionType type) {
+            String fiqlType = FiqlParser.CONDITION_MAP.get(type);
+            if (fiqlType == null) {
+                throw new IllegalArgumentException("Only primitive condition types are supported");
+            }
+            return fiqlType;
+        }
     }
 
 }

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/Property.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/Property.java?rev=1419334&r1=1419333&r2=1419334&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/Property.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/Property.java
Mon Dec 10 10:54:19 2012
@@ -22,10 +22,13 @@ import java.util.Date;
 
 import javax.xml.datatype.Duration;
 
+import org.apache.cxf.jaxrs.ext.search.ConditionType;
+
 /**
  * Part of fluent interface of {@link SearchConditionBuilder}.
  */
 public interface Property {
+    
     /** Is textual property equal to given literal or matching given pattern? */
     CompleteCondition equalTo(String value, String ...moreValues);
 
@@ -43,15 +46,18 @@ public interface Property {
 
     /** Is date property same as date distant from now by given period of time? */
     CompleteCondition equalTo(Duration distanceFromNow, Duration... moreValues);
-
+        
     /** Is textual property different than given literal or not matching given pattern? */
     CompleteCondition notEqualTo(String literalOrPattern);
 
     /** Is numeric property different than given double number? */
-    CompleteCondition notEqualTo(double number);
+    CompleteCondition notEqualTo(Double number);
     
     /** Is numeric property different than given long number? */
-    CompleteCondition notEqualTo(long number);
+    CompleteCondition notEqualTo(Long number);
+    
+    /** Is numeric property different than given int number? */
+    CompleteCondition notEqualTo(Integer number);
 
     /** Is date property different than given date? */
     CompleteCondition notEqualTo(Date date);
@@ -60,29 +66,41 @@ public interface Property {
     CompleteCondition notEqualTo(Duration distanceFromNow);
 
     /** Is numeric property greater than given number? */
-    CompleteCondition greaterThan(double number);
+    CompleteCondition greaterThan(Double number);
+    
+    /** Is numeric property greater than given number? */
+    CompleteCondition greaterThan(Long number);
     
     /** Is numeric property greater than given number? */
-    CompleteCondition greaterThan(long number);
+    CompleteCondition greaterThan(Integer number);
 
     /** Is numeric property less than given number? */
-    CompleteCondition lessThan(double number);
+    CompleteCondition lessThan(Double number);
     
     /** Is numeric property less than given number? */
-    CompleteCondition lessThan(long number);
+    CompleteCondition lessThan(Long number);
 
+    /** Is numeric property less than given number? */
+    CompleteCondition lessThan(Integer number);
+    
+    /** Is numeric property greater or equal to given number? */
+    CompleteCondition greaterOrEqualTo(Double number);
+    
     /** Is numeric property greater or equal to given number? */
-    CompleteCondition greaterOrEqualTo(double number);
+    CompleteCondition greaterOrEqualTo(Long number);
     
     /** Is numeric property greater or equal to given number? */
-    CompleteCondition greaterOrEqualTo(long number);
+    CompleteCondition greaterOrEqualTo(Integer number);
 
     /** Is numeric property less or equal to given number? */
-    CompleteCondition lessOrEqualTo(double number);
+    CompleteCondition lessOrEqualTo(Double number);
     
     /** Is numeric property less or equal to given number? */
-    CompleteCondition lessOrEqualTo(long number);
+    CompleteCondition lessOrEqualTo(Long number);
 
+    /** Is numeric property less or equal to given number? */
+    CompleteCondition lessOrEqualTo(Integer number);
+    
     /** Is date property after (greater than) given date? */
     CompleteCondition after(Date date);
 
@@ -120,4 +138,23 @@ public interface Property {
 
     /** Is textual property lexically not after (less or equal to) given literal? */
     CompleteCondition lexicalNotAfter(String literal);
+    
+    /** Generic */
+    CompleteCondition comparesTo(ConditionType op, String value);
+    
+    /** Generic */
+    CompleteCondition comparesTo(ConditionType op, Double value);
+    
+    /** Generic */
+    CompleteCondition comparesTo(ConditionType op, Long value);
+    
+    /** Generic */
+    CompleteCondition comparesTo(ConditionType op, Integer value);
+    
+    /** Generic */
+    CompleteCondition comparesTo(ConditionType op, Date value);
+    
+    /** Generic */
+    CompleteCondition comparesTo(ConditionType op, Duration value);
+
 }

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/SearchConditionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/SearchConditionBuilder.java?rev=1419334&r1=1419333&r2=1419334&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/SearchConditionBuilder.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/client/SearchConditionBuilder.java
Mon Dec 10 10:54:19 2012
@@ -32,6 +32,7 @@ import java.util.Map;
 public abstract class SearchConditionBuilder implements PartialCondition {
 
     public static final String DEFAULT_LANGUAGE = "FIQL";
+    public static final String FIQL = DEFAULT_LANGUAGE;
     /**
      * Creates instance of builder.
      * 

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java?rev=1419334&r1=1419333&r2=1419334&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/fiql/FiqlParser.java
Mon Dec 10 10:54:19 2012
@@ -69,9 +69,11 @@ public class FiqlParser<T> implements Se
     public static final String EQ = "==";
     public static final String NEQ = "!=";
     
-    private static final Pattern COMPARATORS_PATTERN; 
+    public static final Map<ConditionType, String> CONDITION_MAP;
+    
     private static final Map<String, ConditionType> OPERATORS_MAP;
-
+    private static final Pattern COMPARATORS_PATTERN; 
+    
     static {
         // operatorsMap
         OPERATORS_MAP = new HashMap<String, ConditionType>();
@@ -82,6 +84,15 @@ public class FiqlParser<T> implements Se
         OPERATORS_MAP.put(EQ, ConditionType.EQUALS);
         OPERATORS_MAP.put(NEQ, ConditionType.NOT_EQUALS);
         
+        CONDITION_MAP = new HashMap<ConditionType, String>();
+        CONDITION_MAP.put(ConditionType.GREATER_THAN, GT);
+        CONDITION_MAP.put(ConditionType.GREATER_OR_EQUALS, GE);
+        CONDITION_MAP.put(ConditionType.LESS_THAN, LT);
+        CONDITION_MAP.put(ConditionType.LESS_OR_EQUALS, LE);
+        CONDITION_MAP.put(ConditionType.EQUALS, EQ);
+        CONDITION_MAP.put(ConditionType.NOT_EQUALS, NEQ);
+        
+        
         // pattern
         String comparators = GT + "|" + GE + "|" + LT + "|" + LE + "|" + EQ + "|" + NEQ;
         String s1 = "[\\p{ASCII}]+(" + comparators + ")";

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java?rev=1419334&r1=1419333&r2=1419334&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/client/FiqlSearchConditionBuilderTest.java
Mon Dec 10 10:54:19 2012
@@ -29,6 +29,7 @@ import javax.xml.datatype.DatatypeConfig
 import javax.xml.datatype.DatatypeFactory;
 import javax.xml.datatype.Duration;
 
+import org.apache.cxf.jaxrs.ext.search.ConditionType;
 import org.apache.cxf.jaxrs.ext.search.SearchUtils;
 
 import org.junit.AfterClass;
@@ -69,6 +70,12 @@ public class FiqlSearchConditionBuilderT
         String ret = b.is("foo").equalTo(123.5).query();
         assertEquals("foo==123.5", ret);
     }
+    
+    @Test
+    public void testEqualToNumberCondition() {
+        String ret = b.is("foo").comparesTo(ConditionType.LESS_THAN, 123.5).query();
+        assertEquals("foo=lt=123.5", ret);
+    }
 
     private Date parseDate(String format, String value) throws ParseException {
         return new SimpleDateFormat(format).parse(value);



Mime
View raw message