dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17086
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6695: Using web api for rendering reports
------------------------------------------------------------
revno: 6695
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-04-23 11:35:01 +0200
message:
Using web api for rendering reports
removed:
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ConstantController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserAuthorityGroupController.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/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.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/resources/struts.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/generateReport.js
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.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/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2012-02-12 12:21:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2012-04-23 09:35:01 +0000
@@ -134,10 +134,10 @@
* given identifier. If report mode, this method will return the report
* tables associated with the report.
*
- * @param id the identifier.
+ * @param uid the uid.
* @param mode the mode.
*/
- ReportTable getReportTable( Integer id, String mode );
+ ReportTable getReportTable( String uid, String mode );
Collection<ReportTable> getReportTablesBetween( int first, int max );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2012-04-05 11:57:23 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2012-04-23 09:35:01 +0000
@@ -144,15 +144,15 @@
return getGrid( reportTable );
}
- public ReportTable getReportTable( Integer id, String mode )
+ public ReportTable getReportTable( String uid, String mode )
{
if ( mode.equals( MODE_REPORT_TABLE ) )
{
- return getReportTable( id );
+ return getReportTable( uid );
}
else if ( mode.equals( MODE_REPORT ) )
{
- return reportService.getReport( id ).getReportTable();
+ return reportService.getReport( uid ).getReportTable();
}
return null;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ConstantController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ConstantController.java 2012-04-21 08:25:31 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ConstantController.java 2012-04-23 09:35:01 +0000
@@ -33,7 +33,6 @@
import org.hisp.dhis.constant.Constant;
import org.hisp.dhis.constant.ConstantService;
import org.hisp.dhis.constant.Constants;
-import org.hisp.dhis.dxf2.metadata.MetaData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserAuthorityGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserAuthorityGroupController.java 2012-03-28 07:40:14 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/user/UserAuthorityGroupController.java 2012-04-23 09:35:01 +0000
@@ -27,11 +27,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulator;
import org.hisp.dhis.user.UserAuthorityGroup;
import org.hisp.dhis.user.UserAuthorityGroups;
-import org.hisp.dhis.user.UserGroupService;
import org.hisp.dhis.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -44,11 +49,6 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.InputStream;
-import java.util.ArrayList;
-
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -59,9 +59,6 @@
public static final String RESOURCE_PATH = "/userAuthorityGroups";
@Autowired
- private UserGroupService userGroupService;
-
- @Autowired
private UserService userService;
//-------------------------------------------------------------------------------------------------------
=== removed 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 2012-02-26 21:19:49 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/RenderReportAction.java 1970-01-01 00:00:00 +0000
@@ -1,149 +0,0 @@
-package org.hisp.dhis.reporting.reportviewer.action;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import static org.apache.commons.lang.StringUtils.defaultIfEmpty;
-import static org.apache.commons.lang.StringUtils.trimToEmpty;
-
-import java.io.OutputStream;
-import java.util.Date;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.hisp.dhis.i18n.I18nFormat;
-import org.hisp.dhis.report.Report;
-import org.hisp.dhis.report.ReportService;
-import org.hisp.dhis.system.util.CodecUtils;
-import org.hisp.dhis.system.util.DateUtils;
-import org.hisp.dhis.util.ContextUtils;
-import org.hisp.dhis.util.StreamActionSupport;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class RenderReportAction
- extends StreamActionSupport
-{
- private static final String DEFAULT_TYPE = ReportService.REPORTTYPE_PDF;
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private ReportService reportService;
-
- public void setReportService( ReportService reportService )
- {
- this.reportService = reportService;
- }
-
- private I18nFormat format;
-
- public void setFormat( I18nFormat format )
- {
- this.format = format;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private Integer id;
-
- public void setId( Integer id )
- {
- this.id = id;
- }
-
- private String reportingPeriod;
-
- public void setReportingPeriod( String reportingPeriod )
- {
- this.reportingPeriod = reportingPeriod;
- }
-
- private Integer organisationUnitId;
-
- public void setOrganisationUnitId( Integer organisationUnitId )
- {
- this.organisationUnitId = organisationUnitId;
- }
-
- private String type;
-
- public void setType( String type )
- {
- this.type = type;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- @Override
- protected String execute( HttpServletResponse response, OutputStream out )
- throws Exception
- {
- type = defaultIfEmpty( trimToEmpty( type ), DEFAULT_TYPE );
-
- Report report = reportService.getReport( id );
-
- Date date = reportingPeriod != null ? DateUtils.getMediumDate( reportingPeriod ) : new Date();
-
- reportService.renderReport( out, report, date, organisationUnitId, type, format );
-
- return SUCCESS;
- }
-
- @Override
- protected String getContentType()
- {
- return ContextUtils.getContentType( type, ContextUtils.CONTENT_TYPE_PDF );
- }
-
- @Override
- protected String getFilename()
- {
- Report report = reportService.getReport( id );
-
- return CodecUtils.filenameEncode( report.getName() ) + "." + defaultIfEmpty( type, DEFAULT_TYPE );
- }
-
- @Override
- protected boolean disallowCache()
- {
- return true;
- }
-
- @Override
- protected boolean attachment()
- {
- return !defaultIfEmpty( type, DEFAULT_TYPE ).equals( DEFAULT_TYPE );
- }
-}
=== 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 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ExportTableAction.java 2012-04-23 09:35:01 +0000
@@ -82,29 +82,29 @@
this.format = format;
}
- private String reportingPeriod;
-
- public void setReportingPeriod( String reportingPeriod )
- {
- this.reportingPeriod = reportingPeriod;
- }
-
- private Integer organisationUnitId;
-
- public void setOrganisationUnitId( Integer organisationUnitId )
- {
- this.organisationUnitId = organisationUnitId;
- }
+ private String pe;
+ public void setPe( String pe )
+ {
+ this.pe = pe;
+ }
+
+ private String ou;
+
+ public void setOu( String ou )
+ {
+ this.ou = ou;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
- private Integer id;
-
- public void setId( Integer id )
+ private String uid;
+
+ public void setUid( String uid )
{
- this.id = id;
+ this.uid = uid;
}
private String type;
@@ -155,11 +155,11 @@
}
else
{
- ReportTable reportTable = reportTableService.getReportTable( id );
+ ReportTable reportTable = reportTableService.getReportTable( uid );
- Date date = reportingPeriod != null ? DateUtils.getMediumDate( reportingPeriod ) : new Date();
+ Date date = pe != null ? DateUtils.getMediumDate( pe ) : new Date();
- grid = reportTableService.getReportTableGrid( id, format, date, organisationUnitId );
+ grid = reportTableService.getReportTableGrid( uid, format, date, ou );
params.putAll( constantService.getConstantParameterMap() );
params.putAll( reportTable.getOrganisationUnitGroupMap( organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets() ) );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java 2012-04-23 09:35:01 +0000
@@ -71,16 +71,16 @@
// Input
// -------------------------------------------------------------------------
- private Integer id;
+ private String uid;
- public Integer getId()
+ public String getUid()
{
- return id;
+ return uid;
}
- public void setId( Integer id )
+ public void setUid( String uid )
{
- this.id = id;
+ this.uid = uid;
}
private String mode;
@@ -119,9 +119,9 @@
public String execute()
{
- if ( mode != null && id != null )
+ if ( mode != null && uid != null )
{
- ReportTable reportTable = reportTableService.getReportTable( id, mode);
+ ReportTable reportTable = reportTableService.getReportTable( uid, mode);
if ( reportTable != null )
{
=== 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 2012-04-12 12:39:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-04-23 09:35:01 +0000
@@ -164,11 +164,6 @@
<property name="reportService" ref="org.hisp.dhis.report.ReportService" />
</bean>
- <bean id="org.hisp.dhis.reporting.reportviewer.action.RenderReportAction" class="org.hisp.dhis.reporting.reportviewer.action.RenderReportAction"
- scope="prototype">
- <property name="reportService" ref="org.hisp.dhis.report.ReportService" />
- </bean>
-
<bean id="org.hisp.dhis.reporting.reportviewer.action.GetReportDesignAction" class="org.hisp.dhis.reporting.reportviewer.action.GetReportDesignAction"
scope="prototype">
<property name="reportService" ref="org.hisp.dhis.report.ReportService" />
=== 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-04-07 14:06:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2012-04-23 09:35:01 +0000
@@ -110,10 +110,6 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
- <action name="renderReport" class="org.hisp.dhis.reporting.reportviewer.action.RenderReportAction">
- <result name="success" type="outputStreamResult" />
- </action>
-
<action name="getReportDesign" class="org.hisp.dhis.reporting.reportviewer.action.GetReportDesignAction">
<result name="success" type="outputStreamResult" />
</action>
=== 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 2012-03-02 11:49:40 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm 2012-04-23 09:35:01 +0000
@@ -16,7 +16,7 @@
<h3>$i18n.getString( "report_table_parameters" )</h3>
-<input type="hidden" id="id" name="id" value="$!id" />
+<input type="hidden" id="uid" name="uid" value="$!uid" />
<input type="hidden" id="mode" name="mode" value="$!mode" />
<table>
=== 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-04-08 18:53:04 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js 2012-04-23 09:35:01 +0000
@@ -30,31 +30,32 @@
}
var mode = $( "#mode" ).val();
+ var uid = $( "#uid" ).val();
setMessage( i18n_process_completed );
if ( mode == MODE_REPORT )
{
- window.location.href = "renderReport.action?type=" + reportType + "&" + getUrlParams();
+ window.location.href = "../api/reports/" + uid + "/data." + type + "?" + getUrlParams();
}
else // MODE_TABLE
{
- window.location.href = "exportTable.action?type=html&" + getUrlParams();
+ window.location.href = "exportTable.action?uid=" + uid + "&type=html&" + getUrlParams();
}
}
function getUrlParams()
{
- var url = "id=" + $( "#id" ).val();
+ var url = "";
if ( $( "#reportingPeriod" ).length )
{
- url += "&reportingPeriod=" + $( "#reportingPeriod" ).val();
+ url += "pe=" + $( "#reportingPeriod" ).val() + "&";
}
if ( selectionTreeSelection.isSelected() )
{
- url += "&organisationUnitId=" + selectionTreeSelection.getSelected()[0];
+ url += "ou=" + selectionTreeSelection.getSelectedUid();
}
return url;
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm 2012-04-16 14:54:22 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewReportForm.vm 2012-04-23 09:35:01 +0000
@@ -36,8 +36,8 @@
<tr id="tr${report.id}">
<td>$encoder.htmlEncode( $report.name )</td>
<td style="text-align:right">
- #if ( $report.hasReportTable() ) <a href="getReportParams.action?id=${report.id}&mode=report" title="$i18n.getString( 'create' )">
- #else <a href="renderReport.action?id=${report.id}" title="$i18n.getString( 'create' )">#end
+ #if ( $report.hasReportTable() ) <a href="getReportParams.action?uid=${report.uid}&mode=report" title="$i18n.getString( 'create' )">
+ #else <a href="../api/reports/${report.uid}/data.pdf" title="$i18n.getString( 'create' )">#end
<img src="../images/start_process.png" alt="$i18n.getString( 'create' )"></a>
<a href="displayAddReportForm.action?id=$report.id" title="$i18n.getString( 'edit_report' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit_report' )"></a>
<a href="javascript:addToDashboard( '$report.id' )" title="$i18n.getString( 'add_to_dashboard' )"><img src="../images/add_to_dashboard.png" alt="$i18n.getString( 'add_to_dashboard' )"></a>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm 2012-04-16 14:54:22 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm 2012-04-23 09:35:01 +0000
@@ -38,7 +38,7 @@
<tr id="tr${table.id}">
<td onclick="showTableDetails( $table.id )">$encoder.htmlEncode( $table.name )</td>
<td style="text-align:right">
- <a href="getReportParams.action?id=$table.id&mode=table" title="$i18n.getString( "create" )"><img src="../images/start_process.png" alt="$i18n.getString( "create" )"></a>
+ <a href="getReportParams.action?uid=${table.uid}&mode=table" title="$i18n.getString( "create" )"><img src="../images/start_process.png" alt="$i18n.getString( "create" )"></a>
<a href="displayAddTableForm.action?id=${table.id}&dimension=${table.isDimensional()}" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
<a href="javascript:addReportTableToDashboard( '$table.id' )" title="$i18n.getString( 'add_to_dashboard' )"><img src="../images/add_to_dashboard.png" alt="$i18n.getString( 'add_to_dashboard' )"></a>
#if( $auth.hasAccess( "dhis-web-reporting", "removeTable" ) )