← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18478: Analytics. Checking if dynamic dimensions in request are defined as data dimensions, to avoid fai...

 

------------------------------------------------------------
revno: 18478
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-03-04 17:26:17 +0100
message:
  Analytics. Checking if dynamic dimensions in request are defined as data dimensions, to avoid failed sql queries.
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.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-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-02-22 18:31:40 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-03-04 16:26:17 +0000
@@ -839,11 +839,11 @@
             for ( String param : dimensionParams )
             {
                 String dimension = DimensionalObjectUtils.getDimensionFromParam( param );
-                List<String> options = DimensionalObjectUtils.getDimensionItemsFromParam( param );
+                List<String> items = DimensionalObjectUtils.getDimensionItemsFromParam( param );
 
-                if ( dimension != null && options != null )
+                if ( dimension != null && items != null )
                 {
-                    list.addAll( getDimension( dimension, options, null, format, false ) );
+                    list.addAll( getDimension( dimension, items, null, format, false ) );
                 }
             }
         }
@@ -867,7 +867,7 @@
             List<NameableObject> dataSets = new ArrayList<>();
             List<NameableObject> operandDataElements = new ArrayList<>();
 
-            options:
+            itemLoop:
             for ( String uid : items )
             {
                 if ( uid != null && uid.startsWith( KEY_DE_GROUP ) )
@@ -881,7 +881,7 @@
                         dataElementGroups.add( group );
                     }
                     
-                    continue options;
+                    continue itemLoop;
                 }
                 
                 Indicator in = indicatorService.getIndicator( uid );
@@ -889,7 +889,7 @@
                 if ( in != null )
                 {
                     indicators.add( in );
-                    continue options;
+                    continue itemLoop;
                 }
 
                 DataElement de = dataElementService.getDataElement( uid );
@@ -897,7 +897,7 @@
                 if ( de != null )
                 {
                     dataElements.add( de );
-                    continue options;
+                    continue itemLoop;
                 }
 
                 DataSet ds = dataSetService.getDataSet( uid );
@@ -905,7 +905,7 @@
                 if ( ds != null )
                 {
                     dataSets.add( ds );
-                    continue options;
+                    continue itemLoop;
                 }
 
                 DataElementOperand dc = operandService.getDataElementOperandByUid( uid );
@@ -913,7 +913,7 @@
                 if ( dc != null )
                 {
                     operandDataElements.add( dc.getDataElement() );
-                    continue options;
+                    continue itemLoop;
                 }
 
                 throw new IllegalQueryException( "Data dimension option identifier does not reference any option: " + uid );
@@ -1112,7 +1112,7 @@
 
         OrganisationUnitGroupSet ougs = organisationUnitGroupService.getOrganisationUnitGroupSet( dimension );
 
-        if ( ougs != null )
+        if ( ougs != null && ougs.isDataDimension() )
         {
             List<NameableObject> ous = asList( organisationUnitGroupService.getOrganisationUnitGroupsByUid( items ) );
 
@@ -1123,7 +1123,7 @@
 
         DataElementGroupSet degs = dataElementService.getDataElementGroupSet( dimension );
 
-        if ( degs != null )
+        if ( degs != null && degs.isDataDimension() )
         {
             List<NameableObject> des = asList( dataElementService.getDataElementGroupsByUid( items ) );
 
@@ -1134,7 +1134,7 @@
 
         CategoryOptionGroupSet cogs = categoryService.getCategoryOptionGroupSet( dimension );
 
-        if ( cogs != null )
+        if ( cogs != null && cogs.isDataDimension() )
         {
             List<NameableObject> cogz = asList( categoryService.getCategoryOptionGroupsByUid( items ) );
 
@@ -1219,7 +1219,7 @@
             boolean orgUnitHierarchy = hierarchyMeta && DimensionType.ORGANISATIONUNIT.equals( dimension.getDimensionType() );
 
             // -----------------------------------------------------------------
-            // If dimension is not fixed and has no options, insert all options
+            // If dimension is not fixed and has no options, insert all items
             // -----------------------------------------------------------------
 
             if ( !FIXED_DIMS.contains( dimension.getDimension() ) && items.isEmpty() )