------------------------------------------------------------ revno: 16502 committer: Lars Helge Overland <larshe...@gmail.com> branch nick: dhis2 timestamp: Mon 2014-08-25 14:20:56 +0200 message: Event analytics, max records fix modified: dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryPlanner.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/DefaultEventQueryPlanner.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/event/EventQueryPlanner.java' --- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryPlanner.java 2014-07-10 10:27:53 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryPlanner.java 2014-08-25 12:20:56 +0000 @@ -54,4 +54,9 @@ * @param params the query params. */ EventQueryParams planEventQuery( EventQueryParams params ); + + /** + * Returns the max number of records to return. + */ + int getMaxLimit(); } === 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-25 10:18:10 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2014-08-25 12:20:56 +0000 @@ -149,7 +149,7 @@ Grid grid = new ListGrid(); - int maxLimit = getMaxLimit(); + int maxLimit = queryPlanner.getMaxLimit(); // --------------------------------------------------------------------- // Headers @@ -281,7 +281,7 @@ count += analyticsManager.getEventCount( params ); } - analyticsManager.getEvents( params, grid, getMaxLimit() ); + analyticsManager.getEvents( params, grid, queryPlanner.getMaxLimit() ); t.getTime( "Queried events, got: " + grid.getHeight() ); } @@ -622,12 +622,4 @@ 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/DefaultEventQueryPlanner.java' --- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java 2014-08-15 07:40:20 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java 2014-08-25 12:20:56 +0000 @@ -28,6 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.analytics.AnalyticsTableManager.EVENT_ANALYTICS_TABLE_NAME; + import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -37,7 +39,6 @@ import org.hisp.dhis.analytics.DataQueryParams; import org.hisp.dhis.analytics.QueryPlanner; 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.analytics.event.EventQueryPlanner; import org.hisp.dhis.analytics.partition.PartitionManager; @@ -49,10 +50,9 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; +import org.hisp.dhis.setting.SystemSettingManager; import org.springframework.beans.factory.annotation.Autowired; -import static org.hisp.dhis.analytics.AnalyticsTableManager.EVENT_ANALYTICS_TABLE_NAME; - /** * @author Lars Helge Overland */ @@ -71,6 +71,9 @@ private OrganisationUnitService organisationUnitService; @Autowired + private SystemSettingManager systemSettingManager; + + @Autowired private PartitionManager partitionManager; // ------------------------------------------------------------------------- @@ -125,9 +128,9 @@ violation = "Page size must be zero or positive: " + params.getPageSize(); } - if ( params.hasLimit() && params.getLimit() > EventAnalyticsService.MAX_ROWS_LIMIT ) + if ( params.hasLimit() && params.getLimit() > getMaxLimit() ) { - violation = "Limit of: " + params.getLimit() + " is larger than max limit: " + EventAnalyticsService.MAX_ROWS_LIMIT; + violation = "Limit of: " + params.getLimit() + " is larger than max limit: " + getMaxLimit(); } if ( violation != null ) @@ -195,6 +198,11 @@ queryPlanner.validateMaintenanceMode(); } + public int getMaxLimit() + { + return (Integer) systemSettingManager.getSystemSetting( SystemSettingManager.KEY_ANALYTICS_MAX_LIMIT, SystemSettingManager.DEFAULT_ANALYTICS_MAX_LIMIT ); + } + // ------------------------------------------------------------------------- // Supportive methods // -------------------------------------------------------------------------
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp