← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3986: Made data value import from dhis 1.4 more robust

 

------------------------------------------------------------
revno: 3986
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-06-22 16:52:17 +0200
message:
  Made data value import from dhis 1.4 more robust
modified:
  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


--
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/rowhandler/RoutineDataValueRowHandler.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/RoutineDataValueRowHandler.java	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/RoutineDataValueRowHandler.java	2011-06-22 14:52:17 +0000
@@ -103,6 +103,26 @@
     {
         final Dhis14RoutineDataValue dhis14Value = (Dhis14RoutineDataValue) object;
         
+        final Integer dataElementId = dataElementMapping.get( dhis14Value.getDataElementId() );
+        final Integer periodId = periodMapping.get( dhis14Value.getPeriodId() );
+        final Integer organisationUnitId = organisationUnitMapping.get( dhis14Value.getOrganisationUnitId() );
+        
+        if ( dataElementId == null )
+        {
+            log.warn( "Data element does not exist for identifier: " + dhis14Value.getDataElementId() );
+            return;
+        }        
+        if ( periodId == null )
+        {
+            log.warn( "Period does not exist for identifier: " + dhis14Value.getPeriodId() );
+            return;
+        }        
+        if ( organisationUnitId == null )
+        {
+            log.warn( "Organisation unit does not exist for identifier: " + dhis14Value.getOrganisationUnitId() );
+            return;
+        }
+        
         element.setId( dataElementMapping.get( dhis14Value.getDataElementId() ) );
         period.setId( periodMapping.get( dhis14Value.getPeriodId() ) );
         source.setId( organisationUnitMapping.get( dhis14Value.getOrganisationUnitId() ) );

=== 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	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/rowhandler/SemiPermanentDataValueRowHandler.java	2011-06-22 14:52:17 +0000
@@ -100,14 +100,28 @@
     {
         final Dhis14SemiPermanentDataValue dhis14Value = (Dhis14SemiPermanentDataValue) object;
 
+        final Integer dataElementId = dataElementMapping.get( dhis14Value.getDataElementId() );
+        final Integer organisationUnitId = organisationUnitMapping.get( dhis14Value.getOrganisationUnitId() );
+
+        if ( dataElementId == null )
+        {
+            log.warn( "Data element does not exist for identifier: " + dhis14Value.getDataElementId() );
+            return;
+        }
+        if ( organisationUnitId == null )
+        {
+            log.warn( "Organisation unit does not exist for identifier: " + dhis14Value.getOrganisationUnitId() );
+            return;
+        }
+        
         final Period period = new Period();
         
         period.setPeriodType( dhis14Value.getPeriodType() );
         period.setStartDate( dhis14Value.getStartDate() );
         period.setEndDate( dhis14Value.getEndDate() );
         
-        element.setId( dataElementMapping.get( dhis14Value.getDataElementId() ) );
-        source.setId( organisationUnitMapping.get( dhis14Value.getOrganisationUnitId() ) );        
+        element.setId( dataElementId );
+        source.setId( organisationUnitId );        
         period.setId( periodMapping.get( period ) );
         
         value.setDataElement( element );