← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6676: minor fixes

 

------------------------------------------------------------
revno: 6676
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-04-22 19:42:06 +0300
message:
  minor fixes
modified:
  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/DefaultObjectBridge.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2012-04-22 16:16:24 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultObjectBridge.java	2012-04-22 16:42:06 +0000
@@ -67,17 +67,17 @@
     // Internal and Semi-Public maps
     //-------------------------------------------------------------------------------------------------------
 
-    private Map<Class<?>, Collection<?>> masterMap = new HashMap<Class<?>, Collection<?>>();
-
-    private Map<String, PeriodType> periodTypeMap = new HashMap<String, PeriodType>();
-
-    private Map<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>> uidMap = new HashMap<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>>();
-
-    private Map<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>> codeMap = new HashMap<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>>();
-
-    private Map<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>> nameMap = new HashMap<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>>();
-
-    private Map<Class<? extends NameableObject>, Map<String, NameableObject>> shortNameMap = new HashMap<Class<? extends NameableObject>, Map<String, NameableObject>>();
+    private Map<Class<?>, Collection<?>> masterMap;
+
+    private Map<String, PeriodType> periodTypeMap;
+
+    private Map<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>> uidMap;
+
+    private Map<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>> codeMap;
+
+    private Map<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>> nameMap;
+
+    private Map<Class<? extends NameableObject>, Map<String, NameableObject>> shortNameMap;
 
     private static final List<Class<?>> registeredTypes = new ArrayList<Class<?>>();
 
@@ -100,6 +100,13 @@
     {
         log.info( "Started updating lookup maps at " + new Date() );
 
+        masterMap = new HashMap<Class<?>, Collection<?>>();
+        periodTypeMap = new HashMap<String, PeriodType>();
+        uidMap = new HashMap<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>>();
+        codeMap = new HashMap<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>>();
+        nameMap = new HashMap<Class<? extends IdentifiableObject>, Map<String, IdentifiableObject>>();
+        shortNameMap = new HashMap<Class<? extends NameableObject>, Map<String, NameableObject>>();
+
         for ( Class<?> type : registeredTypes )
         {
             populatePeriodTypeMap( type );

=== 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 16:16:24 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2012-04-22 16:42:06 +0000
@@ -182,7 +182,7 @@
             return conflicts;
         }
 
-        reset();
+        init( options );
 
         // FIXME a bit too static.. implement "pre handler" for types?
         if ( OrganisationUnit.class.isAssignableFrom( objects.get( 0 ).getClass() ) )
@@ -207,7 +207,7 @@
     @Override
     public ImportConflict importObject( T object, ImportOptions options )
     {
-        reset();
+        init( options );
 
         return importObjectLocal( object, options );
     }
@@ -254,11 +254,17 @@
     // Helpers
     //-------------------------------------------------------------------------------------------------------
 
-    private void reset()
+    private void init( ImportOptions options )
     {
         imported = 0;
         updated = 0;
         ignored = 0;
+
+        if ( options.isDryRun() )
+        {
+            // disable writing on the persistence layer
+            objectBridge.setWriteEnabled( false );
+        }
     }
 
     private ImportConflict importObjectLocal( T object, ImportOptions options )