=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/NodePropertyIntrospectorService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/NodePropertyIntrospectorService.java 2014-08-17 13:37:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/NodePropertyIntrospectorService.java 2014-08-20 05:24:14 +0000 @@ -38,6 +38,7 @@ import org.hisp.dhis.node.annotation.NodeAnnotation; import org.hisp.dhis.node.annotation.NodeCollection; import org.hisp.dhis.node.annotation.NodeComplex; +import org.hisp.dhis.node.annotation.NodeRoot; import org.hisp.dhis.node.annotation.NodeSimple; import org.hisp.dhis.system.util.ReflectionUtils; import org.springframework.util.StringUtils; @@ -224,6 +225,18 @@ { property.setName( nodeCollection.itemName() ); } + else // if itemName is not set, check to see if itemKlass have a @RootNode with a name + { + if ( property.getItemKlass() != null && property.getItemKlass().isAnnotationPresent( NodeRoot.class ) ) + { + NodeRoot nodeRoot = property.getItemKlass().getAnnotation( NodeRoot.class ); + + if ( !StringUtils.isEmpty( nodeRoot.value() ) ) + { + property.setName( nodeRoot.value() ); + } + } + } } private Method getGetter( Class klass, Field field ) === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/schema/FieldCollectionNodePropertyIntrospectorServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/schema/FieldCollectionNodePropertyIntrospectorServiceTest.java 2014-08-17 13:37:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/schema/FieldCollectionNodePropertyIntrospectorServiceTest.java 2014-08-20 05:24:14 +0000 @@ -29,6 +29,7 @@ */ import org.hisp.dhis.node.annotation.NodeCollection; +import org.hisp.dhis.node.annotation.NodeRoot; import org.hisp.dhis.node.annotation.NodeSimple; import org.junit.Before; import org.junit.Test; @@ -39,7 +40,7 @@ import static org.junit.Assert.*; -class Item +@NodeRoot( value = "collectionItem" ) class Item { @NodeSimple private String value; @@ -160,10 +161,16 @@ @Test public void testItemName() { - assertEquals( "items1", propertyMap.get( "items1" ).getName() ); + assertEquals( "collectionItem", propertyMap.get( "items1" ).getName() ); assertEquals( "items1", propertyMap.get( "items1" ).getCollectionName() ); assertEquals( "item", propertyMap.get( "items" ).getName() ); assertEquals( "items", propertyMap.get( "items" ).getCollectionName() ); } + + @Test + public void testItemKlass() + { + assertTrue( Item.class.equals( propertyMap.get( "items1" ).getItemKlass() ) ); + } }