dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15705
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5761: Fixed bug with organisation unit update, feature type not set properly
------------------------------------------------------------
revno: 5761
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-01-20 06:42:41 +0100
message:
Fixed bug with organisation unit update, feature type not set properly
modified:
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/UpdateOrganisationUnitAction.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-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-29 14:16:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2012-01-20 05:42:41 +0000
@@ -235,9 +235,6 @@
Date date = format.parseDate( openingDate );
- String coordinates = longitude != null && latitude != null ?
- ValidationUtils.getCoordinate( longitude, latitude ) : null;
-
// ---------------------------------------------------------------------
// Get parent
// ---------------------------------------------------------------------
@@ -259,8 +256,6 @@
OrganisationUnit organisationUnit = new OrganisationUnit( name, shortName, code, date, null, true, comment );
- organisationUnit.setCoordinates( coordinates );
- organisationUnit.setFeatureType( OrganisationUnit.FEATURETYPE_POINT );
organisationUnit.setUrl( url );
organisationUnit.setParent( parent );
organisationUnit.setContactPerson( contactPerson );
@@ -280,6 +275,21 @@
}
// ---------------------------------------------------------------------
+ // Set coordinates and feature type to point if valid
+ // ---------------------------------------------------------------------
+
+ if ( longitude != null && latitude != null )
+ {
+ String coordinates = ValidationUtils.getCoordinate( longitude, latitude );
+
+ if ( ValidationUtils.coordinateIsValid( coordinates ) )
+ {
+ organisationUnit.setCoordinates( coordinates );
+ organisationUnit.setFeatureType( OrganisationUnit.FEATURETYPE_POINT );
+ }
+ }
+
+ // ---------------------------------------------------------------------
// Must persist org unit before adding data sets because association are
// updated on both sides (and this side is inverse)
// ---------------------------------------------------------------------
=== 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 2012-01-05 21:51:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2012-01-20 05:42:41 +0000
@@ -28,6 +28,7 @@
*/
import static org.hisp.dhis.system.util.TextUtils.nullIfEmpty;
+import static org.hisp.dhis.system.util.ValidationUtils.coordinateIsValid;
import java.util.ArrayList;
import java.util.Collection;
@@ -266,9 +267,6 @@
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( id );
- String coordinates = ( longitude != null && latitude != null ) ? ValidationUtils.getCoordinate( longitude,
- latitude ) : ( organisationUnit.getCoordinates() != null ? organisationUnit.getCoordinates() : null );
-
// ---------------------------------------------------------------------
// Update organisation unit
// ---------------------------------------------------------------------
@@ -285,7 +283,6 @@
organisationUnit.setOpeningDate( oDate );
organisationUnit.setClosedDate( cDate );
organisationUnit.setComment( comment );
- organisationUnit.setCoordinates( coordinates );
organisationUnit.setUrl( url );
organisationUnit.setContactPerson( contactPerson );
organisationUnit.setAddress( address );
@@ -298,6 +295,28 @@
attributeService );
}
+ // ---------------------------------------------------------------------
+ // Set coordinates and feature type to point if valid
+ // ---------------------------------------------------------------------
+
+ boolean point = organisationUnit.getCoordinates() == null || coordinateIsValid( organisationUnit.getCoordinates() );
+
+ if ( point )
+ {
+ String coordinates = null;
+ String featureType = null;
+
+ if ( longitude != null && latitude != null &&
+ ValidationUtils.coordinateIsValid( ValidationUtils.getCoordinate( longitude, latitude ) ) )
+ {
+ coordinates = ValidationUtils.getCoordinate( longitude, latitude );
+ featureType = OrganisationUnit.FEATURETYPE_POINT;
+ }
+
+ organisationUnit.setCoordinates( coordinates );
+ organisationUnit.setFeatureType( featureType );
+ }
+
Set<DataSet> sets = new HashSet<DataSet>();
for ( String id : dataSets )