=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/InOp.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/InOp.java 2015-05-29 18:36:33 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/InOp.java 2015-06-05 03:07:51 +0000 @@ -29,6 +29,7 @@ */ import java.util.Collection; +import java.util.Date; /** * @author Morten Olav Hansen @@ -36,24 +37,71 @@ public class InOp extends Op { @Override - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public OpStatus evaluate( Object object ) { Collection items = getValue( Collection.class ); - if ( items == null ) + if ( items == null || object == null ) { - return OpStatus.INCLUDE; + return OpStatus.IGNORE; } for ( String item : items ) { - if ( item.equals( object ) ) + if ( compare( item, object ) ) { return OpStatus.INCLUDE; } } - return OpStatus.IGNORE; + return OpStatus.EXCLUDE; + } + + 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; } } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/Op.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/Op.java 2015-04-09 08:59:36 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ops/Op.java 2015-06-05 03:07:51 +0000 @@ -57,5 +57,10 @@ return QueryUtils.getValue( klass, value ); } + public T getValue( Class klass, Object value ) + { + return QueryUtils.getValue( klass, value ); + } + public abstract OpStatus evaluate( Object object ); }