dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17139
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6727: local vn - Fixed in generating the attribute report.
------------------------------------------------------------
revno: 6727
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-25 09:57:38 +0700
message:
local vn - Fixed in generating the attribute report.
modified:
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.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/GenerateReportAttributeAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java 2012-04-19 05:15:58 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportAttributeAction.java 2012-04-25 02:57:38 +0000
@@ -69,13 +69,16 @@
this.installReadTemplateFile( exportReportInstance, period, organisationUnit );
+ DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+
for ( Integer sheetNo : exportReportService.getSheets( selectionManager.getSelectedReportId() ) )
{
Sheet sheet = this.templateWorkbook.getSheetAt( sheetNo - 1 );
Collection<ExportItem> exportReportItems = exportReportInstance.getExportItemBySheet( sheetNo );
- this.generateOutPutFile( exportReportInstance, exportReportItems, organisationUnit, sheet );
+ this.generateOutPutFile( defaultOptionCombo, exportReportInstance, exportReportItems, organisationUnit,
+ sheet );
}
}
@@ -83,31 +86,43 @@
// Supportive method
// -------------------------------------------------------------------------
- private void generateOutPutFile( ExportReportAttribute exportReport, Collection<ExportItem> exportReportItems,
- OrganisationUnit organisationUnit, Sheet sheet )
+ private void generateOutPutFile( DataElementCategoryOptionCombo optionCombo, ExportReportAttribute exportReport,
+ Collection<ExportItem> exportReportItems, OrganisationUnit organisationUnit, Sheet sheet )
{
- DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+ boolean flag = false;
+ int rowBegin = 0;
- for ( ExportItem exportItem : exportReportItems )
+ for ( AttributeValueGroupOrder avgOrder : exportReport.getAttributeValueOrders() )
{
- int rowBegin = exportItem.getRow();
-
- for ( AttributeValueGroupOrder avgOrder : exportReport.getAttributeValueOrders() )
+ int serial = 1;
+ DataElement de = null;
+ List<DataElement> dataElements = null;
+
+ flag = true;
+
+ for ( String avalue : avgOrder.getAttributeValues() )
{
- int beginChapter = rowBegin;
-
- if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
- {
- ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), avgOrder.getName(), ExcelUtils.TEXT,
- sheet, this.csText12BoldCenter );
- }
-
- rowBegin++;
- int serial = 1;
- List<DataElement> dataElements = null;
-
- for ( String avalue : avgOrder.getAttributeValues() )
- {
+ dataElements = new ArrayList<DataElement>( localDataElementService.getDataElementsByAttribute( avgOrder
+ .getAttribute(), avalue ) );
+
+ Collections.sort( dataElements, new DataElementFormNameComparator() );
+
+ for ( ExportItem exportItem : exportReportItems )
+ {
+ rowBegin = (rowBegin == 0 ? exportItem.getRow() : exportItem.getRow() + rowBegin - 1);
+ // int beginChapter = rowBegin;
+
+ if ( flag )
+ {
+ if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
+ {
+ ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), avgOrder.getName(),
+ ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
+ }
+
+ rowBegin++;
+ }
+
if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_NAME ) )
{
ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), avalue, ExcelUtils.TEXT, sheet,
@@ -115,42 +130,42 @@
}
else if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL ) )
{
- ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), String.valueOf( serial ),
- ExcelUtils.NUMBER, sheet, this.csTextSerial );
+ ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), serial + "", ExcelUtils.NUMBER,
+ sheet, this.csTextSerial );
}
else
{
- int innerColumn = exportItem.getColumn();
-
ExportItem newExportItem = new ExportItem();
- dataElements = new ArrayList<DataElement>( localDataElementService.getDataElementsByAttribute(
- avgOrder.getAttribute(), avalue ) );
-
- Collections.sort( dataElements, new DataElementFormNameComparator() );
-
- for ( DataElement de : dataElements )
+ de = dataElements.get( Integer.parseInt( exportItem.getExtraExpression() ) - 1 );
+
+ if ( de != null )
{
- newExportItem.setExpression( de.getId() + SEPARATOR + defaultOptionCombo.getId() );
+ newExportItem.setExpression( de.getId() + SEPARATOR + optionCombo.getId() );
double value = this.getDataValue( newExportItem, organisationUnit );
- ExcelUtils.writeValueByPOI( rowBegin, innerColumn++, String.valueOf( value ),
+ ExcelUtils.writeValueByPOI( rowBegin, exportItem.getColumn(), value + "",
ExcelUtils.NUMBER, sheet, this.csNumber );
}
}
-
- rowBegin++;
- serial++;
- }
-
- if ( exportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
- {
- String columnName = ExcelUtils.convertColumnNumberToName( exportItem.getColumn() );
- String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")";
-
- ExcelUtils.writeFormulaByPOI( beginChapter, exportItem.getColumn(), formula, sheet, this.csFormula );
- }
+ }
+
+ flag = false;
+ rowBegin++;
+ serial++;
+
+ // if ( exportItem.getItemType().equalsIgnoreCase(
+ // ExportItem.TYPE.DATAELEMENT ) )
+ // {
+ // String columnName = ExcelUtils.convertColumnNumberToName(
+ // exportItem.getColumn() );
+ // String formula = "SUM(" + columnName + (beginChapter + 1) +
+ // ":" + columnName + (rowBegin - 1) + ")";
+ //
+ // ExcelUtils.writeFormulaByPOI( beginChapter,
+ // exportItem.getColumn(), formula, sheet, this.csFormula );
+ // }
}
}
}