← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16885: minor bugfix in property introspector, use collection name for map when property.isCollection = true

 

------------------------------------------------------------
revno: 16885
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-10-01 10:37:54 +0700
message:
  minor bugfix in property introspector, use collection name for map when property.isCollection = true
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.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-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java	2014-09-30 09:27:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java	2014-10-01 03:37:54 +0000
@@ -160,25 +160,13 @@
                 property.setAttribute( jacksonXmlProperty.isAttribute() );
             }
 
-            if ( method.isAnnotationPresent( JacksonXmlElementWrapper.class ) )
-            {
-                JacksonXmlElementWrapper jacksonXmlElementWrapper = method.getAnnotation( JacksonXmlElementWrapper.class );
-
-                // TODO what if element-wrapper have different namespace?
-                if ( !StringUtils.isEmpty( jacksonXmlElementWrapper.localName() ) )
-                {
-                    property.setCollectionName( jacksonXmlElementWrapper.localName() );
-                }
-            }
-
-            propertyMap.put( property.getName(), property );
-
             Class<?> returnType = method.getReturnType();
             property.setKlass( returnType );
 
             if ( Collection.class.isAssignableFrom( returnType ) )
             {
                 property.setCollection( true );
+                property.setCollectionName( property.getName() );
 
                 Type type = method.getGenericReturnType();
 
@@ -211,6 +199,26 @@
                     property.setSimple( true );
                 }
             }
+
+            if ( property.isCollection() )
+            {
+                if ( method.isAnnotationPresent( JacksonXmlElementWrapper.class ) )
+                {
+                    JacksonXmlElementWrapper jacksonXmlElementWrapper = method.getAnnotation( JacksonXmlElementWrapper.class );
+
+                    // TODO what if element-wrapper have different namespace?
+                    if ( !StringUtils.isEmpty( jacksonXmlElementWrapper.localName() ) )
+                    {
+                        property.setCollectionName( jacksonXmlElementWrapper.localName() );
+                    }
+                }
+
+                propertyMap.put( property.getCollectionName(), property );
+            }
+            else
+            {
+                propertyMap.put( property.getName(), property );
+            }
         }
 
         return propertyMap;