dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19255
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8318: Impl function for getting an ireport template with all available parameters included for sql quer...
------------------------------------------------------------
revno: 8318
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-10-01 12:50:34 +0200
message:
Impl function for getting an ireport template with all available parameters included for sql queries.
added:
dhis-2/dhis-support/dhis-support-system/src/main/resources/template.jrxml
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/StreamUtils.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.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-api/src/main/java/org/hisp/dhis/report/ReportService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java 2012-09-26 08:01:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java 2012-10-01 10:50:34 +0000
@@ -45,6 +45,10 @@
final String PARAM_RELATIVE_PERIODS = "periods";
final String PARAM_ORG_UNITS = "organisationunits";
+ final String PARAM_ORGANISATIONUNIT_LEVEL = "organisationunit_level";
+ final String PARAM_ORGANISATIONUNIT_LEVEL_COLUMN = "organisationunit_level_column";
+ final String PARAM_ORGANISATIONUNIT_COLUMN_NAME = "organisationunit_name";
+ final String PARAM_PERIOD_NAME = "period_name";
/**
* Renders a Jasper Report.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2012-09-26 08:01:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2012-10-01 10:50:34 +0000
@@ -107,8 +107,6 @@
public static final String REPORTING_MONTH_COLUMN_NAME = "reporting_month_name";
public static final String PARAM_ORGANISATIONUNIT_COLUMN_NAME = "param_organisationunit_name";
- public static final String PARAM_ORGANISATIONUNIT_LEVEL = "organisationunit_level";
- public static final String PARAM_ORGANISATIONUNIT_LEVEL_COLUMN = "organisationunit_level_column";
public static final String ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME = "organisation_unit_is_parent";
public static final String SEPARATOR = "_";
=== 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 2012-09-26 08:01:02 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java 2012-10-01 10:50:34 +0000
@@ -27,9 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.reporttable.ReportTable.*;
-import static org.hisp.dhis.reporttable.ReportTable.REPORTING_MONTH_COLUMN_NAME;
-import static org.hisp.dhis.reporttable.ReportTable.PARAM_ORGANISATIONUNIT_LEVEL;
import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
@@ -145,7 +142,7 @@
if ( period != null )
{
- params.put( REPORTING_MONTH_COLUMN_NAME, format.formatPeriod( period ) );
+ params.put( PARAM_PERIOD_NAME, format.formatPeriod( period ) );
reportDate = period.getStartDate();
}
@@ -193,7 +190,7 @@
if ( report.hasReportParams() && report.getReportParams().isParamOrganisationUnit() && orgUnit != null )
{
- params.put( PARAM_ORG_UNITS, orgUnit.getId() );
+ params.put( PARAM_ORG_UNITS, String.valueOf( orgUnit.getId() ) );
}
try
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/StreamUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/StreamUtils.java 2012-07-04 20:16:23 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/StreamUtils.java 2012-10-01 10:50:34 +0000
@@ -78,7 +78,7 @@
return classLoader.getResourceAsStream( name );
}
- public static void streamcopy(BufferedInputStream in, BufferedOutputStream out)
+ public static void streamcopy( BufferedInputStream in, BufferedOutputStream out )
{
int b = 0;
=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/template.jrxml'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/template.jrxml 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/template.jrxml 2012-10-01 10:50:34 +0000
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" pageWidth="792" pageHeight="612" orientation="Landscape" whenNoDataType="AllSectionsNoDetail" columnWidth="752" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="df48aa2c-3795-40ea-8bb4-7e8988796c80">
+ <parameter name="periods" class="java.lang.String"/>
+ <parameter name="organisationunits" class="java.lang.String"/>
+ <parameter name="organisationunit_name" class="java.lang.String"/>
+ <parameter name="organisationunit_level" class="java.lang.Integer"/>
+ <parameter name="organisationunit_level_column" class="java.lang.String"/>
+ <background>
+ <band splitType="Stretch"/>
+ </background>
+ <title>
+ <band height="212" splitType="Stretch">
+ <staticText>
+ <reportElement uuid="ac60f476-8e83-423f-b4a9-626128dc5563" x="0" y="26" width="726" height="20"/>
+ <textElement>
+ <font size="11" isBold="true"/>
+ </textElement>
+ <text><![CDATA[This template contains a set of parameters which you can use directly in SQL to make dynamic reports]]></text>
+ </staticText>
+ <staticText>
+ <reportElement uuid="b9814cb8-49b5-46c1-a31a-b9e0b3c38b91" x="0" y="91" width="568" height="20"/>
+ <textElement/>
+ <text><![CDATA[periods: string of comma-separated identifiers of the selected relative period]]></text>
+ </staticText>
+ <staticText>
+ <reportElement uuid="97dcf9d1-0d3b-4573-86b9-3b6349187063" x="0" y="112" width="568" height="20"/>
+ <textElement/>
+ <text><![CDATA[organisationunits: identifier of the selected organisation unit]]></text>
+ </staticText>
+ <staticText>
+ <reportElement uuid="22c8da34-3b81-43c0-ac15-733ae130ea6c" x="0" y="133" width="568" height="20"/>
+ <textElement/>
+ <text><![CDATA[organisationunit_name: name of the selected organisation unit]]></text>
+ </staticText>
+ <staticText>
+ <reportElement uuid="c43ce8d1-73fe-47aa-9005-e8ff1ef77865" x="0" y="154" width="568" height="20"/>
+ <textElement/>
+ <text><![CDATA[organisationunit_level: level of the selected organisation unit]]></text>
+ </staticText>
+ <staticText>
+ <reportElement uuid="f5e4800f-0f16-4ea4-ac58-985b46b32373" x="0" y="175" width="568" height="20"/>
+ <textElement/>
+ <text><![CDATA[organisationunit_level_column: name of the corresponding column in the _orgunitstructure resource table]]></text>
+ </staticText>
+ <textField>
+ <reportElement uuid="83d8575f-02ee-4a79-b438-86d4047cef2c" x="568" y="91" width="158" height="20"/>
+ <textElement/>
+ <textFieldExpression><![CDATA[$P{periods}]]></textFieldExpression>
+ </textField>
+ <textField>
+ <reportElement uuid="78bd3c7a-312a-49a5-9ec6-aa1a6a054620" x="568" y="112" width="158" height="20"/>
+ <textElement/>
+ <textFieldExpression><![CDATA[$P{organisationunits}]]></textFieldExpression>
+ </textField>
+ <textField>
+ <reportElement uuid="ced2e65b-fbd3-415f-b621-a32c2d747515" x="568" y="133" width="158" height="20"/>
+ <textElement/>
+ <textFieldExpression><![CDATA[$P{organisationunit_name}]]></textFieldExpression>
+ </textField>
+ <textField>
+ <reportElement uuid="99fc81bf-ac4a-445a-9864-eafe0b7f8d40" x="568" y="154" width="158" height="20"/>
+ <textElement/>
+ <textFieldExpression><![CDATA[$P{organisationunit_level}]]></textFieldExpression>
+ </textField>
+ <textField>
+ <reportElement uuid="671106c8-b073-447f-ae80-5d616d191836" x="568" y="175" width="158" height="20"/>
+ <textElement/>
+ <textFieldExpression><![CDATA[$P{organisationunit_level_column}]]></textFieldExpression>
+ </textField>
+ <staticText>
+ <reportElement uuid="f5e4800f-0f16-4ea4-ac58-985b46b32373" x="0" y="53" width="726" height="20"/>
+ <textElement/>
+ <text><![CDATA[Note that you can use the format $P!{periods} to evaluate the parameter as text for use e.g. in SQL IN clauses like "period in ($P!{periods})"]]></text>
+ </staticText>
+ </band>
+ </title>
+ <pageHeader>
+ <band height="35" splitType="Stretch"/>
+ </pageHeader>
+ <columnHeader>
+ <band height="61" splitType="Stretch"/>
+ </columnHeader>
+ <detail>
+ <band height="68" splitType="Stretch"/>
+ </detail>
+ <columnFooter>
+ <band height="45" splitType="Stretch"/>
+ </columnFooter>
+ <pageFooter>
+ <band height="54" splitType="Stretch"/>
+ </pageFooter>
+ <summary>
+ <band height="42" splitType="Stretch"/>
+ </summary>
+</jasperReport>
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/GetReportTemplateAction.java 2012-10-01 10:50:34 +0000
@@ -0,0 +1,33 @@
+package org.hisp.dhis.reporting.reportviewer.action;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.system.util.StreamUtils;
+import org.hisp.dhis.util.ContextUtils;
+import org.springframework.core.io.ClassPathResource;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetReportTemplateAction
+ implements Action
+{
+ private static final String TEMPLATE = "template.jrxml";
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ HttpServletResponse response = ServletActionContext.getResponse();
+
+ ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, false, TEMPLATE, true );
+
+ StreamUtils.streamcopy( new BufferedInputStream( new ClassPathResource( TEMPLATE ).getInputStream() ),
+ new BufferedOutputStream( response.getOutputStream() ) );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2012-09-24 12:52:15 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2012-10-01 10:50:34 +0000
@@ -219,4 +219,5 @@
share=Share
share_your_interpretation=Share your interpretation
interpretation_was_shared=Interpretation was shared
-last_3_months = Last 3 months
\ No newline at end of file
+last_3_months = Last 3 months
+get_report_template=Get report template
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2012-09-03 19:48:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2012-10-01 10:50:34 +0000
@@ -125,6 +125,10 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <action name="getReportTemplate" class="org.hisp.dhis.reporting.reportviewer.action.GetReportTemplateAction">
+ <result name="success" type="outputStreamResult" />
+ </action>
+
<!-- ReportTable -->
<action name="displayManageTableForm" class="org.hisp.dhis.reporting.tablecreator.action.GetAllTablesAction">
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm 2012-09-24 05:42:39 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm 2012-10-01 10:50:34 +0000
@@ -28,6 +28,8 @@
<td>
#if( $report )
<input type="button" value="$i18n.getString( 'get_current_design' )" onclick="window.location.href='getReportDesign.action?id=${report.id}'">
+ #else
+ <input type="button" value="$i18n.getString( 'get_report_template' )" onclick="window.location.href='getReportTemplate.action'">
#end
</td>
</tr>