dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28608
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14295: change filter logic for collections, return true if one or more matches (do not require all match...
------------------------------------------------------------
revno: 14295
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-03-19 16:46:00 +0100
message:
change filter logic for collections, return true if one or more matches (do not require all matches anymore)
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java 2014-03-19 15:46:00 +0000
@@ -38,7 +38,6 @@
import org.hisp.dhis.system.util.ReflectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -125,7 +124,7 @@
return output;
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
private Map<String, Object> buildObjectOutput( Object object, Map<String, Map> fieldMap )
{
if ( object == null )
@@ -164,7 +163,7 @@
Map<String, Object> properties = getIdentifiableObjectProperties( returned );
output.put( key, properties );
}
- else if ( descriptor.isCollection() )
+ else
{
List<Map<String, Object>> properties = getIdentifiableObjectCollectionProperties( returned );
output.put( key, properties );
@@ -175,7 +174,7 @@
if ( descriptor.isCollection() )
{
Collection<?> objects = (Collection<?>) returned;
- ArrayList<Object> arrayList = Lists.newArrayList();
+ List<Object> arrayList = Lists.newArrayList();
output.put( key, arrayList );
for ( Object obj : objects )
@@ -201,7 +200,7 @@
return getIdentifiableObjectCollectionProperties( object, fields );
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
private List<Map<String, Object>> getIdentifiableObjectCollectionProperties( Object object, List<String> fields )
{
List<Map<String, Object>> output = Lists.newArrayList();
@@ -257,7 +256,7 @@
return idProps;
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
private <T extends IdentifiableObject> boolean evaluateWithFilters( T object, Filters filters )
{
Map<String, ReflectionUtils.PropertyDescriptor> classMap = ReflectionUtils.getJacksonClassMap( object.getClass() );
@@ -306,7 +305,7 @@
return false;
}
}
- else if ( descriptor.isIdentifiableObject() && descriptor.isCollection() )
+ else if ( descriptor.isIdentifiableObject() )
{
Collection<?> idObjectCollection = (Collection<?>) value;
@@ -315,13 +314,20 @@
return false;
}
+ boolean include = false;
+
for ( Object idObject : idObjectCollection )
{
- if ( !evaluateWithFilters( (IdentifiableObject) idObject, f ) )
+ if ( evaluateWithFilters( (IdentifiableObject) idObject, f ) )
{
- return false;
+ include = true;
}
}
+
+ if ( !include )
+ {
+ return false;
+ }
}
}
}
@@ -354,6 +360,7 @@
return true;
}
}
+
return false;
}
}