=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java 2014-02-06 08:24:34 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebUtils.java 2014-02-06 09:59:02 +0000 @@ -214,11 +214,18 @@ if ( !ReflectionUtils.isCollection( o ) ) { - objMap.put( field, o ); + if ( IdentifiableObject.class.isInstance( o ) ) + { + objMap.put( field, getIdentifiableObjectProperties( (IdentifiableObject) o ) ); + } + else + { + objMap.put( field, o ); + } } else { - objMap.put( field, getIdentifiableObjectProperties( o ) ); + objMap.put( field, getIdentifiableObjectCollectionProperties( o ) ); } } } @@ -230,7 +237,7 @@ } @SuppressWarnings( "unchecked" ) - private static Object getIdentifiableObjectProperties( Object o ) + private static Object getIdentifiableObjectCollectionProperties( Object o ) { List> idPropertiesList = Lists.newArrayList(); Collection identifiableObjects; @@ -246,22 +253,28 @@ for ( IdentifiableObject identifiableObject : identifiableObjects ) { - Map idProps = Maps.newLinkedHashMap(); - - idProps.put( "id", identifiableObject.getUid() ); - idProps.put( "name", identifiableObject.getDisplayName() ); - - if ( identifiableObject.getCode() == null ) - { - idProps.put( "code", identifiableObject.getCode() ); - } - - idProps.put( "created", identifiableObject.getCreated() ); - idProps.put( "lastUpdated", identifiableObject.getLastUpdated() ); - + Map idProps = getIdentifiableObjectProperties( identifiableObject ); idPropertiesList.add( idProps ); } return idPropertiesList; } + + private static Map getIdentifiableObjectProperties( IdentifiableObject identifiableObject ) + { + Map idProps = Maps.newLinkedHashMap(); + + idProps.put( "id", identifiableObject.getUid() ); + idProps.put( "name", identifiableObject.getDisplayName() ); + + if ( identifiableObject.getCode() != null ) + { + idProps.put( "code", identifiableObject.getCode() ); + } + + idProps.put( "created", identifiableObject.getCreated() ); + idProps.put( "lastUpdated", identifiableObject.getLastUpdated() ); + + return idProps; + } }