dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19268
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8322: Data set report, stop putting last accessed report in memory and rather cache the response and fe...
------------------------------------------------------------
revno: 8322
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-10-01 15:44:31 +0200
message:
Data set report, stop putting last accessed report in memory and rather cache the response and fetch from database when needed
modified:
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/dataset/action/GenerateDataSetReportAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js
--
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-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 2012-08-29 16:24:08 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/ContextUtils.java 2012-10-01 13:44:31 +0000
@@ -212,7 +212,8 @@
try
{
port = Integer.parseInt( xForwardedPort );
- } catch ( NumberFormatException e )
+ }
+ catch ( NumberFormatException e )
{
port = request.getServerPort();
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java 2012-09-03 19:48:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java 2012-10-01 13:44:31 +0000
@@ -29,12 +29,15 @@
import static org.hisp.dhis.dataset.DataSet.TYPE_CUSTOM;
import static org.hisp.dhis.dataset.DataSet.TYPE_SECTION;
-import static org.hisp.dhis.util.SessionUtils.KEY_DATASET_REPORT_GRID;
-import static org.hisp.dhis.util.SessionUtils.getSessionVar;
import java.util.ArrayList;
import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.api.utils.ContextUtils;
+import org.hisp.dhis.api.utils.ContextUtils.CacheStrategy;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
@@ -48,7 +51,7 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.util.SessionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -111,6 +114,9 @@
{
this.i18n = i18n;
}
+
+ @Autowired
+ private ContextUtils contextUtils;
// -------------------------------------------------------------------------
// Input
@@ -148,13 +154,6 @@
{
this.selectedUnitOnly = selectedUnitOnly;
}
-
- private boolean useLast;
-
- public void setUseLast( boolean useLast )
- {
- this.useLast = useLast;
- }
private String type;
@@ -221,10 +220,21 @@
// -------------------------------------------------------------------------
@Override
- @SuppressWarnings( "unchecked" )
public String execute()
throws Exception
{
+ // ---------------------------------------------------------------------
+ // Configure response
+ // ---------------------------------------------------------------------
+
+ HttpServletResponse response = ServletActionContext.getResponse();
+
+ contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING, null, false );
+
+ // ---------------------------------------------------------------------
+ // Assemble report
+ // ---------------------------------------------------------------------
+
selectedDataSet = dataSetService.getDataSet( ds );
if ( pe != null )
@@ -241,7 +251,7 @@
if ( TYPE_CUSTOM.equals( dataSetType ) )
{
- if ( useLast )
+ if ( type != null )
{
grid = dataSetReportService.getDefaultDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, selectedUnitOnly, format, i18n );
}
@@ -252,19 +262,13 @@
}
else if ( TYPE_SECTION.equals( dataSetType ) )
{
- grids = useLast ? (List<Grid>) getSessionVar( KEY_DATASET_REPORT_GRID ) :
- dataSetReportService.getSectionDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, selectedUnitOnly, format, i18n );
-
- SessionUtils.setSessionVar( SessionUtils.KEY_DATASET_REPORT_GRID, grids );
+ grids = dataSetReportService.getSectionDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, selectedUnitOnly, format, i18n );
}
else
{
- grid = useLast ? (Grid) getSessionVar( KEY_DATASET_REPORT_GRID ) :
- dataSetReportService.getDefaultDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, selectedUnitOnly, format, i18n );
-
- SessionUtils.setSessionVar( SessionUtils.KEY_DATASET_REPORT_GRID, grid );
+ grid = dataSetReportService.getDefaultDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, selectedUnitOnly, format, i18n );
}
- return useLast ? type : dataSetType;
+ return type != null ? type : dataSetType;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2012-09-03 19:48:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2012-10-01 13:44:31 +0000
@@ -105,7 +105,8 @@
var currentParams = { ds: dataSetReport.dataSet, pe: dataSetReport.period, selectedUnitOnly: dataSetReport.selectedUnitOnly, ou: dataSetReport.orgUnit };
- $( '#content' ).load( 'generateDataSetReport.action', currentParams, function() {
+ $.get( 'generateDataSetReport.action', currentParams, function( data ) {
+ $( '#content' ).html( data );
hideLoader();
showContent();
setTableStyles();
@@ -116,8 +117,8 @@
{
var dataSetReport = getDataSetReport();
- var url = "generateDataSetReport.action?useLast=true" +
- "&ds=" + dataSetReport.dataSet +
+ var url = "generateDataSetReport.action" +
+ "?ds=" + dataSetReport.dataSet +
"&pe=" + dataSetReport.period +
"&selectedUnitOnly=" + dataSetReport.selectedUnitOnly +
"&ou=" + dataSetReport.orgUnit +