← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11090: Analytics, impl option for skipping meta data part of response

 

------------------------------------------------------------
revno: 11090
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-05-29 20:35:32 +0200
message:
  Analytics, impl option for skipping meta data part of response
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-05-23 16:57:03 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java	2013-05-29 18:35:32 +0000
@@ -92,11 +92,12 @@
      * @param filterParams the filter URL parameters.
      * @param aggregationType the aggregation type.
      * @param measureCriteria the measure criteria.
+     * @param skipMeta whether to skip the meta data part of the response.
      * @param format the i18n format.
      * @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, I18nFormat format );
+        AggregationType aggregationType, String measureCriteria, boolean skipMeta, 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-05-29 16:06:43 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2013-05-29 18:35:32 +0000
@@ -110,6 +110,8 @@
     
     private Map<MeasureFilter, Double> measureCriteria = new HashMap<MeasureFilter, Double>();
     
+    private boolean skipMeta;
+    
     // -------------------------------------------------------------------------
     // Transient properties
     // -------------------------------------------------------------------------
@@ -1028,6 +1030,16 @@
         this.measureCriteria = measureCriteria;
     }
 
+    public boolean isSkipMeta()
+    {
+        return skipMeta;
+    }
+
+    public void setSkipMeta( boolean skipMeta )
+    {
+        this.skipMeta = skipMeta;
+    }
+
     // -------------------------------------------------------------------------
     // Get and set methods for transient properties
     // -------------------------------------------------------------------------

=== 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-05-29 16:06:43 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-05-29 18:35:32 +0000
@@ -359,26 +359,29 @@
         // Meta-data
         // ---------------------------------------------------------------------
 
-        Integer cocIndex = params.getCocIndex();
-        
-        Map<Object, Object> metaData = new HashMap<Object, Object>();
-        
-        Map<String, String> uidNameMap = getUidNameMap( params );
-        Map<String, String> cocNameMap = getCocNameMap( grid, cocIndex );
-        
-        uidNameMap.putAll( cocNameMap );
-        
-        metaData.put( NAMES_META_KEY, uidNameMap );
-        metaData.put( PERIOD_DIM_ID, getUids( params.getDimensionOrFilter( PERIOD_DIM_ID ) ) );
-        metaData.put( ORGUNIT_DIM_ID, getUids( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ) );
-        
-        if ( cocIndex != null )
+        if ( !params.isSkipMeta() )
         {
-            metaData.put( CATEGORYOPTIONCOMBO_DIM_ID, cocNameMap.keySet() );
+            Integer cocIndex = params.getCocIndex();
+            
+            Map<Object, Object> metaData = new HashMap<Object, Object>();
+            
+            Map<String, String> uidNameMap = getUidNameMap( params );
+            Map<String, String> cocNameMap = getCocNameMap( grid, cocIndex );
+            
+            uidNameMap.putAll( cocNameMap );
+            
+            metaData.put( NAMES_META_KEY, uidNameMap );
+            metaData.put( PERIOD_DIM_ID, getUids( params.getDimensionOrFilter( PERIOD_DIM_ID ) ) );
+            metaData.put( ORGUNIT_DIM_ID, getUids( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ) );
+            
+            if ( cocIndex != null )
+            {
+                metaData.put( CATEGORYOPTIONCOMBO_DIM_ID, cocNameMap.keySet() );
+            }
+            
+            grid.setMetaData( metaData );
         }
         
-        grid.setMetaData( metaData );
-        
         return grid;
     }
 
@@ -562,7 +565,7 @@
     
     @Override
     public DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams, 
-        AggregationType aggregationType, String measureCriteria, I18nFormat format )
+        AggregationType aggregationType, String measureCriteria, boolean skipMeta, I18nFormat format )
     {
         DataQueryParams params = new DataQueryParams();
 
@@ -600,6 +603,8 @@
         {
             params.setMeasureCriteria( DataQueryParams.getMeasureCriteriaFromParam( measureCriteria ) );
         }
+        
+        params.setSkipMeta( skipMeta );
 
         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-05-23 16:57:03 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/MockAnalyticsService.java	2013-05-29 18:35:32 +0000
@@ -78,7 +78,7 @@
 
     @Override
     public DataQueryParams getFromUrl( Set<String> dimensionParams, Set<String> filterParams,
-        AggregationType aggregationType, String measureCriteria, I18nFormat format )
+        AggregationType aggregationType, String measureCriteria, boolean skipMeta, 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-05-19 18:49:47 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java	2013-05-29 18:35:32 +0000
@@ -144,7 +144,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, null );
+        DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, false, null );
         
         assertEquals( 4, params.getDataElements().size() );
         assertEquals( 3, params.getPeriods().size() );
@@ -161,7 +161,7 @@
         Set<String> filterParams = new HashSet<String>();
         filterParams.add( "ou:" + ouA.getUid() );
         
-        DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, null );
+        DataQueryParams params = analyticsService.getFromUrl( dimensionParams, filterParams, null, null, false, null );
         
         assertEquals( 4, params.getDataElements().size() );
         assertEquals( 1, params.getFilterOrganisationUnits().size() );
@@ -174,7 +174,7 @@
         dimensionParams.add( "dx" );
         dimensionParams.add( "pe:2012,2012S1,2012S2" );
         
-        analyticsService.getFromUrl( dimensionParams, null, null, null, null );        
+        analyticsService.getFromUrl( dimensionParams, null, null, null, false, null );        
     }
     
     @Test( expected = IllegalQueryException.class )
@@ -184,7 +184,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, null );        
+        analyticsService.getFromUrl( dimensionParams, null, null, null, false, null );        
     }
 
     @Test( expected = IllegalQueryException.class )
@@ -194,7 +194,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, null );        
+        analyticsService.getFromUrl( dimensionParams, null, null, null, false, null );        
     }
 
     @Test( expected = IllegalQueryException.class )
@@ -204,7 +204,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, null );        
+        analyticsService.getFromUrl( dimensionParams, null, null, null, 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-05-28 17:29:42 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.java	2013-05-29 18:35:32 +0000
@@ -76,13 +76,14 @@
         @RequestParam(required = false) Set<String> filter,
         @RequestParam(required = false) AggregationType aggregationType,
         @RequestParam(required = false) String measureCriteria,
+        @RequestParam(required = false) boolean skipMeta,
         @RequestParam(required = false) boolean tableLayout,
         @RequestParam(required = false) String columns,
         @RequestParam(required = false) String rows,
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, i18nManager.getI18nFormat() );
+        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, i18nManager.getI18nFormat() );
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING );
         Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) );
@@ -97,13 +98,14 @@
         @RequestParam(required = false) Set<String> filter,
         @RequestParam(required = false) AggregationType aggregationType,
         @RequestParam(required = false) String measureCriteria,
+        @RequestParam(required = false) boolean skipMeta,
         @RequestParam(required = false) boolean tableLayout,
         @RequestParam(required = false) String columns,
         @RequestParam(required = false) String rows,
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, i18nManager.getI18nFormat() );
+        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, i18nManager.getI18nFormat() );
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.RESPECT_SYSTEM_SETTING );
         Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) );
@@ -116,13 +118,14 @@
         @RequestParam(required = false) Set<String> filter,
         @RequestParam(required = false) AggregationType aggregationType,
         @RequestParam(required = false) String measureCriteria,
+        @RequestParam(required = false) boolean skipMeta,
         @RequestParam(required = false) boolean tableLayout,
         @RequestParam(required = false) String columns,
         @RequestParam(required = false) String rows,
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, i18nManager.getI18nFormat() );
+        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, i18nManager.getI18nFormat() );
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING );
         Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) );
@@ -135,13 +138,14 @@
         @RequestParam(required = false) Set<String> filter,
         @RequestParam(required = false) AggregationType aggregationType,
         @RequestParam(required = false) String measureCriteria,
+        @RequestParam(required = false) boolean skipMeta,
         @RequestParam(required = false) boolean tableLayout,
         @RequestParam(required = false) String columns,
         @RequestParam(required = false) String rows,
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, i18nManager.getI18nFormat() );
+        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, 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 ) );
@@ -154,13 +158,14 @@
         @RequestParam(required = false) Set<String> filter,
         @RequestParam(required = false) AggregationType aggregationType,
         @RequestParam(required = false) String measureCriteria,
+        @RequestParam(required = false) boolean skipMeta,
         @RequestParam(required = false) boolean tableLayout,
         @RequestParam(required = false) String columns,
         @RequestParam(required = false) String rows,
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, i18nManager.getI18nFormat() );
+        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, skipMeta, 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 ) );
@@ -173,13 +178,14 @@
         @RequestParam(required = false) Set<String> filter,
         @RequestParam(required = false) AggregationType aggregationType,
         @RequestParam(required = false) String measureCriteria,
+        @RequestParam(required = false) boolean skipMeta,
         @RequestParam(required = false) boolean tableLayout,
         @RequestParam(required = false) String columns,
         @RequestParam(required = false) String rows,
         Model model,
         HttpServletResponse response ) throws Exception
     {
-        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, null, null, i18nManager.getI18nFormat() );
+        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, null, null, true, i18nManager.getI18nFormat() );
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.RESPECT_SYSTEM_SETTING, "data.jrxml", false );
         Grid grid = analyticsService.getAggregatedDataValues( params );