dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20740
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9624: Analytics, impl support for manually overriding the aggregation type (SUM, AVERAGE_INT_AGGREGATIO...
------------------------------------------------------------
revno: 9624
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-01-27 23:03:02 +0200
message:
Analytics, impl support for manually overriding the aggregation type (SUM, AVERAGE_INT_AGGREGATION, AVERAGE_INT_DISAGGREGATION, AVERAGE_BOOL, COUNT) for the request / query. With the on-the-fly aggregation we are not limited by the aggregation operator of the data element. The aggregation operator of the data elements / data element groups will be used by default.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java
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
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.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-api/src/main/java/org/hisp/dhis/common/SharingUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-01-22 15:07:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/SharingUtils.java 2013-01-27 21:03:02 +0000
@@ -106,7 +106,7 @@
return isSupported( object.getClass() );
}
- public static boolean isSupported( Class clazz )
+ public static boolean isSupported( Class<?> clazz )
{
return SUPPORTED_TYPES.containsValue( clazz );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2013-01-22 06:42:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2013-01-27 21:03:02 +0000
@@ -28,7 +28,6 @@
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2013-01-22 06:42:20 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2013-01-27 21:03:02 +0000
@@ -28,7 +28,6 @@
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java 2013-01-18 14:18:49 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java 2013-01-27 21:03:02 +0000
@@ -39,5 +39,5 @@
Map<String, Double> getAggregatedDataValueMap( DataQueryParams params, String tableName ) throws Exception;
- DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams, boolean categories, I18nFormat format );
+ DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams, boolean categories, AggregationType aggregationType, I18nFormat format );
}
=== 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-01-27 20:34:47 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-01-27 21:03:02 +0000
@@ -70,9 +70,11 @@
private List<Dimension> dimensions = new ArrayList<Dimension>();
+ private List<Dimension> filters = new ArrayList<Dimension>();
+
private boolean categories = false;
- private List<Dimension> filters = new ArrayList<Dimension>();
+ private AggregationType aggregationType;
// -------------------------------------------------------------------------
// Transient properties
@@ -84,8 +86,6 @@
private transient int organisationUnitLevel;
- private transient AggregationType aggregationType;
-
private transient PeriodType dataPeriodType;
// -------------------------------------------------------------------------
@@ -576,6 +576,16 @@
this.dimensions = dimensions;
}
+ public List<Dimension> getFilters()
+ {
+ return filters;
+ }
+
+ public void setFilters( List<Dimension> filters )
+ {
+ this.filters = filters;
+ }
+
public boolean isCategories()
{
return categories;
@@ -586,14 +596,14 @@
this.categories = categories;
}
- public List<Dimension> getFilters()
+ public AggregationType getAggregationType()
{
- return filters;
+ return aggregationType;
}
- public void setFilters( List<Dimension> filters )
+ public void setAggregationType( AggregationType aggregationType )
{
- this.filters = filters;
+ this.aggregationType = aggregationType;
}
// -------------------------------------------------------------------------
@@ -763,16 +773,6 @@
// Get and set methods for transient properties
// -------------------------------------------------------------------------
- public AggregationType getAggregationType()
- {
- return aggregationType;
- }
-
- public void setAggregationType( AggregationType aggregationType )
- {
- this.aggregationType = aggregationType;
- }
-
public PeriodType getDataPeriodType()
{
return dataPeriodType;
=== 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-01-27 14:43:24 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-01-27 21:03:02 +0000
@@ -282,11 +282,12 @@
return map;
}
- public DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams, boolean categories, I18nFormat format )
+ public DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams, boolean categories, AggregationType aggregationType, I18nFormat format )
{
DataQueryParams params = new DataQueryParams();
params.setCategories( categories );
+ params.setAggregationType( aggregationType );
if ( dimensionParams != null && !dimensionParams.isEmpty() )
{
=== 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-01-27 20:34:47 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2013-01-27 21:03:02 +0000
@@ -310,11 +310,20 @@
* first group set found. A constraint for data element groups is that they
* must contain data elements with equal aggregation type. Hence it is not
* meaningful to split on multiple data element group sets.
+ *
+ * If the aggregation type is already set/overridden in the request, the
+ * query will be returned unchanged.
*/
private List<DataQueryParams> groupByAggregationType( DataQueryParams params )
{
List<DataQueryParams> queries = new ArrayList<DataQueryParams>();
+ if ( params.getAggregationType() != null )
+ {
+ queries.add( new DataQueryParams( params ) );
+ return queries;
+ }
+
if ( params.getDataElements() != null && !params.getDataElements().isEmpty() )
{
PeriodType periodType = PeriodType.getPeriodTypeByName( params.getPeriodType() );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java 2013-01-22 07:59:25 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java 2013-01-27 21:03:02 +0000
@@ -130,7 +130,7 @@
Set<String> filterParams = new HashSet<String>();
filterParams.add( "ou:" + BASE_UID + "A," + BASE_UID + "B," + BASE_UID + "C," + BASE_UID + "D," + BASE_UID + "E" );
- DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, false, null );
+ DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, false, null, null );
assertEquals( 4, params.getDataElements().size() );
assertEquals( 3, params.getPeriods().size() );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.java 2013-01-26 08:20:27 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.java 2013-01-27 21:03:02 +0000
@@ -31,6 +31,7 @@
import javax.servlet.http.HttpServletResponse;
+import org.hisp.dhis.analytics.AggregationType;
import org.hisp.dhis.analytics.AnalyticsService;
import org.hisp.dhis.analytics.DataQueryParams;
import org.hisp.dhis.analytics.Dimension;
@@ -71,10 +72,11 @@
@RequestParam Set<String> dimension,
@RequestParam(required = false) Set<String> filter,
@RequestParam(required = false) boolean categories,
+ @RequestParam(required = false) AggregationType aggregationType,
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, categories, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, categories, aggregationType, i18nManager.getI18nFormat() );
if ( !valid( params, response ) )
{
@@ -93,10 +95,11 @@
@RequestParam Set<String> dimension,
@RequestParam(required = false) Set<String> filter,
@RequestParam(required = false) boolean categories,
+ @RequestParam(required = false) AggregationType aggregationType,
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, categories, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, categories, aggregationType, i18nManager.getI18nFormat() );
if ( !valid( params, response ) )
{
@@ -113,10 +116,11 @@
@RequestParam Set<String> dimension,
@RequestParam(required = false) Set<String> filter,
@RequestParam(required = false) boolean categories,
+ @RequestParam(required = false) AggregationType aggregationType,
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, categories, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, categories, aggregationType, i18nManager.getI18nFormat() );
if ( !valid( params, response ) )
{
@@ -133,10 +137,11 @@
@RequestParam Set<String> dimension,
@RequestParam(required = false) Set<String> filter,
@RequestParam(required = false) boolean categories,
+ @RequestParam(required = false) AggregationType aggregationType,
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, categories, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, categories, aggregationType, i18nManager.getI18nFormat() );
if ( !valid( params, response ) )
{