← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7441: DHIS 1.4 imports. Minor

 

------------------------------------------------------------
revno: 7441
committer: Jason P. Pickering <jason.p.pickering@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-27 22:01:50 +0200
message:
  DHIS 1.4 imports. Minor
modified:
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14TypeHandler.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/converter/OrganisationUnitConverter.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/util/Dhis14TypeHandler.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14TypeHandler.java	2010-11-19 15:25:29 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14TypeHandler.java	2012-06-27 20:01:50 +0000
@@ -44,10 +44,16 @@
         return value ? DHIS14_TRUE : DHIS14_FALSE;
     }
     
+    public static String convertBooleanToDhis14( String value )
+    {
+        return (String) (value.equals("true") ? "1" : "0");
+    }
+    
     public static boolean convertBooleanFromDhis14( String value )
     {
         return value.equals( DHIS14_TRUE );
     }
+    
 
     // -------------------------------------------------------------------------
     // Aggregation operator

=== 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 12:47:25 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java	2012-06-27 20:01:50 +0000
@@ -59,7 +59,7 @@
 import org.hisp.dhis.importexport.analysis.ImportAnalyser;
 import org.hisp.dhis.importexport.importer.DataValueImporter;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.importexport.dhis14.util.Dhis14DateUtil;
+import org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler;
 
 import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.MimicingHashMap;
@@ -245,12 +245,7 @@
                 }
                 else if ( !values[5].isEmpty() ) // Boolean
                 {
-                    value.setValue( "false" );
-
-                    if ( values[5].trim().equals( "1" ) )
-                    {
-                        value.setValue( "true" );
-                    }
+                    value.setValue(Dhis14TypeHandler.convertYesNoFromDhis14( Integer.parseInt(values[5]) ) );
 
                 }
                 else if ( !values[7].isEmpty() ) // Date
@@ -328,15 +323,8 @@
 
             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( outputValue ) ) );
+                out.write( getCsvValue( csvEncode( Dhis14TypeHandler.convertBooleanToDhis14( value.getValue()) ) ) );
                 out.write( SEPARATOR_B );
                 out.write( SEPARATOR_B );
                 out.write( SEPARATOR_B );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/OrganisationUnitConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/OrganisationUnitConverter.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/OrganisationUnitConverter.java	2012-06-27 20:01:50 +0000
@@ -27,12 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertBooleanToDhis14;
-import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertBooleanFromDhis14;
-
-import java.util.Collection;
-import java.util.Map;
-
 import org.amplecode.staxwax.reader.XMLReader;
 import org.amplecode.staxwax.writer.XMLWriter;
 import org.hisp.dhis.importexport.ExportParams;
@@ -45,6 +39,12 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 
+import java.util.Collection;
+import java.util.Map;
+
+import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertBooleanFromDhis14;
+import static org.hisp.dhis.importexport.dhis14.util.Dhis14TypeHandler.convertBooleanToDhis14;
+
 
 /**
  * @author Lars Helge Overland