← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6906: Improved conflict handling in chart plugin controller

 

------------------------------------------------------------
revno: 6906
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-05-10 21:02:58 +0200
message:
  Improved conflict handling in 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-05-06 19:28:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartPluginController.java	2012-05-10 19:02:58 +0000
@@ -103,6 +103,12 @@
                 
         List<Period> periods = periodService.reloadPeriods( setNames( relativePeriods.getRelativePeriods(), format ) );
 
+        if ( periods.isEmpty() )
+        {
+            ContextUtils.conflictResponse( response, "No valid periods specified" );
+            return null;
+        }
+        
         for ( Period period : periods )
         {
             chartValue.getPeriods().add( period.getName() );
@@ -110,6 +116,12 @@
         
         List<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnitsByUid( organisationUnitIds );
         
+        if ( organisationUnits.isEmpty() )
+        {
+            ContextUtils.conflictResponse( response, "No valid organisation units specified" );
+            return null;
+        }
+        
         for ( OrganisationUnit unit : organisationUnits )
         {
             chartValue.getOrgUnits().add( unit.getName() );
@@ -119,6 +131,12 @@
         {
             List<Indicator> indicators = indicatorService.getIndicatorsByUid( indicatorIds );
 
+            if ( indicators.isEmpty() )
+            {
+                ContextUtils.conflictResponse( response, "No valid indicators specified" );
+                return null;
+            }
+            
             for ( Indicator indicator : indicators )
             {
                 chartValue.getData().add( indicator.getDisplayShortName() );
@@ -145,6 +163,12 @@
         if ( dataElementIds != null )
         {
             List<DataElement> dataElements = dataElementService.getDataElementsByUid( dataElementIds );
+
+            if ( dataElements.isEmpty() )
+            {
+                ContextUtils.conflictResponse( response, "No valid data elements specified" );
+                return null;
+            }
             
             for ( DataElement element : dataElements )
             {