← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1939: Centralized import of datavalues

 

------------------------------------------------------------
revno: 1939
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Tue 2010-06-01 10:53:29 +0200
message:
  Centralized import of datavalues
modified:
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/importer/DefaultDhis14FileImportService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/RoutineDataValueRowHandler.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/SemiPermanentDataValueRowHandler.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/CompleteDataSetRegistrationConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataValueConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/CompleteDataSetRegistrationImporter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataValueImporter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml


--
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-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/importer/DefaultDhis14FileImportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/importer/DefaultDhis14FileImportService.java	2010-05-17 22:14:26 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/importer/DefaultDhis14FileImportService.java	2010-06-01 08:53:29 +0000
@@ -52,7 +52,6 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.importexport.GroupMemberAssociation;
 import org.hisp.dhis.importexport.ImportDataValue;
@@ -219,14 +218,7 @@
     {
         this.indicatorService = indicatorService;
     }
-    
-    private DataValueService dataValueService;
-
-    public void setDataValueService( DataValueService dataValueService )
-    {
-        this.dataValueService = dataValueService;
-    }
-    
+        
     private DataMartService dataMartService;
     
     public void setDataMartService( DataMartService dataMartService )
@@ -756,7 +748,6 @@
                 
         RowHandler rowHandler = new RoutineDataValueRowHandler( batchHandler,
             importDataValueBatchHandler,
-            dataValueService,
             dataMartService,
             objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
             objectMappingGenerator.getPeriodMapping( params.skipMapping() ),
@@ -825,7 +816,6 @@
         
         RowHandler rowHandler = new SemiPermanentDataValueRowHandler( batchHandler,
             importDataValueBatchHandler,
-            dataValueService,
             dataMartService,
             objectMappingGenerator.getDataElementMapping( params.skipMapping() ),
             objectMappingGenerator.getPeriodObjectMapping( params.skipMapping() ),

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/RoutineDataValueRowHandler.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/RoutineDataValueRowHandler.java	2010-05-29 16:06:56 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/RoutineDataValueRowHandler.java	2010-06-01 08:53:29 +0000
@@ -34,7 +34,6 @@
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.datamart.DataMartService;
 import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.importexport.ImportDataValue;
 import org.hisp.dhis.importexport.ImportParams;
 import org.hisp.dhis.importexport.dhis14.object.Dhis14RoutineDataValue;
@@ -74,7 +73,6 @@
 
     public RoutineDataValueRowHandler( BatchHandler<DataValue> batchHandler,
         BatchHandler<ImportDataValue> importDataValueBatchHandler,
-        DataValueService dataValueService,
         DataMartService dataMartService,
         Map<Object, Integer> dataElementMapping,
         Map<Object, Integer> periodMapping, 
@@ -84,7 +82,6 @@
     {
         this.batchHandler = batchHandler;
         this.importDataValueBatchHandler = importDataValueBatchHandler;
-        this.dataValueService = dataValueService;
         this.dataMartService = dataMartService;
         this.dataElementMapping = dataElementMapping;
         this.periodMapping = periodMapping;

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/SemiPermanentDataValueRowHandler.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/SemiPermanentDataValueRowHandler.java	2010-05-29 16:06:56 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/SemiPermanentDataValueRowHandler.java	2010-06-01 08:53:29 +0000
@@ -34,7 +34,6 @@
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.datamart.DataMartService;
 import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.importexport.ImportDataValue;
 import org.hisp.dhis.importexport.ImportParams;
 import org.hisp.dhis.importexport.dhis14.object.Dhis14SemiPermanentDataValue;
@@ -72,7 +71,6 @@
 
     public SemiPermanentDataValueRowHandler( BatchHandler<DataValue> batchHandler,
         BatchHandler<ImportDataValue> importDataValueBatchHandler,
-        DataValueService dataValueService,
         DataMartService dataMartService,
         Map<Object, Integer> dataElementMapping,
         Map<Period, Integer> periodMapping, 
@@ -82,7 +80,6 @@
     {
         this.batchHandler = batchHandler;
         this.importDataValueBatchHandler = importDataValueBatchHandler;
-        this.dataValueService = dataValueService;
         this.dataMartService = dataMartService;
         this.dataElementMapping = dataElementMapping;
         this.periodMapping = periodMapping;

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java	2010-05-29 16:06:56 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java	2010-06-01 08:53:29 +0000
@@ -47,7 +47,6 @@
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.datamart.DataMartService;
 import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.datavalue.DeflatedDataValue;
 import org.hisp.dhis.importexport.CSVConverter;
 import org.hisp.dhis.importexport.ExportParams;
@@ -100,13 +99,11 @@
      * Constructor for read operations.
      */
     public DataValueConverter( BatchHandler<ImportDataValue> importDataValueBatchHandler,
-        DataValueService dataValueService,
         DataElementCategoryService categoryService,
         ImportObjectService importObjectService,
         ImportParams params )
     {
         this.importDataValueBatchHandler = importDataValueBatchHandler;
-        this.dataValueService = dataValueService;
         this.categoryService = categoryService;
         this.importObjectService = importObjectService;
         this.params = params;

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java	2010-05-17 22:14:26 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/importer/DefaultDhis14XMLImportService.java	2010-06-01 08:53:29 +0000
@@ -44,7 +44,6 @@
 import org.hisp.dhis.common.ProcessState;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.importexport.CSVConverter;
 import org.hisp.dhis.importexport.ImportDataValue;
 import org.hisp.dhis.importexport.ImportObjectService;
@@ -127,13 +126,6 @@
         this.organisationUnitService = organisationUnitService;
     }
     
-    private DataValueService dataValueService;
-
-    public void setDataValueService( DataValueService dataValueService )
-    {
-        this.dataValueService = dataValueService;
-    }
-
     private ImportObjectService importObjectService;
 
     public void setImportObjectService( ImportObjectService importObjectService )
@@ -296,7 +288,6 @@
                 importDataValueBatchHandler.init();
                 
                 CSVConverter dataValueConverter = new DataValueConverter( importDataValueBatchHandler,
-                    dataValueService,
                     categoryService,
                     importObjectService,
                     params );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/CompleteDataSetRegistrationConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/CompleteDataSetRegistrationConverter.java	2010-05-31 13:53:07 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/CompleteDataSetRegistrationConverter.java	2010-06-01 08:53:29 +0000
@@ -70,6 +70,8 @@
     // Properties
     // -------------------------------------------------------------------------
 
+    private CompleteDataSetRegistrationService registrationService;
+    
     private DataSetService dataSetService;
     
     private OrganisationUnitService organisationUnitService;

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java	2010-05-31 16:47:43 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DXFConverter.java	2010-06-01 08:53:29 +0000
@@ -50,7 +50,6 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.importexport.ExportParams;
 import org.hisp.dhis.importexport.GroupMemberAssociation;
@@ -220,13 +219,6 @@
         this.olapURLService = olapURLService;
     }
 
-    private DataValueService dataValueService;
-
-    public void setDataValueService( DataValueService dataValueService )
-    {
-        this.dataValueService = dataValueService;
-    }
-
     private DataMartService dataMartService;
 
     public void setDataMartService( DataMartService dataMartService )
@@ -970,7 +962,7 @@
                 importDataValueBatchHandler.init();
 
                 XMLConverter converter = new DataValueConverter( batchHandler, importDataValueBatchHandler,
-                    dataValueService, dataMartService, importObjectService, params, objectMappingGenerator
+                    dataMartService, importObjectService, params, objectMappingGenerator
                         .getDataElementMapping( params.skipMapping() ), objectMappingGenerator
                         .getPeriodMapping( params.skipMapping() ), objectMappingGenerator
                         .getOrganisationUnitMapping( params.skipMapping() ), objectMappingGenerator

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataValueConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataValueConverter.java	2010-05-29 16:06:56 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataValueConverter.java	2010-06-01 08:53:29 +0000
@@ -38,7 +38,6 @@
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.datamart.DataMartService;
 import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.datavalue.DeflatedDataValue;
 import org.hisp.dhis.importexport.ExportParams;
 import org.hisp.dhis.importexport.ImportDataValue;
@@ -105,7 +104,6 @@
      */
     public DataValueConverter( BatchHandler<DataValue> batchHandler,
         BatchHandler<ImportDataValue> importDataValueBatchHandler,
-        DataValueService dataValueService,
         DataMartService dataMartService,
         ImportObjectService importObjectService,
         ImportParams params,
@@ -116,7 +114,6 @@
     {
         this.batchHandler = batchHandler;
         this.importDataValueBatchHandler = importDataValueBatchHandler;
-        this.dataValueService = dataValueService;
         this.dataMartService = dataMartService;
         this.importObjectService = importObjectService;
         this.params = params;

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/CompleteDataSetRegistrationImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/CompleteDataSetRegistrationImporter.java	2010-05-31 13:53:07 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/CompleteDataSetRegistrationImporter.java	2010-06-01 08:53:29 +0000
@@ -29,7 +29,6 @@
 
 import org.amplecode.quick.BatchHandler;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
-import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.importexport.GroupMemberType;
 import org.hisp.dhis.importexport.ImportParams;
 import org.hisp.dhis.importexport.Importer;
@@ -43,16 +42,13 @@
 {
     protected ImportParams params;
 
-    protected CompleteDataSetRegistrationService registrationService;
-
     public CompleteDataSetRegistrationImporter()
     {
     }
 
-    public CompleteDataSetRegistrationImporter( BatchHandler<CompleteDataSetRegistration> batchHandler, CompleteDataSetRegistrationService registrationService, ImportParams params )
+    public CompleteDataSetRegistrationImporter( BatchHandler<CompleteDataSetRegistration> batchHandler, ImportParams params )
     {
         this.batchHandler = batchHandler;
-        this.registrationService = registrationService;
         this.params = params;
     }
     

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataValueImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataValueImporter.java	2010-05-31 13:53:07 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataValueImporter.java	2010-06-01 08:53:29 +0000
@@ -30,7 +30,6 @@
 import org.amplecode.quick.BatchHandler;
 import org.hisp.dhis.datamart.DataMartService;
 import org.hisp.dhis.datavalue.DataValue;
-import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.importexport.GroupMemberType;
 import org.hisp.dhis.importexport.ImportParams;
 import org.hisp.dhis.importexport.Importer;
@@ -42,8 +41,6 @@
 public class DataValueImporter
     extends AbstractImporter<DataValue> implements Importer<DataValue>
 {
-    protected DataValueService dataValueService;
-    
     protected DataMartService dataMartService;
     
     protected ImportParams params;
@@ -52,10 +49,9 @@
     {
     }
     
-    public DataValueImporter( BatchHandler<DataValue> batchHandler, DataValueService dataValueService, DataMartService dataMartService, ImportParams params )
+    public DataValueImporter( BatchHandler<DataValue> batchHandler, DataMartService dataMartService, ImportParams params )
     {
         this.batchHandler = batchHandler;
-        this.dataValueService = dataValueService;
         this.dataMartService = dataMartService;
         this.params = params;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java	2010-06-01 07:57:57 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/service/DefaultImportObjectManager.java	2010-06-01 08:53:29 +0000
@@ -48,6 +48,7 @@
 import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.datamart.DataMartService;
 import org.hisp.dhis.dataset.CompleteDataSetRegistration;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
@@ -66,6 +67,7 @@
 import org.hisp.dhis.importexport.ImportType;
 import org.hisp.dhis.importexport.Importer;
 import org.hisp.dhis.importexport.importer.CalculatedDataElementImporter;
+import org.hisp.dhis.importexport.importer.CompleteDataSetRegistrationImporter;
 import org.hisp.dhis.importexport.importer.DataDictionaryImporter;
 import org.hisp.dhis.importexport.importer.DataElementCategoryComboImporter;
 import org.hisp.dhis.importexport.importer.DataElementCategoryImporter;
@@ -74,6 +76,7 @@
 import org.hisp.dhis.importexport.importer.DataElementGroupSetImporter;
 import org.hisp.dhis.importexport.importer.DataElementImporter;
 import org.hisp.dhis.importexport.importer.DataSetImporter;
+import org.hisp.dhis.importexport.importer.DataValueImporter;
 import org.hisp.dhis.importexport.importer.GroupSetImporter;
 import org.hisp.dhis.importexport.importer.IndicatorGroupImporter;
 import org.hisp.dhis.importexport.importer.IndicatorGroupSetImporter;
@@ -83,6 +86,7 @@
 import org.hisp.dhis.importexport.importer.OrganisationUnitGroupImporter;
 import org.hisp.dhis.importexport.importer.OrganisationUnitImporter;
 import org.hisp.dhis.importexport.importer.OrganisationUnitLevelImporter;
+import org.hisp.dhis.importexport.importer.PeriodImporter;
 import org.hisp.dhis.importexport.importer.ReportTableImporter;
 import org.hisp.dhis.importexport.importer.ValidationRuleImporter;
 import org.hisp.dhis.importexport.mapping.GroupMemberAssociationVerifier;
@@ -134,6 +138,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.reporttable.ReportTableService;
 import org.hisp.dhis.source.Source;
@@ -257,6 +262,20 @@
     {
         this.reportTableService = reportTableService;
     }
+    
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
+    
+    private DataMartService dataMartService;
+
+    public void setDataMartService( DataMartService dataMartService )
+    {
+        this.dataMartService = dataMartService;
+    }
 
     // -------------------------------------------------------------------------
     // ImportObjectManager implementation
@@ -916,13 +935,11 @@
         
         Collection<ImportObject> importObjects = importObjectStore.getImportObjects( Period.class );
         
+        Importer<Period> importer = new PeriodImporter( batchHandler, periodService );
+        
         for ( ImportObject importObject : importObjects )
         {
-            Period period = (Period) importObject.getObject();
-            
-            NameMappingUtil.addPeriodMapping( period.getId(), period );
-            
-            addOrUpdateObject( batchHandler, importObject );
+            importer.importObject( (Period) importObject.getObject(), params );
         }
         
         batchHandler.flush();
@@ -985,6 +1002,8 @@
         Map<Object, Integer> periodMapping = objectMappingGenerator.getPeriodMapping( false );
         Map<Object, Integer> sourceMapping = objectMappingGenerator.getOrganisationUnitMapping( false );
         
+        Importer<CompleteDataSetRegistration> importer = new CompleteDataSetRegistrationImporter( batchHandler, params );
+        
         for ( ImportObject importObject : importObjects )
         {
             CompleteDataSetRegistration registration = (CompleteDataSetRegistration) importObject.getObject();
@@ -993,15 +1012,7 @@
             registration.getPeriod().setId( periodMapping.get( registration.getPeriod().getId() ) );
             registration.getSource().setId( sourceMapping.get( registration.getSource().getId() ) );
             
-            // -----------------------------------------------------------------
-            // Must check for existing registrations since this cannot be done
-            // during preview
-            // -----------------------------------------------------------------
-            
-            if ( !batchHandler.objectExists( registration ) )
-            {
-                batchHandler.addObject( registration );
-            }
+            importer.importObject( registration, params );
         }
         
         batchHandler.flush();
@@ -1025,6 +1036,8 @@
         
         Collection<ImportDataValue> importValues = importDataValueService.getImportDataValues( ImportObjectStatus.NEW );
         
+        Importer<DataValue> importer = new DataValueImporter( batchHandler, dataMartService, params );
+        
         for ( ImportDataValue importValue : importValues )
         {
             DataValue value = importValue.getDataValue();
@@ -1034,15 +1047,7 @@
             value.getSource().setId( sourceMapping.get( value.getSource().getId() ) );
             value.getOptionCombo().setId( categoryOptionComboMapping.get( value.getOptionCombo().getId() ) );
             
-            // -------------------------------------------------------------
-            // Must check for existing datavalues since this cannot be done
-            // during preview
-            // -------------------------------------------------------------
-            
-            if ( !batchHandler.objectExists( value ) )
-            {
-                batchHandler.addObject( value );
-            }
+            importer.importObject( value, params );
         }
         
         batchHandler.flush();
@@ -1057,23 +1062,6 @@
     // -------------------------------------------------------------------------
 
     @SuppressWarnings( "unchecked" )
-    private void addOrUpdateObject( BatchHandler batchHandler, ImportObject importObject )
-    {
-        if ( importObject.getStatus() == ImportObjectStatus.NEW )
-        {
-            batchHandler.addObject( importObject.getObject() );
-        }
-        else if ( importObject.getStatus() == ImportObjectStatus.UPDATE )
-        {
-            batchHandler.updateObject( importObject.getObject() );
-        }
-
-        // ---------------------------------------------------------------------
-        // Ignoring ImportObjects of type MATCH
-        // ---------------------------------------------------------------------
-    }
-
-    @SuppressWarnings( "unchecked" )
     private void importGroupMemberAssociation( BatchHandler batchHandler, GroupMemberType type,
         Map<Object, Integer> groupMapping, Map<Object, Integer> memberMapping )
     {

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2010-05-31 15:06:26 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2010-06-01 08:53:29 +0000
@@ -91,6 +91,8 @@
 		<property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
 		<property name="importDataValueService"	ref="org.hisp.dhis.importexport.ImportDataValueService" />
 		<property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService" />
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+		<property name="dataMartService" ref="org.hisp.dhis.datamart.DataMartService" />
 	</bean>
 
 	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
@@ -147,7 +149,6 @@
 		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="importObjectService"
 			ref="org.hisp.dhis.importexport.ImportObjectService" />
 		<property name="batchHandlerFactory" ref="batchHandlerFactory" />
@@ -191,7 +192,6 @@
 		<property name="organisationUnitGroupService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
 		<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
-		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="dataMartService" ref="org.hisp.dhis.datamart.DataMartService" />
 		<property name="importAnalyser"
 			ref="org.hisp.dhis.importexport.analysis.ImportAnalyser" />
@@ -248,7 +248,6 @@
         <property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService" />
         <property name="olapURLService" ref="org.hisp.dhis.olap.OlapURLService" />
         <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
-        <property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
         <property name="dataMartService" ref="org.hisp.dhis.datamart.DataMartService" />
         <property name="batchHandlerFactory" ref="batchHandlerFactory" />
         <property name="objectMappingGenerator"