dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16947
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6593: Merge MD Report of local/in from 2.7 to trunk
------------------------------------------------------------
revno: 6593
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-04-16 14:17:07 +0530
message:
Merge MD Report of local/in from 2.7 to trunk
modified:
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/MDReportFormAction.java
local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml
local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties
local/in/dhis-web-reports-national/src/main/resources/struts.xml
local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/mdReportForm.vm
local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menuWithTreeForMDReport.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-reports-national/src/main/java/org/hisp/dhis/reports/md/action/MDReportFormAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/MDReportFormAction.java 2011-12-14 11:06:08 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/MDReportFormAction.java 2012-04-16 08:47:07 +0000
@@ -1,5 +1,6 @@
package org.hisp.dhis.reports.md.action;
+import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
@@ -7,11 +8,21 @@
import java.util.Iterator;
import java.util.List;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.comparator.PeriodComparator;
+import org.hisp.dhis.reports.ReportOption;
+import org.hisp.dhis.reports.ReportService;
import org.hisp.dhis.reports.ReportType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
import com.opensymphony.xwork2.Action;
@@ -27,7 +38,14 @@
{
this.periodService = periodService;
}
+
+ private ReportService reportService;
+ public void setReportService( ReportService reportService )
+ {
+ this.reportService = reportService;
+ }
+
//--------------------------------------------------------------------------
//Input/Output
//--------------------------------------------------------------------------
@@ -53,10 +71,6 @@
return periodTypeName;
}
- //--------------------------------------------------------------------------
- // Action Implementation
- //--------------------------------------------------------------------------
-
private SimpleDateFormat simpleDateFormat;
public SimpleDateFormat getSimpleDateFormat()
@@ -64,11 +78,28 @@
return simpleDateFormat;
}
+ private List<ReportOption> reportOptionList;
+
+ public List<ReportOption> getReportOptionList()
+ {
+ return reportOptionList;
+ }
+
+ private String raFolderName;
+
+ //--------------------------------------------------------------------------
+ // Action Implementation
+ //--------------------------------------------------------------------------
+
+
+
public String execute() throws Exception
{
reportTypeName = ReportType.RT_MD_REPORT;
periodTypeName = MonthlyPeriodType.NAME;
+ raFolderName = reportService.getRAFolderName();
+
//period information
periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( new MonthlyPeriodType() ) );
@@ -85,8 +116,72 @@
}
simpleDateFormat = new SimpleDateFormat( "MMM-yy" );
Collections.sort( periods, new PeriodComparator() );
+ reportOptionList = new ArrayList<ReportOption>( getReportOptions() );
+
return SUCCESS;
}
-
+ private List<ReportOption> getReportOptions( )
+ {
+ List<ReportOption> reportOptionList = new ArrayList<ReportOption>();
+
+ String newpath = "";
+ try
+ {
+ newpath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + "mdreport.xml";
+ }
+ catch ( NullPointerException npe )
+ {
+ System.out.println("DHIS_HOME is not set");
+ return null;
+ }
+
+ try
+ {
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+ Document doc = docBuilder.parse( new File( newpath ) );
+ if ( doc == null )
+ {
+ System.out.println( "There is no MAP XML file in the DHIS2 Home" );
+ return null;
+ }
+
+ NodeList listOfOption = doc.getElementsByTagName( "option" );
+ int totalOptions = listOfOption.getLength();
+
+ for( int s = 0; s < totalOptions; s++ )
+ {
+ Element element = (Element) listOfOption.item( s );
+ String optiontext = element.getAttribute( "optiontext" );
+ String optionvalue = element.getAttribute( "optionvalue" );
+
+ optionvalue += "#@#" + optiontext;
+ if( optiontext != null && optionvalue != null )
+ {
+ ReportOption reportOption = new ReportOption( optiontext, optionvalue );
+ reportOptionList.add( reportOption );
+ }
+ }// end of for loop with s var
+ }// try block end
+ catch ( SAXParseException err )
+ {
+ System.out.println( "** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId() );
+ System.out.println( " " + err.getMessage() );
+ return null;
+ }
+ catch ( SAXException e )
+ {
+ Exception x = e.getException();
+ ((x == null) ? e : x).printStackTrace();
+ return null;
+ }
+ catch ( Throwable t )
+ {
+ t.printStackTrace();
+ return null;
+ }
+
+ return reportOptionList;
+ }
}
=== modified file 'local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml'
--- local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml 2012-04-04 11:58:27 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml 2012-04-16 08:47:07 +0000
@@ -232,7 +232,25 @@
class="org.hisp.dhis.reports.md.action.MDReportFormAction"
scope="prototype">
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+ <property name="reportService" ref="org.hisp.dhis.reports.ReportService" />
</bean>
+
+ <bean id="org.hisp.dhis.reports.md.action.GetOrgUnitsAction"
+ class="org.hisp.dhis.reports.md.action.GetOrgUnitsAction"
+ scope="prototype">
+ <property name="reportService" ref="org.hisp.dhis.reports.ReportService" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.reports.md.action.MDReportResultAction"
+ class="org.hisp.dhis.reports.md.action.MDReportResultAction"
+ scope="prototype">
+ <property name="statementManager" ref="statementManager"/>
+ <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+ <property name="reportService" ref="org.hisp.dhis.reports.ReportService" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ </bean>
+
<bean id="org.hisp.dhis.reports.md.action.GenerateMDReportAnalyserResultAction"
class="org.hisp.dhis.reports.md.action.GenerateMDReportAnalyserResultAction"
scope="prototype">
=== modified file 'local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties'
--- local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties 2012-04-04 11:58:27 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties 2012-04-16 08:47:07 +0000
@@ -331,4 +331,6 @@
patient_system_id = System generated ID
attributes = Attributes
no_xls_xml = There is no xml and xls template for selected program
-in_selected_orgU = In Selected Organisation Unit
\ No newline at end of file
+in_selected_orgU = In Selected Organisation Unit
+available_delist = Available dataelements
+selected_delist = Selected dataelements
\ No newline at end of file
=== modified file 'local/in/dhis-web-reports-national/src/main/resources/struts.xml'
--- local/in/dhis-web-reports-national/src/main/resources/struts.xml 2012-04-04 11:58:27 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/struts.xml 2012-04-16 08:47:07 +0000
@@ -224,11 +224,12 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-reports/mdReportForm.vm</param>
<param name="menu">/dhis-web-reports/menuWithTreeForMDReport.vm</param>
- <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/lists/lists.js,javascript/reportManagement.js,javascript/hashtable.js</param>
+ <param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/lists/lists.js,javascript/mdReport.js,javascript/hashtable.js</param>
<param name="stylesheets">css/StylesForTags.css</param>
<param name="requiredAuthorities">F_MDREPORT_GENERATE</param>
<interceptor-ref name="organisationUnitTreeStack"/>
- </action>
+ </action>
+ <!--
<action name="generateMDReport"
class="org.hisp.dhis.reports.md.action.GenerateMDReportAnalyserResultAction">
<result name="success" type="stream">
@@ -238,7 +239,23 @@
<param name="bufferSize">1024</param>
</result>
</action>
-
+ -->
+ <action name="generateMDReport"
+ class="org.hisp.dhis.reports.md.action.MDReportResultAction">
+ <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">1024</param>
+ </result>
+ </action>
+
+ <action name="getOrgUnitDetailsForMDReport"
+ class="org.hisp.dhis.reports.md.action.GetOrgUnitsAction">
+ <result name="success" type="velocity-xml">/dhis-web-reports/responseOrgunit_md.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
<!-- Auto Reports -->
<action name="autoReportAnalyser"
class="org.hisp.dhis.reports.auto.action.GenerateAutoReportAnalyserFormAction">
=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/mdReportForm.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/mdReportForm.vm 2011-12-14 11:06:08 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/mdReportForm.vm 2012-04-16 08:47:07 +0000
@@ -1,102 +1,132 @@
-<script>
- function formValidationsForMDReport()
- {
- var reportList = document.getElementById("reportList");
- var reportListIndex = reportList.selectedIndex;
- var ouIdTb = document.getElementById("ouIDTB");
- var orgunitIdValue = ouIdTb.value;
-
- if( orgunitIdValue == null || orgunitIdValue == "" || orgunitIdValue == " " )
- {
- alert("Please Select OrganisationUnit");
- return false;
- }
- else if( reportListIndex < 0 || reportList.options[reportListIndex].text == null )
- {
- alert("Please Select Report");
- return false;
- }
-
- return true;
- }
-</script>
+<style>
+ #overlay {
+ z-index:9998;
+ position:absolute;
+ top:0;
+ bottom:0;
+ left:0;
+ width:100%;
+ background:#000;
+ opacity:0.45;
+ -moz-opacity:0.45;
+ filter:alpha(opacity=45);
+ visibility:hidden;
+ }
+ #overlayImg{ width: 50px; height: 50px; z-index: 9999; position: absolute; left:50%}
+</style>
+<div id="overlay">
+ <div id="overlayImg"><img width="50" height="50" src="images/ajax-loader.gif" /></div>
+</div>
<h1>$i18n.getString( "md_report_ra" )</h1>
<hr /><br />
-<form id="reportForm" name="reportForm" action="generateMDReport.action" method="post" onsubmit="return formValidationsForMDReport()" target="_blank">
- <table align="center" style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" width="70%" border=0>
- <tr>
- <td class="NormalB">
- 1.$i18n.getString( "organisationunit" ) :<br />
- <input type="text" name="ouNameTB" id="ouNameTB" style="width:200px" disabled>
- </td>
- <td class="NormalB">
- 3.From Date : <br />
- <select id="selectedStartPeriodId" name="selectedStartPeriodId" style="width:200px">
- #foreach ( $mperiod in $periods )
- <option value="$mperiod.id">$simpleDateFormat.format( $mperiod.startDate )</option>
- #end
- </select>
- </td>
- </tr>
- <tr>
- <td>
- <select id="periodTypeId" name="periodTypeId" style="display:none">
- <option value="$periodTypeName">$periodTypeName</option>
- </select>
- </td>
- <td> </td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td class="NormalB">
- 2. $i18n.getString( "reports" ) :<br />
- <select id="reportList" name="reportList" style="width:200px"></select>
- </td>
- <td class="NormalB">
- 4.To Date : <br />
- <select id="selectedEndPeriodId" name="selectedEndPeriodId" style="width:200px">
- #foreach ( $mperiod in $periods )
- <option value="$mperiod.id">$simpleDateFormat.format( $mperiod.startDate )</option>
- #end
- </select>
- </td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td class="NormalB">
- 5.$i18n.getString( "generated_data_type" ) :<br />
- <select id="aggData" name="aggData" style="width:200px">
- <option value="generateaggdata">$i18n.getString( "generate_agg_data" )</option>
- <option value="useexistingaggdata">$i18n.getString( "use_existing_agg_data" )</option>
- <option value="usecaptureddata" selected>$i18n.getString( "use_captured_data" )</option>
- </select>
- </td>
- </tr>
- </tr>
- <tr>
- <td> </td><td> </td>
- </tr>
- <tr>
- <td> </td><td> </td>
- </tr>
- <tr>
- <td class="NormalB">
- <input type="submit" name="generate" value="$i18n.getString( "generate_report" )" />
- <input type="hidden" name="autogen" id="autogen" value="0" >
- <input type="hidden" name="ouIDTB" id="ouIDTB">
- <input type="hidden" name="ouLevelTB" id="ouLevelTB">
- <input type="hidden" name="reportTypeNameTB" id="reportTypeNameTB" value="$reportTypeName">
- </td>
- </tr>
- </table>
- </form>
\ No newline at end of file
+<form id="reportForm" name="reportForm" action="generateMDReport.action" method="post" onSubmit="return formValidationsForMDReport()" target="_blank">
+
+ <table style=" border-collapse: collapse; margin-top: 0;" cellpadding="0" cellspacing="0" border=0 width="75%" align="center">
+ <tr>
+ <td width="37%" class="NormalB">
+ $i18n.getString( "filter" ):
+ <input type="text" id="availableDataElementsFilter" onKeyUp="filterAvailableDataElements()" style="min-width:24em">
+ </td>
+ <td width="11%" class="NormalB"> </td>
+ <td width="52%" class="NormalB"> </td>
+ </tr>
+ <tr>
+ <td class="NormalB"> </td>
+ <td class="NormalB"> </td>
+ <td class="NormalB"> </td>
+ </tr>
+
+ <tr>
+ <td class="NormalB">$i18n.getString( "available_delist" )<br>
+ <select multiple size="7" id="availableDataElements" name="availableDataElements" style="width:325px; height:100px" ondblclick="moveSelectedById( 'availableDataElements', 'selectedDataElements' )">
+ #foreach ( $reportOption in $reportOptionList )
+ <option value="$reportOption.optionValue" title="$reportOption.optionText">$reportOption.optionText</option>
+ #end
+ </select>
+ </td>
+ <td class="NormalB" align="center"><br />
+ <input type="button" value=">" style="width:40px" onClick="moveSelectedById( 'availableDataElements', 'selectedDataElements' )"> <br />
+ <input type="button" value="<" style="width:40px" onClick="moveSelectedById( 'selectedDataElements', 'availableDataElements' )"> <br />
+ <input type="button" value=">>" style="width:40px" onClick="moveAllById( 'availableDataElements', 'selectedDataElements' )"> <br />
+ <input type="button" value="<<" style="width:40px" onClick="moveAllById( 'selectedDataElements', 'availableDataElements' )">
+ </td>
+ <td class="NormalB"> $i18n.getString( "selected_delist" )<br />
+ <select multiple size="7" id="selectedDataElements" name="selectedDataElements" style="width:350px; height:100px" ondblclick="moveSelectedById( 'selectedDataElements', 'availableDataElements' )">
+ </select>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="NormalB">
+ $i18n.getString( "organisationunit" ) :<br />
+ <input type="text" name="ouNameTB" id="ouNameTB" style="width:320px" disabled>
+ <br/>
+ <select name="orgUnitLevelCB" id="orgUnitLevelCB" size="7" style="width: 325px;"></select>
+ </td>
+ <td> </td>
+ <td class="NormalB">
+ <table>
+ <tr>
+ <td>
+ From Date : <br />
+ <select id="selectedStartPeriodId" name="selectedStartPeriodId" style="width:175px">
+ #foreach ( $mperiod in $periods )
+ <option value="$mperiod.id">$simpleDateFormat.format( $mperiod.startDate )</option>
+ #end
+ </select>
+ </td>
+ <td class="NormalB">
+ To Date : <br />
+ <select id="selectedEndPeriodId" name="selectedEndPeriodId" style="width:145px">
+ #foreach ( $mperiod in $periods )
+ <option value="$mperiod.id">$simpleDateFormat.format( $mperiod.startDate )</option>
+ #end
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>
+ $i18n.getString( "generated_data_type" ) :<br />
+ <select id="aggData" name="aggData" style="width:200px" onChange="enableCheckBox();">
+ <option value="generateaggdata" selected>$i18n.getString( "generate_agg_data" )</option>
+ <option value="useexistingaggdata">$i18n.getString( "use_existing_agg_data" )</option>
+ <option value="usecaptureddata">$i18n.getString( "use_captured_data" )</option>
+ </select>
+ </td>
+ <td>
+ <br />
+ <input type="checkbox" id="excludeZeroData" name="excludeZeroData" disabled="disabled" /> Exclude Zero Data
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input type="submit" id="ViewReport" name="generate" value="$i18n.getString( "generate_report" )" />
+ <input type="hidden" name="autogen" id="autogen" value="0" />
+ <input type="hidden" name="ouIDTB" id="ouIDTB" />
+ <input type="hidden" name="ouLevelTB" id="ouLevelTB" />
+ <input type="hidden" name="reportTypeNameTB" id="reportTypeNameTB" value="$reportTypeName" />
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </form>
+
+
+<script type="text/javascript">
+
+ var availableDataElements = new Object();
+ #foreach ( $reportOption in $reportOptionList )
+ availableDataElements['$reportOption.optionValue'] = '$encoder.jsEscape( $reportOption.optionText, "'" )';
+ #end
+
+</script>
\ No newline at end of file
=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menuWithTreeForMDReport.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menuWithTreeForMDReport.vm 2011-12-14 11:06:08 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menuWithTreeForMDReport.vm 2012-04-16 08:47:07 +0000
@@ -22,7 +22,8 @@
if(orgUnitIds != null && orgUnitIds != "" )
{
- getReports(orgUnitIds, reportTypeName)
+ //getReports(orgUnitIds, reportTypeName)
+ getOUDeatilsForMDReport( orgUnitIds );
}
}