← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12897: Analytics web api resources, implemented support for date query parameter to change base for rela...

 

------------------------------------------------------------
revno: 12897
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-11-07 12:52:20 +0100
message:
  Analytics web api resources, implemented support for date query parameter to change base for relative periods consistently across all analysis-related resources.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/html-report.vm
  dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html
  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/ChartController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapViewController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.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-api/src/main/java/org/hisp/dhis/period/Period.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java	2013-10-01 08:54:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Period.java	2013-11-07 11:52:20 +0000
@@ -289,7 +289,7 @@
     @Override
     public String toString()
     {
-        return "[" + (periodType == null ? "" : periodType.getName() + ": ") + startDate + " - " + endDate + "] " + name;
+        return "[" + (periodType == null ? "" : periodType.getName() + ": ") + startDate + " - " + endDate + "]";
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java	2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java	2013-11-07 11:52:20 +0000
@@ -31,6 +31,7 @@
 import java.io.OutputStream;
 import java.io.Writer;
 import java.util.Collection;
+import java.util.Date;
 import java.util.List;
 
 import net.sf.jasperreports.engine.JasperPrint;
@@ -86,11 +87,11 @@
      * 
      * @param writer the Writer.
      * @param uid the report uid.
-     * @param pe the period iso identifier.
+     * @param date the date.
      * @param ou the organisation unit uid.
      * @param format the I18nFormat.
      */
-    void renderHtmlReport( Writer writer, String uid, String pe, String ou, I18nFormat format );
+    void renderHtmlReport( Writer writer, String uid, Date date, String ou, I18nFormat format );
 
     /**
      * Saves a Report.

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java	2013-09-03 18:28:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java	2013-11-07 11:52:20 +0000
@@ -58,11 +58,11 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.report.Report;
 import org.hisp.dhis.report.ReportService;
 import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.reporttable.ReportTableService;
+import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.system.util.Encoder;
 import org.hisp.dhis.system.util.Filter;
 import org.hisp.dhis.system.util.FilterUtils;
@@ -223,7 +223,7 @@
         return print;
     }
     
-    public void renderHtmlReport( Writer writer, String uid, String pe, String ou, I18nFormat format )
+    public void renderHtmlReport( Writer writer, String uid, Date date, String ou, I18nFormat format )
     {
         Report report = getReport( uid );        
         OrganisationUnit organisationUnit = null;
@@ -250,14 +250,7 @@
                 organisationUnitChildren.addAll( organisationUnit.getChildren() );
             }
         }
-        
-        Date date = new Date();
-        
-        if ( pe != null )
-        {
-            date = PeriodType.getPeriodFromIsoString( pe ).getStartDate();
-        }
-        
+                
         if ( report != null && report.hasRelativePeriods() )
         {
             periods = report.getRelatives().getRelativePeriods( date, format, true );
@@ -268,6 +261,7 @@
         context.put( "organisationUnit", organisationUnit );
         context.put( "organisationUnitHierarchy", organisationUnitHierarchy );
         context.put( "organisationUnitChildren", organisationUnitChildren );
+        context.put( "date", DateUtils.getMediumDateString( date ) );
         context.put( "periods", periods );
         context.put( "format", format );
         context.put( "encoder", ENCODER );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/html-report.vm'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/html-report.vm	2013-08-12 15:41:12 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/html-report.vm	2013-11-07 11:52:20 +0000
@@ -23,15 +23,6 @@
 #end
 ];
 
-dhis2.report.periods = [
-#if( $periods )
-#set( $size = $periods.size() )
-#foreach( $period in $periods )
-"$period.getIsoDate()"#if( $velocityCount < $size ),#end
-#end
-#end
-];
-
 dhis2.report.organisationUnitChildren = [
 #if( $organisationUnitChildren )
 #set( $size = $organisationUnitChildren.size() )
@@ -44,6 +35,17 @@
 #end
 #end
 ];
+
+dhis2.report.date = "$!{date}";
+
+dhis2.report.periods = [
+#if( $periods )
+#set( $size = $periods.size() )
+#foreach( $period in $periods )
+"$period.getIsoDate()"#if( $velocityCount < $size ),#end
+#end
+#end
+];
 
 </script>
 

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html	2013-06-08 16:53:04 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html	2013-11-07 11:52:20 +0000
@@ -58,6 +58,8 @@
 
 var orgUnitChildren = dhis2.report.organisationUnitChildren; // An array with child org unit objects<br><br>
 
+var date = dhis2.report.date; // A date in yyyy-MM-dd format<br><br>
+
 var periods = dhis2.report.periods; // An array with period identifiers<br><br>
 
 var period = periods[0];

=== 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-11-06 12:24:02 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.java	2013-11-07 11:52:20 +0000
@@ -73,7 +73,7 @@
     // -------------------------------------------------------------------------
     // Resources
     // -------------------------------------------------------------------------
-  
+
     @RequestMapping( value = RESOURCE_PATH, method = RequestMethod.GET, produces = { "application/json", "application/javascript" } )
     public String getJson( // JSON, JSONP
         @RequestParam Set<String> dimension,

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java	2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java	2013-11-07 11:52:20 +0000
@@ -52,7 +52,6 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.system.util.CodecUtils;
 import org.hisp.dhis.user.UserService;
 import org.jfree.chart.ChartUtilities;
@@ -67,6 +66,8 @@
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseStatus;
 
+import static org.hisp.dhis.api.utils.ContextUtils.DATE_PATTERN;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  * @author Lars Helge Overland
@@ -159,9 +160,9 @@
     //--------------------------------------------------------------------------
 
     @RequestMapping( value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET )
-    public void getChart( @PathVariable( "uid" ) String uid,
-        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date date,
-        @RequestParam( value = "pe", required = false) String pe,
+    public void getChart( 
+        @PathVariable( "uid" ) String uid,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
         @RequestParam( value = "ou", required = false ) String ou,
         @RequestParam( value = "width", defaultValue = "800", required = false ) int width,
         @RequestParam( value = "height", defaultValue = "500", required = false ) int height,
@@ -177,12 +178,6 @@
         
         OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit( ou ) : null;
         
-        if ( pe != null )
-        {
-            Period period = PeriodType.getPeriodFromIsoString( pe );            
-            date = period != null ? period.getStartDate() : date;
-        }
-        
         JFreeChart jFreeChart = chartService.getJFreeChart( chart, date, unit, i18nManager.getI18nFormat() );
 
         String filename = CodecUtils.filenameEncode( chart.getName() ) + ".png";
@@ -193,7 +188,8 @@
     }
 
     @RequestMapping( value = { "/data", "/data.png" }, method = RequestMethod.GET )
-    public void getChart( @RequestParam( value = "in" ) String indicatorUid,
+    public void getChart( 
+        @RequestParam( value = "in" ) String indicatorUid,
         @RequestParam( value = "ou" ) String organisationUnitUid,
         @RequestParam( value = "periods", required = false ) boolean periods,
         @RequestParam( value = "width", defaultValue = "800", required = false ) int width,
@@ -219,7 +215,11 @@
 
         ChartUtilities.writeChartAsPNG( response.getOutputStream(), chart, width, height );
     }
-    
+
+    //--------------------------------------------------------------------------
+    // Hooks
+    //--------------------------------------------------------------------------
+
     @Override
     public void postProcessEntity( Chart chart ) throws Exception
     {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java	2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java	2013-11-07 11:52:20 +0000
@@ -28,8 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.api.utils.ContextUtils.DATE_PATTERN;
 import static org.hisp.dhis.system.util.CodecUtils.filenameEncode;
 
+import java.util.Calendar;
+import java.util.Date;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -42,6 +46,7 @@
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Cal;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
@@ -49,6 +54,7 @@
 import org.hisp.dhis.report.ReportService;
 import org.hisp.dhis.system.util.CodecUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -80,33 +86,10 @@
     @Autowired
     private ContextUtils contextUtils;
 
-    @RequestMapping( value = { "/{uid}/data", "/{uid}/data.pdf" }, method = RequestMethod.GET )
-    public void getReportAsPdf( @PathVariable( "uid" ) String uid,
-        @RequestParam( value = "ou", required = false ) String organisationUnitUid,
-        @RequestParam( value = "pe", required = false ) String period,
-        HttpServletRequest request, HttpServletResponse response ) throws Exception
-    {
-        getReport( request, response, uid, organisationUnitUid, period, "pdf", ContextUtils.CONTENT_TYPE_PDF, false );
-    }
-
-    @RequestMapping( value = "/{uid}/data.xls", method = RequestMethod.GET )
-    public void getReportAsXls( @PathVariable( "uid" ) String uid,
-        @RequestParam( value = "ou", required = false ) String organisationUnitUid,
-        @RequestParam( value = "pe", required = false ) String period,
-        HttpServletRequest request, HttpServletResponse response ) throws Exception
-    {
-        getReport( request, response, uid, organisationUnitUid, period, "xls", ContextUtils.CONTENT_TYPE_EXCEL, true );
-    }
-
-    @RequestMapping( value = "/{uid}/data.html", method = RequestMethod.GET )
-    public void getReportAsHtml( @PathVariable( "uid" ) String uid,
-        @RequestParam( value = "ou", required = false ) String organisationUnitUid,
-        @RequestParam( value = "pe", required = false ) String period,
-        HttpServletRequest request, HttpServletResponse response ) throws Exception
-    {
-        getReport( request, response, uid, organisationUnitUid, period, "html", ContextUtils.CONTENT_TYPE_HTML, false );
-    }
-    
+    // -------------------------------------------------------------------------
+    // CRUD
+    // -------------------------------------------------------------------------
+
     @RequestMapping( value = "/{uid}/design", method = RequestMethod.PUT )
     @PreAuthorize( "hasRole('ALL')" )
     public void updateReportDesign( @PathVariable( "uid" ) String uid, 
@@ -153,7 +136,45 @@
         
         response.getWriter().write( report.getDesignContent() );
     }
-    
+
+    // -------------------------------------------------------------------------
+    // Get data
+    // -------------------------------------------------------------------------
+
+    @RequestMapping( value = { "/{uid}/data", "/{uid}/data.pdf" }, method = RequestMethod.GET )
+    public void getReportAsPdf( @PathVariable( "uid" ) String uid,
+        @RequestParam( value = "ou", required = false ) String organisationUnitUid,
+        @RequestParam( value = "pe", required = false ) String period,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
+        HttpServletRequest request, HttpServletResponse response ) throws Exception
+    {
+        getReport( request, response, uid, organisationUnitUid, period, date, "pdf", ContextUtils.CONTENT_TYPE_PDF, false );
+    }
+
+    @RequestMapping( value = "/{uid}/data.xls", method = RequestMethod.GET )
+    public void getReportAsXls( @PathVariable( "uid" ) String uid,
+        @RequestParam( value = "ou", required = false ) String organisationUnitUid,
+        @RequestParam( value = "pe", required = false ) String period,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
+        HttpServletRequest request, HttpServletResponse response ) throws Exception
+    {
+        getReport( request, response, uid, organisationUnitUid, period, date, "xls", ContextUtils.CONTENT_TYPE_EXCEL, true );
+    }
+
+    @RequestMapping( value = "/{uid}/data.html", method = RequestMethod.GET )
+    public void getReportAsHtml( @PathVariable( "uid" ) String uid,
+        @RequestParam( value = "ou", required = false ) String organisationUnitUid,
+        @RequestParam( value = "pe", required = false ) String period,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
+        HttpServletRequest request, HttpServletResponse response ) throws Exception
+    {
+        getReport( request, response, uid, organisationUnitUid, period, date, "html", ContextUtils.CONTENT_TYPE_HTML, false );
+    }
+
+    // -------------------------------------------------------------------------
+    // Images
+    // -------------------------------------------------------------------------
+
     /**
      * This methods wraps the Jasper image servlet to avoid having a separate
      * servlet mapping around. Note that the path to images are relative to the
@@ -171,7 +192,7 @@
     // -------------------------------------------------------------------------
 
     private void getReport( HttpServletRequest request, HttpServletResponse response, String uid, String organisationUnitUid, String isoPeriod,
-        String type, String contentType, boolean attachment ) throws Exception
+        Date date, String type, String contentType, boolean attachment ) throws Exception
     {
         Report report = reportService.getReport( uid );
         
@@ -189,16 +210,18 @@
             organisationUnitUid = organisationUnitService.getRootOrganisationUnits().iterator().next().getUid();
         }
 
-        Period period = isoPeriod != null ? PeriodType.getPeriodFromIsoString( isoPeriod ) : new MonthlyPeriodType().createPeriod();
-        
         if ( report.isTypeHtml() )
         {
             contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING );
             
-            reportService.renderHtmlReport( response.getWriter(), uid, isoPeriod, organisationUnitUid, format );
+            reportService.renderHtmlReport( response.getWriter(), uid, date, organisationUnitUid, format );
         }
         else
         {
+            date = date != null ? date : new Cal().now().subtract( Calendar.MONTH, 1 ).time();
+            
+            Period period = isoPeriod != null ? PeriodType.getPeriodFromIsoString( isoPeriod ) : new MonthlyPeriodType().createPeriod( date );
+            
             String filename = CodecUtils.filenameEncode( report.getName() ) + "." + type;
             
             contextUtils.configureResponse( response, contentType, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, attachment );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java	2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java	2013-11-07 11:52:20 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.api.utils.ContextUtils.DATE_PATTERN;
 import static org.hisp.dhis.common.DimensionalObjectUtils.getUniqueDimensions;
 import static org.hisp.dhis.system.util.CodecUtils.filenameEncode;
 
@@ -58,9 +59,9 @@
 import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.reporttable.ReportTableService;
 import org.hisp.dhis.system.grid.GridUtils;
-import org.hisp.dhis.system.util.DateUtils;
 import org.hisp.dhis.user.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -172,27 +173,6 @@
         reportTableService.deleteReportTable( reportTable );
     }
 
-    @Override
-    protected void postProcessEntity( ReportTable reportTable ) throws Exception
-    {
-        reportTable.populateAnalyticalProperties();
-        
-        for ( OrganisationUnit organisationUnit : reportTable.getOrganisationUnits() )
-        {
-            reportTable.getParentGraphMap().put( organisationUnit.getUid(), organisationUnit.getParentGraph() );
-        }
-
-        I18nFormat format = i18nManager.getI18nFormat();
-
-        if ( reportTable.getPeriods() != null && !reportTable.getPeriods().isEmpty() )
-        {
-            for ( Period period : reportTable.getPeriods() )
-            {
-                period.setName( format.formatPeriod( period ) );
-            }
-        }
-    }
-
     //--------------------------------------------------------------------------
     // GET - Report table data
     //--------------------------------------------------------------------------
@@ -200,10 +180,10 @@
     @RequestMapping( value = "/{uid}/data", method = RequestMethod.GET ) // For json, jsonp
     public String getReportTableData( @PathVariable( "uid" ) String uid, Model model,
         @RequestParam( value = "ou", required = false ) String organisationUnitUid,
-        @RequestParam( value = "pe", required = false ) String period,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
         HttpServletResponse response ) throws Exception
     {
-        model.addAttribute( "model", getReportTableGrid( uid, organisationUnitUid, period ) );
+        model.addAttribute( "model", getReportTableGrid( uid, organisationUnitUid, date ) );
         model.addAttribute( "viewClass", "detailed" );
 
         return "grid";
@@ -212,10 +192,10 @@
     @RequestMapping( value = "/{uid}/data.html", method = RequestMethod.GET )
     public void getReportTableHtml( @PathVariable( "uid" ) String uid,
         @RequestParam( value = "ou", required = false ) String organisationUnitUid,
-        @RequestParam( value = "pe", required = false ) String period,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
         HttpServletResponse response ) throws Exception
     {
-        Grid grid = getReportTableGrid( uid, organisationUnitUid, period );
+        Grid grid = getReportTableGrid( uid, organisationUnitUid, date );
 
         String filename = filenameEncode( grid.getTitle() ) + ".html";
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, false );
@@ -226,10 +206,10 @@
     @RequestMapping( value = "/{uid}/data.xml", method = RequestMethod.GET )
     public void getReportTableXml( @PathVariable( "uid" ) String uid,
         @RequestParam( value = "ou", required = false ) String organisationUnitUid,
-        @RequestParam( value = "pe", required = false ) String period,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
         HttpServletResponse response ) throws Exception
     {
-        Grid grid = getReportTableGrid( uid, organisationUnitUid, period );
+        Grid grid = getReportTableGrid( uid, organisationUnitUid, date );
 
         String filename = filenameEncode( grid.getTitle() ) + ".xml";
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, false );
@@ -240,10 +220,10 @@
     @RequestMapping( value = "/{uid}/data.pdf", method = RequestMethod.GET )
     public void getReportTablePdf( @PathVariable( "uid" ) String uid,
         @RequestParam( value = "ou", required = false ) String organisationUnitUid,
-        @RequestParam( value = "pe", required = false ) String period,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
         HttpServletResponse response ) throws Exception
     {
-        Grid grid = getReportTableGrid( uid, organisationUnitUid, period );
+        Grid grid = getReportTableGrid( uid, organisationUnitUid, date );
 
         String filename = filenameEncode( grid.getTitle() ) + ".pdf";
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PDF, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, false );
@@ -254,10 +234,10 @@
     @RequestMapping( value = "/{uid}/data.xls", method = RequestMethod.GET )
     public void getReportTableXls( @PathVariable( "uid" ) String uid,
         @RequestParam( value = "ou", required = false ) String organisationUnitUid,
-        @RequestParam( value = "pe", required = false ) String period,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
         HttpServletResponse response ) throws Exception
     {
-        Grid grid = getReportTableGrid( uid, organisationUnitUid, period );
+        Grid grid = getReportTableGrid( uid, organisationUnitUid, date );
 
         String filename = filenameEncode( grid.getTitle() ) + ".xls";
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, true );
@@ -268,10 +248,10 @@
     @RequestMapping( value = "/{uid}/data.csv", method = RequestMethod.GET )
     public void getReportTableCsv( @PathVariable( "uid" ) String uid,
         @RequestParam( value = "ou", required = false ) String organisationUnitUid,
-        @RequestParam( value = "pe", required = false ) String period,
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
         HttpServletResponse response ) throws Exception
     {
-        Grid grid = getReportTableGrid( uid, organisationUnitUid, period );
+        Grid grid = getReportTableGrid( uid, organisationUnitUid, date );
 
         String filename = filenameEncode( grid.getTitle() ) + ".csv";
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, true );
@@ -279,7 +259,7 @@
         GridUtils.toCsv( grid, response.getOutputStream() );
     }
 
-    private Grid getReportTableGrid( String uid, String organisationUnitUid, String period )
+    private Grid getReportTableGrid( String uid, String organisationUnitUid, Date date )
         throws Exception
     {
         ReportTable reportTable = reportTableService.getReportTableNoAcl( uid );
@@ -289,12 +269,37 @@
             organisationUnitUid = organisationUnitService.getRootOrganisationUnits().iterator().next().getUid();
         }
 
-        Date date = period != null ? DateUtils.getMediumDate( period ) : new Cal().now().subtract( Calendar.MONTH, 1 ).time();
+        date = date != null ? date : new Cal().now().subtract( Calendar.MONTH, 1 ).time();
 
         return reportTableService.getReportTableGrid( uid, i18nManager.getI18nFormat(), date, organisationUnitUid );
     }
 
     //--------------------------------------------------------------------------
+    // Hooks
+    //--------------------------------------------------------------------------
+
+    @Override
+    protected void postProcessEntity( ReportTable reportTable ) throws Exception
+    {
+        reportTable.populateAnalyticalProperties();
+        
+        for ( OrganisationUnit organisationUnit : reportTable.getOrganisationUnits() )
+        {
+            reportTable.getParentGraphMap().put( organisationUnit.getUid(), organisationUnit.getParentGraph() );
+        }
+
+        I18nFormat format = i18nManager.getI18nFormat();
+
+        if ( reportTable.getPeriods() != null && !reportTable.getPeriods().isEmpty() )
+        {
+            for ( Period period : reportTable.getPeriods() )
+            {
+                period.setName( format.formatPeriod( period ) );
+            }
+        }
+    }
+
+    //--------------------------------------------------------------------------
     // Supportive methods
     //--------------------------------------------------------------------------
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java	2013-11-06 16:30:25 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java	2013-11-07 11:52:20 +0000
@@ -68,6 +68,8 @@
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseStatus;
 
+import static org.hisp.dhis.api.utils.ContextUtils.DATE_PATTERN;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  * @author Lars Helge Overland
@@ -201,6 +203,35 @@
         mappingService.deleteMap( map );
     }
 
+    //--------------------------------------------------------------------------
+    // Get data
+    //--------------------------------------------------------------------------
+
+    @RequestMapping(value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET)
+    public void getMapData( @PathVariable String uid, 
+        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = DATE_PATTERN ) Date date,
+        @RequestParam( value = "ou", required = false ) String ou,
+        @RequestParam( required = false ) Integer width, 
+        @RequestParam( required = false ) Integer height, 
+        HttpServletResponse response ) throws Exception
+    {
+        Map map = mappingService.getMapNoAcl( uid );
+
+        if ( map == null )
+        {
+            ContextUtils.notFoundResponse( response, "Map does not exist: " + uid );
+            return;
+        }
+
+        OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit( ou ) : null;
+        
+        renderMapViewPng( map, date, unit, width, height, response );
+    }
+
+    //--------------------------------------------------------------------------
+    // Hooks
+    //--------------------------------------------------------------------------
+
     @Override
     public void postProcessEntity( Map map ) throws Exception
     {
@@ -226,32 +257,6 @@
     }
 
     //--------------------------------------------------------------------------
-    // Get data
-    //--------------------------------------------------------------------------
-
-    @RequestMapping(value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET)
-    public void getMapData( 
-        @PathVariable String uid, 
-        @RequestParam( value = "date", required = false ) @DateTimeFormat( pattern = "yyyy-MM-dd" ) Date date,
-        @RequestParam( value = "ou", required = false ) String ou,
-        @RequestParam( required = false ) Integer width, 
-        @RequestParam( required = false ) Integer height, 
-        HttpServletResponse response ) throws Exception
-    {
-        Map map = mappingService.getMapNoAcl( uid );
-
-        if ( map == null )
-        {
-            ContextUtils.notFoundResponse( response, "Map does not exist: " + uid );
-            return;
-        }
-
-        OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit( ou ) : null;
-        
-        renderMapViewPng( map, date, unit, width, height, response );
-    }
-
-    //--------------------------------------------------------------------------
     // Supportive methods
     //--------------------------------------------------------------------------
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapViewController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapViewController.java	2013-11-06 16:30:25 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapViewController.java	2013-11-07 11:52:20 +0000
@@ -75,6 +75,10 @@
     @Autowired
     private ContextUtils contextUtils;
 
+    //--------------------------------------------------------------------------
+    // Get data
+    //--------------------------------------------------------------------------
+
     @RequestMapping(value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET)
     public void getMapViewData( @PathVariable String uid, HttpServletResponse response ) throws Exception
     {
@@ -109,6 +113,10 @@
         renderMapViewPng( mapView, response );
     }
 
+    //--------------------------------------------------------------------------
+    // Hooks
+    //--------------------------------------------------------------------------
+
     @Override
     protected List<MapView> getEntityList( WebMetaData metaData, WebOptions options )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java	2013-10-25 20:37:23 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java	2013-11-07 11:52:20 +0000
@@ -78,6 +78,8 @@
     public static final String HEADER_CONTENT_DISPOSITION = "Content-Disposition";
     public static final String HEADER_CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
     public static final String HEADER_LOCATION = "Location";
+    
+    public static final String DATE_PATTERN = "yyyy-MM-dd";
 
     @Autowired
     private SystemSettingManager systemSettingManager;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportAndParamsAction.java	2013-11-07 11:52:20 +0000
@@ -30,9 +30,11 @@
 
 import java.io.StringWriter;
 import java.io.Writer;
+import java.util.Date;
 
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.report.ReportService;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -102,7 +104,9 @@
     {
         Writer writer = new StringWriter();
         
-        reportService.renderHtmlReport( writer, uid, pe, ou, format );
+        Date date = pe != null ? PeriodType.getPeriodFromIsoString( pe ).getStartDate() : null; 
+        
+        reportService.renderHtmlReport( writer, uid, date, ou, format );
         
         content = writer.toString();