← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3771: Fixed bug in dhis 1.4 import

 

------------------------------------------------------------
revno: 3771
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-05-27 16:50:01 +0200
message:
  Fixed bug in dhis 1.4 import
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/DataSetRowHandler.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/PeriodRowHandler.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlMapConfiguration.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	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/importer/DefaultDhis14FileImportService.java	2011-05-27 14:50:01 +0000
@@ -242,75 +242,66 @@
     @Override
     public void importData( ImportParams params, InputStream inputStream ) throws ImportException
     {
-        
+        importData( params, inputStream, null );
     }
 
     @Override
     public void importData( ImportParams params, InputStream inputStream, ProcessState state )
         throws ImportException
     {
-        try
-        {
-            NameMappingUtil.clearMapping();
-
-            importAnalyser = new DefaultImportAnalyser( expressionService );
-
-            if ( !verifyImportFile( params, state ) )
-            {
-                return;
-            }
-
-            if ( params.isPreview() )
-            {
-                importObjectService.deleteImportObjects();
-            }
-
-            importDataElements( params, state );
-            importIndicatorTypes( params, state );
-            importIndicators( params, state );
-            importDataElementGroups( params, state );
-            importDataElementGroupMembers( params, state );
-            importIndicatorGroups( params, state );
-            importIndicatorGroupMembers( params, state );
-
-            importDataSets( params, state );
-            importDataSetMembers( params, state );
-
-            importOrganisationUnits( params, state );
-            importOrganisationUnitGroups( params, state );
-            importOrganisationUnitGroupMembers( params, state );
-            importGroupSets( params, state );
-            importGroupSetMembers( params, state );
-            importOrganisationUnitRelationships( params, state );
-
-            importDataSetOrganisationUnitAssociations( params, state );
-
-            if ( params.isDataValues() && !params.isAnalysis() )
-            {
-                importPeriods( params, state );
-                importRoutineDataValues( params, state );
-
-                importOnChangePeriods( params, state );
-                importSemiPermanentDataValues( params, state );
-            }
-
-            if ( params.isAnalysis() )
-            {
-                state.setOutput( importAnalyser.getImportAnalysis() );
-            }
-
-            Dhis14PeriodUtil.clear();
-
-            NameMappingUtil.clearMapping();
-
-            cacheManager.clearCache();
-        }
-        catch ( Exception ex )
-        {
-            log.error( ex );
-         
-            throw new ImportException( "DHIS14 import failed", ex );
-        }
+        NameMappingUtil.clearMapping();
+
+        importAnalyser = new DefaultImportAnalyser( expressionService );
+
+        if ( !verifyImportFile( params, state ) )
+        {
+            return;
+        }
+
+        if ( params.isPreview() )
+        {
+            importObjectService.deleteImportObjects();
+        }
+
+        importDataElements( params, state );
+        importIndicatorTypes( params, state );
+        importIndicators( params, state );
+        importDataElementGroups( params, state );
+        importDataElementGroupMembers( params, state );
+        importIndicatorGroups( params, state );
+        importIndicatorGroupMembers( params, state );
+
+        importDataSets( params, state );
+        importDataSetMembers( params, state );
+
+        importOrganisationUnits( params, state );
+        importOrganisationUnitGroups( params, state );
+        importOrganisationUnitGroupMembers( params, state );
+        importGroupSets( params, state );
+        importGroupSetMembers( params, state );
+        importOrganisationUnitRelationships( params, state );
+
+        importDataSetOrganisationUnitAssociations( params, state );
+
+        if ( params.isDataValues() && !params.isAnalysis() )
+        {
+            importPeriods( params, state );
+            importRoutineDataValues( params, state );
+
+            importOnChangePeriods( params, state );
+            importSemiPermanentDataValues( params, state );
+        }
+
+        if ( params.isAnalysis() )
+        {
+            state.setOutput( importAnalyser.getImportAnalysis() );
+        }
+
+        Dhis14PeriodUtil.clear();
+
+        NameMappingUtil.clearMapping();
+
+        cacheManager.clearCache();
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/DataSetRowHandler.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/DataSetRowHandler.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/DataSetRowHandler.java	2011-05-27 14:50:01 +0000
@@ -36,6 +36,7 @@
 import org.hisp.dhis.importexport.ImportParams;
 import org.hisp.dhis.importexport.analysis.ImportAnalyser;
 import org.hisp.dhis.importexport.importer.DataSetImporter;
+import org.hisp.dhis.period.YearlyPeriodType;
 
 import com.ibatis.sqlmap.client.event.RowHandler;
 
@@ -77,7 +78,10 @@
     {
         final DataSet dataSet = (DataSet) object;
         
-        dataSet.getPeriodType().setId( periodTypeMapping.get( dataSet.getPeriodType().getName() ) );
+        Integer periodTypeId = periodTypeMapping.get( dataSet.getPeriodType().getName() );
+        Integer defaultId = periodTypeMapping.get( YearlyPeriodType.NAME );
+        
+        dataSet.getPeriodType().setId( periodTypeId != null ? periodTypeId : defaultId );
         
         importObject( dataSet, params );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/PeriodRowHandler.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/PeriodRowHandler.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/PeriodRowHandler.java	2011-05-27 14:50:01 +0000
@@ -37,6 +37,7 @@
 import org.hisp.dhis.importexport.importer.PeriodImporter;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.period.YearlyPeriodType;
 
 import com.ibatis.sqlmap.client.event.RowHandler;
 
@@ -81,8 +82,11 @@
         final Period period = (Period) object;
         
         if ( identifiers.contains( period.getId() ) ) // Data is registered for period which is distinct
-        {        
-            period.getPeriodType().setId( periodTypeMapping.get( period.getPeriodType().getName() ) );
+        {
+            Integer periodTypeId = periodTypeMapping.get( period.getPeriodType().getName() );
+            Integer defaultId = periodTypeMapping.get( YearlyPeriodType.NAME );
+            
+            period.getPeriodType().setId( periodTypeId != null ? periodTypeId : defaultId  );
             
             Dhis14PeriodUtil.addPeriod( period ); // For uniqueness
             

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlMapConfiguration.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlMapConfiguration.xml	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/sqlMapConfiguration.xml	2011-05-27 14:50:01 +0000
@@ -26,8 +26,6 @@
     </transactionManager>
 	
     <sqlMap resource="sqlmap/dataElement.sqlmap.xml"/>
-    <sqlMap resource="sqlmap/calculatedDataElementEntry.sqlmap.xml"/>
-    <sqlMap resource="sqlmap/calculatedDataElement.sqlmap.xml"/>
     <sqlMap resource="sqlmap/dataElementGroup.sqlmap.xml"/>
     <sqlMap resource="sqlmap/dataElementGroupMember.sqlmap.xml"/>
     <sqlMap resource="sqlmap/indicator.sqlmap.xml"/>