dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35752
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18300: Event analytics, rounding of values, added support for skipRounding parameter
------------------------------------------------------------
revno: 18300
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-02-17 22:46:41 +0100
message:
Event analytics, rounding of values, added support for skipRounding parameter
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/event/EventAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java
tools/dhis-adhoc/src/main/java/org/hisp/dhis/adhoc/command/RandomEventPopulator.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-02-17 16:50:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2015-02-17 21:46:41 +0000
@@ -121,7 +121,7 @@
/**
* Indicates that full precision should be provided for values.
*/
- private boolean skipRounding;
+ protected boolean skipRounding;
/**
* Indicates i) if the names of all ancestors of the organisation units part
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java 2015-02-17 16:50:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java 2015-02-17 21:46:41 +0000
@@ -62,6 +62,7 @@
* @param value the value dimension identifier.
* @param aggregationType the aggregation type for the value dimension.
* @param skipMeta whether to skip meta-data in response.
+ * @param skipRounding whether to skip rounding of values in response.
* @param hierarchyMeta whether to include hierarchy meta-data in the response.
* @param sortOrder the sort order of the aggregate values.
* @param limit the max limit of records to return.
@@ -71,7 +72,7 @@
*/
EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
Set<String> dimension, Set<String> filter, String value, AggregationType aggregationType,
- boolean skipMeta, boolean hierarchyMeta, SortOrder sortOrder, Integer limit,
+ boolean skipMeta, boolean skipRounding, boolean hierarchyMeta, SortOrder sortOrder, Integer limit,
EventOutputType outputType, DisplayProperty displayProperty, I18nFormat format );
/**
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2015-02-17 16:50:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java 2015-02-17 21:46:41 +0000
@@ -112,6 +112,7 @@
params.filters = new ArrayList<>( this.filters );
params.displayProperty = this.displayProperty;
params.aggregationType = this.aggregationType;
+ params.skipRounding = this.skipRounding;
params.partitions = new Partitions( this.partitions );
params.periodType = this.periodType;
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2015-02-17 17:51:08 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2015-02-17 21:46:41 +0000
@@ -344,14 +344,15 @@
@Override
public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
- Set<String> dimension, Set<String> filter, String value, AggregationType aggregationType, boolean skipMeta, boolean hierarchyMeta, SortOrder sortOrder,
- Integer limit, EventOutputType outputType, DisplayProperty displayProperty, I18nFormat format )
+ Set<String> dimension, Set<String> filter, String value, AggregationType aggregationType, boolean skipMeta, boolean skipRounding, boolean hierarchyMeta,
+ SortOrder sortOrder, Integer limit, EventOutputType outputType, DisplayProperty displayProperty, I18nFormat format )
{
EventQueryParams params = getFromUrl( program, stage, startDate, endDate, dimension, filter, null, null, null,
skipMeta, hierarchyMeta, false, displayProperty, null, null, format );
params.setValue( getValueDimension( value ) );
params.setAggregationType( aggregationType );
+ params.setSkipRounding( skipRounding );
params.setSortOrder( sortOrder );
params.setLimit( limit );
params.setOutputType( MoreObjects.firstNonNull( outputType, EventOutputType.EVENT ) );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2015-02-17 16:50:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2015-02-17 21:46:41 +0000
@@ -61,6 +61,7 @@
import org.hisp.dhis.common.QueryItem;
import org.hisp.dhis.jdbc.StatementBuilder;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.system.util.MathUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -177,7 +178,7 @@
if ( params.hasValueDimension() )
{
double value = rowSet.getDouble( "value" );
- grid.addValue( value );
+ grid.addValue( params.isSkipRounding() ? value : MathUtils.getRounded( value ) );
}
else
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java 2015-02-17 16:50:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java 2015-02-17 21:46:41 +0000
@@ -158,7 +158,7 @@
filterParams.add( "pe:201401;201402" );
EventQueryParams params = analyticsService.getFromUrl( prA.getUid(), null,
- null, null, dimensionParams, filterParams, null, null, false, false, null, null, null, null, null );
+ null, null, dimensionParams, filterParams, null, null, false, false, false, null, null, null, null, null );
assertEquals( prA, params.getProgram() );
assertEquals( 1, params.getOrganisationUnits().size() );
@@ -177,7 +177,7 @@
filterParams.add( "pe:201401" );
EventQueryParams params = analyticsService.getFromUrl( prA.getUid(), null,
- null, null, dimensionParams, filterParams, deA.getUid(), AggregationType.AVERAGE, false, false, null, null, null, null, null );
+ null, null, dimensionParams, filterParams, deA.getUid(), AggregationType.AVERAGE, false, false, false, null, null, null, null, null );
assertEquals( prA, params.getProgram() );
assertEquals( 1, params.getOrganisationUnits().size() );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml 2013-03-01 08:36:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/mapping/hibernate/MapLegend.hbm.xml 2015-02-17 21:46:41 +0000
@@ -22,9 +22,9 @@
<property name="lastUpdated" type="timestamp" />
- <property name="startValue" column="startvalue" />
+ <property name="startValue" column="startvalue" index="maplegend_startvalue" />
- <property name="endValue" column="endvalue" />
+ <property name="endValue" column="endvalue" index="maplegend_endvalue" />
<property name="color" column="color" />
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java 2015-02-17 16:50:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java 2015-02-17 21:46:41 +0000
@@ -88,6 +88,7 @@
@RequestParam( required = false ) String value,
@RequestParam( required = false ) AggregationType aggregationType,
@RequestParam( required = false ) boolean skipMeta,
+ @RequestParam( required = false ) boolean skipRounding,
@RequestParam( required = false ) boolean hierarchyMeta,
@RequestParam( required = false ) Integer limit,
@RequestParam( required = false ) EventOutputType outputType,
@@ -97,7 +98,7 @@
HttpServletResponse response ) throws Exception
{
EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter,
- value, aggregationType, skipMeta, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
+ value, aggregationType, skipMeta, skipRounding, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING );
Grid grid = analyticsService.getAggregatedEventData( params );
@@ -117,6 +118,7 @@
@RequestParam( required = false ) String value,
@RequestParam( required = false ) AggregationType aggregationType,
@RequestParam( required = false ) boolean skipMeta,
+ @RequestParam( required = false ) boolean skipRounding,
@RequestParam( required = false ) boolean hierarchyMeta,
@RequestParam( required = false ) Integer limit,
@RequestParam( required = false ) EventOutputType outputType,
@@ -126,7 +128,7 @@
HttpServletResponse response ) throws Exception
{
EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter,
- value, aggregationType, skipMeta, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
+ value, aggregationType, skipMeta, skipRounding, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xml", false );
Grid grid = analyticsService.getAggregatedEventData( params );
@@ -144,6 +146,7 @@
@RequestParam( required = false ) String value,
@RequestParam( required = false ) AggregationType aggregationType,
@RequestParam( required = false ) boolean skipMeta,
+ @RequestParam( required = false ) boolean skipRounding,
@RequestParam( required = false ) boolean hierarchyMeta,
@RequestParam( required = false ) Integer limit,
@RequestParam( required = false ) EventOutputType outputType,
@@ -153,7 +156,7 @@
HttpServletResponse response ) throws Exception
{
EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter,
- value, aggregationType, skipMeta, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
+ value, aggregationType, skipMeta, skipRounding, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xls", true );
Grid grid = analyticsService.getAggregatedEventData( params );
@@ -171,6 +174,7 @@
@RequestParam( required = false ) String value,
@RequestParam( required = false ) AggregationType aggregationType,
@RequestParam( required = false ) boolean skipMeta,
+ @RequestParam( required = false ) boolean skipRounding,
@RequestParam( required = false ) boolean hierarchyMeta,
@RequestParam( required = false ) Integer limit,
@RequestParam( required = false ) EventOutputType outputType,
@@ -180,7 +184,7 @@
HttpServletResponse response ) throws Exception
{
EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter,
- value, aggregationType, skipMeta, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
+ value, aggregationType, skipMeta, skipRounding, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.csv", true );
Grid grid = analyticsService.getAggregatedEventData( params );
@@ -198,6 +202,7 @@
@RequestParam( required = false ) String value,
@RequestParam( required = false ) AggregationType aggregationType,
@RequestParam( required = false ) boolean skipMeta,
+ @RequestParam( required = false ) boolean skipRounding,
@RequestParam( required = false ) boolean hierarchyMeta,
@RequestParam( required = false ) Integer limit,
@RequestParam( required = false ) EventOutputType outputType,
@@ -207,7 +212,7 @@
HttpServletResponse response ) throws Exception
{
EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter,
- value, aggregationType, skipMeta, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
+ value, aggregationType, skipMeta, skipRounding, hierarchyMeta, sortOrder, limit, outputType, displayProperty, i18nManager.getI18nFormat() );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.html", false );
Grid grid = analyticsService.getAggregatedEventData( params );
=== modified file 'tools/dhis-adhoc/src/main/java/org/hisp/dhis/adhoc/command/RandomEventPopulator.java'
--- tools/dhis-adhoc/src/main/java/org/hisp/dhis/adhoc/command/RandomEventPopulator.java 2015-02-17 21:39:32 +0000
+++ tools/dhis-adhoc/src/main/java/org/hisp/dhis/adhoc/command/RandomEventPopulator.java 2015-02-17 21:46:41 +0000
@@ -24,7 +24,7 @@
public class RandomEventPopulator
implements Command
{
- private static final int EVENT_NO = 1000;
+ private static final int EVENT_NO = 10000;
private static final List<String> OPT_GENDER = Arrays.asList( "male", "female" );
@Autowired