← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8008: iReport in CCEM

 

------------------------------------------------------------
revno: 8008
committer: Samta <samta-bajpayee@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-09-06 08:02:12 +0100
message:
  iReport in CCEM
modified:
  local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java
  local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties
  local/in/dhis-web-coldchain/src/main/resources/struts.xml
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm
  local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.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 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java'
--- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java	2012-08-17 10:21:10 +0000
+++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/reports/action/GenerateJRXMLReportAction.java	2012-09-06 07:02:12 +0000
@@ -203,53 +203,12 @@
     }
 
     // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private Grid grid;
-
-    public Grid getGrid()
-    {
-        return grid;
-    }
-
-    private Map<String, Object> params = new HashMap<String, Object>();
-
-    public Map<String, Object> getParams()
-    {
-        return params;
-    }
-
-    // -------------------------------------------------------------------------
     // Result implementation
     // -------------------------------------------------------------------------
-    private InputStream fileStream;
-
-    public void setFileStream( InputStream arg )
-    {
-        fileStream = arg;
-    }
-
-    public InputStream getFileStream()
-    {
-        return fileStream;
-    }
-
-    private String ReportPath;
-
-    public String getReportPath()
-    {
-        return ReportPath;
-    }
-
-    public void setReportPath( String reportPath )
-    {
-        ReportPath = reportPath;
-    }
-
+  
     @Override
     public String execute()
-        throws Exception
+        throws Exception,JRException 
     {
         Connection con = jdbcTemplate.getDataSource().getConnection();
         String fileName = null;
@@ -260,8 +219,7 @@
         String orgUnitIdsByComma = ccemReportManager.getOrgunitIdsByComma( selOrgUnitList, orgunitGroupList );
         ccemReport = ccemReportManager.getCCEMReportByReportId( reportList );
         Map<String, String> ccemSettingsMap = new HashMap<String, String>( ccemReportManager.getCCEMSettings() );
-        List<CCEMReportDesign> reportDesignList = new ArrayList<CCEMReportDesign>( ccemReportManager
-            .getCCEMReportDesign( ccemReport.getXmlTemplateName() ) );
+        List<CCEMReportDesign> reportDesignList = new ArrayList<CCEMReportDesign>( ccemReportManager.getCCEMReportDesign( ccemReport.getXmlTemplateName() ) );
 
         String oName = null;
         String oUnitGrpName = null;
@@ -362,8 +320,7 @@
             jasperPrint = JasperFillManager.fillReport( jasperReport, hash, con );
         }
         else if ( ccemReport.getReportType().equals( CCEMReport.ORGUNITGROUP_DATAVALUE ) )
-        {
-            ccemReportOutput = new CCEMReportOutput();
+        {            
             List<String> tableHeadings = new ArrayList<String>();
             List<List<String>> tableSubHeadings = new ArrayList<List<String>>();
             List tableData = new ArrayList();
@@ -476,6 +433,7 @@
                 }
             }
             frb.setTemplateFile( path + "ORGUNITGROUP_DATAVALUE.jrxml" );
+            frb.setPrintBackgroundOnOddRows(true);
             for ( Integer orgUnitGroupId : orgunitGroupList )
             {
                 Map numberOfData = new HashMap();
@@ -513,7 +471,7 @@
 
             JRDataSource ds = new JRMapCollectionDataSource( tableData );
             DynamicReport dynamicReport = frb.build();
-            dynamicReport.getOptions().getDefaultDetailStyle().setBackgroundColor( Color.BLUE );
+            dynamicReport.getOptions().getOddRowBackgroundStyle().setBackgroundColor( Color.decode( "#F5F5F6" ) );
             dynamicReport.getOptions().getDefaultHeaderStyle().setBorder( Border.THIN() );
             dynamicReport.getOptions().getDefaultHeaderStyle().setHorizontalAlign( HorizontalAlign.CENTER );
             dynamicReport.getOptions().getDefaultDetailStyle().setBorder( Border.THIN() );
@@ -524,8 +482,7 @@
         }
 
         else if ( ccemReport.getReportType().equals( CCEMReport.ORGUNIT_EQUIPMENT_ROUTINE_DATAVALUE ) )
-        {
-            ccemReportOutput = new CCEMReportOutput();
+        {            
             List<String> tableHeadings = new ArrayList<String>();
             List<List<String>> tableSubHeadings = new ArrayList<List<String>>();
             List<String> oneSubHeadingRow = new ArrayList<String>();
@@ -707,8 +664,7 @@
 
             for ( OrganisationUnit orgUnit : orgUnitList )
             {
-                Map<String, String> numberOfData = new HashMap<String, String>();
-                List<String> oneTableDataRow = new ArrayList<String>();
+                Map<String, String> numberOfData = new HashMap<String, String>();               
                 String orgUnitBranch = "";
                 if ( orgUnit.getParent() != null )
                 {
@@ -725,8 +681,7 @@
                 for ( CCEMReportDesign ccemReportDesign1 : reportDesignList )
                 {
                     String ccemCellContent1 = ccemSettingsMap.get( ccemReportDesign1.getContent() );
-                    Integer dataElementId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );
-                    Integer optComboId = Integer.parseInt( ccemCellContent1.split( ":" )[1] );
+                    Integer dataElementId = Integer.parseInt( ccemCellContent1.split( ":" )[0] );                    
 
                     for ( Period period : periodList )
                     {
@@ -748,9 +703,10 @@
             }
 
             frb.setTemplateFile( path + "ORGUNIT_EQUIPMENT_ROUTINE_DATAVALUE.jrxml" );
+            frb.setPrintBackgroundOnOddRows(true);
             JRDataSource ds = new JRMapCollectionDataSource( tableData );
             DynamicReport dynamicReport = frb.build();
-            dynamicReport.getOptions().getDefaultDetailStyle().setBackgroundColor( Color.BLUE );
+            dynamicReport.getOptions().getOddRowBackgroundStyle().setBackgroundColor( Color.decode( "#F5F5F6" ) );
             dynamicReport.getOptions().getDefaultHeaderStyle().setBorder( Border.THIN() );
             dynamicReport.getOptions().getDefaultHeaderStyle().setHorizontalAlign( HorizontalAlign.CENTER );
             dynamicReport.getOptions().getDefaultDetailStyle().setBorder( Border.THIN() );
@@ -760,18 +716,11 @@
             jasperPrint = JasperFillManager.fillReport( jr, hash, ds );
         }
         else if ( ccemReport.getReportType().equals( CCEMReport.VACCINE_STORAGE_CAPACITY ) )
-        {
-            ccemReportOutput = new CCEMReportOutput();
-            List<String> tableHeadings = new ArrayList<String>();
-            List<List<String>> tableSubHeadings = new ArrayList<List<String>>();
-            List<String> oneSubHeadingRow = new ArrayList<String>();
+        {            
             List tableData = new ArrayList();
-
             List<OrganisationUnit> orgUnitList = new ArrayList<OrganisationUnit>();
-            List<OrganisationUnit> orgUnitGroupMembers = new ArrayList<OrganisationUnit>();
-            List<String> content = new ArrayList<String>();
-            String orgUnitGroupIdsByComma = "-1";
-            Map<String, Integer> subHeadingNumber = new HashMap<String, Integer>();
+            List<OrganisationUnit> orgUnitGroupMembers = new ArrayList<OrganisationUnit>();            
+            String orgUnitGroupIdsByComma = "-1";           
             Integer periodId = 0;
             Date date2 = new Date();
             Calendar calendar = Calendar.getInstance();
@@ -1112,12 +1061,7 @@
                         System.out.println( "Exception while calculating individualVaccineRequirement" );
                         individualVaccineRequirement = 0.0;
                     }
-
-                    // System.out.println( vsReqUsageData
-                    // +":"+vsReqTargetPopData +":"+vsReqDosesData
-                    // +":"+vsReqPackedVolData +":"+ vsReqWastageData +":"+
-                    // vsReqSupplyIntervalData +":"+ vsReqReserveStockData );
-
+                    
                     vaccineRequirement += individualVaccineRequirement;
 
                 }
@@ -1177,15 +1121,14 @@
             frb.setPrintColumnNames( true );
             frb.setHeaderHeight( 100 );
             frb.setColumnsPerPage( 1, 15 ).setUseFullPageWidth( true );
+            frb.setPrintBackgroundOnOddRows(true);
             frb.setTemplateFile( path + "VACCINE_STORAGE_CAPACITY.jrxml" );
-            Style oddRowStyle = new Style();
-            oddRowStyle.setBorder( Border.NO_BORDER() );
-            oddRowStyle.setBackgroundColor( Color.LIGHT_GRAY );
-            oddRowStyle.setTransparency( Transparency.OPAQUE );
+            
             JRDataSource ds = new JRMapCollectionDataSource( tableData );
-            frb.setOddRowBackgroundStyle( oddRowStyle );
             DynamicReport dynamicReport = frb.build();
             dynamicReport.getOptions().getDefaultHeaderStyle().setBorder( Border.THIN() );
+            //Color.LIGHT_GRAY
+            dynamicReport.getOptions().getOddRowBackgroundStyle().setBackgroundColor( Color.decode( "#F5F5F6" ) );
             dynamicReport.getOptions().getDefaultHeaderStyle().setHorizontalAlign( HorizontalAlign.CENTER );
             dynamicReport.getOptions().getDefaultDetailStyle().setBorder( Border.THIN() );
             dynamicReport.getOptions().getDefaultDetailStyle().setHorizontalAlign( HorizontalAlign.CENTER );
@@ -1201,7 +1144,6 @@
         {
             response.setContentType( "application/pdf" );
             response.setHeader( "Content-Disposition", "inline; fileName=\"file.pdf\"" );
-
             exporter = new JRPdfExporter();
             exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
             exporter.setParameter( JRExporterParameter.OUTPUT_STREAM, ouputStream );
@@ -1220,14 +1162,13 @@
             exporter = new JRHtmlExporter();
             exporter.setParameter( JRHtmlExporterParameter.OUTPUT_STREAM, false );
             exporter.setParameter( JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean( false ) );
-
             exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
             exporter.setParameter( JRExporterParameter.OUTPUT_STREAM, ouputStream );
         }
         else if ( "xls".equalsIgnoreCase( type ) )
         {
             response.setContentType( "application/xls" );
-            response.setHeader( "Content-Disposition", "attachment; fileName=\"file.xls\"" );
+            response.setHeader( "Content-Disposition", "inline; fileName=\"file.xls\"" );
 
             exporter = new JRXlsExporter();
             exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
@@ -1242,7 +1183,7 @@
             exporter.setParameter( JRExporterParameter.JASPER_PRINT, jasperPrint );
             exporter.setParameter( JRExporterParameter.OUTPUT_STREAM, ouputStream );
         }
-        con.close();
+        con.close();       
         try
         {
             exporter.exportReport();
@@ -1251,20 +1192,7 @@
         {
             throw new ServletException( e );
         }
-        finally
-        {
-            if ( ouputStream != null )
-            {
-                try
-                {
-                    ouputStream.close();
-                }
-                catch ( IOException ex )
-                {
-                    System.out.println( "exception thrown" );
-                }
-            }
-        }
+        
         return SUCCESS;
     }
 

=== modified file 'local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties'
--- local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties	2012-08-01 12:21:34 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties	2012-09-06 07:02:12 +0000
@@ -143,4 +143,12 @@
 orgunit_group_list = Orgunit Group List
 selected_orgunit_list = Selected Orgunit List
 generate = Generate
-orgunit_tree = Orgunit Tree
\ No newline at end of file
+orgunit_tree = Orgunit Tree
+jrxml_reports = JRXML Report
+output_type = Output type
+rtf = RTF
+html = HTML
+xls = XLS
+csv = CSV
+text = TEXT
+pdf = PDF
\ No newline at end of file

=== modified file 'local/in/dhis-web-coldchain/src/main/resources/struts.xml'
--- local/in/dhis-web-coldchain/src/main/resources/struts.xml	2012-08-17 10:21:10 +0000
+++ local/in/dhis-web-coldchain/src/main/resources/struts.xml	2012-09-06 07:02:12 +0000
@@ -582,7 +582,7 @@
 	<action name="jrxmlReportsPage" class="org.hisp.dhis.coldchain.reports.action.CCEMReportPageAction">
         <result name="success" type="velocity">/main.vm</result>
         <param name="page">/dhis-web-coldchain/jrxmlReportsPage.vm</param>
-        <param name="menu">/dhis-web-coldchain/ccemReportMenu.vm</param>
+        <param name="menu">/dhis-web-coldchain/jrxmlReportMenu.vm</param>
         <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/ccemReports.js</param>
         <interceptor-ref name="organisationUnitTreeStack" />
     </action>
@@ -610,8 +610,11 @@
     </action>-->
 	
 	<action name="exportTable" class="org.hisp.dhis.coldchain.reports.action.GenerateJRXMLReportAction">     
-			<result name="success" type="redirect">jrxmlReportsPage.action</result>			  
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="menu">/dhis-web-coldchain/menu.vm</param>
+			<param name="page">/dhis-web-coldchain/welcome.vm</param>		  
     </action>
 		
+	
 </package>
 </struts>
\ No newline at end of file

=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm	2012-08-17 10:21:10 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/jrxmlReportsPage.vm	2012-09-06 07:02:12 +0000
@@ -1,13 +1,11 @@
-<script src="javascript/highcharts.js"></script>
-<script src="javascript/exporting.js"></script>
 <!--
 <script>
     leftBar.hideAnimated();
 </script>
 -->
-<h3>$i18n.getString( "ccem_reports_page" )</h3>
+<h3>$i18n.getString( "jrxml_reports" )</h3>
 
-<form id="ccemReportForm" name="ccemReportForm" >
+<form id="ccemReportForm" name="ccemReportForm" action="exportTable.action" method="post" target="_blank">
 	#foreach( $ccemReport in $reportList )
 		<input type="hidden" id="$ccemReport.reportId" value="$ccemReport.periodRequire" />
     #end
@@ -18,7 +16,7 @@
 					<tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "orgunit_tree" )</strong></td></tr>
 					<tr><td><div style="height:450px;width:200px;overflow:auto;">#parse( "/dhis-web-commons/ouwt/orgunittree.vm" )</div></td></tr>
 				</table>
-			</td>-->			
+			</td>-->		
 			<td>				
 				<table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
                     <tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "ccem_reports_list" )</strong></td></tr>
@@ -37,10 +35,10 @@
                     <tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "ccem_reports_period_list" ):</strong></td></tr>
 					<tr>			
                         <td>
-							<input type="radio" id="periodRadio" name="periodRadio" value="LAST_3_MONTHS" disabled />$i18n.getString( "last_3months" )
-							<input type="radio" id="periodRadio" name="periodRadio" value="CURRENT_YEAR" disabled />$i18n.getString( "current_year" )<br/>
-							<input type="radio" id="periodRadio" name="periodRadio" value="LAST_6_MONTHS" disabled />$i18n.getString( "last_6months" )							
-                            <input type="radio" id="periodRadio" name="periodRadio" value="LAST_YEAR" disabled />$i18n.getString( "last_year" )
+							<input type="radio" id="periodRadio" name="periodRadio" value="LAST_3_MONTHS" disabled /><strong>$i18n.getString( "last_3months" )</strong>
+							<input type="radio" id="periodRadio" name="periodRadio" value="CURRENT_YEAR" disabled /><strong>$i18n.getString( "current_year" )</strong><br/>
+							<input type="radio" id="periodRadio" name="periodRadio" value="LAST_6_MONTHS" disabled /><strong>$i18n.getString( "last_6months" )</strong>							
+                            <input type="radio" id="periodRadio" name="periodRadio" value="LAST_YEAR" disabled /><strong>$i18n.getString( "last_year" )</strong>
                         </td>
                     </tr>
                     <tr>
@@ -68,16 +66,16 @@
                     <tr>
                         <td>&nbsp;</td>
                     </tr>
-                    <tr style="background-color: #C0C0C0;"><td><strong>Report Type</td></tr>
+                    <tr style="background-color: #C0C0C0;"><td><strong>$i18n.getString( "output_type" )</td></tr>
                     <tr>
                         <td>        
-                            <select name="type" id="type">                            	
-                                <option>pdf</option>	
-                                <option>rtf</option>
-                                <option>html</option>
-                                <option>xls</option>
-                                <option>csv</option>
-                                <option>text</option>
+                            <select name="type" id="type" style="width:200px;">
+                            	<option value="pdf">$i18n.getString( "pdf" )</option>
+                                <option value="rtf">$i18n.getString( "rtf" )</option>
+                                <option value="html">$i18n.getString( "html" )</option>
+                                <option value="xls">$i18n.getString( "xls" )</option>
+                                <option value="csv">$i18n.getString( "csv" )</option>
+                                <option value="text">$i18n.getString( "text" )</option>
                             </select>
                         </td>
                     </tr>   
@@ -92,11 +90,16 @@
                 </table>
 			</td>
 			<td>
-				<!-- <table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
-					<tr><td><div>#parse( "/dhis-web-commons/loader/loader.vm" )</div>
-						<div id="resultContent"> </div></td>
-					</tr>
-				</table> -->
+				<!--<table style="border-collapse: collapse;border-style: solid;border-width: 1px;">
+					<tr><td><div>#parse( "/dhis-web-commons/loader/loader.vm" )</div>
+						<div id="resultContent"> </div></td>
+					</tr>
+				</table>-->
+				<table>
+					<tr><td><div>#parse( "/dhis-web-commons/loader/loader.vm" )</div>
+						<div id="resultContent"> </div></td>
+					</tr>
+				</table>							
 			</td>
 		</tr>
 	</table>	

=== modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm'
--- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm	2012-07-24 05:31:29 +0000
+++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/menu.vm	2012-09-06 07:02:12 +0000
@@ -20,5 +20,5 @@
 <h2>$i18n.getString( "ccem_reports" )</h2>
 <ul>
 	<li><a href="ccemReportsPage.action">$i18n.getString( "ccem_reports_page" )</a></li> 
-	<li><a href="jrxmlReportsPage.action">JRXML Report</a></li>   
+	<li><a href="jrxmlReportsPage.action">$i18n.getString( "jrxml_reports" )</a></li>   
 </ul>