← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15582: minor fix to FilterService

 

------------------------------------------------------------
revno: 15582
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-06-07 15:35:27 +0200
message:
  minor fix to FilterService
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java
  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-api/src/main/java/org/hisp/dhis/option/OptionSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/option/OptionSet.java	2014-06-07 13:35:27 +0000
@@ -47,13 +47,13 @@
 /**
  * @author Lars Helge Overland
  */
-@JacksonXmlRootElement( localName = "optionSet", namespace = DxfNamespaces.DXF_2_0)
+@JacksonXmlRootElement( localName = "optionSet", namespace = DxfNamespaces.DXF_2_0 )
 public class OptionSet
     extends BaseIdentifiableObject
 {
     private static final Pattern OPTION_PATTERN = Pattern.compile( "\\[(.*)\\]" );
 
-    private List<String> options = new ArrayList<String>();
+    private List<String> options = new ArrayList<>();
 
     /**
      * Indicating version number.
@@ -75,9 +75,9 @@
     }
 
     @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "options", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "option", namespace = DxfNamespaces.DXF_2_0)
+    @JsonView( { DetailedView.class, ExportView.class } )
+    @JacksonXmlElementWrapper( localName = "options", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "option", namespace = DxfNamespaces.DXF_2_0 )
     public List<String> getOptions()
     {
         return options;

=== 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 06:08:25 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java	2014-06-07 13:35:27 +0000
@@ -125,7 +125,7 @@
         return collectionNode;
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     private ComplexNode buildObjectOutput( Map<String, Map> fieldMap, Object object )
     {
         if ( object == null )
@@ -174,11 +174,19 @@
 
                         for ( Object collectionObject : (Collection<?>) returnValue )
                         {
-                            ComplexNode node = buildObjectOutput( map, collectionObject );
+                            if ( map.isEmpty() )
+                            {
+                                SimpleNode simpleNode = new SimpleNode( property.getName(), collectionObject );
+                                collectionNode.addChild( simpleNode );
+                            }
+                            else
+                            {
+                                ComplexNode node = buildObjectOutput( map, collectionObject );
 
-                            if ( !node.getChildren().isEmpty() )
-                            {
-                                collectionNode.addChild( node );
+                                if ( !node.getChildren().isEmpty() )
+                                {
+                                    collectionNode.addChild( node );
+                                }
                             }
                         }
                     }
@@ -367,7 +375,7 @@
         return complexNode;
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     private <T> boolean evaluateWithFilters( T object, Filters filters )
     {
         Schema schema = schemaService.getDynamicSchema( object.getClass() );