dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14904
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5185: Merge NRHM-Report from 2.3 to trunk
------------------------------------------------------------
revno: 5185
committer: Mithilesh Kumar Thakur<mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-11-21 17:16:15 +0530
message:
Merge NRHM-Report from 2.3 to trunk
modified:
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ouwiseprogress/action/GenerateOuWiseProgressReportResultAction.java
local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/periodwiseprogress/action/GeneratePeriodWiseProgressAnalyserResultAction.java
local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml
--
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/ouwiseprogress/action/GenerateOuWiseProgressReportResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ouwiseprogress/action/GenerateOuWiseProgressReportResultAction.java 2011-09-03 05:48:23 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/ouwiseprogress/action/GenerateOuWiseProgressReportResultAction.java 2011-11-21 11:46:15 +0000
@@ -27,6 +27,7 @@
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.VerticalAlignment;
+import jxl.write.Formula;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.WritableCellFormat;
@@ -36,8 +37,6 @@
import org.amplecode.quick.StatementManager;
import org.hisp.dhis.config.Configuration_IN;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -91,21 +90,21 @@
{
this.organisationUnitService = organisationUnitService;
}
-
+/*
private DataSetService dataSetService;
public void setDataSetService( DataSetService dataSetService )
{
this.dataSetService = dataSetService;
}
-
+
private DataElementService dataElementService;
public void setDataElementService( DataElementService dataElementService )
{
this.dataElementService = dataElementService;
}
-
+*/
private I18nFormat format;
public void setFormat( I18nFormat format )
@@ -212,13 +211,18 @@
// OrgUnit Related Info
selectedOrgUnit = new OrganisationUnit();
selectedOrgUnit = organisationUnitService.getOrganisationUnit( ouIDTB );
+ int selectedOrgUnitLevel = organisationUnitService.getLevelOfOrganisationUnit( ouIDTB );
if ( reportModelTB.equalsIgnoreCase( "PROGRESSIVE-ORGUNIT" ) )
{
orgUnitList = new ArrayList<OrganisationUnit>( selectedOrgUnit.getChildren() );
Collections.sort( orgUnitList, new OrganisationUnitShortNameComparator() );
- orgUnitList.add( selectedOrgUnit );
+ //Hardcoded to level 2 to make report fast for state level
+ if( selectedOrgUnitLevel != 2 )
+ {
+ orgUnitList.add( selectedOrgUnit );
+ }
/*
if( orgUnitList == null || orgUnitList.size() == 0 )
@@ -251,25 +255,6 @@
wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
wCellformat.setWrap( true );
- /*
- String dataSetIds = selReportObj.getDataSetIds();
- Collection<Integer> dataElementIdList = new ArrayList<Integer>();
- if( dataSetIds != null && !dataSetIds.trim().equalsIgnoreCase( "" ) )
- {
- String[] partsOfDataSetIds = dataSetIds.split( "," );
- for( int i = 0; i < partsOfDataSetIds.length; i++ )
- {
- DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( partsOfDataSetIds[i] ) );
- dataElementIdList.addAll( getIdentifiers( DataElement.class, dataSet.getDataElements() ) );
- }
- }
- else
- {
- dataElementIdList.addAll( getIdentifiers( DataElement.class, dataElementService.getAggregateableDataElements() ) );
- }
-
- String dataElmentIdsByComma = getCommaDelimitedString( dataElementIdList );
- */
// Period Info
sDate = format.parseDate( startDate );
@@ -285,7 +270,10 @@
List<Report_inDesign> reportDesignList = reportService.getReportDesign( deCodesXMLFileName );
String dataElmentIdsByComma = reportService.getDataelementIds( reportDesignList );
-
+
+ Map<String, String> aggDeMapForselectedFacility = new HashMap<String, String>();
+ aggDeMapForselectedFacility.putAll( reportService.getAggDataFromDataValueTable( ""+selectedOrgUnit.getId(), dataElmentIdsByComma, periodIdsByComma ) );
+
int orgUnitCount = 0;
Iterator<OrganisationUnit> it = orgUnitList.iterator();
while ( it.hasNext() )
@@ -319,42 +307,52 @@
String sType = report_inDesign.getStype();
String deCodeString = report_inDesign.getExpression();
String tempStr = "";
-
+ String tempStrForSelectedFacility = "";
if ( deCodeString.equalsIgnoreCase( "FACILITY" ) )
{
tempStr = selectedOrgUnit.getName();
+ tempStrForSelectedFacility = selectedOrgUnit.getName();
}
else if( deCodeString.equalsIgnoreCase( "PROGRESSIVE-ORGUNIT" ) )
{
tempStr = currentOrgUnit.getName();
+ tempStrForSelectedFacility = selectedOrgUnit.getName()+"-ONLY";
}
else if( deCodeString.equalsIgnoreCase( "FACILITYP" ) )
{
tempStr = selectedOrgUnit.getParent().getName();
+ tempStrForSelectedFacility = selectedOrgUnit.getParent().getName();
+
}
else if( deCodeString.equalsIgnoreCase( "FACILITYPP" ) )
{
tempStr = selectedOrgUnit.getParent().getParent().getName();
+ tempStrForSelectedFacility = selectedOrgUnit.getParent().getParent().getName();
}
else if ( deCodeString.equalsIgnoreCase( "DATE-FROM" ) )
{
tempStr = dayFormat.format( sDate );
+ tempStrForSelectedFacility = dayFormat.format( sDate );
}
else if ( deCodeString.equalsIgnoreCase( "DATE-TO" ) )
{
tempStr = dayFormat.format( eDate );
+ tempStrForSelectedFacility = dayFormat.format( eDate );
}
else if ( deCodeString.equalsIgnoreCase( "MONTH-FROM" ) )
{
tempStr = simpleDateFormat.format( sDate );
+ tempStrForSelectedFacility = simpleDateFormat.format( sDate );
}
else if ( deCodeString.equalsIgnoreCase( "MONTH-TO" ) )
{
tempStr = simpleDateFormat.format( eDate );
+ tempStrForSelectedFacility = simpleDateFormat.format( eDate );
}
else if ( deCodeString.equalsIgnoreCase( "NA" ) )
{
tempStr = " ";
+ tempStrForSelectedFacility = " ";
}
else
{
@@ -364,17 +362,24 @@
{
tempStr = getAggVal( deCodeString, aggDeMap );
//tempStr = reportService.getIndividualResultDataValue( deCodeString, sDate, eDate, currentOrgUnit, reportModelTB );
+ tempStrForSelectedFacility = getAggVal( deCodeString, aggDeMapForselectedFacility );
}
else if( aggData.equalsIgnoreCase( GENERATEAGGDATA ) )
{
//tempStr = reportService.getResultDataValue( deCodeString, sDate, eDate, currentOrgUnit, reportModelTB );
tempStr = getAggVal( deCodeString, aggDeMap );
+ tempStrForSelectedFacility = getAggVal( deCodeString, aggDeMapForselectedFacility );
}
else if( aggData.equalsIgnoreCase( USEEXISTINGAGGDATA ) )
{
tempStr = getAggVal( deCodeString, aggDeMap );
+ tempStrForSelectedFacility = getAggVal( deCodeString, aggDeMapForselectedFacility );
}
}
+ else if ( sType.equalsIgnoreCase( "formula" ) )
+ {
+ tempStr = deCodeString;
+ }
}
int tempRowNo = report_inDesign.getRowno();
@@ -396,20 +401,61 @@
try
{
- if( orgUnitCount == orgUnitList.size()-1 )
+
+ if( sType.equalsIgnoreCase( "formula" ) )
{
- sheet0.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStr ), getCellFormat1() ) );
+ tempStr = tempStr.replace( "?", colArray[tempColNo] );
+ if( orgUnitCount == orgUnitList.size()-1 && selectedOrgUnitLevel != 2 )
+ {
+ sheet0.addCell( new Formula( tempColNo+1, tempRowNo, tempStr, getCellFormat1() ) );
+ }
+ else
+ {
+ sheet0.addCell( new Formula( tempColNo, tempRowNo, tempStr, wCellformat ) );
+ }
}
else
- {
- sheet0.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStr ), wCellformat ) );
- }
+ {
+ if( orgUnitCount == orgUnitList.size()-1 && selectedOrgUnitLevel != 2 )
+ {
+ //sheet0.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStrForSelectedFacility ), getCellFormat2() ) );
+ if( deCodeString.equalsIgnoreCase( "FACILITY" ) || deCodeString.equalsIgnoreCase( "FACILITYP" ) || deCodeString.equalsIgnoreCase( "FACILITYPP" )
+ || deCodeString.equalsIgnoreCase( "MONTH-FROM" ) || deCodeString.equalsIgnoreCase( "MONTH-TO" )
+ || deCodeString.equalsIgnoreCase( "DATE-FROM" ) || deCodeString.equalsIgnoreCase( "DATE-TO" ) )
+ {
+ continue;
+ }
+ else
+ {
+ sheet0.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStrForSelectedFacility ), getCellFormat2() ) );
+ sheet0.addCell( new Number( tempColNo+1, tempRowNo, Double.parseDouble( tempStr ), getCellFormat1() ) );
+ }
+
+
+ }
+ else
+ {
+ sheet0.addCell( new Number( tempColNo, tempRowNo, Double.parseDouble( tempStr ), wCellformat ) );
+ }
+ }
}
catch( Exception e )
{
- if( orgUnitCount == orgUnitList.size()-1 )
+ if( orgUnitCount == orgUnitList.size()-1 && selectedOrgUnitLevel != 2 )
{
- sheet0.addCell( new Label( tempColNo, tempRowNo, tempStr, getCellFormat1() ) );
+ //sheet0.addCell( new Label( tempColNo, tempRowNo, tempStrForSelectedFacility, getCellFormat2() ) );
+ if( deCodeString.equalsIgnoreCase( "FACILITY" ) || deCodeString.equalsIgnoreCase( "FACILITYP" ) || deCodeString.equalsIgnoreCase( "FACILITYPP" )
+ || deCodeString.equalsIgnoreCase( "MONTH-FROM" ) || deCodeString.equalsIgnoreCase( "MONTH-TO" )
+ || deCodeString.equalsIgnoreCase( "DATE-FROM" ) || deCodeString.equalsIgnoreCase( "DATE-TO" ) )
+ {
+ continue;
+ }
+ else
+ {
+ sheet0.addCell( new Label( tempColNo, tempRowNo, tempStrForSelectedFacility, getCellFormat2() ) );
+ sheet0.addCell( new Label( tempColNo+1, tempRowNo, tempStr, getCellFormat1() ) );
+ }
+
}
else
{
@@ -426,56 +472,59 @@
// ---------------------------------------------------------------------
// Writing Total Values
// ---------------------------------------------------------------------
- /*
- WritableCellFormat totalCellformat = new WritableCellFormat( arialBold );
- totalCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
- totalCellformat.setAlignment( Alignment.CENTRE );
- totalCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
- totalCellformat.setWrap( true );
- Iterator<Report_inDesign> reportDesignIterator = reportDesignList.iterator();
- while ( reportDesignIterator.hasNext() )
+ if( selectedOrgUnitLevel == 2 )
{
- Report_inDesign reportDesign = reportDesignIterator.next();
-
- String deCodeString = reportDesign.getExpression();
-
- if( deCodeString.equalsIgnoreCase( "FACILITY" ) ||
- deCodeString.equalsIgnoreCase( "FACILITYP" ) ||
- deCodeString.equalsIgnoreCase( "FACILITYPP" ) ||
- deCodeString.equalsIgnoreCase( "MONTH-FROM" ) ||
- deCodeString.equalsIgnoreCase( "MONTH-TO" ) ||
- deCodeString.equalsIgnoreCase( "DATE-FROM" ) ||
- deCodeString.equalsIgnoreCase( "DATE-TO" ) )
- {
- continue;
- }
-
- int tempRowNo = reportDesign.getRowno();
- int tempColNo = reportDesign.getColno();
- int sheetNo = reportDesign.getSheetno();
-
- String colStart = ""+ colArray[tempColNo];
- String colEnd = ""+ colArray[tempColNo+orgUnitCount-1];
-
- String tempFormula = "SUM("+colStart+(tempRowNo+1)+":"+colEnd+(tempRowNo+1)+")";
-
- WritableSheet totalSheet = outputReportWorkbook.getSheet( sheetNo );
-
- if( deCodeString.equalsIgnoreCase( "PROGRESSIVE-ORGUNIT" ) )
- {
- totalSheet.addCell( new Label( tempColNo+orgUnitCount, tempRowNo, selectedOrgUnit.getName(), totalCellformat ) );
- }
- else if( deCodeString.equalsIgnoreCase( "NA" ) )
- {
- totalSheet.addCell( new Label( tempColNo+orgUnitCount, tempRowNo, " ", totalCellformat ) );
- }
- else
- {
- totalSheet.addCell( new Formula( tempColNo+orgUnitCount, tempRowNo, tempFormula, totalCellformat ) );
+ WritableCellFormat totalCellformat = new WritableCellFormat( getCellFormat1() );
+ totalCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+ totalCellformat.setAlignment( Alignment.CENTRE );
+ totalCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
+ totalCellformat.setWrap( true );
+
+ Iterator<Report_inDesign> reportDesignIterator = reportDesignList.iterator();
+ while ( reportDesignIterator.hasNext() )
+ {
+ Report_inDesign reportDesign = reportDesignIterator.next();
+
+ String deCodeString = reportDesign.getExpression();
+
+ if( deCodeString.equalsIgnoreCase( "FACILITY" ) ||
+ deCodeString.equalsIgnoreCase( "FACILITYP" ) ||
+ deCodeString.equalsIgnoreCase( "FACILITYPP" ) ||
+ deCodeString.equalsIgnoreCase( "MONTH-FROM" ) ||
+ deCodeString.equalsIgnoreCase( "MONTH-TO" ) ||
+ deCodeString.equalsIgnoreCase( "DATE-FROM" ) ||
+ deCodeString.equalsIgnoreCase( "DATE-TO" ) )
+ {
+ continue;
+ }
+
+ int tempRowNo = reportDesign.getRowno();
+ int tempColNo = reportDesign.getColno();
+ int sheetNo = reportDesign.getSheetno();
+
+ String colStart = ""+ colArray[tempColNo];
+ String colEnd = ""+ colArray[tempColNo+orgUnitCount-1];
+
+ String tempFormula = "SUM("+colStart+(tempRowNo+1)+":"+colEnd+(tempRowNo+1)+")";
+
+ WritableSheet totalSheet = outputReportWorkbook.getSheet( sheetNo );
+
+ if( deCodeString.equalsIgnoreCase( "PROGRESSIVE-ORGUNIT" ) )
+ {
+ totalSheet.addCell( new Label( tempColNo+orgUnitCount, tempRowNo, selectedOrgUnit.getName(), totalCellformat ) );
+ }
+ else if( deCodeString.equalsIgnoreCase( "NA" ) )
+ {
+ totalSheet.addCell( new Label( tempColNo+orgUnitCount, tempRowNo, " ", totalCellformat ) );
+ }
+ else
+ {
+ totalSheet.addCell( new Formula( tempColNo+orgUnitCount, tempRowNo, tempFormula, totalCellformat ) );
+ }
}
}
-*/
+
outputReportWorkbook.write();
outputReportWorkbook.close();
@@ -507,7 +556,19 @@
return wCellformat;
}
-
+ public WritableCellFormat getCellFormat2() throws Exception
+ {
+ WritableFont arialBold = new WritableFont( WritableFont.ARIAL, 10, WritableFont.NO_BOLD );
+ WritableCellFormat wCellformat = new WritableCellFormat( arialBold );
+
+ wCellformat.setBorder( Border.ALL, BorderLineStyle.THIN );
+ wCellformat.setAlignment( Alignment.CENTRE );
+ wCellformat.setBackground( Colour.ICE_BLUE );
+ wCellformat.setVerticalAlignment( VerticalAlignment.CENTRE );
+ wCellformat.setWrap( true );
+
+ return wCellformat;
+ }
private String getAggVal( String expression, Map<String, String> aggDeMap )
{
=== modified file 'local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/periodwiseprogress/action/GeneratePeriodWiseProgressAnalyserResultAction.java'
--- local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/periodwiseprogress/action/GeneratePeriodWiseProgressAnalyserResultAction.java 2011-09-03 05:48:23 +0000
+++ local/in/dhis-web-reports-national/src/main/java/org/hisp/dhis/reports/periodwiseprogress/action/GeneratePeriodWiseProgressAnalyserResultAction.java 2011-11-21 11:46:15 +0000
@@ -36,8 +36,6 @@
import org.amplecode.quick.StatementManager;
import org.hisp.dhis.config.Configuration_IN;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -93,7 +91,7 @@
{
this.organisationUnitService = organisationUnitService;
}
-
+/*
private DataSetService dataSetService;
public void setDataSetService( DataSetService dataSetService )
@@ -107,7 +105,7 @@
{
this.dataElementService = dataElementService;
}
-
+*/
private I18nFormat format;
public void setFormat( I18nFormat format )
@@ -270,25 +268,6 @@
}
// To get Aggregation Data
- /*
- String dataSetIds = selReportObj.getDataSetIds();
- Collection<Integer> dataElementIdList = new ArrayList<Integer>();
- if( dataSetIds != null && !dataSetIds.trim().equalsIgnoreCase( "" ) )
- {
- String[] partsOfDataSetIds = dataSetIds.split( "," );
- for( int i = 0; i < partsOfDataSetIds.length; i++ )
- {
- DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( partsOfDataSetIds[i] ) );
- dataElementIdList.addAll( getIdentifiers( DataElement.class, dataSet.getDataElements() ) );
- }
- }
- else
- {
- dataElementIdList.addAll( getIdentifiers( DataElement.class, dataElementService.getAggregateableDataElements() ) );
- }
-
- String dataElmentIdsByComma = getCommaDelimitedString( dataElementIdList );
- */
List<Report_inDesign> reportDesignList = reportService.getReportDesign( deCodesXMLFileName );
@@ -315,7 +294,6 @@
aggDeMap.putAll( reportService.getAggDataFromDataValueTable( ""+currentOrgUnit.getId(), dataElmentIdsByComma, periodsByComma ) );
}
-
Iterator<Report_inDesign> reportDesignIterator = reportDesignList.iterator();
while ( reportDesignIterator.hasNext() )
{
=== 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-11-02 09:54:19 +0000
+++ local/in/dhis-web-reports-national/src/main/resources/META-INF/dhis/beans.xml 2011-11-21 11:46:15 +0000
@@ -421,8 +421,8 @@
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="reportService" ref="org.hisp.dhis.reports.ReportService" />
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+<!-- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />-->
</bean>
<!-- Orgunitwise Progress Reports -->
@@ -440,8 +440,8 @@
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="reportService" ref="org.hisp.dhis.reports.ReportService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+<!-- <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />-->
</bean>
<!-- Meta Data Reports -->