dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17779
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7206: local vn - Fixed bug when generate the category vertical report.
------------------------------------------------------------
revno: 7206
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-06 16:43:47 +0700
message:
local vn - Fixed bug when generate the category vertical report.
modified:
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java
--
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/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java 2012-05-09 05:19:35 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportVerticalCategoryAction.java 2012-06-06 09:43:47 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.reportsheet.exporting.action;
/*
- * Copyright (c) 2004-2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,23 +26,20 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.dataelement.DataElementOperand.SEPARATOR;
-
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.apache.poi.ss.usermodel.Sheet;
-import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
-import org.hisp.dhis.reportsheet.CategoryOptionAssociationService;
import org.hisp.dhis.reportsheet.CategoryOptionGroupOrder;
import org.hisp.dhis.reportsheet.ExportItem;
import org.hisp.dhis.reportsheet.ExportReport;
import org.hisp.dhis.reportsheet.ExportReportVerticalCategory;
+import org.hisp.dhis.reportsheet.OptionComboAssociationService;
import org.hisp.dhis.reportsheet.exporting.AbstractGenerateExcelReportSupport;
import org.hisp.dhis.reportsheet.utils.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -55,17 +52,17 @@
extends AbstractGenerateExcelReportSupport
{
@Autowired
- private CategoryOptionAssociationService categoryOptionAssociationService;
+ private OptionComboAssociationService optionComboAssociationService;
@Override
protected void executeGenerateOutputFile( ExportReport exportReport, Period period )
throws Exception
{
- OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit();
+ OrganisationUnit unit = organisationUnitSelectionManager.getSelectedOrganisationUnit();
ExportReportVerticalCategory exportReportInstance = (ExportReportVerticalCategory) exportReport;
- this.installReadTemplateFile( exportReportInstance, period, organisationUnit );
+ this.installReadTemplateFile( exportReportInstance, period, unit );
for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) )
{
@@ -73,7 +70,7 @@
Collection<ExportItem> exportReportItems = exportReportInstance.getExportItemBySheet( sheetNo );
- this.generateVerticalOutPutFile( exportReportInstance, exportReportItems, organisationUnit, sheet );
+ this.generateVerticalOutPutFile( exportReportInstance, exportReportItems, unit, sheet );
}
}
@@ -84,24 +81,14 @@
private void generateVerticalOutPutFile( ExportReportVerticalCategory exportReport,
Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit, Sheet sheet )
{
- DataElement de = null;
- Set<DataElementCategoryOptionCombo> optionCombos = new HashSet<DataElementCategoryOptionCombo>();
- Set<DataElementCategoryOption> associatedCategoryOptions = new HashSet<DataElementCategoryOption>(
- categoryOptionAssociationService.getCategoryOptions( organisationUnit ) );
+ Set<DataElementCategoryOptionCombo> associatedOptionCombos = new HashSet<DataElementCategoryOptionCombo>(
+ optionComboAssociationService.getOptionCombos( organisationUnit ) );
for ( ExportItem reportItem : exportReportItems )
{
int run = 0;
int rowBegin = reportItem.getRow();
- if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
- {
- de = dataElementService.getDataElement( Integer.parseInt( reportItem.getExpression().split(
- "\\" + SEPARATOR )[0].replace( "[", "" ) ) );
-
- optionCombos = de.getCategoryCombo().getOptionCombos();
- }
-
for ( CategoryOptionGroupOrder group : exportReport.getCategoryOptionGroupOrders() )
{
int beginChapter = rowBegin;
@@ -118,59 +105,58 @@
for ( DataElementCategoryOption categoryOption : group.getCategoryOptions() )
{
- if ( associatedCategoryOptions.contains( categoryOption ) )
+ for ( DataElementCategoryOptionCombo optionCombo : associatedOptionCombos )
{
- if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
- {
- ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), categoryOption.getName(),
- ExcelUtils.TEXT, sheet, this.csText8Bold );
- }
- else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) )
- {
- ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( serial ),
- ExcelUtils.NUMBER, sheet, this.csTextSerial );
- }
- else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) )
- {
- ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils
- .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula );
- }
- else
- {
- for ( DataElementCategoryOptionCombo optionCombo : optionCombos )
- {
- if ( optionCombo.getCategoryOptions().contains( categoryOption ) )
- {
- ExportItem newReportItem = new ExportItem();
-
- String expression = reportItem.getExpression();
- expression = expression.replace( "*", String.valueOf( optionCombo.getId() ) );
-
- newReportItem.setPeriodType( reportItem.getPeriodType() );
- newReportItem.setExpression( expression );
-
- double value = this.getDataValue( newReportItem, organisationUnit );
-
- ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String
- .valueOf( value ), ExcelUtils.NUMBER, sheet, this.csNumber );
-
- break;
- }
- }
- }
-
- rowBegin++;
- serial++;
- run++;
-
- if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
- {
- String columnName = ExcelUtils.convertColumnNumberToName( reportItem.getColumn() );
- String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName
- + (rowBegin - 1) + ")";
-
- ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet,
- this.csFormula );
+ if ( categoryOption.getCategoryOptionCombos().contains( optionCombo ) )
+ {
+ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
+ {
+ ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), categoryOption.getName(),
+ ExcelUtils.TEXT, sheet, this.csText8Bold );
+ }
+ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) )
+ {
+ ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( serial ),
+ ExcelUtils.NUMBER, sheet, this.csTextSerial );
+ }
+ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.FORMULA_EXCEL ) )
+ {
+ ExcelUtils.writeFormulaByPOI( rowBegin, reportItem.getColumn(), ExcelUtils
+ .generateExcelFormula( reportItem.getExpression(), run, run ), sheet, csFormula );
+ }
+ else
+ {
+ ExportItem newReportItem = new ExportItem();
+
+ String expression = reportItem.getExpression();
+ expression = expression.replace( "*", String.valueOf( optionCombo.getId() ) );
+
+ newReportItem.setPeriodType( reportItem.getPeriodType() );
+ newReportItem.setExpression( expression );
+
+ double value = this.getDataValue( newReportItem, organisationUnit );
+
+ ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), String.valueOf( value ),
+ ExcelUtils.NUMBER, sheet, this.csNumber );
+
+ break;
+ }
+
+ rowBegin++;
+ serial++;
+ run++;
+
+ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+ {
+ String columnName = ExcelUtils.convertColumnNumberToName( reportItem.getColumn() );
+ String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName
+ + (rowBegin - 1) + ")";
+
+ ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet,
+ this.csFormula );
+ }
+
+ break;
}
}
}