← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12865: minor changes on OrganisationUnitController for Org Units Near By task.

 

------------------------------------------------------------
revno: 12865
committer: James Chang <jamesbchang@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-11-04 13:18:11 +0700
message:
  minor changes on OrganisationUnitController for Org Units Near By task.
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.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-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java	2013-11-02 16:06:03 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java	2013-11-04 06:18:11 +0000
@@ -50,6 +50,7 @@
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitByLevelComparator;
 import org.hisp.dhis.user.CurrentUserService;
@@ -267,18 +268,13 @@
         Double latitude = Double.parseDouble( options.getOptions().get( "latitude" ) );
         Double distance = Double.parseDouble( options.getOptions().get( "distance" ) );
         String orgUnitGroupSetId = options.getOptions().get( "orgUnitGroupSetId" );
-        
+                
         entityList = new ArrayList<OrganisationUnit>( organisationUnitService.getWithinCoordinateArea( longitude, latitude, distance ) );
                 
         if ( entityList != null )
         {            
             for( OrganisationUnit orgunit : entityList )
             {
-                // Clear out all data not needed for this task
-                orgunit.removeAllDataSets();
-                orgunit.removeAllUsers();
-                orgunit.removeAllOrganisationUnitGroups();
-
                 Set<AttributeValue> attributeValues = orgunit.getAttributeValues();
                 attributeValues.clear();
 
@@ -287,18 +283,28 @@
                 {
                     for ( OrganisationUnitGroup orgunitGroup : orgunit.getGroups() )
                     {
-                        if( orgunitGroup.getGroupSet().getUid() == orgUnitGroupSetId )
-                        {                        
-                            AttributeValue attributeValue = new AttributeValue();
-                            attributeValue.setAttribute( new Attribute( "OrgUnitGroupSymbol", "OrgUnitGroupSymbol" ) );
-                            attributeValue.setValue( orgunitGroup.getSymbol() );
-        
-                            attributeValues.add( attributeValue );
+                        if( orgunitGroup.getGroupSet() != null )
+                        {
+                            OrganisationUnitGroupSet orgunitGroupSet = orgunitGroup.getGroupSet();
+                                                        
+                            if( orgunitGroupSet.getUid().compareTo( orgUnitGroupSetId ) == 0 )
+                            {                        
+                                AttributeValue attributeValue = new AttributeValue();
+                                attributeValue.setAttribute( new Attribute( "OrgUnitGroupSymbol", "OrgUnitGroupSymbol" ) );
+                                attributeValue.setValue( orgunitGroup.getSymbol() );
+            
+                                attributeValues.add( attributeValue );
+                            }
                         }
                     }
                 }
                 
                 orgunit.setAttributeValues( attributeValues );
+                
+                // Clear out all data not needed for this task
+                orgunit.removeAllDataSets();
+                orgunit.removeAllUsers();
+                orgunit.removeAllOrganisationUnitGroups();
             }
         }