dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20911
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9763: Analytics, validating that category option combos cannot be set as filter
------------------------------------------------------------
revno: 9763
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-02-07 14:24:13 +0200
message:
Analytics, validating that category option combos cannot be set as filter
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/DefaultAnalyticsService.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-02-07 07:41:13 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-02-07 12:24:13 +0000
@@ -120,6 +120,18 @@
// -------------------------------------------------------------------------
/**
+ * Ensures conformity for this query. Removes the category option combo
+ * dimension if it exists and if the data element dimension does not exist.
+ */
+ public void conform()
+ {
+ if ( !dimensions.contains( new Dimension( DATAELEMENT_DIM_ID ) ) )
+ {
+ removeDimension( CATEGORYOPTIONCOMBO_DIM_ID );
+ }
+ }
+
+ /**
* Creates a list of dimensions for use as headers. Will replace any of
* the indicator, data element or data set dimensions with the common
* data x dimension. If the category option combo dimension is given but
@@ -129,11 +141,6 @@
{
List<Dimension> list = new ArrayList<Dimension>( dimensions );
- if ( list.contains( new Dimension( CATEGORYOPTIONCOMBO_DIM_ID ) ) && !list.contains( new Dimension( DATAELEMENT_DIM_ID ) ) )
- {
- list.remove( new Dimension( CATEGORYOPTIONCOMBO_DIM_ID ) );
- }
-
ListIterator<Dimension> iter = list.listIterator();
dimensions : while ( iter.hasNext() )
=== 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 2013-02-05 08:50:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-02-07 12:24:13 +0000
@@ -140,12 +140,14 @@
queryPlanner.validate( params );
+ params.conform();
+
+ // ---------------------------------------------------------------------
+ // Headers and meta-data
+ // ---------------------------------------------------------------------
+
Grid grid = new ListGrid();
- // ---------------------------------------------------------------------
- // Headers and meta-data
- // ---------------------------------------------------------------------
-
grid.setMetaData( getUidNameMap( params ) );
for ( Dimension col : params.getHeaderDimensions() )
=== 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-02-01 14:57:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2013-02-07 12:24:13 +0000
@@ -32,6 +32,7 @@
import static org.hisp.dhis.analytics.AggregationType.AVERAGE_INT_DISAGGREGATION;
import static org.hisp.dhis.analytics.AggregationType.SUM;
import static org.hisp.dhis.analytics.DataQueryParams.INDICATOR_DIM_ID;
+import static org.hisp.dhis.analytics.DataQueryParams.CATEGORYOPTIONCOMBO_DIM_ID;
import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE;
import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM;
import static org.hisp.dhis.dataelement.DataElement.VALUE_TYPE_BOOL;
@@ -89,11 +90,16 @@
throw new IllegalQueryException( "At least one period must be specified as dimension or filter" );
}
- if ( params.getFilters() != null && params.getFilters().contains( new Dimension( INDICATOR_DIM_ID ) ) )
+ if ( params.getFilters().contains( new Dimension( INDICATOR_DIM_ID ) ) )
{
throw new IllegalQueryException( "Indicators cannot be specified as filter" );
}
-
+
+ if ( params.getFilters().contains( new Dimension( CATEGORYOPTIONCOMBO_DIM_ID ) ) )
+ {
+ throw new IllegalQueryException( "Category option combos cannot be specified as filter" );
+ }
+
//TODO check if any dimension occur more than once
}