← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7234: Improved chart plugin controller

 

------------------------------------------------------------
revno: 7234
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-06-07 13:28:12 +0200
message:
  Improved chart plugin controller
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartPluginController.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/ChartPluginController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartPluginController.java	2012-06-05 14:27:07 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartPluginController.java	2012-06-07 11:28:12 +0000
@@ -164,12 +164,6 @@
             organisationUnits = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsByUid( organisationUnitIds ) );
         }
 
-        if ( organisationUnits.isEmpty() )
-        {
-            ContextUtils.conflictResponse( response, "No valid organisation units specified" );
-            return null;
-        }
-
         if ( orgUnitIsParent )
         {
             List<OrganisationUnit> childOrganisationUnits = new ArrayList<OrganisationUnit>();
@@ -182,9 +176,10 @@
             organisationUnits = childOrganisationUnits;
         }
 
-        for ( OrganisationUnit unit : organisationUnits )
+        if ( organisationUnits.isEmpty() )
         {
-            chartValue.getOrgUnits().add( unit.getName() );
+            ContextUtils.conflictResponse( response, "No valid organisation units specified" );
+            return null;
         }
 
         // ---------------------------------------------------------------------
@@ -196,12 +191,27 @@
         
         List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();        
         
-        if ( organisationUnitGroupSetId != null )
+        if ( useGroupSets )
         {
             OrganisationUnitGroupSet groupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( organisationUnitGroupSetId );
             organisationUnitGroups.addAll( groupSet.getOrganisationUnitGroups() );
         }
-        
+
+        if ( useGroupSets )
+        {
+            for ( OrganisationUnitGroup groupSet : organisationUnitGroups )
+            {
+                chartValue.getOrgUnits().add( groupSet.getName() );
+            }
+        }
+        else
+        {
+            for ( OrganisationUnit unit : organisationUnits )
+            {
+                chartValue.getOrgUnits().add( unit.getName() );
+            }
+        }
+
         // ---------------------------------------------------------------------
         // Indicators
         // ---------------------------------------------------------------------