← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 262: Technical doc first release. Implemented export to excel for report table data.

 

------------------------------------------------------------
revno: 262
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-04-28 20:39:58 +0200
message:
  Technical doc first release. Implemented export to excel for report table data.
added:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/excel.png
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.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/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/xwork.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm
  docs/Technical Architecture DHIS 2.doc

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java	2009-04-24 14:44:38 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/WorkbookService.java	2009-04-28 18:39:58 +0000
@@ -45,7 +45,7 @@
 {
     String ID = WorkbookService.class.getName();
     
-    void writeReportTableData( OutputStream outputStream, int id );
+    String writeReportTableData( OutputStream outputStream, int id );
     
     void writeAllDataElements( OutputStream outputStream );
     

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java	2009-04-24 14:44:38 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/workbook/impl/JExcelWorkbookService.java	2009-04-28 18:39:58 +0000
@@ -114,7 +114,7 @@
     // WorkbookService implementation
     // -------------------------------------------------------------------------
 
-    public void writeReportTableData( OutputStream outputStream, int id )
+    public String writeReportTableData( OutputStream outputStream, int id )
     {
         ReportTableData data = reportTableService.getReportTableData( id );
         
@@ -166,6 +166,8 @@
         {
             throw new RuntimeException( "Failed to generate workbook for data elements", ex );
         }
+        
+        return data.getName();
     }
     
     public void writeAllDataElements( OutputStream outputStream )

=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/excel.png'
Binary files dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/excel.png	1970-01-01 00:00:00 +0000 and dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/images/excel.png	2009-04-28 18:39:58 +0000 differ
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GenerateTableDataWorkbookAction.java	2009-04-28 18:39:58 +0000
@@ -0,0 +1,99 @@
+package org.hisp.dhis.reporting.tablecreator.action;
+
+/*
+ * Copyright (c) 2004-2007, 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 java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.hisp.dhis.workbook.WorkbookService;
+
+import com.opensymphony.xwork.Action;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class GenerateTableDataWorkbookAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private WorkbookService workbookService;
+
+    public void setWorkbookService( WorkbookService workbookService )
+    {
+        this.workbookService = workbookService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private InputStream inputStream;
+
+    public InputStream getInputStream()
+    {
+        return inputStream;
+    }
+
+    private String fileName;
+
+    public String getFileName()
+    {
+        return fileName;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        
+        fileName = workbookService.writeReportTableData( out, id );
+
+        inputStream = new ByteArrayInputStream( out.toByteArray() );
+                
+        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	2009-04-24 14:44:38 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml	2009-04-28 18:39:58 +0000
@@ -259,6 +259,13 @@
       ref="org.hisp.dhis.importexport.ImportExportServiceManager"/>
   </bean>
   
+  <bean id="org.hisp.dhis.reporting.tablecreator.action.GenerateTableDataWorkbookAction"
+    class="org.hisp.dhis.reporting.tablecreator.action.GenerateTableDataWorkbookAction"
+    scope="prototype">
+    <property name="workbookService"
+      ref="org.hisp.dhis.workbook.WorkbookService"/>
+  </bean>
+  
   <!-- ReportViewer -->
   
   <bean id="org.hisp.dhis.reporting.reportviewer.action.AddReportAction"

=== 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	2009-04-16 09:53:17 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2009-04-28 18:39:58 +0000
@@ -242,3 +242,4 @@
 url = URL
 type = Type
 export_to_csv = Export to CSV
+export_to_excel = Export to Excel

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/xwork.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/xwork.xml	2009-04-24 12:42:45 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/xwork.xml	2009-04-28 18:39:58 +0000
@@ -235,6 +235,15 @@
       </result>
     </action>
     
+    <action name="generateTableDataWorkbook" class="org.hisp.dhis.reporting.tablecreator.action.GenerateTableDataWorkbookAction">
+      <result name="success" type="stream">
+        <param name="contentType">application/vnd.ms-excel</param>
+        <param name="inputName">inputStream</param>
+        <param name="contentDisposition">filename="${fileName}"</param>
+        <param name="bufferSize">10240</param>
+      </result>
+    </action>
+    
     <!-- PivotTable -->
     
     <action name="displayPivotTableForm" class="org.hisp.dhis.reporting.action.NoAction">

=== 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	2009-04-16 09:53:17 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewTableForm.vm	2009-04-28 18:39:58 +0000
@@ -12,8 +12,9 @@
                 <col width="20">
 				<col width="20">
                 <col width="20">
+                <col width="20">
 		        <tr>
-                    <td colspan="6" style="text-align:right">
+                    <td colspan="7" style="text-align:right">
                     	<input type="button" value="$i18n.getString( 'add_indicator_reporttable' )" style="width:250px" onclick="window.location.href='displayAddTableForm.action?mode=indicators'"><br>
                     	<input type="button" value="$i18n.getString( 'add_dataelement_reporttable' )" style="width:250px" onclick="window.location.href='displayAddTableForm.action?mode=dataelements'"><br>
                         <input type="button" value="$i18n.getString( 'add_dataelement_category_reporttable' )" style="width:250px" onclick="window.location.href='displayAddTableForm.action?mode=dataelements&category=true'"><br>
@@ -22,7 +23,7 @@
                 </tr>
 				<tr>
 					<th>$i18n.getString( "name" )</th>
-					<th colspan="5">$i18n.getString( "operations" )</th>
+					<th colspan="6">$i18n.getString( "operations" )</th>
 				</tr>
 				#set( $mark = false )
 				#foreach ( $table in $tables )
@@ -30,6 +31,7 @@
 					<td#alternate( $mark )>$encoder.htmlEncode( $table.name )</td>
 					<td style="text-align:center"#alternate( $mark )><a href="getReportParams.action?id=$table.id&mode=table" title="$i18n.getString( "create" )"><img src="../images/start_process.png" alt="$i18n.getString( "create" )"></a></td>
                     <td style="text-align:center"#alternate( $mark )><a href="displayAddTableForm.action?id=$table.id&mode=$table.mode&category=$table.hasCategoryOptionCombos()" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a></td>
+                    <td style="text-align:center"#alternate( $mark )><a href="generateTableDataWorkbook.action?id=$table.id" title="$i18n.getString( "export_to_excel" )"><img src="../images/excel.png" alt="$i18n.getString( "export_to_excel" )"></a></td>
                     <td style="text-align:center"#alternate( $mark )><a href="getTableDataExport.action?id=$table.id&exportFormat=CSV" title="$i18n.getString( "export_to_csv" )"><img src="../images/csv.png" alt="$i18n.getString( "export_to_csv" )"></a></td>
                     <td style="text-align:center"#alternate( $mark )><a href="javascript:removeTable( $table.id, '$encoder.jsEncode( $table.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a></td>
 					<td style="text-align:center"#alternate( $mark )><a href="javascript:showTableDetails( $table.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a></td>

=== modified file 'docs/Technical Architecture DHIS 2.doc'
Binary files docs/Technical Architecture DHIS 2.doc	2009-04-27 13:27:32 +0000 and docs/Technical Architecture DHIS 2.doc	2009-04-28 18:39:58 +0000 differ


--
Trunk
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.