← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14027: Event analytics, skipMeta option

 

------------------------------------------------------------
revno: 14027
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-02-14 14:48:40 +0100
message:
  Event analytics, skipMeta option
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/data/DefaultEventAnalyticsService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.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-02-04 21:38:37 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2014-02-14 13:48:40 +0000
@@ -115,7 +115,7 @@
     /**
      * Indicates if the meta data part of the query response should be omitted.
      */
-    private boolean skipMeta;
+    protected boolean skipMeta;
 
     /**
      * Indicates that full precision should be provided for values.

=== 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	2013-12-31 09:28:55 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventAnalyticsService.java	2014-02-14 13:48:40 +0000
@@ -47,11 +47,11 @@
      * Used for aggregate query.
      */
     EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate, 
-        Set<String> dimension, Set<String> filter, boolean hierarchyMeta, SortOrder sortOrder, Integer limit, I18nFormat format );
+        Set<String> dimension, Set<String> filter, boolean skipMeta, boolean hierarchyMeta, SortOrder sortOrder, Integer limit, I18nFormat format );
 
     /**
      * Used for event query.
      */
     EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate, Set<String> dimension, Set<String> filter, 
-        String ouMode, Set<String> asc, Set<String> desc, boolean hierarchyMeta, boolean coordinatesOnly, Integer page, Integer pageSize, I18nFormat format );
+        String ouMode, Set<String> asc, Set<String> desc, boolean skipMeta, boolean hierarchyMeta, boolean coordinatesOnly, Integer page, Integer pageSize, 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-02-13 14:40:12 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2014-02-14 13:48:40 +0000
@@ -133,7 +133,7 @@
     // -------------------------------------------------------------------------
 
     // TODO order event analytics tables on execution date to avoid default
-    // sorting in queries
+    // TODO sorting in queries
     // TODO parallel processing of queries
 
     public Grid getAggregatedEventData( EventQueryParams params )
@@ -174,21 +174,24 @@
         // ---------------------------------------------------------------------
         // Meta-data
         // ---------------------------------------------------------------------
-
-        Map<Object, Object> metaData = new HashMap<Object, Object>();
-
-        Map<String, String> uidNameMap = getUidNameMap( params );
-
-        metaData.put( NAMES_META_KEY, uidNameMap );
-
-        if ( params.isHierarchyMeta() )
+        
+        if ( !params.isSkipMeta() )
         {
-            metaData.put( OU_HIERARCHY_KEY, getParentGraphMap( asTypedList( 
-                params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ) ) );
+            Map<Object, Object> metaData = new HashMap<Object, Object>();
+    
+            Map<String, String> uidNameMap = getUidNameMap( params );
+    
+            metaData.put( NAMES_META_KEY, uidNameMap );
+    
+            if ( params.isHierarchyMeta() )
+            {
+                metaData.put( OU_HIERARCHY_KEY, getParentGraphMap( asTypedList( 
+                    params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ) ) );
+            }
+
+            grid.setMetaData( metaData );
         }
 
-        grid.setMetaData( metaData );
-
         return grid;
     }
 
@@ -270,11 +273,12 @@
     }
 
     public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
-        Set<String> dimension, Set<String> filter, boolean hierarchyMeta, SortOrder sortOrder, Integer limit,
+        Set<String> dimension, Set<String> filter, boolean skipMeta, boolean hierarchyMeta, SortOrder sortOrder, Integer limit,
         I18nFormat format )
     {
         EventQueryParams params = getFromUrl( program, stage, startDate, endDate, dimension, filter, null, null, null,
-            hierarchyMeta, false, null, null, format );
+            skipMeta, hierarchyMeta, false, null, null, format );
+        
         params.setSortOrder( sortOrder );
         params.setLimit( limit );
         params.setAggregate( true );
@@ -284,7 +288,7 @@
 
     public EventQueryParams getFromUrl( String program, String stage, String startDate, String endDate,
         Set<String> dimension, Set<String> filter, String ouMode, Set<String> asc, Set<String> desc,
-        boolean hierarchyMeta, boolean coordinatesOnly, Integer page, Integer pageSize, I18nFormat format )
+        boolean skipMeta, boolean hierarchyMeta, boolean coordinatesOnly, Integer page, Integer pageSize, I18nFormat format )
     {
         EventQueryParams params = new EventQueryParams();
 
@@ -383,6 +387,7 @@
         params.setStartDate( start );
         params.setEndDate( end );
         params.setOrganisationUnitMode( ouMode );
+        params.setSkipMeta( skipMeta );
         params.setHierarchyMeta( hierarchyMeta );
         params.setCoordinatesOnly( coordinatesOnly );
         params.setPage( page );

=== 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-02-13 14:40:12 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2014-02-14 13:48:40 +0000
@@ -299,6 +299,8 @@
             "where table_name like '" + EventQueryPlanner.TABLE_PREFIX + "_%_" + program.getUid().toLowerCase() + "' " +
             "and table_type = 'BASE TABLE'";
         
+        log.info( "Information schema SQL: " + sql );
+        
         return jdbcTemplate.queryForList( sql, String.class );
     }
     

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java	2013-12-31 09:28:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java	2014-02-14 13:48:40 +0000
@@ -82,13 +82,14 @@
         @RequestParam(required=false) String endDate,
         @RequestParam Set<String> dimension,
         @RequestParam(required=false) Set<String> filter,
+        @RequestParam(required=false) boolean skipMeta,
         @RequestParam(required=false) boolean hierarchyMeta,
         @RequestParam(required=false) Integer limit,
         @RequestParam(required=false) SortOrder sortOrder,
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, hierarchyMeta, sortOrder, limit, i18nManager.getI18nFormat() );
+        EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, skipMeta, hierarchyMeta, sortOrder, limit, i18nManager.getI18nFormat() );
         
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING );
         Grid grid = analyticsService.getAggregatedEventData( params );
@@ -105,13 +106,14 @@
         @RequestParam(required=false) String endDate,
         @RequestParam Set<String> dimension,
         @RequestParam(required=false) Set<String> filter,
+        @RequestParam(required=false) boolean skipMeta,
         @RequestParam(required=false) boolean hierarchyMeta,
         @RequestParam(required=false) Integer limit,
         @RequestParam(required=false) SortOrder sortOrder,
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, hierarchyMeta, sortOrder, limit, i18nManager.getI18nFormat() );
+        EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, skipMeta, hierarchyMeta, sortOrder, limit, i18nManager.getI18nFormat() );
         
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xls", true );
         Grid grid = analyticsService.getAggregatedEventData( params );
@@ -126,13 +128,14 @@
         @RequestParam(required=false) String endDate,
         @RequestParam Set<String> dimension,
         @RequestParam(required=false) Set<String> filter,
+        @RequestParam(required=false) boolean skipMeta,
         @RequestParam(required=false) boolean hierarchyMeta,
         @RequestParam(required=false) Integer limit,
         @RequestParam(required=false) SortOrder sortOrder,
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, hierarchyMeta, sortOrder, limit, i18nManager.getI18nFormat() );
+        EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, skipMeta, hierarchyMeta, sortOrder, limit, i18nManager.getI18nFormat() );
         
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.csv", true );
         Grid grid = analyticsService.getAggregatedEventData( params );
@@ -154,6 +157,7 @@
         @RequestParam(required=false) String ouMode,
         @RequestParam(required=false) Set<String> asc,
         @RequestParam(required=false) Set<String> desc,
+        @RequestParam(required=false) boolean skipMeta,
         @RequestParam(required=false) boolean hierarchyMeta,
         @RequestParam(required=false) boolean coordinatesOnly,
         @RequestParam(required=false) Integer page,
@@ -162,7 +166,7 @@
         HttpServletResponse response ) throws Exception
     {
         EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, ouMode, 
-            asc, desc, hierarchyMeta, coordinatesOnly, page, pageSize, i18nManager.getI18nFormat() );
+            asc, desc, skipMeta, hierarchyMeta, coordinatesOnly, page, pageSize, i18nManager.getI18nFormat() );
         
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING );
         Grid grid = analyticsService.getEvents( params );
@@ -182,6 +186,7 @@
         @RequestParam(required=false) String ouMode,
         @RequestParam(required=false) Set<String> asc,
         @RequestParam(required=false) Set<String> desc,
+        @RequestParam(required=false) boolean skipMeta,
         @RequestParam(required=false) boolean hierarchyMeta,
         @RequestParam(required=false) boolean coordinatesOnly,
         @RequestParam(required=false) Integer page,
@@ -190,7 +195,7 @@
         HttpServletResponse response ) throws Exception
     {
         EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, 
-            ouMode, asc, desc, hierarchyMeta, coordinatesOnly, page, pageSize, i18nManager.getI18nFormat() );
+            ouMode, asc, desc, skipMeta, hierarchyMeta, coordinatesOnly, page, pageSize, i18nManager.getI18nFormat() );
         
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xls", true );
         Grid grid = analyticsService.getEvents( params );
@@ -208,6 +213,7 @@
         @RequestParam(required=false) String ouMode,
         @RequestParam(required=false) Set<String> asc,
         @RequestParam(required=false) Set<String> desc,
+        @RequestParam(required=false) boolean skipMeta,
         @RequestParam(required=false) boolean hierarchyMeta,
         @RequestParam(required=false) boolean coordinatesOnly,
         @RequestParam(required=false) Integer page,
@@ -216,7 +222,7 @@
         HttpServletResponse response ) throws Exception
     {
         EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, 
-            ouMode, asc, desc, hierarchyMeta, coordinatesOnly, page, pageSize, i18nManager.getI18nFormat() );
+            ouMode, asc, desc, skipMeta, hierarchyMeta, coordinatesOnly, page, pageSize, i18nManager.getI18nFormat() );
         
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.csv", true );
         Grid grid = analyticsService.getEvents( params );