dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08880
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2231: Improved the way database connection is given to jasperreports fillmanager. Added validation for ...
------------------------------------------------------------
revno: 2231
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-11-29 23:36:15 +0100
message:
Improved the way database connection is given to jasperreports fillmanager. Added validation for orgunit report parameter.
modified:
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.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-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java 2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java 2010-11-29 22:36:15 +0000
@@ -28,6 +28,7 @@
*/
import java.io.OutputStream;
+import java.sql.Connection;
import javax.servlet.http.HttpServletResponse;
@@ -37,11 +38,11 @@
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
+import org.amplecode.quick.StatementManager;
import org.hisp.dhis.report.Report;
import org.hisp.dhis.report.ReportService;
import org.hisp.dhis.system.util.StreamUtils;
import org.hisp.dhis.util.StreamActionSupport;
-import org.springframework.jdbc.core.JdbcTemplate;
/**
* @author Lars Helge Overland
@@ -61,11 +62,11 @@
this.reportService = reportService;
}
- private JdbcTemplate jdbcTemplate;
+ private StatementManager statementManager;
- public void setJdbcTemplate( JdbcTemplate jdbcTemplate )
+ public void setStatementManager( StatementManager statementManager )
{
- this.jdbcTemplate = jdbcTemplate;
+ this.statementManager = statementManager;
}
// -------------------------------------------------------------------------
@@ -91,9 +92,23 @@
JasperReport jasperReport = JasperCompileManager.compileReport( StreamUtils.getInputStream( report.getDesignContent() ) );
- JasperPrint print = JasperFillManager.fillReport( jasperReport, null, jdbcTemplate.getDataSource().getConnection() );
-
- JasperExportManager.exportReportToPdfStream( print, out );
+ Connection connection = statementManager.getHolder().getConnection();
+
+ JasperPrint print = null;
+
+ try
+ {
+ print = JasperFillManager.fillReport( jasperReport, null, connection );
+ }
+ finally
+ {
+ connection.close();
+ }
+
+ if ( print != null )
+ {
+ JasperExportManager.exportReportToPdfStream( print, out );
+ }
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-11-23 08:13:14 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-11-29 22:36:15 +0000
@@ -374,8 +374,8 @@
scope="prototype">
<property name="reportService"
ref="org.hisp.dhis.report.ReportService"/>
- <property name="jdbcTemplate"
- ref="jdbcTemplate"/>
+ <property name="statementManager"
+ ref="statementManager"/>
</bean>
<bean id="org.hisp.dhis.reporting.reportviewer.action.GetReportDesignAction"
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm 2010-11-29 17:23:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm 2010-11-29 22:36:15 +0000
@@ -54,12 +54,12 @@
<!-- OrganisationUnit -->
#if ( $!reportParams.isParamParentOrganisationUnit() || $!reportParams.isParamOrganisationUnit() )
-
+
<tr>
<th>$i18n.getString( "organisation_unit" )</th>
</tr>
<td>
- <div id="selectionTree" style="width:325px; height:270px"></div>
+ <div id="selectionTree" style="width:325px; height:240px"></div>
<script type="text/javascript">
selectionTreeSelection.setMultipleSelectionAllowed( false );
selectionTreeSelection.setListenerFunction( paramOrganisationUnitSet );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js 2010-09-16 14:29:20 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js 2010-11-29 22:36:15 +0000
@@ -16,6 +16,12 @@
function runAndViewReport( reportId, reportUrl )
{
+ if ( $( '#selectionTree' ).length && paramOrganisationUnit == null )
+ {
+ setMessage( i18n_please_select_unit );
+ return false;
+ }
+
setWaitMessage( i18n_please_wait );
var url = "createTable.action?id=" + reportId + "&doDataMart=" + getListValue( "doDataMart" ) + "&mode=report";
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js 2010-11-29 17:23:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js 2010-11-29 22:36:15 +0000
@@ -12,6 +12,12 @@
function createTable( tableId )
{
+ if ( $( '#selectionTree' ).length && paramOrganisationUnit == null )
+ {
+ setMessage( i18n_please_select_unit );
+ return false;
+ }
+
var url = "createTable.action?id=" + tableId + "&doDataMart=" + getListValue( "doDataMart" ) + "&mode=table";
if ( document.getElementById( "reportingPeriod" ) != null )