← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6661: fixed updateParents bug

 

------------------------------------------------------------
revno: 6661
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-04-20 11:34:30 +0300
message:
  fixed updateParents bug
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/importers/DefaultIdentifiableObjectImporter.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/OrganisationUnitUtils.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-04-19 16:40:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultExportService.java	2012-04-20 08:34:30 +0000
@@ -86,6 +86,8 @@
     {
         MetaData metaData = new MetaData();
 
+        System.err.println("Starting export..");
+
         if ( exportOptions.isAttributeTypes() )
         {
             metaData.setAttributeTypes( new ArrayList<Attribute>( manager.getAll( Attribute.class ) ) );
@@ -264,6 +266,8 @@
             metaData.setDataDictionaries( new ArrayList<DataDictionary>( manager.getAll( DataDictionary.class ) ) );
         }
 
+        System.err.println("Ending export..");
+
         return metaData;
     }
 }

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2012-04-19 19:39:07 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2012-04-20 08:34:30 +0000
@@ -171,7 +171,6 @@
         manager.update( oldObject );
 
         log.info( "Update successful." );
-        log.info( oldObject );
 
         return null;
     }
@@ -270,7 +269,11 @@
      */
     protected String getDisplayName( IdentifiableObject object )
     {
-        if ( object.getUid() != null )
+        if ( object.getName() != null )
+        {
+            return object.getName();
+        }
+        else if ( object.getUid() != null )
         {
             return object.getUid();
         }
@@ -278,10 +281,6 @@
         {
             return object.getCode();
         }
-        else if ( object.getName() != null )
-        {
-            return object.getName();
-        }
 
         return object.getClass().getName();
     }
@@ -611,7 +610,7 @@
     {
         for ( Field field : identifiableObjects.keySet() )
         {
-            IdentifiableObject ref = findObjectByReference( identifiableObject );
+            IdentifiableObject ref = findObjectByReference( identifiableObjects.get( field ) );
 
             if ( ref != null )
             {

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/OrganisationUnitUtils.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/OrganisationUnitUtils.java	2012-04-19 16:40:00 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/OrganisationUnitUtils.java	2012-04-20 08:34:30 +0000
@@ -44,29 +44,24 @@
 
         for ( OrganisationUnit organisationUnit : organisationUnits )
         {
-            OrganisationUnit parent = organisationUnit.getParent();
-
-            if ( parent != null )
-            {
-                if ( parent.getUid() != null )
-                {
-                    organisationUnitMap.put( parent.getUid(), parent );
-                }
-
-                if ( parent.getCode() != null )
-                {
-                    organisationUnitMap.put( parent.getCode(), parent );
-                }
-
-                if ( parent.getName() != null )
-                {
-                    organisationUnitMap.put( parent.getName(), parent );
-                }
-
-                if ( parent.getShortName() != null )
-                {
-                    organisationUnitMap.put( parent.getShortName(), parent );
-                }
+            if ( organisationUnit.getUid() != null )
+            {
+                organisationUnitMap.put( organisationUnit.getUid(), organisationUnit );
+            }
+
+            if ( organisationUnit.getCode() != null )
+            {
+                organisationUnitMap.put( organisationUnit.getCode(), organisationUnit );
+            }
+
+            if ( organisationUnit.getName() != null )
+            {
+                organisationUnitMap.put( organisationUnit.getName(), organisationUnit );
+            }
+
+            if ( organisationUnit.getShortName() != null )
+            {
+                organisationUnitMap.put( organisationUnit.getShortName(), organisationUnit );
             }
         }