← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4700: Minor fix light module

 

------------------------------------------------------------
revno: 4700
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-09-27 09:39:54 +0200
message:
  Minor fix light module
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetOrganisationUnitsAction.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-light/src/main/java/org/hisp/dhis/light/action/GetOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetOrganisationUnitsAction.java	2011-09-23 13:11:20 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetOrganisationUnitsAction.java	2011-09-27 07:39:54 +0000
@@ -33,6 +33,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
 
 import com.opensymphony.xwork2.Action;
 
@@ -78,17 +79,22 @@
     @Override
     public String execute()
     {
-        List<OrganisationUnit> userOrganisationUnits = new ArrayList<OrganisationUnit>( currentUserService
-            .getCurrentUser().getOrganisationUnits() );
-
-        for ( OrganisationUnit unit : userOrganisationUnits )
+        User user = currentUserService.getCurrentUser();
+        
+        if ( user != null )
         {
-            organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( unit.getId() ) );
+            List<OrganisationUnit> userOrganisationUnits = new ArrayList<OrganisationUnit>( user.getOrganisationUnits() );
+    
+            for ( OrganisationUnit unit : userOrganisationUnits )
+            {
+                organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( unit.getId() ) );
+            }
+    
+            // Collections.sort( organisationUnits, new OrganisationUnitNameComparator() );
+            
+            organisationUnits = organisationUnits.subList( 0, 50 );
         }
-
-//        Collections.sort( organisationUnits, new OrganisationUnitNameComparator() );
-        organisationUnits = organisationUnits.subList( 0, 50 );
-
+        
         return SUCCESS;
     }
 }