← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4991: Fixed nasty bug: add / update org unit screen saving coordinates as lat/long while GIS uses long/lat

 

------------------------------------------------------------
revno: 4991
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-10-20 20:51:07 +0200
message:
  Fixed nasty bug: add / update org unit screen saving coordinates as lat/long while GIS uses long/lat
modified:
  dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ValidationUtilsTest.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm


--
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-support/dhis-support-hibernate/src/main/resources/ehcache.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2011-09-21 12:46:20 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2011-10-20 18:51:07 +0000
@@ -167,7 +167,7 @@
 
   <cache name="org.hisp.dhis.reporttable.ReportTable.indicators" maxElementsInMemory="500" />
 
-  <cache name="org.hisp.dhis.reporttable.ReportTable.dataSets" maxElementsInMemory="100" />
+  <cache name="org.hisp.dhis.reporttable.ReportTable.dataSets" maxElementsInMemory="200" />
 
   <cache name="org.hisp.dhis.reporttable.ReportTable.periods" maxElementsInMemory="200" />
 
@@ -184,6 +184,8 @@
   <cache name="org.hisp.dhis.chart.Chart.periods" maxElementsInMemory="200" />
 
   <cache name="org.hisp.dhis.chart.Chart.organisationUnits" maxElementsInMemory="2000" />
+  
+  <cache name="org.hisp.dhis.chart.Chart.dataSets" maxElementsInMemory="200" />
 
   <cache name="org.hisp.dhis.chart.Chart.groups" maxElementsInMemory="500" />
 

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java	2011-10-12 07:51:57 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ValidationUtils.java	2011-10-20 18:51:07 +0000
@@ -110,8 +110,29 @@
     }
     
     /**
+     * Returns the longitude from the given coordinate. Returns null if the
+     * coordinate string is not valid. The coordinate is on the form
+     * longitude / latitude.
+     * 
+     * @param coordinate the coordinate string.
+     * @return the longitude.
+     */
+    public static String getLongitude( String coordinate )
+    {
+        if ( coordinate == null )
+        {
+            return null;
+        }
+        
+        Matcher matcher = COORDINATE_PATTERN.matcher( coordinate );
+        
+        return matcher.find() ? matcher.group( 1 ) : null;
+    }
+
+    /**
      * Returns the latitude from the given coordinate. Returns null if the
-     * coordinate string is not valid.
+     * coordinate string is not valid. The coordinate is on the form
+     * longitude / latitude.
      * 
      * @param coordinate the coordinate string.
      * @return the latitude.
@@ -125,37 +146,19 @@
         
         Matcher matcher = COORDINATE_PATTERN.matcher( coordinate );
         
-        return matcher.find() ? matcher.group( 1 ) : null;
-    }
-
-    /**
-     * Returns the longitude from the given coordinate. Returns null if the
-     * coordinate string is not valid.
-     * 
-     * @param coordinate the coordinate string.
-     * @return the longitude.
-     */
-    public static String getLongitude( String coordinate )
-    {
-        if ( coordinate == null )
-        {
-            return null;
-        }
-        
-        Matcher matcher = COORDINATE_PATTERN.matcher( coordinate );
-        
         return matcher.find() ? matcher.group( 2 ) : null;
     }
-    
+
     /**
-     * Returns a coordinate string based on the given latitude and longitude.
+     * Returns a coordinate string based on the given latitude and longitude. 
+     * The coordinate is on the form longitude / latitude.
      * 
+     * @param longitude the longitude string.
      * @param latitude the latitude string.
-     * @param longitude the longitude string.
      * @return a coordinate string.
      */
-    public static String getCoordinate( String latitude, String longitude )
+    public static String getCoordinate( String longitude, String latitude )
     {
-        return "[" + latitude + "," + longitude + "]";
+        return "[" + longitude + "," + latitude + "]";
     }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ValidationUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ValidationUtilsTest.java	2011-10-12 07:51:57 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ValidationUtilsTest.java	2011-10-20 18:51:07 +0000
@@ -56,22 +56,22 @@
         assertFalse( coordinateIsValid( "S-0.27726 E37.08472" ) );
         assertFalse( coordinateIsValid( null ) );
     }
+
+    @Test
+    public void testGetLongitude()
+    {
+        assertEquals( "+37.99034", getLongitude( "[+37.99034,-28.94221]" ) );
+        assertEquals( "37.99034", getLongitude( "[37.99034,28.94221]" ) );
+        assertNull( getLongitude( "23.34343,56.3232" ) );
+        assertNull( getLongitude( null ) );
+    }
     
     @Test
     public void testGetLatitude()
     {
-        assertEquals( "+37.99034", getLatitude( "[+37.99034,-28.94221]" ) );
-        assertEquals( "37.99034", getLatitude( "[37.99034,28.94221]" ) );
+        assertEquals( "-28.94221", getLatitude( "[+37.99034,-28.94221]" ) );
+        assertEquals( "28.94221", getLatitude( "[37.99034,28.94221]" ) );
         assertNull( getLatitude( "23.34343,56.3232" ) );
         assertNull( getLatitude( null ) );
     }
-    
-    @Test
-    public void testGetLongitude()
-    {
-        assertEquals( "-28.94221", getLongitude( "[+37.99034,-28.94221]" ) );
-        assertEquals( "28.94221", getLongitude( "[37.99034,28.94221]" ) );
-        assertNull( getLongitude( "23.34343,56.3232" ) );
-        assertNull( getLongitude( null ) );
-    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java	2011-10-06 18:31:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java	2011-10-20 18:51:07 +0000
@@ -138,6 +138,13 @@
         this.comment = comment;
     }
 
+    private String longitude;
+
+    public void setLongitude( String longitude )
+    {
+        this.longitude = longitude;
+    }
+
     private String latitude;
 
     public void setLatitude( String latitude )
@@ -145,13 +152,6 @@
         this.latitude = latitude;
     }
 
-    private String longitude;
-
-    public void setLongitude( String longitude )
-    {
-        this.longitude = longitude;
-    }
-
     private String url;
 
     public void setUrl( String url )
@@ -224,8 +224,8 @@
     {
         code = nullIfEmpty( code );
         comment = nullIfEmpty( comment );
+        longitude = nullIfEmpty( longitude );
         latitude = nullIfEmpty( latitude );
-        longitude = nullIfEmpty( longitude );
         url = nullIfEmpty( url );
 
         contactPerson = nullIfEmpty( contactPerson );
@@ -235,8 +235,8 @@
 
         Date date = format.parseDate( openingDate );
 
-        String coordinates = latitude != null && longitude != null ?
-            ValidationUtils.getCoordinate( latitude, longitude ) : null;
+        String coordinates = longitude != null && latitude != null ?
+            ValidationUtils.getCoordinate( longitude, latitude ) : null;
         
         // ---------------------------------------------------------------------
         // Get parent

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java	2011-10-06 18:31:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitAction.java	2011-10-20 18:51:07 +0000
@@ -155,7 +155,14 @@
     {
         return point;
     }
-    
+
+    private String longitude;
+
+    public String getLongitude()
+    {
+        return longitude;
+    }
+
     private String latitude;
     
     public String getLatitude()
@@ -163,13 +170,6 @@
         return latitude;
     }
 
-    private String longitude;
-
-    public String getLongitude()
-    {
-        return longitude;
-    }
-
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -203,8 +203,8 @@
         // ---------------------------------------------------------------------
 
         point = organisationUnit.getCoordinates() == null || coordinateIsValid( organisationUnit.getCoordinates() );
+        longitude = ValidationUtils.getLongitude( organisationUnit.getCoordinates() );
         latitude = ValidationUtils.getLatitude( organisationUnit.getCoordinates() );
-        longitude = ValidationUtils.getLongitude( organisationUnit.getCoordinates() );
         
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java	2011-10-06 18:31:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java	2011-10-20 18:51:07 +0000
@@ -160,6 +160,13 @@
         this.comment = comment;
     }
 
+    private String longitude;
+
+    public void setLongitude( String longitude )
+    {
+        this.longitude = longitude;
+    }
+
     private String latitude;
 
     public void setLatitude( String latitude )
@@ -167,13 +174,6 @@
         this.latitude = latitude;
     }
 
-    private String longitude;
-
-    public void setLongitude( String longitude )
-    {
-        this.longitude = longitude;
-    }
-
     private String url;
 
     public void setUrl( String url )
@@ -246,8 +246,8 @@
     {
         code = nullIfEmpty( code );
         comment = nullIfEmpty( comment );
+        longitude = nullIfEmpty( longitude );
         latitude = nullIfEmpty( latitude );
-        longitude = nullIfEmpty( longitude );
         url = nullIfEmpty( url );
 
         contactPerson = nullIfEmpty( contactPerson );
@@ -264,8 +264,8 @@
             cDate = format.parseDate( closedDate );
         }
 
-        String coordinates = latitude != null && longitude != null ?
-            ValidationUtils.getCoordinate( latitude, longitude ) : null;
+        String coordinates = longitude != null && latitude != null ?
+            ValidationUtils.getCoordinate( longitude, latitude ) : null;
         
         // ---------------------------------------------------------------------
         // Update organisation unit

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm	2011-10-06 18:31:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm	2011-10-20 18:51:07 +0000
@@ -51,13 +51,13 @@
 		<td><textarea id="comment" name="comment" style="width:20em; height:5em"></textarea></td>
 	</tr>
 	<tr>
+		<td><label for="longitude">$i18n.getString( "longitude_optional" )</label></td>
+		<td><input type="text" id="longitude" name="longitude" style="width:20em"/></td>
+	</tr>
+	<tr>
 		<td><label for="latitude">$i18n.getString( "latitude_optional" )</label></td>
 		<td><input type="text" id="latitude" name="latitude" style="width:20em"/></td>
 	</tr>
-	<tr>
-		<td><label for="longitude">$i18n.getString( "longitude_optional" )</label></td>
-		<td><input type="text" id="longitude" name="longitude" style="width:20em"/></td>
-	</tr>
     <tr>
         <td><label for="url">$i18n.getString( "url" )</label></td>
         <td><input type="text" id="url" name="url" style="width:20em"/></td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm	2011-10-06 18:31:41 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm	2011-10-20 18:51:07 +0000
@@ -77,13 +77,13 @@
 	</tr>
 	#if( $point )
 	<tr>
+		<td><label for="longitude">$i18n.getString( "longitude_optional" )</label></td>
+		<td><input type="text" id="longitude" name="longitude" value="$!{longitude}" style="width:20em"/></td>
+	</tr>
+	<tr>
 		<td><label for="latitude">$i18n.getString( "latitude_optional" )</label></td>
 		<td><input type="text" id="latitude" name="latitude" value="$!{latitude}" style="width:20em"/></td>
 	</tr>
-	<tr>
-		<td><label for="longitude">$i18n.getString( "longitude_optional" )</label></td>
-		<td><input type="text" id="longitude" name="longitude" value="$!{longitude}" style="width:20em"/></td>
-	</tr>
 	#end
     <tr>
         <td><label for="url">$i18n.getString( "url" )</label></td>