← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7423: Minor fixes to DHIS 1.4 import export service.

 

------------------------------------------------------------
revno: 7423
committer: Jason P. Pickering <jason.p.pickering@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-27 11:03:06 +0200
message:
  Minor fixes to DHIS 1.4 import export service.
modified:
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.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/xml/converter/DataValueConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java	2012-06-27 07:16:03 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java	2012-06-27 09:03:06 +0000
@@ -233,11 +233,11 @@
                 value.setPeriod( period );
                 value.setSource( organisationUnit );
 
-                if ( values[4] != null || !values[4].isEmpty() ) // Text
+                if ( values[4] != null  ) // Text
                 {
                     value.setValue( values[4].trim() );
                 }
-                else if ( values[5] != null || !values[5].isEmpty() ) // Boolean
+                else if ( values[5] != null ) // Boolean
                 {
 
                     value.setValue( "false" );
@@ -248,31 +248,30 @@
                     }
 
                 }
-                else if ( values[6] != null || !values[6].isEmpty() ) // Numeric
+                else if ( values[6] != null  ) // Numeric
                 {
                     value.setValue( handleNumericValue( values[6] ) );
                     validValue = isValidNumeric( value.getValue() );
                 }
-                else if ( values[7] != null || !values[7].isEmpty() ) // Date
+                else if ( values[7] != null ) // Date
                 {
                     try
                     {
-                        value.setValue( handleNumericValue( DateUtils.convertDate( values[7] ) ) );
+                        value.setValue(  DateUtils.getDefaultDate( values[7] ).toString()  ); //TODO Check conversion
                     }
                     catch ( Exception e )
                     {
                         validValue = false;
                     }
                 }
-                else if ( values[8] != null || !values[8].isEmpty() ) // Memo
-                                                                      // not
-                                                                      // supported
+                else if ( values[8] != null ) // Memo not supported
+ 
                 {
                     validValue = false;
                 }
 
-                else if ( values[9] != null || !values[9].isEmpty() ) // OLE not
-                                                                      // supported
+                else if ( values[9] != null  ) // OLE not supported
+                                                                      
                 {
                     validValue = false;
                 }
@@ -282,7 +281,7 @@
                 value.setOptionCombo( proxyCategoryOptionCombo );
                 value.setStoredBy( owner );
 
-                if ( validValue )
+                if ( validValue && value.getValue() != null )
                 {
                     importObject( value, params );
                 }
@@ -337,15 +336,23 @@
 
             else if ( dataElementType.equals( DataElement.VALUE_TYPE_BOOL ) )
             {
+                String outputValue;
+                if ( value.getValue().equals( "true" ) )  {
+                    outputValue = "1";
+                }
+                else outputValue = "0";
                 out.write( SEPARATOR_B );
-                out.write( getCsvValue( csvEncode( value.getValue() ) ) );
+                out.write( getCsvValue( csvEncode( outputValue) ) );
                 out.write( SEPARATOR_B );
                 out.write( SEPARATOR_B );
                 out.write( SEPARATOR_B );
                 out.write( SEPARATOR_B );
             }
 
-            else if ( dataElementType.equals( DataElement.VALUE_TYPE_NUMBER ) )
+            else if ( dataElementType.equals( DataElement.VALUE_TYPE_NUMBER) ||
+                      dataElementType.equals( DataElement.VALUE_TYPE_INT ) ||
+                      dataElementType.equals( DataElement.VALUE_TYPE_NEGATIVE_INT ) ||
+                      dataElementType.equals( DataElement.VALUE_TYPE_POSITIVE_INT ) )
             {
                 out.write( SEPARATOR_B );
                 out.write( SEPARATOR_B );
@@ -360,7 +367,7 @@
                 out.write( SEPARATOR_B );
                 out.write( SEPARATOR_B );
                 out.write( SEPARATOR_B );
-                out.write( getCsvValue( DateUtils.getMediumDate( value.getValue() ).toString() ) );
+                out.write( getCsvValue( csvEncode( DateUtils.getAccessDateString( DateUtils.getDefaultDate( value.getValue() ) ) ) ) );
                 out.write( SEPARATOR_B );
                 out.write( SEPARATOR_B );
             }