=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/config/InclusionStrategy.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/config/InclusionStrategy.java 2014-06-17 14:33:44 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/config/InclusionStrategy.java 2014-06-17 15:45:23 +0000 @@ -50,40 +50,40 @@ * Inclusion strategy that only includes non null objects. */ NON_NULL - { - @Override - public boolean include( T object ) { - return object != null; - } - }, + @Override + public boolean include( T object ) + { + return object != null; + } + }, /** * Inclusion strategy that only includes non empty objects: * - */ NON_EMPTY - { - @Override - public boolean include( T object ) { - if ( object == null ) - { - return false; - } - - if ( Collection.class.isAssignableFrom( object.getClass() ) ) - { - return !((Collection) object).isEmpty(); - } - else if ( String.class.isAssignableFrom( object.getClass() ) ) - { - return !StringUtils.isEmpty( object ); - } - - return true; - } - }; + @Override + public boolean include( T object ) + { + if ( object == null ) + { + return false; + } + + if ( Collection.class.isAssignableFrom( object.getClass() ) ) + { + return !((Collection) object).isEmpty(); + } + else if ( String.class.isAssignableFrom( object.getClass() ) ) + { + return !StringUtils.isEmpty( object ); + } + + return true; + } + }; @Override public boolean include( T object ) === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-06-17 15:28:24 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-06-17 15:45:23 +0000 @@ -28,6 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import com.google.common.base.Enums; import com.google.common.base.Optional; import com.google.common.collect.Lists; import org.hisp.dhis.acl.Access; @@ -47,6 +48,7 @@ import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException; import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException; import org.hisp.dhis.importexport.ImportStrategy; +import org.hisp.dhis.node.config.InclusionStrategy; import org.hisp.dhis.node.types.CollectionNode; import org.hisp.dhis.node.types.ComplexNode; import org.hisp.dhis.node.types.RootNode; @@ -181,6 +183,8 @@ rootNode.setDefaultNamespace( DxfNamespaces.DXF_2_0 ); rootNode.setNamespace( DxfNamespaces.DXF_2_0 ); + rootNode.getConfig().setInclusionStrategy( getInclusionStrategy( parameters.get( "inclusionStrategy" ) ) ); + if ( pager != null ) { ComplexNode pagerNode = rootNode.addChild( new ComplexNode( "pager" ) ); @@ -256,6 +260,8 @@ rootNode.setNamespace( DxfNamespaces.DXF_2_0 ); rootNode.addChild( collectionNode ); + rootNode.getConfig().setInclusionStrategy( getInclusionStrategy( parameters.get( "inclusionStrategy" ) ) ); + return rootNode; } else @@ -264,6 +270,8 @@ rootNode.setDefaultNamespace( DxfNamespaces.DXF_2_0 ); rootNode.setNamespace( DxfNamespaces.DXF_2_0 ); + rootNode.getConfig().setInclusionStrategy( getInclusionStrategy( parameters.get( "inclusionStrategy" ) ) ); + return rootNode; } } @@ -552,4 +560,19 @@ throw new RuntimeException( ex ); } } + + private InclusionStrategy.Include getInclusionStrategy( String inclusionStrategy ) + { + if ( inclusionStrategy != null ) + { + Optional optional = Enums.getIfPresent( InclusionStrategy.Include.class, inclusionStrategy ); + + if ( optional.isPresent() ) + { + return optional.get(); + } + } + + return InclusionStrategy.Include.NON_NULL; + } }