dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19272
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8326: Report table, stop putting last generated table in memory and rather cache and fetch from databas...
------------------------------------------------------------
revno: 8326
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-10-01 17:58:02 +0200
message:
Report table, stop putting last generated table in memory and rather cache and fetch from database when needed. Also more friendly to intermediary caches.
modified:
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/tablecreator/action/ExportTableAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm
--
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-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-10-01 13:44:31 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java 2012-10-01 15:58:02 +0000
@@ -248,7 +248,7 @@
String dataSetType = selectedDataSet.getDataSetType();
registration = registrationService.getCompleteDataSetRegistration( selectedDataSet, selectedPeriod, selectedOrgunit );
-
+
if ( TYPE_CUSTOM.equals( dataSetType ) )
{
if ( type != null )
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2012-09-24 12:52:15 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2012-10-01 15:58:02 +0000
@@ -31,6 +31,12 @@
import java.util.HashMap;
import java.util.Map;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+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.constant.ConstantService;
import org.hisp.dhis.i18n.I18nFormat;
@@ -39,7 +45,7 @@
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.reporttable.ReportTableService;
-import org.hisp.dhis.util.SessionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -84,6 +90,9 @@
this.format = format;
}
+ @Autowired
+ private ContextUtils contextUtils;
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -102,6 +111,11 @@
private String pe;
+ public String getPe()
+ {
+ return pe;
+ }
+
public void setPe( String pe )
{
this.pe = pe;
@@ -126,13 +140,6 @@
this.type = type;
}
- private Boolean useLast = false;
-
- public void setUseLast( boolean useLast )
- {
- this.useLast = useLast;
- }
-
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -159,6 +166,22 @@
public String execute()
throws Exception
{
+ // ---------------------------------------------------------------------
+ // Configure response
+ // ---------------------------------------------------------------------
+
+ HttpServletResponse response = ServletActionContext.getResponse();
+
+ contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING, null, false );
+
+ uid = StringUtils.trimToNull( uid );
+ pe = StringUtils.trimToNull( pe );
+ ou = StringUtils.trimToNull( ou );
+
+ // ---------------------------------------------------------------------
+ // Assemble report
+ // ---------------------------------------------------------------------
+
ReportTable reportTable = reportTableService.getReportTable( uid );
if ( TYPE_JRXML.equals( format ) )
@@ -167,23 +190,12 @@
params.putAll( reportTable.getOrganisationUnitGroupMap( organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets() ) );
}
- //TODO stop putting in memory, too expensive
-
- if ( useLast )
- {
- grid = (Grid) SessionUtils.getSessionVar( SessionUtils.KEY_REPORT_TABLE_GRID );
- }
- else
- {
- Period period = PeriodType.getPeriodFromIsoString( pe );
-
- Date date = period != null ? period.getStartDate() : new Date();
-
- grid = reportTableService.getReportTableGrid( uid, format, date, ou );
- }
+ Period period = PeriodType.getPeriodFromIsoString( pe );
+
+ Date date = period != null ? period.getStartDate() : new Date();
+
+ grid = reportTableService.getReportTableGrid( uid, format, date, ou );
- SessionUtils.setSessionVar( SessionUtils.KEY_REPORT_TABLE_GRID, grid );
-
return type != null ? type : TYPE_DEFAULT;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js 2012-09-24 05:42:39 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js 2012-10-01 15:58:02 +0000
@@ -65,9 +65,10 @@
// Report table
// -----------------------------------------------------------------------------
-function exportReport( type, uid )
+function exportReport( type, uid, pe, ou )
{
- var url = "exportTable.action?uid=" + uid + "&type=" + type + "&useLast=true";
+ var url = "exportTable.action?type=" + type +
+ "&uid=" + uid + "&pe=" + pe + "&ou=" + ou;
url += $( "#id" ).length ? ( "&id=" + $( "#id" ).val() ) : "";
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm 2012-06-14 18:56:38 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/reportTableGrid.vm 2012-10-01 15:58:02 +0000
@@ -9,11 +9,11 @@
</script>
<div>
-<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportReport( 'xls', '${uid}' )" style="width:140px">
-<input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="exportReport( 'csv', '${uid}' )" style="width:140px">
-<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportReport( 'pdf', '${uid}' )" style="width:140px">
-<input type="button" value="$i18n.getString( 'get_report_as_jasper' )" onclick="exportReport( 'jasper', '${uid}' )" style="width:140px">
-<input type="button" value="$i18n.getString( 'get_report_as_jrxml' )" onclick="exportReport( 'jrxml', '${uid}' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportReport( 'xls', '$!{uid}', '$!{pe}', '$!{ou}' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'get_report_as_csv' )" onclick="exportReport( 'csv', '$!{uid}', '$!{pe}', '$!{ou}' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportReport( 'pdf', '$!{uid}', '$!{pe}', '$!{ou}' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'get_report_as_jasper' )" onclick="exportReport( 'jasper', '$!{uid}', '$!{pe}', '$!{ou}' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'get_report_as_jrxml' )" onclick="exportReport( 'jrxml', '$!{uid}', '$!{pe}', '$!{ou}' )" style="width:140px">
<input type="button" value="$i18n.getString( 'share' )" onclick="viewShareForm()" style="width:140px">
<input type="button" value="$i18n.getString( 'back' )" onclick="javascript:window.location.href='displayManageTableForm.action'" style="width:140px">
</div>