← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20941: new operators for queryservice/objectfilterservice merge, wip

 

------------------------------------------------------------
revno: 20941
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-11-04 12:48:42 +0700
message:
  new operators for queryservice/objectfilterservice merge, wip
added:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Between.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Equal.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/GreaterEqual.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/GreaterThan.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/ILike.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/In.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/LessEqual.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/LessThan.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Like.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotEqual.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotNull.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Null.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Operator.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators'
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Between.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Between.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Between.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class Between extends Operator
+{
+    public Between( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class, Number.class, Date.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        return false;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Equal.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Equal.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Equal.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,106 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class Equal extends Operator
+{
+    public Equal( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        if ( propertyValue == null || value == null )
+        {
+            return false;
+        }
+
+        if ( String.class.isInstance( value ) )
+        {
+            String s1 = getValue( String.class );
+            String s2 = (String) value;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Boolean.class.isInstance( value ) )
+        {
+            Boolean s1 = getValue( Boolean.class );
+            Boolean s2 = (Boolean) value;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Integer.class.isInstance( value ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) value;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Float.class.isInstance( value ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) value;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Collection.class.isInstance( value ) )
+        {
+            Collection<?> collection = (Collection<?>) value;
+            Integer size = getValue( Integer.class );
+
+            return size != null && collection.size() == size;
+        }
+        else if ( Date.class.isInstance( value ) )
+        {
+            Date s1 = getValue( Date.class );
+            Date s2 = (Date) value;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Enum.class.isInstance( value ) )
+        {
+            String s1 = propertyValue;
+            String s2 = String.valueOf( value );
+
+            return s2.equals( s1 );
+        }
+
+        return false;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/GreaterEqual.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/GreaterEqual.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/GreaterEqual.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,85 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class GreaterEqual extends Operator
+{
+    public GreaterEqual( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        if ( propertyValue == null || value == null )
+        {
+            return false;
+        }
+
+        if ( Integer.class.isInstance( value ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) value;
+
+            return s1 != null && s2 >= s1;
+        }
+        else if ( Float.class.isInstance( value ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) value;
+
+            return s1 != null && s2 >= s1;
+        }
+        else if ( Collection.class.isInstance( value ) )
+        {
+            Collection<?> collection = (Collection<?>) value;
+            Integer size = getValue( Integer.class );
+
+            return size != null && collection.size() >= size;
+        }
+        else if ( Date.class.isInstance( value ) )
+        {
+            Date s1 = getValue( Date.class );
+            Date s2 = (Date) value;
+
+            return s1 != null && (s2.after( s1 ) || s2.equals( s1 ));
+        }
+
+        return false;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/GreaterThan.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/GreaterThan.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/GreaterThan.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,85 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class GreaterThan extends Operator
+{
+    public GreaterThan( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        if ( propertyValue == null || value == null )
+        {
+            return false;
+        }
+
+        if ( Integer.class.isInstance( value ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) value;
+
+            return s1 != null && s2 > s1;
+        }
+        else if ( Float.class.isInstance( value ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) value;
+
+            return s1 != null && s2 > s1;
+        }
+        else if ( Collection.class.isInstance( value ) )
+        {
+            Collection<?> collection = (Collection<?>) value;
+            Integer size = getValue( Integer.class );
+
+            return size != null && collection.size() > size;
+        }
+        else if ( Date.class.isInstance( value ) )
+        {
+            Date s1 = getValue( Date.class );
+            Date s2 = (Date) value;
+
+            return s1 != null && s2.after( s1 );
+        }
+
+        return false;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/ILike.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/ILike.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/ILike.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,61 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class ILike extends Operator
+{
+    public ILike( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        if ( propertyValue == null || value == null )
+        {
+            return false;
+        }
+
+        if ( String.class.isInstance( value ) )
+        {
+            String s1 = getValue( String.class );
+            String s2 = (String) value;
+
+            return s1 != null && s2.toLowerCase().contains( s1.toLowerCase() );
+        }
+
+        return false;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/In.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/In.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/In.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,114 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class In extends Operator
+{
+    public In( String propertyValue )
+    {
+        super( propertyValue, Typed.from( Collection.class ) );
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public boolean test( Object value )
+    {
+        Collection<String> items = getValue( Collection.class );
+
+        if ( items == null || value == null )
+        {
+            return false;
+        }
+
+        for ( String item : items )
+        {
+            if ( compare( item, value ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    private boolean compare( String item, Object object )
+    {
+        if ( String.class.isInstance( object ) )
+        {
+            String s1 = getValue( String.class, item );
+            String s2 = (String) object;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Boolean.class.isInstance( object ) )
+        {
+            Boolean s1 = getValue( Boolean.class, item );
+            Boolean s2 = (Boolean) object;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Integer.class.isInstance( object ) )
+        {
+            Integer s1 = getValue( Integer.class, item );
+            Integer s2 = (Integer) object;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Float.class.isInstance( object ) )
+        {
+            Float s1 = getValue( Float.class, item );
+            Float s2 = (Float) object;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Date.class.isInstance( object ) )
+        {
+            Date s1 = getValue( Date.class, item );
+            Date s2 = (Date) object;
+
+            return s1 != null && s2.equals( s1 );
+        }
+        else if ( Enum.class.isInstance( object ) )
+        {
+            String s2 = String.valueOf( object );
+
+            return item != null && s2.equals( item );
+        }
+
+        return false;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/LessEqual.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/LessEqual.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/LessEqual.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,85 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class LessEqual extends Operator
+{
+    public LessEqual( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        if ( propertyValue == null || value == null )
+        {
+            return false;
+        }
+
+        if ( Integer.class.isInstance( value ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) value;
+
+            return s1 != null && s2 <= s1;
+        }
+        else if ( Float.class.isInstance( value ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) value;
+
+            return s1 != null && s2 <= s1;
+        }
+        else if ( Collection.class.isInstance( value ) )
+        {
+            Collection<?> collection = (Collection<?>) value;
+            Integer size = getValue( Integer.class );
+
+            return size != null && collection.size() <= size;
+        }
+        else if ( Date.class.isInstance( value ) )
+        {
+            Date s1 = getValue( Date.class );
+            Date s2 = (Date) value;
+
+            return s1 != null && (s2.before( s1 ) || s2.equals( s1 ));
+        }
+
+        return false;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/LessThan.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/LessThan.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/LessThan.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,85 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class LessThan extends Operator
+{
+    public LessThan( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        if ( propertyValue == null || value == null )
+        {
+            return false;
+        }
+
+        if ( Integer.class.isInstance( value ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) value;
+
+            return s1 != null && s2 < s1;
+        }
+        else if ( Float.class.isInstance( value ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) value;
+
+            return s1 != null && s2 < s1;
+        }
+        else if ( Collection.class.isInstance( value ) )
+        {
+            Collection<?> collection = (Collection<?>) value;
+            Integer size = getValue( Integer.class );
+
+            return size != null && collection.size() < size;
+        }
+        else if ( Date.class.isInstance( value ) )
+        {
+            Date s1 = getValue( Date.class );
+            Date s2 = (Date) value;
+
+            return s1 != null && (s2.before( s1 ));
+        }
+
+        return false;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Like.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Like.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Like.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,61 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class Like extends Operator
+{
+    public Like( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        if ( propertyValue == null || value == null )
+        {
+            return false;
+        }
+
+        if ( String.class.isInstance( value ) )
+        {
+            String s1 = getValue( String.class );
+            String s2 = (String) value;
+
+            return s1 != null && s2.contains( s1 );
+        }
+
+        return false;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotEqual.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotEqual.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotEqual.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,46 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class NotEqual extends Equal
+{
+    public NotEqual( String propertyValue )
+    {
+        super( propertyValue );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        return !super.test( value );
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotNull.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotNull.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/NotNull.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class NotNull extends Operator
+{
+    public NotNull( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        return value != null;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Null.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Null.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Null.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.Typed;
+
+import java.util.Date;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class Null extends Operator
+{
+    public Null( String propertyValue )
+    {
+        super( propertyValue, Typed.from( String.class, Boolean.class, Number.class, Date.class ) );
+    }
+
+    @Override
+    public boolean test( Object value )
+    {
+        return value == null;
+    }
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Operator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Operator.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/operators/Operator.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,65 @@
+package org.hisp.dhis.query.operators;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.QueryUtils;
+import org.hisp.dhis.query.Typed;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public abstract class Operator
+{
+    protected final String propertyValue;
+
+    protected final Typed typed;
+
+    public Operator( String propertyValue, Typed typed )
+    {
+        this.propertyValue = propertyValue;
+        this.typed = typed;
+    }
+
+    protected <T> T getValue( Class<T> klass )
+    {
+        return QueryUtils.getValue( klass, propertyValue );
+    }
+
+    protected <T> T getValue( Class<T> klass, Object value )
+    {
+        return QueryUtils.getValue( klass, value );
+    }
+
+    public boolean isValid( Class<?> klass )
+    {
+        return typed.isValid( klass );
+    }
+
+    public abstract boolean test( Object value );
+}

=== added file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/query/OperatorTest.java	2015-11-04 05:48:42 +0000
@@ -0,0 +1,197 @@
+package org.hisp.dhis.query;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.query.operators.Between;
+import org.hisp.dhis.query.operators.Equal;
+import org.hisp.dhis.query.operators.GreaterEqual;
+import org.hisp.dhis.query.operators.GreaterThan;
+import org.hisp.dhis.query.operators.ILike;
+import org.hisp.dhis.query.operators.LessEqual;
+import org.hisp.dhis.query.operators.LessThan;
+import org.hisp.dhis.query.operators.Like;
+import org.hisp.dhis.query.operators.NotEqual;
+import org.hisp.dhis.query.operators.NotNull;
+import org.hisp.dhis.query.operators.Null;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class OperatorTest
+{
+    @Test
+    public void testBetweenValidTypes()
+    {
+        Between operator = new Between( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertTrue( operator.isValid( Number.class ) );
+        assertTrue( operator.isValid( Date.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testEqualValidTypes()
+    {
+        Equal operator = new Equal( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertTrue( operator.isValid( Number.class ) );
+        assertTrue( operator.isValid( Date.class ) );
+        assertTrue( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testEqual()
+    {
+        Equal operator = new Equal( "operator" );
+
+        assertTrue( operator.test( "operator" ) );
+        assertFalse( operator.test( Boolean.TRUE ) );
+        assertFalse( operator.test( new Float( 0 ) ) );
+        assertFalse( operator.test( Collections.emptyList() ) );
+    }
+
+    @Test
+    public void testNotEqualValidTypes()
+    {
+        NotEqual operator = new NotEqual( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertTrue( operator.isValid( Number.class ) );
+        assertTrue( operator.isValid( Date.class ) );
+        assertTrue( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testGreaterEqualValidTypes()
+    {
+        GreaterEqual operator = new GreaterEqual( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertTrue( operator.isValid( Number.class ) );
+        assertTrue( operator.isValid( Date.class ) );
+        assertTrue( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testGreaterThanValidTypes()
+    {
+        GreaterThan operator = new GreaterThan( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertTrue( operator.isValid( Number.class ) );
+        assertTrue( operator.isValid( Date.class ) );
+        assertTrue( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testILikeValidTypes()
+    {
+        ILike operator = new ILike( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertFalse( operator.isValid( Number.class ) );
+        assertFalse( operator.isValid( Date.class ) );
+        assertFalse( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testLikeValidTypes()
+    {
+        Like operator = new Like( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertFalse( operator.isValid( Number.class ) );
+        assertFalse( operator.isValid( Date.class ) );
+        assertFalse( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testLessEqualValidTypes()
+    {
+        LessEqual operator = new LessEqual( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertTrue( operator.isValid( Number.class ) );
+        assertTrue( operator.isValid( Date.class ) );
+        assertTrue( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testLessThanValidTypes()
+    {
+        LessThan operator = new LessThan( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertTrue( operator.isValid( Number.class ) );
+        assertTrue( operator.isValid( Date.class ) );
+        assertTrue( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testNullValidTypes()
+    {
+        Null operator = new Null( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertTrue( operator.isValid( Number.class ) );
+        assertTrue( operator.isValid( Date.class ) );
+        assertTrue( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+
+    @Test
+    public void testNotNullValidTypes()
+    {
+        NotNull operator = new NotNull( "operator" );
+
+        assertTrue( operator.isValid( String.class ) );
+        assertTrue( operator.isValid( Number.class ) );
+        assertTrue( operator.isValid( Date.class ) );
+        assertTrue( operator.isValid( Boolean.class ) );
+        assertFalse( operator.isValid( Collection.class ) );
+    }
+}