dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15211
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5404: Merge NRHM Report Module in trunk
------------------------------------------------------------
revno: 5404
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-12-14 16:36:08 +0530
message:
Merge NRHM Report Module in trunk
added:
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/GenerateMDReportAnalyserResultAction.java
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/webapp/dhis-web-reports/mdReportForm.vm
local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menuWithTreeForMDReport.vm
modified:
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/TwentyPoint/action/GenerateTwentyPointReportsResultAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/GetOrgUnitsAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/advanced/action/GenerateAdvancedReportResultAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/BenificiaryInfoReportsResultAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateGradingReportResultAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateImmChildGradingReportAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateSelChildGradingReportAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GradingAbstractionResultAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/leprosy/action/LeprosyReportResultAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/malarya/action/GenerateMalaryaReportResultAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/util/OrganisationUnitLevelComparator.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/menu.vm
local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/ouWiseProgressReportFront.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/TwentyPoint/action/GenerateTwentyPointReportsResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/TwentyPoint/action/GenerateTwentyPointReportsResultAction.java 2011-07-07 10:56:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/TwentyPoint/action/GenerateTwentyPointReportsResultAction.java 2011-12-14 11:06:08 +0000
@@ -66,14 +66,14 @@
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
-import com.opensymphony.xwork2.ActionSupport;
+import com.opensymphony.xwork2.Action;
/**
* @author Brajesh Murari
*
*/
public class GenerateTwentyPointReportsResultAction
- extends ActionSupport
+ implements Action
{
// private static final long serialVersionUID = 1L;
@@ -486,7 +486,8 @@
List<String> deCodesList = getDECodes( deCodesXMLFileName );
String levelName = "Level";
- int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit ) + 1;
+ //int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit ) + 1;
+ int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit.getId() ) + 1;
if ( selOULevel <= organisationUnitService.getNumberOfOrganisationalLevels() )
{
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/GetOrgUnitsAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/GetOrgUnitsAction.java 2010-12-22 07:29:08 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/action/GetOrgUnitsAction.java 2011-12-14 11:06:08 +0000
@@ -54,8 +54,8 @@
if ( orgUnitId != null )
{
orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
- ouLevel = "" + organisationUnitService.getLevelOfOrganisationUnit( orgUnit );
-
+ ouLevel = "" + organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getId() );
+ //ouLevel = "" + organisationUnitService.getLevelOfOrganisationUnit( orgUnit )
System.out.println( " Org Short name : " + orgUnit.getShortName() + ", level is : " + ouLevel );
}
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/advanced/action/GenerateAdvancedReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/advanced/action/GenerateAdvancedReportResultAction.java 2011-07-07 10:56:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/advanced/action/GenerateAdvancedReportResultAction.java 2011-12-14 11:06:08 +0000
@@ -441,7 +441,8 @@
List<String> deCodesList = getDECodes( deCodesXMLFileName );
String levelName = "Level";
- int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit ) + 1;
+ int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit.getId() ) + 1;
+ //int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit ) + 1;
if ( selOULevel <= organisationUnitService.getNumberOfOrganisationalLevels() )
{
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/BenificiaryInfoReportsResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/BenificiaryInfoReportsResultAction.java 2011-07-07 10:56:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/benificiaryinfo/action/BenificiaryInfoReportsResultAction.java 2011-12-14 11:06:08 +0000
@@ -412,8 +412,8 @@
for ( OrganisationUnit ou : orgUnitList )
{
- int level = organisationUnitService.getLevelOfOrganisationUnit( ou );
-
+ //int level = organisationUnitService.getLevelOfOrganisationUnit( ou );
+ int level = organisationUnitService.getLevelOfOrganisationUnit( ou.getId() );
ouAndLevel.put( ou, level );
if ( !levelsList.contains( level ) )
{
@@ -592,7 +592,8 @@
for ( int i = levelsList.size() - 1; i >= 0; i-- )
{
colNo++;
- int level = organisationUnitService.getLevelOfOrganisationUnit( ouname );
+ int level = organisationUnitService.getLevelOfOrganisationUnit( ouname.getId() );
+ //int level = organisationUnitService.getLevelOfOrganisationUnit( ouname );
if ( levelsList.get( i ) == level )
{
sheet0.addCell( new Label( colNo, rowNo, ouname.getName(), wCellformat ) );
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateGradingReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateGradingReportResultAction.java 2011-07-07 10:56:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateGradingReportResultAction.java 2011-12-14 11:06:08 +0000
@@ -407,7 +407,8 @@
String heading1 = "";
String heading2 = "";
- int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit );
+ int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit.getId() );
+ //int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit );
int maxOULevels = organisationUnitService.getNumberOfOrganisationalLevels();
if( selOULevel < maxOULevels-1 )
@@ -549,16 +550,16 @@
OrganisationUnit tempOU = new OrganisationUnit();
- if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 2)
- tempOU = ccOU.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 3)
- tempOU = ccOU.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 4)
+ if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 2)
+ tempOU = ccOU.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 3)
+ tempOU = ccOU.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 4)
tempOU = ccOU.getParent().getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 5)
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 5)
tempOU = ccOU.getParent().getParent();
- if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) != 1)
+ if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) != 1)
{
String tempdeCodeString = "([1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*100/([14.1]+[15.1]+[1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*10";
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateImmChildGradingReportAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateImmChildGradingReportAction.java 2011-07-07 10:56:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateImmChildGradingReportAction.java 2011-12-14 11:06:08 +0000
@@ -511,17 +511,16 @@
resultVal = tempd1;
OrganisationUnit tempOU = new OrganisationUnit();
-
- if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 2)
- tempOU = ccOU.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 3)
- tempOU = ccOU.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 4)
- tempOU = ccOU.getParent().getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 5)
- tempOU = ccOU.getParent().getParent();
-
- if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) != 1)
+ if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 2)
+ tempOU = ccOU.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 3)
+ tempOU = ccOU.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 4)
+ tempOU = ccOU.getParent().getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 5)
+ tempOU = ccOU.getParent().getParent();
+
+ if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) != 1)
{
String tempdeCodeString = "([1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*100/([14.1]+[15.1]+[1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*10";
//tempd1 = reportService.getResultDataValue( tempdeCodeString, tempStartDate.getTime(), tempEndDate.getTime(), tempOU, sType, con);
@@ -687,16 +686,16 @@
OrganisationUnit tempOU = new OrganisationUnit();
- if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 2)
- tempOU = ccOU.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 3)
- tempOU = ccOU.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 4)
+ if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 2)
+ tempOU = ccOU.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 3)
+ tempOU = ccOU.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 4)
tempOU = ccOU.getParent().getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 5)
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 5)
tempOU = ccOU.getParent().getParent();
- if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) != 1)
+ if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) != 1)
{
String tempdeCodeString = "([1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*100/([14.1]+[15.1]+[1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*10";
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateSelChildGradingReportAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateSelChildGradingReportAction.java 2011-07-07 10:56:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GenerateSelChildGradingReportAction.java 2011-12-14 11:06:08 +0000
@@ -500,16 +500,16 @@
OrganisationUnit tempOU = new OrganisationUnit();
- if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit ) == 2)
- tempOU = orgUnit.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit ) == 3)
- tempOU = orgUnit.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit ) == 4)
+ if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getId() ) == 2)
+ tempOU = orgUnit.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getId() ) == 3)
+ tempOU = orgUnit.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getId() ) == 4)
tempOU = orgUnit.getParent().getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit ) == 5)
+ else if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getId() ) == 5)
tempOU = orgUnit.getParent().getParent();
- if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit ) != 1)
+ if(organisationUnitService.getLevelOfOrganisationUnit( orgUnit.getId() ) != 1)
{
String tempdeCodeString = "([1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*100/([14.1]+[15.1]+[1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*10";
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GradingAbstractionResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GradingAbstractionResultAction.java 2011-07-07 10:56:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/grading/action/GradingAbstractionResultAction.java 2011-12-14 11:06:08 +0000
@@ -397,7 +397,8 @@
String reportHeading = "";
- int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit );
+ int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit.getId() );
+ //int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit );
int maxOULevels = organisationUnitService.getNumberOfOrganisationalLevels();
if( selOULevel < maxOULevels-1 )
@@ -431,17 +432,17 @@
selLevel = 5;
}
- if(organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit) == 2)
+ if( organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit.getId() ) == 2)
{
reportHeading += "Block, "+simpleDateFormat.format( eDate );
heading1 = "Taluk / Block";
}
- else if(organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit) == 1)
+ else if(organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit.getId() ) == 1)
{
reportHeading += "District, "+simpleDateFormat.format( eDate );
heading1 = "District";
}
- else if(organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit) == 3)
+ else if(organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit.getId() ) == 3)
{
reportHeading += "PHC, "+simpleDateFormat.format( eDate );
heading1 = "PHC";
@@ -573,16 +574,16 @@
OrganisationUnit tempOU = new OrganisationUnit();
- if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 2)
- tempOU = ccOU.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 3)
- tempOU = ccOU.getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 4)
+ if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 2)
+ tempOU = ccOU.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 3)
+ tempOU = ccOU.getParent();
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 4)
tempOU = ccOU.getParent().getParent();
- else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) == 5)
+ else if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) == 5)
tempOU = ccOU.getParent().getParent();
- if(organisationUnitService.getLevelOfOrganisationUnit( ccOU ) != 1)
+ if(organisationUnitService.getLevelOfOrganisationUnit( ccOU.getId() ) != 1)
{
String tempdeCodeString = "([1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*100/([14.1]+[15.1]+[1251.1]+[1252.1]+[1253.1]+[1254.1]+[1255.1]+[26.1])*10";
@@ -768,7 +769,7 @@
while(it.hasNext())
{
OrganisationUnit ou = (OrganisationUnit) it.next();
- if(organisationUnitService.getLevelOfOrganisationUnit( ou ) == selLevel)
+ if(organisationUnitService.getLevelOfOrganisationUnit( ou.getId() ) == selLevel)
{
ouList.add( ou );
}
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/leprosy/action/LeprosyReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/leprosy/action/LeprosyReportResultAction.java 2011-07-07 10:56:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/leprosy/action/LeprosyReportResultAction.java 2011-12-14 11:06:08 +0000
@@ -405,7 +405,8 @@
List<String> deCodesList = getDECodes( deCodesXMLFileName );
String levelName = "Level";
- int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit ) + 1;
+ //int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit ) + 1;
+ int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit.getId() ) + 1;
if ( selOULevel <= organisationUnitService.getNumberOfOrganisationalLevels() )
{
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/malarya/action/GenerateMalaryaReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/malarya/action/GenerateMalaryaReportResultAction.java 2011-07-07 10:56:12 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/malarya/action/GenerateMalaryaReportResultAction.java 2011-12-14 11:06:08 +0000
@@ -447,7 +447,8 @@
List<String> deCodesList = getDECodes( deCodesXMLFileName );
String levelName = "Level";
- int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit ) + 1;
+ //int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit ) + 1;
+ int selOULevel = organisationUnitService.getLevelOfOrganisationUnit( selectedOrgUnit.getId() ) + 1;
if ( selOULevel <= organisationUnitService.getNumberOfOrganisationalLevels() )
{
=== added directory 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md'
=== added directory 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action'
=== added file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/GenerateMDReportAnalyserResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/GenerateMDReportAnalyserResultAction.java 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/GenerateMDReportAnalyserResultAction.java 2011-12-14 11:06:08 +0000
@@ -0,0 +1,680 @@
+package org.hisp.dhis.reports.md.action;
+
+import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers;
+import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import jxl.Workbook;
+import jxl.format.Alignment;
+import jxl.format.Border;
+import jxl.format.BorderLineStyle;
+import jxl.format.Colour;
+import jxl.format.VerticalAlignment;
+import jxl.write.Blank;
+import jxl.write.Label;
+import jxl.write.Number;
+import jxl.write.WritableCellFormat;
+import jxl.write.WritableFont;
+import jxl.write.WritableSheet;
+import jxl.write.WritableWorkbook;
+
+import org.amplecode.quick.StatementManager;
+import org.hisp.dhis.config.Configuration_IN;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.reports.ReportService;
+import org.hisp.dhis.reports.Report_in;
+import org.hisp.dhis.reports.Report_inDesign;
+import org.hisp.dhis.system.util.MathUtils;
+
+import com.opensymphony.xwork2.Action;
+
+public class GenerateMDReportAnalyserResultAction implements Action
+{
+ private final String GENERATEAGGDATA = "generateaggdata";
+
+ private final String USEEXISTINGAGGDATA = "useexistingaggdata";
+
+ private final String USECAPTUREDDATA = "usecaptureddata";
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private StatementManager statementManager;
+
+ public void setStatementManager( StatementManager statementManager )
+ {
+ this.statementManager = statementManager;
+ }
+
+ private PeriodService periodService;
+
+ public void setPeriodService( PeriodService periodService )
+ {
+ this.periodService = periodService;
+ }
+
+ private ReportService reportService;
+
+ public void setReportService( ReportService reportService )
+ {
+ this.reportService = reportService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+/*
+ private I18nFormat format;
+
+ public void setFormat( I18nFormat format )
+ {
+ this.format = format
+ }
+*/
+ // -------------------------------------------------------------------------
+ // Input/Output
+ // -------------------------------------------------------------------------
+
+ private InputStream inputStream;
+
+ public InputStream getInputStream()
+ {
+ return inputStream;
+ }
+
+ private String fileName;
+
+ public String getFileName()
+ {
+ return fileName;
+ }
+
+ private Integer selectedStartPeriodId;
+
+ public void setSelectedStartPeriodId( Integer selectedStartPeriodId )
+ {
+ this.selectedStartPeriodId = selectedStartPeriodId;
+ }
+
+ private Integer selectedEndPeriodId;
+
+ public void setSelectedEndPeriodId( Integer selectedEndPeriodId )
+ {
+ this.selectedEndPeriodId = selectedEndPeriodId;
+ }
+
+ private String reportList;
+
+ public void setReportList( String reportList )
+ {
+ this.reportList = reportList;
+ }
+
+ private int ouIDTB;
+
+ public void setOuIDTB( int ouIDTB )
+ {
+ this.ouIDTB = ouIDTB;
+ }
+
+ private String aggData;
+
+ public void setAggData( String aggData )
+ {
+ this.aggData = aggData;
+ }
+
+
+ private List<OrganisationUnit> orgUnitList;
+
+ private String raFolderName;
+
+ private SimpleDateFormat simpleDateFormat;
+
+ //private SimpleDateFormat monthFormat;
+
+ //private SimpleDateFormat yearFormat;
+
+ //private SimpleDateFormat simpleMonthFormat;
+
+ private String reportFileNameTB;
+
+ //private String reportModelTB;
+
+ private Date sDate;
+
+ private Date eDate;
+
+ // private OrganisationUnit selectedFacilityName;
+
+ private List<OrganisationUnit> orgUnitGroupMemberList;
+
+ // -------------------------------------------------------------------------
+ // Action Implementation
+ // -------------------------------------------------------------------------
+ public String execute() throws Exception
+ {
+
+ // Initialization
+ statementManager.initialise();
+
+ raFolderName = reportService.getRAFolderName();
+ String deCodesXMLFileName = "";
+ simpleDateFormat = new SimpleDateFormat( "MMM-yyyy" );
+ //monthFormat = new SimpleDateFormat( "MMMM" );
+ //yearFormat = new SimpleDateFormat( "yyyy" );
+ //simpleMonthFormat = new SimpleDateFormat( "MMM" );
+ //String parentUnit = "";
+
+ Report_in selReportObj = reportService.getReport( Integer.parseInt( reportList ) );
+
+ deCodesXMLFileName = selReportObj.getXmlTemplateName();
+
+
+ reportFileNameTB = selReportObj.getExcelTemplateName();
+
+ String inputTemplatePath = System.getenv( "DHIS2_HOME" ) + File.separator + raFolderName + File.separator + "template" + File.separator + reportFileNameTB;
+ String outputReportPath = System.getenv( "DHIS2_HOME" ) + File.separator + Configuration_IN.DEFAULT_TEMPFOLDER;
+ File newdir = new File( outputReportPath );
+ if( !newdir.exists() )
+ {
+ newdir.mkdirs();
+ }
+ outputReportPath += File.separator + UUID.randomUUID().toString() + ".xls";
+
+ Workbook templateWorkbook = Workbook.getWorkbook( new File( inputTemplatePath ) );
+ WritableWorkbook outputReportWorkbook = Workbook.createWorkbook( new File( outputReportPath ), templateWorkbook );
+
+ WritableCellFormat wCellformat = new WritableCellFormat();
+ wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+ wCellformat.setAlignment( Alignment.CENTRE );
+ wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
+ wCellformat.setWrap( true );
+
+ // Getting selected orgunit and its immediate children
+ OrganisationUnit selOrgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
+ orgUnitList = new ArrayList<OrganisationUnit>( selOrgUnit.getChildren() );
+ Collections.sort( orgUnitList, new OrganisationUnitNameComparator() );
+
+ // Org unit Group Information
+ OrganisationUnitGroup orgUnitGroup = selReportObj.getOrgunitGroup();
+ orgUnitGroupMemberList = new ArrayList<OrganisationUnit>( orgUnitGroup.getMembers() );
+
+ // Period Info
+ Period selectedStartPeriod = periodService.getPeriod( selectedStartPeriodId );
+ Period selectedEndPeriod = periodService.getPeriod( selectedEndPeriodId );
+ sDate = selectedStartPeriod.getStartDate();
+ eDate = selectedEndPeriod.getEndDate();
+
+ List<Period> periodList = new ArrayList<Period>( periodService.getIntersectingPeriods( selectedStartPeriod.getStartDate(), selectedEndPeriod.getEndDate() ) );
+ Collection<Integer> tempPeriodIds = new ArrayList<Integer>( getIdentifiers(Period.class, periodList ) );
+ String periodIdsByComma = getCommaDelimitedString( tempPeriodIds );
+
+ // Getting DataValues
+ List<Report_inDesign> reportDesignList = reportService.getReportDesign( deCodesXMLFileName );
+
+ // collect dataElementIDs by commaSepareted
+ String dataElmentIdsByComma = reportService.getDataelementIds( reportDesignList );
+ System.out.println( selOrgUnit.getName()+ " : " + selReportObj.getName()+" : Report Generation Start Time is : " + new Date() );
+
+ int orgUnitCount = 0;
+ int rowIncr = 0;
+ int tempOrgUnitCount = 0;
+
+ int rowStart = 5;
+ int colStart = 0;
+
+ int rowInc = 0;
+ int slno = 1;
+
+
+ Iterator<OrganisationUnit> it = orgUnitList.iterator();
+ while ( it.hasNext() )
+ {
+ OrganisationUnit tempOrgUnit = (OrganisationUnit) it.next();
+
+ Map<Integer, Double> subTotalMap = new HashMap<Integer, Double>();
+
+ List<OrganisationUnit> orgUnitWithChildTree = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( tempOrgUnit.getId() ) );
+ orgUnitWithChildTree.retainAll( orgUnitGroupMemberList );
+
+ List<Integer> childOrgUnitTreeIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, orgUnitWithChildTree ) );
+ String childOrgUnitsByComma = getCommaDelimitedString( childOrgUnitTreeIds );
+
+ WritableSheet sheet0 = outputReportWorkbook.getSheet( 0 );
+
+ Map<String, String> aggDeMap = new HashMap<String, String>();
+ if( aggData.equalsIgnoreCase( USECAPTUREDDATA ) )
+ {
+ aggDeMap.putAll( reportService.getAggDataFromDataValueTableForOrgUnitWise( childOrgUnitsByComma, dataElmentIdsByComma, periodIdsByComma ) );
+ }
+ //else if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) )
+ //{
+ // List<OrganisationUnit> childOrgUnitTree = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( tempOrgUnit.getId() ) );
+ // List<Integer> tempChildOrgUnitTreeIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, childOrgUnitTree ) );
+ // String tempChildOrgUnitsByComma = getCommaDelimitedString( tempChildOrgUnitTreeIds );
+
+ // aggDeMap.putAll( reportService.getAggDataFromDataValueTable( tempChildOrgUnitsByComma, dataElmentIdsByComma, periodIdsByComma ) );
+ //}
+ else if( aggData.equalsIgnoreCase( USEEXISTINGAGGDATA ) )
+ {
+ aggDeMap.putAll( reportService.getAggDataFromAggDataValueTableForOrgUnitWise( childOrgUnitsByComma, dataElmentIdsByComma, periodIdsByComma ) );
+ }
+
+ Double tempSubTotal = 0.0;
+
+ //List<String> tempTotal = new ArrayList<String>();
+ int tempOuMemeberCount = 0;
+ Iterator<OrganisationUnit> currIt = orgUnitWithChildTree.iterator();
+ while ( currIt.hasNext() )
+ {
+ OrganisationUnit currentOrgUnit = (OrganisationUnit) currIt.next();
+
+ Map<String, String> tempAggDeMap = new HashMap<String, String>();
+ if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) )
+ {
+ List<OrganisationUnit> childOrgUnitTree = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitWithChildren( currentOrgUnit.getId() ) );
+ List<Integer> tempchildOrgUnitTreeIds = new ArrayList<Integer>( getIdentifiers( OrganisationUnit.class, childOrgUnitTree ) );
+ String tempchildOrgUnitsByComma = getCommaDelimitedString( tempchildOrgUnitTreeIds );
+
+ tempAggDeMap.putAll( reportService.getAggDataFromDataValueTable( tempchildOrgUnitsByComma, dataElmentIdsByComma, periodIdsByComma ) );
+ }
+ sheet0.addCell( new Number( colStart, rowStart+rowInc, slno, getCellFormat1() ) );
+ sheet0.addCell( new Label( colStart+1, rowStart+rowInc, tempOrgUnit.getName(), getCellFormat1() ) );
+ sheet0.addCell( new Label( colStart+2, rowStart+rowInc, currentOrgUnit.getName(), getCellFormat1() ) );
+
+ int count1 = 0;
+ Integer deCount = 0;
+ Iterator<Report_inDesign> reportDesignIterator = reportDesignList.iterator();
+ while ( reportDesignIterator.hasNext() )
+ {
+ Report_inDesign report_inDesign = (Report_inDesign) reportDesignIterator.next();
+
+ //String deType = report_inDesign.getPtype();
+ String sType = report_inDesign.getStype();
+ String deCodeString = report_inDesign.getExpression();
+ String tempStr = "";
+ // String tempSubTotal = "";
+
+ if( deCodeString.equalsIgnoreCase( "FACILITY" ) )
+ {
+ tempStr = selOrgUnit.getName();
+ }
+ else if( deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" ) )
+ {
+ tempStr = simpleDateFormat.format( sDate ) + " To " + simpleDateFormat.format( eDate );
+ }
+ else if ( deCodeString.equalsIgnoreCase( "NA" ) )
+ {
+ tempStr = " ";
+ }
+ else
+ {
+ deCount++;
+ if( sType.equalsIgnoreCase( "dataelement" ) )
+ {
+ if ( aggData.equalsIgnoreCase( USECAPTUREDDATA ) )
+ {
+ Double tempAggValue = 0.0;
+ tempStr = getAggVal( deCodeString, currentOrgUnit.getId(), aggDeMap );
+
+ try
+ {
+ tempAggValue = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ tempAggValue = 0.0;
+ }
+ tempSubTotal += tempAggValue;
+
+ Double tempST = subTotalMap.get( deCount );
+ if( tempST != null )
+ {
+ tempST += tempAggValue;
+ }
+ else
+ {
+ tempST = tempAggValue;
+ }
+ //System.out.println( "tempST : "+tempST + " Count : "+ deCount + " OU : "+ currentOrgUnit.getName());
+ subTotalMap.put( deCount, tempST );
+ //tempSubTotal += aggValue;
+ }
+
+ else if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) )
+ {
+ Double tempAggValue = 0.0;
+ //tempStr = reportService.getResultDataValue( deCodeString, sDate, eDate, currentOrgUnit, selReportObj.getModel() );
+ tempStr = getAggVal( deCodeString, tempAggDeMap );
+ try
+ {
+ tempAggValue = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ tempAggValue = 0.0;
+ }
+ tempSubTotal += tempAggValue;
+ Double tempST = subTotalMap.get( deCount );
+ if( tempST != null )
+ {
+ tempST += tempAggValue;
+ }
+ else
+ {
+ tempST = tempAggValue;
+ }
+ //System.out.println( "tempST : "+tempST + " Count : "+ deCount + " OU : "+ currentOrgUnit.getName());
+ subTotalMap.put( deCount, tempST );
+
+ }
+ else if( aggData.equalsIgnoreCase( USEEXISTINGAGGDATA ) )
+ {
+ Double tempAggValue = 0.0;
+ tempStr = getAggVal( deCodeString, aggDeMap );
+ try
+ {
+ tempAggValue = Double.parseDouble( tempStr );
+ }
+ catch ( Exception e )
+ {
+ tempAggValue = 0.0;
+ }
+ tempSubTotal += tempAggValue;
+ Double tempST = subTotalMap.get( deCount );
+ if( tempST != null )
+ {
+ tempST += tempAggValue;
+ }
+ else
+ {
+ tempST = tempAggValue;
+ }
+ subTotalMap.put( deCount, tempST );
+
+ }
+ //tempTotal.add( tempSubTotal );
+ }
+ }
+ int tempRowNo = report_inDesign.getRowno();
+ rowIncr = tempRowNo;
+ int tempColNo = report_inDesign.getColno();
+ int sheetNo = report_inDesign.getSheetno();
+ sheet0 = outputReportWorkbook.getSheet( sheetNo );
+
+ if ( tempStr == null || tempStr.equals( " " ) )
+ {
+ sheet0.addCell( new Blank( tempColNo, tempRowNo, wCellformat ) );
+ }
+ else
+ {
+ if ( deCodeString.equalsIgnoreCase( "FACILITY" ) || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" ) )
+ {
+
+ }
+ else
+ {
+ tempRowNo += tempOrgUnitCount;
+ rowIncr += tempOrgUnitCount;
+ }
+
+ if ( sType.equalsIgnoreCase( "dataelement" ) )
+ {
+ if( tempOuMemeberCount == orgUnitWithChildTree.size()-1 )
+ {
+ if( deCodeString.equalsIgnoreCase( "FACILITY" ) || deCodeString.equalsIgnoreCase( "PERIOD-NOREPEAT" ) )
+ {
+
+ }
+ else
+ {
+ try
+ {
+ sheet0.addCell( new Number( tempColNo, tempRowNo, Integer.parseInt( tempStr ), getCellFormat1() ) );
+ }
+ catch ( Exception e )
+ {
+ sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, getCellFormat1() ) );
+ }
+
+ tempRowNo++;
+
+ try
+ {
+ sheet0.addCell( new Number( tempColNo, tempRowNo, subTotalMap.get( deCount ) , getCellFormat2() ) );
+ }
+ catch ( Exception e )
+ {
+ sheet0.addCell( new Label( tempColNo, tempRowNo, " ", getCellFormat2() ) );
+ }
+ //tempOrgUnitCount++;
+ //rowInc++;
+ }
+ }
+ else
+ {
+ try
+ {
+ sheet0.addCell( new Number( tempColNo, tempRowNo, Integer.parseInt( tempStr ), getCellFormat1() ) );
+ }
+ catch ( Exception e )
+ {
+ sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, getCellFormat1() ) );
+ }
+ }
+ }
+ }
+ count1++;
+ }
+
+ rowIncr++;
+ rowInc++;
+ tempOuMemeberCount++;
+ tempOrgUnitCount++;
+ slno++;
+ }
+
+ if( orgUnitWithChildTree.size() != 0 )
+ {
+ sheet0.addCell( new Label( colStart, rowStart+rowInc, " ", getCellFormat2() ) );
+ sheet0.addCell( new Label( colStart+1, rowStart+rowInc, " ", getCellFormat2() ) );
+ sheet0.addCell( new Label( colStart+2, rowStart+rowInc, "SUB TOTAL", getCellFormat2() ) );
+ rowInc++;
+ tempOrgUnitCount++;
+ }
+
+ rowIncr++;
+ orgUnitCount++;
+ }
+
+ outputReportWorkbook.write();
+ outputReportWorkbook.close();
+
+ fileName = reportFileNameTB.replace( ".xls", "" );
+ fileName += "_" + selOrgUnit.getShortName() + "_";
+ fileName += "_" + simpleDateFormat.format( sDate ) + ".xls";
+ File outputReportFile = new File( outputReportPath );
+ inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) );
+
+ System.out.println( selOrgUnit.getName()+ " : " + selReportObj.getName()+" : Report Generation End Time is : " + new Date() );
+
+ statementManager.destroy();
+ return SUCCESS;
+ }
+
+ // Returns the OrgUnitTree for which Root is the orgUnit
+ @SuppressWarnings( "unchecked" )
+ public List<OrganisationUnit> getChildOrgUnitTree( OrganisationUnit orgUnit )
+ {
+ List<OrganisationUnit> orgUnitTree = new ArrayList<OrganisationUnit>();
+ orgUnitTree.add( orgUnit );
+
+ List<OrganisationUnit> children = new ArrayList<OrganisationUnit>( orgUnit.getChildren() );
+ Collections.sort( children, new OrganisationUnitNameComparator() );
+
+ Iterator childIterator = children.iterator();
+ OrganisationUnit child;
+ while ( childIterator.hasNext() )
+ {
+ child = (OrganisationUnit) childIterator.next();
+ orgUnitTree.addAll( getChildOrgUnitTree( child ) );
+ }
+ return orgUnitTree;
+ }// getChildOrgUnitTree end
+
+
+ // getting data value using Map
+ private String getAggVal( String expression, Integer orgUnitID, Map<String, String> aggDeMap )
+ {
+ try
+ {
+ Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
+
+ Matcher matcher = pattern.matcher( expression );
+ StringBuffer buffer = new StringBuffer();
+
+ String resultValue = "";
+
+ while ( matcher.find() )
+ {
+ String replaceString = matcher.group();
+
+ replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
+
+ replaceString = aggDeMap.get( replaceString +":"+ orgUnitID );
+
+ if( replaceString == null )
+ {
+ replaceString = "0";
+ }
+
+ matcher.appendReplacement( buffer, replaceString );
+
+ resultValue = replaceString;
+ }
+
+ matcher.appendTail( buffer );
+
+ double d = 0.0;
+ try
+ {
+ d = MathUtils.calculateExpression( buffer.toString() );
+ }
+ catch ( Exception e )
+ {
+ d = 0.0;
+ resultValue = "";
+ }
+
+ resultValue = "" + (double) d;
+
+ return resultValue;
+ }
+ catch ( NumberFormatException ex )
+ {
+ throw new RuntimeException( "Illegal DataElement id", ex );
+ }
+ }
+
+ public WritableCellFormat getCellFormat1()throws Exception
+ {
+ WritableCellFormat wCellformat = new WritableCellFormat();
+
+ wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+ wCellformat.setAlignment( Alignment.CENTRE );
+ wCellformat.setWrap( true );
+
+ return wCellformat;
+ }
+
+ public WritableCellFormat getCellFormat2() throws Exception
+ {
+ WritableFont arialBold = new WritableFont( WritableFont.ARIAL, 10, WritableFont.BOLD );
+ WritableCellFormat wCellformat = new WritableCellFormat( arialBold );
+
+ wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+ wCellformat.setAlignment( Alignment.CENTRE );
+ wCellformat.setBackground( Colour.ICE_BLUE );
+ wCellformat.setWrap( true );
+
+ return wCellformat;
+ }
+
+ private String getAggVal( String expression, Map<String, String> aggDeMap )
+ {
+ try
+ {
+ Pattern pattern = Pattern.compile( "(\\[\\d+\\.\\d+\\])" );
+
+ Matcher matcher = pattern.matcher( expression );
+ StringBuffer buffer = new StringBuffer();
+
+ String resultValue = "";
+
+ while ( matcher.find() )
+ {
+ String replaceString = matcher.group();
+
+ replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
+
+ replaceString = aggDeMap.get( replaceString );
+
+ if( replaceString == null )
+ {
+ replaceString = "0";
+ }
+
+ matcher.appendReplacement( buffer, replaceString );
+
+ resultValue = replaceString;
+ }
+
+ matcher.appendTail( buffer );
+
+ double d = 0.0;
+ try
+ {
+ d = MathUtils.calculateExpression( buffer.toString() );
+ }
+ catch ( Exception e )
+ {
+ d = 0.0;
+ resultValue = "";
+ }
+
+ resultValue = "" + (double) d;
+
+ return resultValue;
+ }
+ catch ( NumberFormatException ex )
+ {
+ throw new RuntimeException( "Illegal DataElement id", ex );
+ }
+ }
+}
=== added 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 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/md/action/MDReportFormAction.java 2011-12-14 11:06:08 +0000
@@ -0,0 +1,92 @@
+package org.hisp.dhis.reports.md.action;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+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.ReportType;
+
+import com.opensymphony.xwork2.Action;
+
+public class MDReportFormAction implements Action
+{
+ //--------------------------------------------------------------------------
+ // Dependencies
+ //--------------------------------------------------------------------------
+
+ private PeriodService periodService;
+
+ public void setPeriodService( PeriodService periodService )
+ {
+ this.periodService = periodService;
+ }
+
+ //--------------------------------------------------------------------------
+ //Input/Output
+ //--------------------------------------------------------------------------
+
+ private List<Period> periods;
+
+ public List<Period> getPeriods()
+ {
+ return periods;
+ }
+
+ private String reportTypeName;
+
+ public String getReportTypeName()
+ {
+ return reportTypeName;
+ }
+
+ private String periodTypeName;
+
+ public String getPeriodTypeName()
+ {
+ return periodTypeName;
+ }
+
+ //--------------------------------------------------------------------------
+ // Action Implementation
+ //--------------------------------------------------------------------------
+
+ private SimpleDateFormat simpleDateFormat;
+
+ public SimpleDateFormat getSimpleDateFormat()
+ {
+ return simpleDateFormat;
+ }
+
+ public String execute() throws Exception
+ {
+ reportTypeName = ReportType.RT_MD_REPORT;
+ periodTypeName = MonthlyPeriodType.NAME;
+
+ //period information
+ periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( new MonthlyPeriodType() ) );
+
+ Iterator<Period> periodIterator = periods.iterator();
+ while ( periodIterator.hasNext() )
+ {
+ Period p1 = periodIterator.next();
+ if ( p1.getStartDate().compareTo( new Date() ) > 0 )
+ {
+ periodIterator.remove();
+ }
+
+
+ }
+ simpleDateFormat = new SimpleDateFormat( "MMM-yy" );
+ Collections.sort( periods, new PeriodComparator() );
+ return SUCCESS;
+ }
+
+
+}
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/util/OrganisationUnitLevelComparator.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/util/OrganisationUnitLevelComparator.java 2010-06-04 11:50:05 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/util/OrganisationUnitLevelComparator.java 2011-12-14 11:06:08 +0000
@@ -10,7 +10,8 @@
OrganisationUnitService organisationUnitService = new org.hisp.dhis.organisationunit.DefaultOrganisationUnitService();
public int compare( OrganisationUnit organisationUnit0, OrganisationUnit organisationUnit1 )
- {
- return (organisationUnitService.getLevelOfOrganisationUnit(organisationUnit1) - organisationUnitService.getLevelOfOrganisationUnit(organisationUnit0));
+ {
+ //return (organisationUnitService.getLevelOfOrganisationUnit(organisationUnit1) - organisationUnitService.getLevelOfOrganisationUnit(organisationUnit0));
+ return (organisationUnitService.getLevelOfOrganisationUnit(organisationUnit1.getId()) - organisationUnitService.getLevelOfOrganisationUnit(organisationUnit0.getId()));
}
}
=== 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 2011-12-05 05:56:00 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml 2011-12-14 11:06:08 +0000
@@ -207,7 +207,22 @@
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
</bean>
-
+
+ <!-- MD Report -->
+ <bean id="org.hisp.dhis.reports.md.action.MDReportFormAction"
+ class="org.hisp.dhis.reports.md.action.MDReportFormAction"
+ scope="prototype">
+ <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+ </bean>
+ <bean id="org.hisp.dhis.reports.md.action.GenerateMDReportAnalyserResultAction"
+ class="org.hisp.dhis.reports.md.action.GenerateMDReportAnalyserResultAction"
+ 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>
+
<!-- Auto Reports -->
<bean
id="org.hisp.dhis.reports.auto.action.GenerateAutoReportAnalyserFormAction"
=== 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 2011-12-05 05:56:00 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/org/hisp/dhis/reports/i18n_module.properties 2011-12-14 11:06:08 +0000
@@ -302,4 +302,5 @@
idsp_ra = IDSP Reports Analyser
back = Back
select_orgUnitGroup = Select OrgUnit Group
-orgunitgroup = OrgUnit Group
\ No newline at end of file
+orgunitgroup = OrgUnit Group
+md_report_ra = MD Report Analyser
\ 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 2011-10-14 12:26:01 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/struts.xml 2011-12-14 11:06:08 +0000
@@ -197,7 +197,28 @@
<param name="bufferSize">1024</param>
</result>
</action>
-
+
+ <!-- MD Reports -->
+ <action name="mdReportAnalyser"
+ class="org.hisp.dhis.reports.md.action.MDReportFormAction">
+ <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="stylesheets">css/StylesForTags.css</param>
+ <param name="requiredAuthorities">F_MDREPORT_GENERATE</param>
+ <interceptor-ref name="organisationUnitTreeStack"/>
+ </action>
+ <action name="generateMDReport"
+ class="org.hisp.dhis.reports.md.action.GenerateMDReportAnalyserResultAction">
+ <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>
+
<!-- Auto Reports -->
<action name="autoReportAnalyser"
class="org.hisp.dhis.reports.auto.action.GenerateAutoReportAnalyserFormAction">
=== added 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 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/mdReportForm.vm 2011-12-14 11:06:08 +0000
@@ -0,0 +1,102 @@
+<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>
+<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
=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm 2011-10-14 12:26:01 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menu.vm 2011-12-14 11:06:08 +0000
@@ -71,7 +71,10 @@
#end
#if( $auth.hasAccess( "dhis-web-reports", "lineListingBulkReportAnalyser") )
<li><a href = "lineListingBulkReportAnalyser.action">Linelisting Bulk Report</a>
- #end
+ #end
+ #if( $auth.hasAccess( "dhis-web-reports", "mdReportAnalyser") )
+ <li><a href = "mdReportAnalyser.action">MD Report</a>
+ #end
<!--<li><a href = "advancedReportAnalyser.action">Advanced Reports</a></li>-->
</ul>
</ul>
=== added 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 1970-01-01 00:00:00 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/menuWithTreeForMDReport.vm 2011-12-14 11:06:08 +0000
@@ -0,0 +1,31 @@
+
+<a href="index.action"><h2>Report Analyser</h2></a>
+
+<ul>
+ <li>Report Analysis</li>
+ <ul>
+ <li>
+ MD Reports
+ </li>
+ </ul>
+</ul>
+
+#parse( "/dhis-web-commons/ouwt/orgunittreesearch.vm" )
+
+<script type="text/javascript">
+
+ function orgUnitHasBeenSelected( orgUnitIds )
+ {
+ document.reportForm.ouIDTB.value = orgUnitIds;
+
+ reportTypeName = document.reportForm.reportTypeNameTB.value;
+
+ if(orgUnitIds != null && orgUnitIds != "" )
+ {
+ getReports(orgUnitIds, reportTypeName)
+ }
+ }
+
+ selection.setListenerFunction( orgUnitHasBeenSelected );
+
+</script>
\ No newline at end of file
=== modified file 'local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/ouWiseProgressReportFront.vm'
--- local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/ouWiseProgressReportFront.vm 2011-12-05 05:56:00 +0000
+++ local/in/dhis-web-reports-national/src/main/webapp/dhis-web-reports/ouWiseProgressReportFront.vm 2011-12-14 11:06:08 +0000
@@ -92,7 +92,7 @@
</select>
</td>
<td class="NormalB">
- 6. $i18n.getString( "orgunit_group" ) :<br />
+ 6. $i18n.getString( "orgunitgroup" ) :<br />
<select id="orgUnitGroup" name="orgUnitGroup" style="width:200px">
<option value="0">ALL</option>
#foreach( $orgUnitGroup in $orgUnitGroups )