← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14195: minor fix

 

------------------------------------------------------------
revno: 14195
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-03-12 09:16:09 +0100
message:
  minor fix
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EmptyCollectionOp.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EqOp.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Filters.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GtOp.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GteOp.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LikeOp.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LtOp.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LteOp.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NeqOp.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NullOp.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Op.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
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EmptyCollectionOp.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EmptyCollectionOp.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EmptyCollectionOp.java	2014-03-12 08:16:09 +0000
@@ -36,23 +36,23 @@
 public class EmptyCollectionOp extends Op
 {
     @Override
-    public boolean wantLeft()
+    public boolean wantValue()
     {
         return false;
     }
 
     @Override
-    public OpStatus evaluate( Object right )
+    public OpStatus evaluate( Object object )
     {
-        if ( right == null )
+        if ( object == null )
         {
             // TODO: ignore or include here?
             return OpStatus.IGNORE;
         }
 
-        if ( Collection.class.isInstance( right ) )
+        if ( Collection.class.isInstance( object ) )
         {
-            Collection<?> c = (Collection<?>) right;
+            Collection<?> c = (Collection<?>) object;
 
             if ( c.isEmpty() )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EqOp.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EqOp.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/EqOp.java	2014-03-12 08:16:09 +0000
@@ -36,45 +36,45 @@
 public class EqOp extends Op
 {
     @Override
-    public OpStatus evaluate( Object right )
+    public OpStatus evaluate( Object object )
     {
-        if ( getLeft() == null || right == null )
+        if ( getValue() == null || object == null )
         {
             return OpStatus.IGNORE;
         }
 
-        if ( String.class.isInstance( right ) )
-        {
-            String s1 = getLeft( String.class );
-            String s2 = (String) right;
-
-            return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Boolean.class.isInstance( right ) )
-        {
-            Boolean s1 = getLeft( Boolean.class );
-            Boolean s2 = (Boolean) right;
-
-            return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Integer.class.isInstance( right ) )
-        {
-            Integer s1 = getLeft( Integer.class );
-            Integer s2 = (Integer) right;
-
-            return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Float.class.isInstance( right ) )
-        {
-            Float s1 = getLeft( Float.class );
-            Float s2 = (Float) right;
-
-            return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Collection.class.isInstance( right ) )
-        {
-            Collection<?> collection = (Collection<?>) right;
-            Integer size = getLeft( Integer.class );
+        if ( String.class.isInstance( object ) )
+        {
+            String s1 = getValue( String.class );
+            String s2 = (String) object;
+
+            return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Boolean.class.isInstance( object ) )
+        {
+            Boolean s1 = getValue( Boolean.class );
+            Boolean s2 = (Boolean) object;
+
+            return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Integer.class.isInstance( object ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) object;
+
+            return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Float.class.isInstance( object ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) object;
+
+            return (s1 != null && s2.equals( s1 )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Collection.class.isInstance( object ) )
+        {
+            Collection<?> collection = (Collection<?>) object;
+            Integer size = getValue( Integer.class );
 
             if ( size != null && collection.size() == size )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Filters.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Filters.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Filters.java	2014-03-12 08:16:09 +0000
@@ -35,7 +35,6 @@
 /**
 * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
 */
-@SuppressWarnings( "unchecked" )
 public class Filters
 {
     private Map<String, Object> filters = Maps.newHashMap();
@@ -57,20 +56,21 @@
         {
             Op op = OpFactory.create( operator );
 
-            if ( op.wantLeft() )
+            if ( op.wantValue() )
             {
                 if ( value == null )
                 {
                     return;
                 }
 
-                op.setLeft( value );
+                op.setValue( value );
             }
 
             filterOps.addFilter( operator, op );
         }
     }
 
+    @SuppressWarnings( "unchecked" )
     private FilterOps createPath( String path )
     {
         if ( !path.contains( "." ) )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GtOp.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GtOp.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GtOp.java	2014-03-12 08:16:09 +0000
@@ -36,31 +36,31 @@
 public class GtOp extends Op
 {
     @Override
-    public OpStatus evaluate( Object right )
+    public OpStatus evaluate( Object object )
     {
-        if ( getLeft() == null || right == null )
+        if ( getValue() == null || object == null )
         {
             return OpStatus.IGNORE;
         }
 
-        if ( Integer.class.isInstance( right ) )
-        {
-            Integer s1 = getLeft( Integer.class );
-            Integer s2 = (Integer) right;
-
-            return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Float.class.isInstance( right ) )
-        {
-            Float s1 = getLeft( Float.class );
-            Float s2 = (Float) right;
-
-            return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Collection.class.isInstance( right ) )
-        {
-            Collection<?> collection = (Collection<?>) right;
-            Integer size = getLeft( Integer.class );
+        if ( Integer.class.isInstance( object ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) object;
+
+            return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Float.class.isInstance( object ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) object;
+
+            return (s1 != null && s2 > s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Collection.class.isInstance( object ) )
+        {
+            Collection<?> collection = (Collection<?>) object;
+            Integer size = getValue( Integer.class );
 
             if ( size != null && collection.size() > size )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GteOp.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GteOp.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/GteOp.java	2014-03-12 08:16:09 +0000
@@ -28,9 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.api.utils.ops.Op;
-import org.hisp.dhis.api.utils.ops.OpStatus;
-
 import java.util.Collection;
 
 /**
@@ -39,31 +36,31 @@
 public class GteOp extends Op
 {
     @Override
-    public OpStatus evaluate( Object right )
+    public OpStatus evaluate( Object object )
     {
-        if ( getLeft() == null || right == null )
+        if ( getValue() == null || object == null )
         {
             return OpStatus.IGNORE;
         }
 
-        if ( Integer.class.isInstance( right ) )
-        {
-            Integer s1 = getLeft( Integer.class );
-            Integer s2 = (Integer) right;
-
-            return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Float.class.isInstance( right ) )
-        {
-            Float s1 = getLeft( Float.class );
-            Float s2 = (Float) right;
-
-            return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Collection.class.isInstance( right ) )
-        {
-            Collection<?> collection = (Collection<?>) right;
-            Integer size = getLeft( Integer.class );
+        if ( Integer.class.isInstance( object ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) object;
+
+            return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Float.class.isInstance( object ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) object;
+
+            return (s1 != null && s2 >= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Collection.class.isInstance( object ) )
+        {
+            Collection<?> collection = (Collection<?>) object;
+            Integer size = getValue( Integer.class );
 
             if ( size != null && collection.size() >= size )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LikeOp.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LikeOp.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LikeOp.java	2014-03-12 08:16:09 +0000
@@ -34,17 +34,17 @@
 public class LikeOp extends Op
 {
     @Override
-    public OpStatus evaluate( Object right )
+    public OpStatus evaluate( Object object )
     {
-        if ( getLeft() == null || right == null )
+        if ( getValue() == null || object == null )
         {
             return OpStatus.IGNORE;
         }
 
-        if ( String.class.isInstance( right ) )
+        if ( String.class.isInstance( object ) )
         {
-            String s1 = getLeft( String.class );
-            String s2 = (String) right;
+            String s1 = getValue( String.class );
+            String s2 = (String) object;
 
             return (s1 != null && s2.toLowerCase().contains( s1.toLowerCase() )) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
         }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LtOp.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LtOp.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LtOp.java	2014-03-12 08:16:09 +0000
@@ -36,31 +36,31 @@
 public class LtOp extends Op
 {
     @Override
-    public OpStatus evaluate( Object right )
+    public OpStatus evaluate( Object object )
     {
-        if ( getLeft() == null || right == null )
+        if ( getValue() == null || object == null )
         {
             return OpStatus.IGNORE;
         }
 
-        if ( Integer.class.isInstance( right ) )
-        {
-            Integer s1 = getLeft( Integer.class );
-            Integer s2 = (Integer) right;
-
-            return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Float.class.isInstance( right ) )
-        {
-            Float s1 = getLeft( Float.class );
-            Float s2 = (Float) right;
-
-            return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Collection.class.isInstance( right ) )
-        {
-            Collection<?> collection = (Collection<?>) right;
-            Integer size = getLeft( Integer.class );
+        if ( Integer.class.isInstance( object ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) object;
+
+            return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Float.class.isInstance( object ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) object;
+
+            return (s1 != null && s2 < s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Collection.class.isInstance( object ) )
+        {
+            Collection<?> collection = (Collection<?>) object;
+            Integer size = getValue( Integer.class );
 
             if ( size != null && collection.size() < size )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LteOp.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LteOp.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/LteOp.java	2014-03-12 08:16:09 +0000
@@ -28,9 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.api.utils.ops.Op;
-import org.hisp.dhis.api.utils.ops.OpStatus;
-
 import java.util.Collection;
 
 /**
@@ -39,31 +36,31 @@
 public class LteOp extends Op
 {
     @Override
-    public OpStatus evaluate( Object right )
+    public OpStatus evaluate( Object object )
     {
-        if ( getLeft() == null || right == null )
+        if ( getValue() == null || object == null )
         {
             return OpStatus.IGNORE;
         }
 
-        if ( Integer.class.isInstance( right ) )
-        {
-            Integer s1 = getLeft( Integer.class );
-            Integer s2 = (Integer) right;
-
-            return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Float.class.isInstance( right ) )
-        {
-            Float s1 = getLeft( Float.class );
-            Float s2 = (Float) right;
-
-            return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
-        }
-        else if ( Collection.class.isInstance( right ) )
-        {
-            Collection<?> collection = (Collection<?>) right;
-            Integer size = getLeft( Integer.class );
+        if ( Integer.class.isInstance( object ) )
+        {
+            Integer s1 = getValue( Integer.class );
+            Integer s2 = (Integer) object;
+
+            return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Float.class.isInstance( object ) )
+        {
+            Float s1 = getValue( Float.class );
+            Float s2 = (Float) object;
+
+            return (s1 != null && s2 <= s1) ? OpStatus.INCLUDE : OpStatus.EXCLUDE;
+        }
+        else if ( Collection.class.isInstance( object ) )
+        {
+            Collection<?> collection = (Collection<?>) object;
+            Integer size = getValue( Integer.class );
 
             if ( size != null && collection.size() <= size )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NeqOp.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NeqOp.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NeqOp.java	2014-03-12 08:16:09 +0000
@@ -36,10 +36,10 @@
     private Op op = OpFactory.create( "eq" );
 
     @Override
-    public OpStatus evaluate( Object right )
+    public OpStatus evaluate( Object object )
     {
-        op.setLeft( getLeft() );
-        OpStatus status = op.evaluate( right );
+        op.setValue( getValue() );
+        OpStatus status = op.evaluate( object );
 
         // switch status from EqOp
         switch ( status )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NullOp.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NullOp.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/NullOp.java	2014-03-12 08:16:09 +0000
@@ -28,24 +28,21 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hisp.dhis.api.utils.ops.Op;
-import org.hisp.dhis.api.utils.ops.OpStatus;
-
 /**
 * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
 */
 public class NullOp extends Op
 {
     @Override
-    public boolean wantLeft()
+    public boolean wantValue()
     {
         return false;
     }
 
     @Override
-    public OpStatus evaluate( Object right )
+    public OpStatus evaluate( Object object )
     {
-        if ( right == null )
+        if ( object == null )
         {
             return OpStatus.INCLUDE;
         }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Op.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Op.java	2014-03-10 04:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ops/Op.java	2014-03-12 08:16:09 +0000
@@ -28,41 +28,43 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Date;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
 public abstract class Op
 {
-    private String left;
+    private String value;
 
-    public boolean wantLeft()
+    public boolean wantValue()
     {
         return true;
     }
 
-    public void setLeft( String left )
+    public void setValue( String value )
     {
-        this.left = left;
+        this.value = value;
     }
 
-    public String getLeft()
+    public String getValue()
     {
-        return left;
+        return value;
     }
 
     @SuppressWarnings( "unchecked" )
-    public <T> T getLeft( Class<?> klass )
+    public <T> T getValue( Class<?> klass )
     {
-        if ( klass.isInstance( left ) )
+        if ( klass.isInstance( value ) )
         {
-            return (T) left;
+            return (T) value;
         }
 
         if ( Boolean.class.isAssignableFrom( klass ) )
         {
             try
             {
-                return (T) Boolean.valueOf( left );
+                return (T) Boolean.valueOf( value );
             }
             catch ( Exception ignored )
             {
@@ -72,7 +74,7 @@
         {
             try
             {
-                return (T) Integer.valueOf( left );
+                return (T) Integer.valueOf( value );
             }
             catch ( Exception ignored )
             {
@@ -82,15 +84,18 @@
         {
             try
             {
-                return (T) Float.valueOf( left );
+                return (T) Float.valueOf( value );
             }
             catch ( Exception ignored )
             {
             }
         }
+        else if ( Date.class.isAssignableFrom( klass ) )
+        {
+        }
 
         return null;
     }
 
-    public abstract OpStatus evaluate( Object right );
+    public abstract OpStatus evaluate( Object object );
 }