← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11028: Analytics, fixed but related to validation of table layout

 

------------------------------------------------------------
revno: 11028
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-05-27 21:46:30 +0200
message:
  Analytics, fixed but related to validation of table layout
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.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/DataQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2013-05-27 18:24:15 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2013-05-27 19:46:30 +0000
@@ -1064,7 +1064,23 @@
     {
         return dimensions.indexOf( new BaseDimensionalObject( key ) ) != -1 || filters.indexOf( new BaseDimensionalObject( key ) ) != -1;
     }
-        
+    
+    /**
+     * Indicates whether a dimension with the given identifier exists. Returns
+     * true for the dx argument if any of the data dimensions is present.
+     */
+    public boolean hasDimensionCollapseDx( String dimension )
+    {
+        List<String> dims = getDimensionIdentifiersAsList();
+        
+        if ( DATA_X_DIM_ID.equals( dimension ) )
+        {
+            return CollectionUtils.intersection( dims, DATA_DIMS ).size() > 0;
+        }
+        
+        return dims.contains( dimension );
+    }
+            
     // -------------------------------------------------------------------------
     // Get and set helpers for dimensions
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java	2013-05-26 14:06:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java	2013-05-27 19:46:30 +0000
@@ -153,7 +153,7 @@
         {
             for ( String column : columns )
             {
-                if ( params.getDimensionArrayCollapseDx( column ).length == 0 )
+                if ( !params.hasDimensionCollapseDx( column ) )
                 {
                     violation = "Column must be present as dimension in query: " + column;
                 }
@@ -164,7 +164,7 @@
         {
             for ( String row : rows )
             {
-                if ( params.getDimensionArrayCollapseDx( row ).length == 0 )
+                if ( !params.hasDimensionCollapseDx( row ) )
                 {
                     violation = "Row must be present as dimension in query: " + row;
                 }