← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6685: Fixed ou importer bugs. Should now be able to bootstrap empty db.

 

------------------------------------------------------------
revno: 6685
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-04-23 00:25:27 +0300
message:
  Fixed ou importer bugs. Should now be able to bootstrap empty db.
modified:
  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/DefaultObjectBridge.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.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/DefaultImportService.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-04-22 18:21:40 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-04-22 21:25:27 +0000
@@ -131,12 +131,13 @@
 
         doImport( metaData.getDataSets(), importOptions, importSummary );
 */
+        cacheManager.clearCache();
+        objectBridge.destroy();
+
         Date endDate = new Date();
         log.info( "Started import at " + startDate );
         log.info( "Finished import at " + endDate );
 
-        objectBridge.destroy();
-        cacheManager.clearCache();
 
         return importSummary;
     }

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2012-04-22 20:14:05 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2012-04-22 21:25:27 +0000
@@ -27,14 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.IdentifiableObject;
@@ -49,6 +41,8 @@
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.*;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */

=== 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-22 18:54:45 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2012-04-22 21:25:27 +0000
@@ -30,7 +30,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.BaseIdentifiableObject;
-import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.common.annotation.Scanned;
@@ -42,6 +41,7 @@
 import org.hisp.dhis.dxf2.utils.OrganisationUnitUtils;
 import org.hisp.dhis.importexport.ImportStrategy;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitComparator;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -107,7 +107,9 @@
     {
         // make sure that the internalId is 0, so that the system will generate a ID
         object.setId( 0 );
-        object.setUid( CodeGenerator.generateCode() );
+
+        // FIXME add uidValidator.. part of bean validation impl?
+        // object.setUid( CodeGenerator.generateCode() );
 
         log.debug( "Trying to save new object => " + getDisplayName( object ) );
 
@@ -467,7 +469,8 @@
     {
         for ( Field field : identifiableObjects.keySet() )
         {
-            IdentifiableObject ref = findObjectByReference( identifiableObjects.get( field ) );
+            IdentifiableObject idObject = identifiableObjects.get( field );
+            IdentifiableObject ref = findObjectByReference( idObject );
 
             if ( ref != null )
             {
@@ -475,7 +478,10 @@
             }
             else
             {
-                log.warn( "Ignored reference " + ref + " on object " + identifiableObject + "." );
+                if ( !OrganisationUnitGroupSet.class.isInstance( idObject ) )
+                {
+                    log.warn( "Ignored reference " + idObject + " on object " + identifiableObject + "." );
+                }
             }
         }
     }
@@ -483,8 +489,7 @@
     private Map<Field, Set<? extends IdentifiableObject>> scanIdentifiableObjectCollections( IdentifiableObject
         identifiableObject )
     {
-        Map<Field, Set<? extends IdentifiableObject>> collected = new HashMap<Field,
-            Set<? extends IdentifiableObject>>();
+        Map<Field, Set<? extends IdentifiableObject>> collected = new HashMap<Field, Set<? extends IdentifiableObject>>();
         Field[] fields = identifiableObject.getClass().getDeclaredFields();
 
         for ( Field field : fields )
@@ -541,7 +546,7 @@
                 }
                 else
                 {
-                    log.warn( "Ignored reference " + ref + " on object " + identifiableObject + "." );
+                    log.warn( "Ignored reference " + idObject + " on object " + identifiableObject + "." );
                 }
             }