=== 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-06-07 13:45:37 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java 2014-06-07 19:14:09 +0000 @@ -159,40 +159,47 @@ if ( fieldValue.isEmpty() ) { + List fields = FilterService.FIELD_PRESETS.get( "identifiable" ); + if ( property.isCollection() ) { + Collection collection = (Collection) returnValue; + + CollectionNode collectionNode = complexNode.addChild( new CollectionNode( property.getCollectionName() ) ); + collectionNode.setNamespace( property.getNamespaceURI() ); + if ( property.isIdentifiableObject() ) { - complexNode.addChild( getCollectionProperties( returnValue, FilterService.FIELD_PRESETS.get( "identifiable" ), property ) ); + for ( Object collectionObject : collection ) + { + collectionNode.addChild( getProperties( collectionObject, fields ) ); + } } - else + else if ( !property.isSimple() ) { - CollectionNode collectionNode = complexNode.addChild( new CollectionNode( property.getCollectionName() ) ); - collectionNode.setNamespace( property.getNamespaceURI() ); - Map map = getFullFieldMap( schemaService.getDynamicSchema( property.getItemKlass() ) ); - for ( Object collectionObject : (Collection) returnValue ) + for ( Object collectionObject : collection ) { - if ( map.isEmpty() ) - { - collectionNode.addChild( new SimpleNode( property.getName(), collectionObject ) ); - } - else - { - ComplexNode node = buildObjectOutput( map, collectionObject ); + ComplexNode node = buildObjectOutput( map, collectionObject ); - if ( !node.getChildren().isEmpty() ) - { - collectionNode.addChild( node ); - } + if ( !node.getChildren().isEmpty() ) + { + collectionNode.addChild( node ); } } } + else + { + for ( Object collectionObject : collection ) + { + collectionNode.addChild( new SimpleNode( property.getName(), collectionObject ) ); + } + } } else if ( property.isIdentifiableObject() ) { - complexNode.addChild( getProperties( returnValue, FilterService.FIELD_PRESETS.get( "identifiable" ) ) ); + complexNode.addChild( getProperties( returnValue, fields ) ); } else { @@ -312,32 +319,6 @@ return map; } - @SuppressWarnings( "unchecked" ) - private CollectionNode getCollectionProperties( Object object, List fields, Property property ) - { - if ( object == null ) - { - return null; - } - - if ( !Collection.class.isInstance( object ) ) - { - return null; - } - - CollectionNode collectionNode = new CollectionNode( property.getCollectionName() ); - collectionNode.setNamespace( property.getNamespaceURI() ); - - Collection collection = (Collection) object; - - for ( Object collectionObject : collection ) - { - collectionNode.addChild( getProperties( collectionObject, fields ) ); - } - - return collectionNode; - } - private ComplexNode getProperties( Object object, List fields ) { if ( object == null ) @@ -374,7 +355,7 @@ return complexNode; } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") private boolean evaluateWithFilters( T object, Filters filters ) { Schema schema = schemaService.getDynamicSchema( object.getClass() );