Changeset 2439


Ignore:
Timestamp:
11/30/09 22:48:35 (2 years ago)
Author:
mswertz
Message:

Added shorthand for query functions such as 'eq' and 'gt' for equals and greaterThan

Location:
molgenis/3.3/src/org/molgenis/framework/db
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • molgenis/3.3/src/org/molgenis/framework/db/Query.java

    r2382 r2439  
    4343         
    4444        /** 
     45         * Shorthand for equals 
     46         * @param field 
     47         * @param value 
     48         * @return 
     49         */ 
     50        public abstract Query<E> eq( String field, Object value ); 
     51         
     52         
     53        /** 
    4554         * Shorthand for 
    4655         *  
     
    5968         */ 
    6069        public abstract Query<E> greater( String field, Object value ); 
     70         
     71        /** 
     72         * Shorthand for greater 
     73         * @param field 
     74         * @param value 
     75         * @return 
     76         */ 
     77        public abstract Query<E> gt(String field, Object value); 
    6178 
    6279        /** 
     
    6784         * </pre> 
    6885         */ 
    69         public abstract Query greaterOrEqual( String field, Object value ); 
     86        public abstract Query<E> greaterOrEqual( String field, Object value ); 
    7087 
    7188        /** 
     
    7794         */ 
    7895        public abstract Query<E> less( String field, Object value ); 
     96         
     97        /** 
     98         * Shorthand for lessThan 
     99         */ 
     100        public abstract Query<E> lt( String field, Object value ); 
    79101 
    80102        /** 
     
    85107         * </pre> 
    86108         */ 
    87         public abstract Query lessOrEqual( String field, Object value ); 
     109        public abstract Query<E> lessOrEqual( String field, Object value ); 
    88110 
    89111         
     
    95117         * </pre> 
    96118         */ 
    97         public abstract Query like(String field, Object value); 
     119        public abstract Query<E> like(String field, Object value); 
     120         
     121        /** 
     122         * Between, inclusive 
     123         * @param field 
     124         * @param min minimum valid value 
     125         * @param max maximum valid value 
     126         * @return Query 
     127         */ 
     128        public abstract Query<E> between(String field, Object min, Object max); 
     129         
     130        /** Add the 'or' option on last queryrule */ 
     131        public abstract Query<E> or(); 
     132         
     133        /**  
     134         * Add the 'and' option on last query rule (default) 
     135         */ 
     136        public abstract Query<E> and(); 
    98137         
    99138        /** 
     
    131170         * </pre> 
    132171         */ 
    133         public abstract Query<E> orderASC( String orderByField ); 
     172        public abstract Query<E> sortASC( String orderByField ); 
    134173 
    135174        /** 
     
    140179         * </pre> 
    141180         */ 
    142         public abstract Query<E> orderDESC( String orderByField ); 
     181        public abstract Query<E> sortDESC( String orderByField ); 
    143182 
    144183        /** 
     
    205244        /** Add rules to the query */ 
    206245        public abstract void addRules( QueryRule... addRules ); 
    207  
    208         /** Add the 'or' option on last queryrule */ 
    209         public abstract void or(); 
    210  
    211246} 
  • molgenis/3.3/src/org/molgenis/framework/db/QueryImp.java

    r2382 r2439  
    9090                return this; 
    9191        } 
    92  
     92         
     93        @Override 
     94        public Query<E> between(String field, Object min, Object max) 
     95        { 
     96                return this.lessOrEqual(field, max).greaterOrEqual(field, min); 
     97        } 
     98         
    9399        public Query<E> like(String field, Object value) 
    94100        { 
     
    115121        } 
    116122 
    117         public Query<E> orderASC(String orderByField) 
     123        public Query<E> sortASC(String orderByField) 
    118124        { 
    119125                rules.add(new QueryRule(Operator.SORTASC, orderByField)); 
     
    121127        } 
    122128 
    123         public Query<E> orderDESC(String orderByField) 
     129        public Query<E> sortDESC(String orderByField) 
    124130        { 
    125131                rules.add(new QueryRule(Operator.SORTDESC, orderByField)); 
     
    207213 
    208214        @Override 
    209         public void or() 
     215        public Query<E> or() 
    210216        { 
    211217                if (this.rules.size() > 0) 
     
    213219                        this.rules.lastElement().setOr(true); 
    214220                } 
    215  
     221                return this; 
     222        } 
     223 
     224        @Override 
     225        public Query<E> and() 
     226        { 
     227                if (this.rules.size() > 0) 
     228                { 
     229                        this.rules.lastElement().setOr(false); 
     230                } 
     231                return this; 
     232        } 
     233 
     234        @Override 
     235        public Query<E> eq(String field, Object value) 
     236        { 
     237                return this.equals(field, value); 
     238        } 
     239 
     240        @Override 
     241        public Query<E> gt(String field, Object value) 
     242        { 
     243                return this.greater(field, value); 
     244        } 
     245 
     246        @Override 
     247        public Query<E> lt(String field, Object value) 
     248        { 
     249                return this.less(field, value); 
    216250        } 
    217251} 
Note: See TracChangeset for help on using the changeset viewer.