← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1887: Fixed minor issue with nulls in OrganisationUnitConverter

 

------------------------------------------------------------
revno: 1887
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Fri 2010-07-30 16:13:32 +0200
message:
  Fixed minor issue with nulls in OrganisationUnitConverter
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitImporter.java
  dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLStreamReader.java
  dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultXMLStreamWriter.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties


--
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-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2010-07-14 19:36:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2010-07-30 14:13:32 +0000
@@ -35,6 +35,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.commons.lang.StringUtils;
 import org.hisp.dhis.dimension.DimensionOption;
 import org.hisp.dhis.dimension.DimensionOptionElement;
 import org.hisp.dhis.source.Source;
@@ -207,7 +208,7 @@
             builder.append( "]" );
         }
         
-        this.coordinates = builder.toString();
+        this.coordinates = StringUtils.trimToNull( builder.toString() );
     }
     
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2010-07-19 08:31:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2010-07-30 14:13:32 +0000
@@ -157,6 +157,9 @@
         executeSql( "ALTER TABLE expression ALTER expression TYPE text" );
         executeSql( "ALTER TABLE translation ALTER value TYPE text" );
         
+        //orgunit coord
+        executeSql( "ALTER TABLE organisationunit DROP COLUMN polygoncoordinates" );
+        
         log.info( "Tables updated" );
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java	2010-07-14 19:36:41 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/OrganisationUnitConverter.java	2010-07-30 14:13:32 +0000
@@ -179,7 +179,7 @@
             unit.setOpeningDate( DateUtils.getMediumDate( reader.getElementValue() ) );
 
             reader.moveToStartElement( FIELD_CLOSED_DATE );
-            unit.setOpeningDate( DateUtils.getMediumDate( reader.getElementValue() ) );
+            unit.setClosedDate( DateUtils.getMediumDate( reader.getElementValue() ) );
             
             reader.moveToStartElement( FIELD_ACTIVE );
             unit.setActive( Boolean.parseBoolean( reader.getElementValue() ) );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitImporter.java	2010-05-31 16:47:43 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitImporter.java	2010-07-30 14:13:32 +0000
@@ -115,42 +115,55 @@
     {
         if ( !object.getName().equals( existing.getName() ) )
         {
+            System.out.println( "1" );
             return false;
         }
         if ( !object.getShortName().equals( existing.getShortName() ) )
         {
+            System.out.println( "2" );
             return false;
         }
         if ( !isSimiliar( object.getCode(), existing.getCode() ) || ( isNotNull( object.getCode(), existing.getCode() ) && !object.getCode().equals( existing.getCode() ) ) )
         {
+            System.out.println( "3" );
             return false;
         }
         if ( !isSimiliar( object.getOpeningDate(), existing.getOpeningDate() ) || ( isNotNull( object.getOpeningDate(), existing.getOpeningDate() ) && !object.getOpeningDate().equals( existing.getOpeningDate() ) ) )
         {
+            System.out.println( "4" );
+            System.out.println( "." + object.getOpeningDate() + "-" + existing.getOpeningDate() + "."); 
             return false;
         }
         if ( !isSimiliar( object.getClosedDate(), existing.getClosedDate() ) || ( isNotNull( object.getClosedDate(), existing.getClosedDate() ) && !object.getClosedDate().equals( existing.getClosedDate() ) ) )
         {
+            System.out.println( "5" );
             return false;
         }
         if ( object.isActive() != existing.isActive() )
         {
+            System.out.println( "6" );
             return false;
         }
         if ( !isSimiliar( object.getComment(), existing.getComment() ) || ( isNotNull( object.getComment(), existing.getComment() ) && !object.getComment().equals( existing.getComment() ) ) )
         {
+            System.out.println( "7" );
             return false;
         }
         if ( !isSimiliar( object.getGeoCode(), existing.getGeoCode() ) || ( isNotNull( object.getGeoCode(), existing.getGeoCode() ) && !object.getGeoCode().equals( existing.getGeoCode() ) ) )
         {
+            System.out.println( "8" );
             return false;
         }
         if ( !isSimiliar( object.getFeatureType(), existing.getFeatureType() ) || ( isNotNull( object.getFeatureType(), existing.getFeatureType() ) && !object.getFeatureType().equals( existing.getFeatureType() ) ) )
         {
+            System.out.println( "9" );
+            System.out.println( "." + object.getFeatureType() + "-" + existing.getFeatureType() + "."); 
             return false;
         }
         if ( !isSimiliar( object.getCoordinates(), existing.getCoordinates() ) || ( isNotNull( object.getCoordinates(), existing.getCoordinates() ) && !object.getCoordinates().equals( existing.getCoordinates() ) ) )
         {
+            System.out.println( "10" );
+            System.out.println( "." + object.getCoordinates() + "-" + existing.getCoordinates() + "."); 
             return false;
         }
         

=== modified file 'dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLStreamReader.java'
--- dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLStreamReader.java	2010-07-16 20:12:45 +0000
+++ dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/reader/DefaultXMLStreamReader.java	2010-07-30 14:13:32 +0000
@@ -56,12 +56,10 @@
 {
     private static final Log log = LogFactory.getLog( DefaultXMLStreamReader.class );
 
-    private static final String[] EVENTS =
-    {
+    private static final String[] EVENTS = {
         "None", "Start Element", "End Element", "Processing Instruction",
         "Characters", "Comment", "Space", "Start Document", "End Document", "Entity Reference", "Attribute", "DTD",
-        "CData", "Namespace", "Notation Declaration", "Entity Declaration"
-    };
+        "CData", "Namespace", "Notation Declaration", "Entity Declaration" };
 
     private XMLStreamReader2 reader;
 
@@ -214,7 +212,7 @@
     @Override
     public String getAttributeValue( String attributeName )
     {
-        return reader.getAttributeValue( null, attributeName );
+        return nullIfEmpty( reader.getAttributeValue( null, attributeName ) );
     }
 
     @Override
@@ -245,7 +243,7 @@
 
                     for ( int i = 0; i < reader.getAttributeCount(); i++ )
                     {
-                        elements.put( reader.getAttributeLocalName( i ), reader.getAttributeValue( i ) );
+                        elements.put( reader.getAttributeLocalName( i ), nullIfEmpty( reader.getAttributeValue( i ) ) );
                     }
 
                     currentElementName = reader.getLocalName();
@@ -298,7 +296,7 @@
                     for ( int i = 0; i < reader.getAttributeCount(); i++ )
                     {
                         text.append( "ATTR NAME: '" + reader.getAttributeLocalName( i ) + "' VALUE: '"
-                            + reader.getAttributeValue( i ) + "' " );
+                            + nullIfEmpty( reader.getAttributeValue( i ) ) + "' " );
                     }
                 }
 
@@ -355,4 +353,9 @@
         }
         return sb.length() == 0 ? null : sb.toString();
     }
+    
+    private String nullIfEmpty( String value )
+    {
+        return value != null && value.isEmpty() ? null : value;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultXMLStreamWriter.java'
--- dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultXMLStreamWriter.java	2010-02-19 18:38:02 +0000
+++ dhis-2/dhis-services/dhis-service-xml/src/main/java/org/amplecode/staxwax/writer/DefaultXMLStreamWriter.java	2010-07-30 14:13:32 +0000
@@ -221,7 +221,7 @@
     
     private String replaceNull( String string )
     {
-        return string != null ? string : new String();
+        return string != null ? string : "";
     }
     
     private String verifyNotNull( String string )

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2010-07-30 12:59:39 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/org/hisp/dhis/importexport/i18n_module.properties	2010-07-30 14:13:32 +0000
@@ -306,12 +306,6 @@
 importing_previewed_data = Importing previewed data
 importing_complete_data_set_registrations = Importing complete data set registrations
 importing_report_tables = Importing report tables
-importing_report_table_dataelements = Importing report table dataelements
-importing_report_table_category_option_combos = Importing report table category option combos
-importing_report_table_indicators = Importing report table indicators
-importing_report_table_datasets = Importing report table data sets
-importing_report_table_periods = Importing report table periods
-importing_report_table_organisation_units = Importing report table organisation units
 importing_olap_urls = Importing OLAP URLs
 importing_data_set_organisation_unit_associations = Importing data set organisation unit associations
 no_import_process_running = No import process running
@@ -438,6 +432,8 @@
 horizontal_plot_orientation = Horizontal plot orientation
 regression = Regression
 design = Design
+report = Report
+chart = Chart
 intro_DHIS14_xml_import = Do an import from an XML based format. DHIS 1.4 is the predecessor of DHIS 2.
 intro_DHIS14_file_import = Do an import from an Access data file. DHIS 1.4 is the predecessor of DHIS 2.
 intro_DHIS14_metadata_export = Do an export of meta-data or dimensional data describing the facts. DHIS 1.4 is the predecessor of DHIS 2.