dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38024
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19423: Analytics, preventing query for reporting rates when dimensions which are not relevant to data se...
------------------------------------------------------------
revno: 19423
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-06-16 19:25:14 +0200
message:
Analytics, preventing query for reporting rates when dimensions which are not relevant to data sets are present
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
--
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 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2015-06-16 17:25:14 +0000
@@ -31,8 +31,10 @@
import static org.hisp.dhis.analytics.AggregationType.AVERAGE_INT_DISAGGREGATION;
import static org.hisp.dhis.analytics.AggregationType.AVERAGE_SUM_INT_DISAGGREGATION;
import static org.hisp.dhis.common.DimensionType.DATASET;
+import static org.hisp.dhis.common.DimensionType.PERIOD;
import static org.hisp.dhis.common.DimensionType.ORGANISATIONUNIT;
import static org.hisp.dhis.common.DimensionType.ORGANISATIONUNIT_GROUPSET;
+import static org.hisp.dhis.common.DimensionType.CATEGORYOPTION_GROUPSET;
import static org.hisp.dhis.common.DimensionalObject.CATEGORYOPTIONCOMBO_DIM_ID;
import static org.hisp.dhis.common.DimensionalObject.DATAELEMENT_DIM_ID;
import static org.hisp.dhis.common.DimensionalObject.DATAELEMENT_OPERAND_ID;
@@ -110,8 +112,10 @@
DATA_X_DIM_ID, INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATASET_DIM_ID, PROGRAM_DATAELEMENT_DIM_ID, PERIOD_DIM_ID, ORGUNIT_DIM_ID );
private static final List<String> DIMENSION_PERMUTATION_IGNORE_DIMS = Arrays.asList(
INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, CATEGORYOPTIONCOMBO_DIM_ID, DATASET_DIM_ID, PROGRAM_DATAELEMENT_DIM_ID );
-
- private static final List<DimensionType> COMPLETENESS_DIMENSION_TYPES = Arrays.asList( DATASET, ORGANISATIONUNIT, ORGANISATIONUNIT_GROUPSET );
+ public static final List<DimensionType> COMPLETENESS_DIMENSION_TYPES = Arrays.asList(
+ DATASET, PERIOD, ORGANISATIONUNIT, ORGANISATIONUNIT_GROUPSET, CATEGORYOPTION_GROUPSET );
+ private static final List<DimensionType> COMPLETENESS_TARGET_DIMENSION_TYPES = Arrays.asList(
+ DATASET, ORGANISATIONUNIT, ORGANISATIONUNIT_GROUPSET );
private static final DimensionItem[] DIM_OPT_ARR = new DimensionItem[0];
private static final DimensionItem[][] DIM_OPT_2D_ARR = new DimensionItem[0][];
@@ -376,7 +380,7 @@
for ( int i = 0; i < dimensions.size(); i++ )
{
- if ( COMPLETENESS_DIMENSION_TYPES.contains( dimensions.get( i ).getDimensionType() ) )
+ if ( COMPLETENESS_TARGET_DIMENSION_TYPES.contains( dimensions.get( i ).getDimensionType() ) )
{
indexes.add( i );
}
@@ -394,7 +398,7 @@
for ( int i = 0; i < filters.size(); i++ )
{
- if ( COMPLETENESS_DIMENSION_TYPES.contains( filters.get( i ).getDimensionType() ) )
+ if ( COMPLETENESS_TARGET_DIMENSION_TYPES.contains( filters.get( i ).getDimensionType() ) )
{
indexes.add( i );
}
@@ -907,6 +911,22 @@
}
/**
+ * Retrieves the set of dimension types which are present in dimensions and
+ * filters.
+ */
+ public Set<DimensionType> getDimensionTypes()
+ {
+ Set<DimensionType> types = new HashSet<>();
+
+ for ( DimensionalObject dim : getDimensionsAndFilters() )
+ {
+ types.add( dim.getDimensionType() );
+ }
+
+ return types;
+ }
+
+ /**
* Indicates whether this params defines an identifier scheme different from
* UID.
*/
@@ -1422,7 +1442,7 @@
return !dimensionOptions.isEmpty() ? dimensionOptions : getFilterOptions( key );
}
-
+
/**
* Retrieves the options for the given dimension identifier. If the dx dimension
* is specified, all concrete dimensions (in|de|dc|ds) are returned as a single
=== 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-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-06-16 17:25:14 +0000
@@ -40,6 +40,7 @@
import static org.hisp.dhis.analytics.DataQueryParams.DISPLAY_NAME_PERIOD;
import static org.hisp.dhis.analytics.DataQueryParams.DISPLAY_NAME_PROGRAM_INDICATOR;
import static org.hisp.dhis.analytics.DataQueryParams.KEY_DE_GROUP;
+import static org.hisp.dhis.analytics.DataQueryParams.COMPLETENESS_DIMENSION_TYPES;
import static org.hisp.dhis.common.DimensionalObject.CATEGORYOPTIONCOMBO_DIM_ID;
import static org.hisp.dhis.common.DimensionalObject.DATAELEMENT_DIM_ID;
import static org.hisp.dhis.common.DimensionalObject.DATASET_DIM_ID;
@@ -428,6 +429,11 @@
dataSourceParams.removeDimension( PROGRAM_DATAELEMENT_DIM_ID );
dataSourceParams.setAggregationType( AggregationType.COUNT );
+ if ( !COMPLETENESS_DIMENSION_TYPES.containsAll( dataSourceParams.getDimensionTypes() ) )
+ {
+ return;
+ }
+
Map<String, Double> aggregatedDataMap = getAggregatedCompletenessValueMap( dataSourceParams );
// -----------------------------------------------------------------
@@ -483,7 +489,8 @@
/**
* Adds values to the given grid based on dynamic dimensions from the given
- * data query parameters.
+ * data query parameters. This assumes that no fixed dimensions are part of
+ * the query.
*
* @param params the data query parameters.
* @param grid the grid.