dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32327
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16497: Event analytics, max limit of results according to system setting
------------------------------------------------------------
revno: 16497
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-08-25 12:18:10 +0200
message:
Event analytics, max limit of results according to system setting
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/DefaultQueryPlanner.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.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/data/DefaultEventAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.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 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2014-08-25 10:18:10 +0000
@@ -96,8 +96,6 @@
public static final List<String> DATA_DIMS = Arrays.asList( INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATAELEMENT_OPERAND_ID, DATASET_DIM_ID );
public static final List<String> FIXED_DIMS = Arrays.asList( DATA_X_DIM_ID, INDICATOR_DIM_ID, DATAELEMENT_DIM_ID, DATASET_DIM_ID, PERIOD_DIM_ID, ORGUNIT_DIM_ID );
- public static final int DEFAULT_MAX_DIM_OPT_PERM = 50000;
-
private static final List<DimensionType> COMPLETENESS_DIMENSION_TYPES = Arrays.asList( DATASET, ORGANISATIONUNIT, ORGANISATIONUNIT_GROUPSET );
private static final DimensionItem[] DIM_OPT_ARR = new DimensionItem[0];
=== 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 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2014-08-25 10:18:10 +0000
@@ -32,7 +32,6 @@
import static org.hisp.dhis.analytics.AggregationType.AVERAGE_INT;
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.DEFAULT_MAX_DIM_OPT_PERM;
import static org.hisp.dhis.analytics.DataQueryParams.LEVEL_PREFIX;
import static org.hisp.dhis.common.DimensionalObject.CATEGORYOPTIONCOMBO_DIM_ID;
import static org.hisp.dhis.common.DimensionalObject.DATAELEMENT_DIM_ID;
@@ -714,6 +713,6 @@
*/
private int getMaxLimit()
{
- return (Integer) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_ANALYTICS_MAX_LIMIT, DEFAULT_MAX_DIM_OPT_PERM );
+ return (Integer) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_ANALYTICS_MAX_LIMIT, SystemSettingManager.DEFAULT_ANALYTICS_MAX_LIMIT );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java 2014-04-19 10:55:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsManager.java 2014-08-25 10:18:10 +0000
@@ -35,9 +35,9 @@
*/
public interface EventAnalyticsManager
{
- Grid getAggregatedEventData( EventQueryParams params, Grid grid );
+ Grid getAggregatedEventData( EventQueryParams params, Grid grid, int maxLimit );
- Grid getEvents( EventQueryParams params, Grid grid );
+ Grid getEvents( EventQueryParams params, Grid grid, int maxLimit );
int getEventCount( EventQueryParams params );
}
=== 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 2014-07-15 14:43:47 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java 2014-08-25 10:18:10 +0000
@@ -40,9 +40,7 @@
* @author Lars Helge Overland
*/
public interface EventAnalyticsService
-{
- final int MAX_ROWS_LIMIT = 10000;
-
+{
Grid getAggregatedEventData( EventQueryParams params );
Grid getAggregatedEventData( AnalyticalObject object, I18nFormat format );
=== 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 2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2014-08-25 10:18:10 +0000
@@ -77,6 +77,7 @@
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.system.grid.ListGrid;
import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.system.util.ListUtils;
@@ -130,6 +131,9 @@
@Autowired
private AnalyticsService analyticsService;
+ @Autowired
+ private SystemSettingManager systemSettingManager;
+
// -------------------------------------------------------------------------
// EventAnalyticsService implementation
// -------------------------------------------------------------------------
@@ -145,6 +149,8 @@
Grid grid = new ListGrid();
+ int maxLimit = getMaxLimit();
+
// ---------------------------------------------------------------------
// Headers
// ---------------------------------------------------------------------
@@ -169,12 +175,12 @@
for ( EventQueryParams query : queries )
{
- analyticsManager.getAggregatedEventData( query, grid );
+ analyticsManager.getAggregatedEventData( query, grid, maxLimit );
}
-
- if ( grid.getHeight() > MAX_ROWS_LIMIT )
+
+ if ( grid.getHeight() > maxLimit )
{
- throw new IllegalQueryException( "Number of rows produced by query is larger than the max limit: " + MAX_ROWS_LIMIT );
+ throw new IllegalQueryException( "Number of rows produced by query is larger than the max limit: " + maxLimit );
}
// ---------------------------------------------------------------------
@@ -233,7 +239,7 @@
params.replacePeriodsWithStartEndDates();
Grid grid = new ListGrid();
-
+
// ---------------------------------------------------------------------
// Headers
// ---------------------------------------------------------------------
@@ -275,7 +281,7 @@
count += analyticsManager.getEventCount( params );
}
- analyticsManager.getEvents( params, grid );
+ analyticsManager.getEvents( params, grid, getMaxLimit() );
t.getTime( "Queried events, got: " + grid.getHeight() );
}
@@ -616,4 +622,12 @@
throw new IllegalQueryException( "Item identifier does not reference any item part of the program: " + item );
}
+
+ /**
+ * Returns the max records limit. 0 indicates no limit.
+ */
+ private int getMaxLimit()
+ {
+ return (Integer) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_ANALYTICS_MAX_LIMIT, SystemSettingManager.DEFAULT_ANALYTICS_MAX_LIMIT );
+ }
}
=== 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 2014-07-02 11:08:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2014-08-25 10:18:10 +0000
@@ -44,7 +44,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.analytics.event.EventAnalyticsManager;
-import org.hisp.dhis.analytics.event.EventAnalyticsService;
import org.hisp.dhis.analytics.event.EventQueryParams;
import org.hisp.dhis.common.DimensionType;
import org.hisp.dhis.common.DimensionalObject;
@@ -78,12 +77,12 @@
@Autowired
private StatementBuilder statementBuilder;
-
+
// -------------------------------------------------------------------------
// EventAnalyticsManager implementation
// -------------------------------------------------------------------------
- public Grid getAggregatedEventData( EventQueryParams params, Grid grid )
+ public Grid getAggregatedEventData( EventQueryParams params, Grid grid, int maxLimit )
{
String countClause = ( params.isProgramRegistration() && params.isUniqueInstances() ) ? "count(distinct tei)" : "count(psi)";
@@ -127,7 +126,7 @@
}
else
{
- sql += "limit " + ( EventAnalyticsService.MAX_ROWS_LIMIT + 1 );
+ sql += "limit " + ( maxLimit + 1 );
}
// ---------------------------------------------------------------------
@@ -176,7 +175,7 @@
}
}
- public Grid getEvents( EventQueryParams params, Grid grid )
+ public Grid getEvents( EventQueryParams params, Grid grid, int maxLimit )
{
List<String> fixedCols = Arrays.asList( "psi", "ps", "executiondate", "longitude", "latitude", "ouname", "oucode" );
@@ -226,7 +225,7 @@
}
else
{
- sql += "limit " + ( EventAnalyticsService.MAX_ROWS_LIMIT + 1 );
+ sql += "limit " + ( maxLimit + 1 );
}
// ---------------------------------------------------------------------