← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6473: minor changes

 

------------------------------------------------------------
revno: 6473
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-04-03 14:59:54 +0200
message:
  minor changes
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/Importer.java
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.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-03 10:24:37 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/DefaultImportService.java	2012-04-03 12:59:54 +0000
@@ -145,7 +145,7 @@
         if ( importer != null )
         {
             List<ImportConflict> conflicts = importer.importCollection( objects, importOptions );
-            ImportCount count = importer.getImportCount();
+            ImportCount count = importer.getCurrentImportCount();
 
             importSummary.getConflicts().addAll( conflicts );
             importSummary.getCounts().add( count );

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Importer.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Importer.java	2012-04-03 10:24:37 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/Importer.java	2012-04-03 12:59:54 +0000
@@ -38,11 +38,28 @@
  */
 public interface Importer<T>
 {
+    /**
+     * @param object  Object to import
+     * @param options Import options
+     * @return ImportConflict instance if a conflict occurred, if not null
+     */
     ImportConflict importObject( T object, ImportOptions options );
 
+    /**
+     * Import a collection of objects.
+     *
+     * @param objects The collection to import
+     * @param options Import options
+     * @return List of all the ImportConflicts encountered
+     */
     List<ImportConflict> importCollection( Collection<T> objects, ImportOptions options );
 
-    ImportCount getImportCount();
+    /**
+     * Get an ImportCount instance for the current import numbers.
+     *
+     * @return ImportCount instance filled with current values
+     */
+    ImportCount getCurrentImportCount();
 
     boolean canHandle( Class<?> clazz );
 }

=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java	2012-04-03 10:24:37 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/AbstractImporter.java	2012-04-03 12:59:54 +0000
@@ -47,21 +47,53 @@
 public abstract class AbstractImporter<T extends IdentifiableObject>
     implements Importer<T>
 {
+    //-------------------------------------------------------------------------------------------------------
+    // Dependencies
+    //-------------------------------------------------------------------------------------------------------
+
     @Autowired
     private IdentifiableObjectManager manager;
 
+    //-------------------------------------------------------------------------------------------------------
+    // Current import counts
+    //-------------------------------------------------------------------------------------------------------
+
     protected int imports;
 
     protected int updates;
 
     protected int ignores;
 
+    //-------------------------------------------------------------------------------------------------------
+    // Abstract methods that sub-classes needs to implement
+    //-------------------------------------------------------------------------------------------------------
+
+    /**
+     * Called every time a new object is to be imported.
+     *
+     * @param object Object to import
+     */
     protected abstract void newObject( T object );
 
+    /**
+     * Update object from old => new.
+     *
+     * @param object    Object to import
+     * @param oldObject The current version of the object
+     */
     protected abstract void updatedObject( T object, T oldObject );
 
+    /**
+     * Current object name, used to fill name part of a ImportConflict
+     *
+     * @return Name of object
+     */
     protected abstract String getObjectName();
 
+    //-------------------------------------------------------------------------------------------------------
+    // Importer<T> Implementation
+    //-------------------------------------------------------------------------------------------------------
+
     @Override
     public List<ImportConflict> importCollection( Collection<T> objects, ImportOptions options )
     {
@@ -131,7 +163,7 @@
     }
 
     @Override
-    public ImportCount getImportCount()
+    public ImportCount getCurrentImportCount()
     {
         ImportCount importCount = new ImportCount( getObjectName() );
 
@@ -142,6 +174,10 @@
         return importCount;
     }
 
+    //-------------------------------------------------------------------------------------------------------
+    // Helpers
+    //-------------------------------------------------------------------------------------------------------
+
     protected Map<String, T> getIdMap( Class<T> clazz, IdScheme scheme )
     {
         if ( scheme.isUidScheme() )