← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7064: Fixes meta-data export.

 

------------------------------------------------------------
revno: 7064
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-05-28 17:41:40 +0200
message:
  Fixes meta-data export.
modified:
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.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-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2012-05-27 21:50:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2012-05-28 15:41:40 +0000
@@ -106,7 +106,9 @@
             log.info( "Exporting " + idObjects.size() + " " + StringUtils.capitalize( entry.getKey() ) );
 
             List<? extends IdentifiableObject> idObjectsList = new ArrayList<IdentifiableObject>( idObjects );
-            ReflectionUtils.invokeSetterMethod( entry.getKey(), metaData, idObjectsList );
+
+            String fieldName = entry.getValue().getSimpleName() + "List";
+            ReflectionUtils.invokeSetterMethod( fieldName, metaData, idObjectsList );
         }
 
         log.info( "Finished export at " + new Date() );

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-05-25 21:10:19 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-05-28 15:41:40 +0000
@@ -94,7 +94,8 @@
 
         for ( Map.Entry<String, Class<?>> entry : ExchangeClasses.getImportMap().entrySet() )
         {
-            Object value = ReflectionUtils.invokeGetterMethod( entry.getKey(), metaData );
+            String fieldName = entry.getValue().getSimpleName() + "List";
+            Object value = ReflectionUtils.invokeGetterMethod( fieldName, metaData );
 
             if ( value != null )
             {

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java	2012-05-28 14:59:25 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ReflectionUtils.java	2012-05-28 15:41:40 +0000
@@ -222,13 +222,16 @@
         Field field = _findField( target.getClass(), StringUtils.uncapitalize( fieldName ) );
         Method method;
 
-        for ( String getterName : getterNames )
+        if ( field != null )
         {
-            method = _findMethod( target.getClass(), getterName + StringUtils.capitalize( field.getName() ), field.getType() );
-
-            if ( method != null )
+            for ( String getterName : getterNames )
             {
-                return method;
+                method = _findMethod( target.getClass(), getterName + StringUtils.capitalize( field.getName() ), field.getType() );
+
+                if ( method != null )
+                {
+                    return method;
+                }
             }
         }
 
@@ -258,13 +261,16 @@
         Field field = _findField( target.getClass(), StringUtils.uncapitalize( fieldName ) );
         Method method;
 
-        for ( String setterName : setterNames )
+        if ( field != null )
         {
-            method = _findMethod( target.getClass(), setterName + StringUtils.capitalize( field.getName() ), field.getType() );
-
-            if ( method != null )
+            for ( String setterName : setterNames )
             {
-                return method;
+                method = _findMethod( target.getClass(), setterName + StringUtils.capitalize( field.getName() ), field.getType() );
+
+                if ( method != null )
+                {
+                    return method;
+                }
             }
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java	2012-05-27 21:50:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MetaDataController.java	2012-05-28 15:41:40 +0000
@@ -80,7 +80,7 @@
         MetaData metaData = exportService.getMetaData( options );
 
         model.addAttribute( "model", metaData );
-        model.addAttribute( "view", "export" );
+        model.addAttribute( "viewClass", "export" );
 
         return "export";
     }