← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10953: Made csv import more robust

 

------------------------------------------------------------
revno: 10953
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-05-23 12:27:27 +0200
message:
  Made csv import more robust
modified:
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/StreamingCsvDataValue.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/datavalue/StreamingCsvDataValue.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/StreamingCsvDataValue.java	2012-04-18 16:38:59 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalue/StreamingCsvDataValue.java	2013-05-23 10:27:27 +0000
@@ -52,6 +52,15 @@
     {
         this.values = Arrays.asList( row );
     }
+
+    //--------------------------------------------------------------------------
+    // Supportive methods
+    //--------------------------------------------------------------------------
+
+    private String getValue( int index )
+    {
+        return index >= 0 && index < values.size() ? values.get( index ) : null;
+    }
     
     //--------------------------------------------------------------------------
     // Getters
@@ -60,55 +69,55 @@
     @Override
     public String getDataElement()
     {
-        return dataElement = dataElement == null ? values.get( 0 ) : dataElement;
+        return dataElement = dataElement == null ? getValue( 0 ) : dataElement;
     }
 
     @Override
     public String getPeriod()
     {
-        return period = period == null ? values.get( 1 ) : period;
+        return period = period == null ? getValue( 1 ) : period;
     }
 
     @Override
     public String getOrgUnit()
     {
-        return orgUnit = orgUnit == null ? values.get( 2 ) : orgUnit;
+        return orgUnit = orgUnit == null ? getValue( 2 ) : orgUnit;
     }
 
     @Override
     public String getCategoryOptionCombo()
     {
-        return categoryOptionCombo = categoryOptionCombo == null ? values.get( 3 ) : categoryOptionCombo;
+        return categoryOptionCombo = categoryOptionCombo == null ? getValue( 3 ) : categoryOptionCombo;
     }
 
     @Override
     public String getValue()
     {
-        return value = value == null ? values.get( 4 ) : value;
+        return value = value == null ? getValue( 4 ) : value;
     }
 
     @Override
     public String getStoredBy()
     {
-        return storedBy = storedBy == null ? values.get( 5 ) : storedBy;
+        return storedBy = storedBy == null ? getValue( 5 ) : storedBy;
     }
 
     @Override
     public String getTimestamp()
     {
-        return timestamp = timestamp == null ? values.get( 6 ) : timestamp;
+        return timestamp = timestamp == null ? getValue( 6 ) : timestamp;
     }
 
     @Override
     public String getComment()
     {
-        return comment = comment == null ? values.get( 7 ) : comment;
+        return comment = comment == null ? getValue( 7 ) : comment;
     }
 
     @Override
     public Boolean getFollowup()
     {
-        return followup = followup == null ? valueOf( values.get( 8 ) ) : followup;
+        return followup = followup == null ? valueOf( getValue( 8 ) ) : followup;
     }
 
     //--------------------------------------------------------------------------