dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26653
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13181: Analytics, implemented option for skipping rounding of values
------------------------------------------------------------
revno: 13181
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-12-09 18:14:49 +0100
message:
Analytics, implemented option for skipping rounding of values
modified:
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/MockAnalyticsService.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-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-10-08 17:16:47 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java 2013-12-09 17:14:49 +0000
@@ -148,6 +148,7 @@
* @param aggregationType the aggregation type.
* @param measureCriteria the measure criteria.
* @param skipMeta whether to skip the meta data part of the response.
+ * @param skipRounding whether to skip rounding and provide full precision for values.
* @param hierarchyMeta whether to include meta data about the org units
* in the hierarchy.
* @param ignoreLimit whether to ignore the max number of cells limit.
@@ -155,7 +156,7 @@
* @return a data query parameter object created based on the given URL info.
*/
DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams,
- AggregationType aggregationType, String measureCriteria, boolean skipMeta, boolean hierarchyMeta, boolean ignoreLimit, I18nFormat format );
+ AggregationType aggregationType, String measureCriteria, boolean skipMeta, boolean skipRounding, boolean hierarchyMeta, boolean ignoreLimit, I18nFormat format );
/**
* Creates a data query parameter object from the given BaseAnalyticalObject.
=== 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-11-27 19:02:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-12-09 17:14:49 +0000
@@ -118,6 +118,11 @@
private boolean skipMeta;
/**
+ * Indicates that full precision should be provided for values.
+ */
+ private boolean skipRounding;
+
+ /**
* Indicates i) if the names of all ancestors of the organisation units part
* of the query should be included in the "names" key and ii) if the hierarchy
* path of all organisation units part of the query should be included as a
@@ -1065,6 +1070,16 @@
this.skipMeta = skipMeta;
}
+ public boolean isSkipRounding()
+ {
+ return skipRounding;
+ }
+
+ public void setSkipRounding( boolean skipRounding )
+ {
+ this.skipRounding = skipRounding;
+ }
+
public boolean isHierarchyMeta()
{
return hierarchyMeta;
=== 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-10-04 12:27:33 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-12-09 17:14:49 +0000
@@ -268,7 +268,7 @@
grid.addRow();
grid.addValues( DimensionItem.getItemIdentifiers( row ) );
- grid.addValue( MathUtils.getRounded( value ) );
+ grid.addValue( params.isSkipRounding() ? value : MathUtils.getRounded( value ) );
}
}
}
@@ -290,7 +290,7 @@
{
grid.addRow();
grid.addValues( entry.getKey().split( DIMENSION_SEP ) );
- grid.addValue( MathUtils.getRounded( entry.getValue() ) );
+ grid.addValue( params.isSkipRounding() ? entry.getValue() : MathUtils.getRounded( entry.getValue() ) );
}
}
@@ -356,7 +356,7 @@
grid.addRow();
grid.addValues( dataRow.toArray() );
- grid.addValue( MathUtils.getRounded( value ) );
+ grid.addValue( params.isSkipRounding() ? value : MathUtils.getRounded( value ) );
}
}
}
@@ -373,7 +373,7 @@
{
grid.addRow();
grid.addValues( entry.getKey().split( DIMENSION_SEP ) );
- grid.addValue( MathUtils.getRounded( entry.getValue() ) );
+ grid.addValue( params.isSkipRounding() ? entry.getValue() : MathUtils.getRounded( entry.getValue() ) );
}
}
@@ -587,7 +587,7 @@
@Override
public DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams,
- AggregationType aggregationType, String measureCriteria, boolean skipMeta, boolean hierarchyMeta, boolean ignoreLimit, I18nFormat format )
+ AggregationType aggregationType, String measureCriteria, boolean skipMeta, boolean skipRounding, boolean hierarchyMeta, boolean ignoreLimit, I18nFormat format )
{
DataQueryParams params = new DataQueryParams();
@@ -628,6 +628,7 @@
}
params.setSkipMeta( skipMeta );
+ params.setSkipRounding( skipRounding );
params.setHierarchyMeta( hierarchyMeta );
return params;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java 2013-11-29 16:29:48 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java 2013-12-09 17:14:49 +0000
@@ -81,7 +81,7 @@
@Override
public DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams,
- AggregationType aggregationType, String measureCriteria, boolean skipMeta, boolean hierarchyMeta, boolean ignoreLimit, I18nFormat format )
+ AggregationType aggregationType, String measureCriteria, boolean skipMeta, boolean skipRounding, boolean hierarchyMeta, boolean ignoreLimit, I18nFormat format )
{
throw new NotImplementedException();
}
=== 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-10-03 08:22:21 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java 2013-12-09 17:14:49 +0000
@@ -164,7 +164,7 @@
Set<String> filterParams = new HashSet<String>();
filterParams.add( "ou:" + ouA.getUid() + ";" + ouB.getUid() + ";" + ouC.getUid() + ";" + ouD.getUid() + ";" + ouE.getUid() );
- DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, false, false, false, null );
+ DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, false, false, false, false, null );
assertEquals( 4, params.getDataElements().size() );
assertEquals( 3, params.getPeriods().size() );
@@ -181,7 +181,7 @@
Set<String> filterParams = new HashSet<String>();
filterParams.add( "ou:" + ouA.getUid() );
- DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, false, false, false, null );
+ DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, false, false, false, false, null );
assertEquals( 4, params.getDataElements().size() );
assertEquals( 1, params.getFilterOrganisationUnits().size() );
@@ -197,7 +197,7 @@
Set<String> filterParams = new HashSet<String>();
filterParams.add( "ou:" + ouA.getUid() + ";" + ouB.getUid() );
- DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, false, false, false, null );
+ DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, false, false, false, false, null );
assertEquals( 4, params.getDataElements().size() );
assertEquals( 12, params.getPeriods().size() );
@@ -212,7 +212,7 @@
dimensionParams.add( "dx:" + deA.getUid() + ";" + deB.getUid() );
dimensionParams.add( "pe:2011;2012" );
- DataQueryParams params = analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, null );
+ DataQueryParams params = analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, false, null );
assertEquals( 1, params.getOrganisationUnits().size() );
assertEquals( 2, params.getDataElements().size() );
@@ -227,7 +227,7 @@
dimensionParams.add( "dx:" + deA.getUid() + ";" + deB.getUid() );
dimensionParams.add( "pe:2011;2012" );
- DataQueryParams params = analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, null );
+ DataQueryParams params = analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, false, null );
assertEquals( 2, params.getOrganisationUnits().size() );
assertEquals( 2, params.getDataElements().size() );
@@ -241,7 +241,7 @@
dimensionParams.add( "dx" );
dimensionParams.add( "pe:2012,2012S1,2012S2" );
- analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, null );
+ analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, false, null );
}
@Test( expected = IllegalQueryException.class )
@@ -251,7 +251,7 @@
dimensionParams.add( "dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D" );
dimensionParams.add( "pe" );
- analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, null );
+ analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, false, null );
}
@Test( expected = IllegalQueryException.class )
@@ -261,7 +261,7 @@
dimensionParams.add( "dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D" );
dimensionParams.add( "ou" );
- analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, null );
+ analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, false, null );
}
@Test( expected = IllegalQueryException.class )
@@ -271,7 +271,7 @@
dimensionParams.add( "dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D" );
dimensionParams.add( "yebo:2012,2012S1,2012S2" );
- analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, null );
+ analyticsService.getFromUrl( dimensionParams, null, null, null, false, false, false, false, null );
}
@Test
=== 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-11-07 11:52:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.java 2013-12-09 17:14:49 +0000
@@ -81,6 +81,7 @@
@RequestParam(required = false) AggregationType aggregationType,
@RequestParam(required = false) String measureCriteria,
@RequestParam(required = false) boolean skipMeta,
+ @RequestParam(required = false) boolean skipRounding,
@RequestParam(required = false) boolean hierarchyMeta,
@RequestParam(required = false) boolean ignoreLimit,
@RequestParam(required = false) boolean tableLayout,
@@ -89,7 +90,7 @@
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, skipRounding, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING );
Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) );
@@ -105,6 +106,7 @@
@RequestParam(required = false) AggregationType aggregationType,
@RequestParam(required = false) String measureCriteria,
@RequestParam(required = false) boolean skipMeta,
+ @RequestParam(required = false) boolean skipRounding,
@RequestParam(required = false) boolean hierarchyMeta,
@RequestParam(required = false) boolean ignoreLimit,
@RequestParam(required = false) boolean tableLayout,
@@ -113,7 +115,7 @@
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, skipRounding, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.RESPECT_SYSTEM_SETTING );
Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) );
@@ -127,6 +129,7 @@
@RequestParam(required = false) AggregationType aggregationType,
@RequestParam(required = false) String measureCriteria,
@RequestParam(required = false) boolean skipMeta,
+ @RequestParam(required = false) boolean skipRounding,
@RequestParam(required = false) boolean hierarchyMeta,
@RequestParam(required = false) boolean ignoreLimit,
@RequestParam(required = false) boolean tableLayout,
@@ -135,7 +138,7 @@
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, skipRounding, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING );
Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) );
@@ -149,6 +152,7 @@
@RequestParam(required = false) AggregationType aggregationType,
@RequestParam(required = false) String measureCriteria,
@RequestParam(required = false) boolean skipMeta,
+ @RequestParam(required = false) boolean skipRounding,
@RequestParam(required = false) boolean hierarchyMeta,
@RequestParam(required = false) boolean ignoreLimit,
@RequestParam(required = false) boolean tableLayout,
@@ -157,7 +161,7 @@
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, skipRounding, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "data.csv", true );
Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) );
@@ -171,6 +175,7 @@
@RequestParam(required = false) AggregationType aggregationType,
@RequestParam(required = false) String measureCriteria,
@RequestParam(required = false) boolean skipMeta,
+ @RequestParam(required = false) boolean skipRounding,
@RequestParam(required = false) boolean hierarchyMeta,
@RequestParam(required = false) boolean ignoreLimit,
@RequestParam(required = false) boolean tableLayout,
@@ -179,7 +184,7 @@
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, skipRounding, hierarchyMeta, ignoreLimit, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "data.xls", true );
Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) );
@@ -193,6 +198,7 @@
@RequestParam(required = false) AggregationType aggregationType,
@RequestParam(required = false) String measureCriteria,
@RequestParam(required = false) boolean skipMeta,
+ @RequestParam(required = false) boolean skipRounding,
@RequestParam(required = false) boolean hierarchyMeta,
@RequestParam(required = false) boolean ignoreLimit,
@RequestParam(required = false) boolean tableLayout,
@@ -201,7 +207,7 @@
Model model,
HttpServletResponse response ) throws Exception
{
- DataQueryParams params = analyticsService.getFromUrl( dimension, filter, null, null, true, false, ignoreLimit, i18nManager.getI18nFormat() );
+ DataQueryParams params = analyticsService.getFromUrl( dimension, filter, null, null, true, false, false, ignoreLimit, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.RESPECT_SYSTEM_SETTING, "data.jrxml", false );
Grid grid = analyticsService.getAggregatedDataValues( params );