=== 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 reportOptionList; + + public List 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( periodService.getPeriodsByPeriodType( new MonthlyPeriodType() ) ); @@ -85,8 +116,72 @@ } simpleDateFormat = new SimpleDateFormat( "MMM-yy" ); Collections.sort( periods, new PeriodComparator() ); + reportOptionList = new ArrayList( getReportOptions() ); + return SUCCESS; } - + private List getReportOptions( ) + { + List reportOptionList = new ArrayList(); + + 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"> + + + + + + + + + + + + + + === 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 @@ /main.vm /dhis-web-reports/mdReportForm.vm /dhis-web-reports/menuWithTreeForMDReport.vm - ../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/lists/lists.js,javascript/reportManagement.js,javascript/hashtable.js + ../dhis-web-commons/ouwt/ouwt.js,../dhis-web-commons/lists/lists.js,javascript/mdReport.js,javascript/hashtable.js css/StylesForTags.css F_MDREPORT_GENERATE - + + + + + application/vnd.ms-excel + inputStream + filename="${fileName}" + 1024 + + + + + /dhis-web-reports/responseOrgunit_md.vm + plainTextError + + === 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 @@ - + +
+
+

$i18n.getString( "md_report_ra" )



-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- 1.$i18n.getString( "organisationunit" ) :
- -
- 3.From Date :
- -
- -  
  
- 2. $i18n.getString( "reports" ) :
- -
- 4.To Date :
- -
  
  
- 5.$i18n.getString( "generated_data_type" ) :
- -
  
  
- - - - - -
-
\ No newline at end of file +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ $i18n.getString( "filter" ):  + +   
   
$i18n.getString( "available_delist" )
+ +

+     
+     
+     
+      +
$i18n.getString( "selected_delist" )
+ +
+ $i18n.getString( "organisationunit" ) :
+ +
+ +
  + + + + + + + + + + + + + + + + + + + + +
+ From Date :
+ +
+ To Date :
+ +
  
+ $i18n.getString( "generated_data_type" ) :
+ +
+
+ Exclude Zero Data +
  
+ + + + + +
+
+
+ + + \ 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 ); } }