dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15360
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5538: local vn - Added a new export item "Extra Expression" to support in the case of Indicator export ...
------------------------------------------------------------
revno: 5538
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-22 14:43:18 +0700
message:
local vn - Added a new export item "Extra Expression" to support in the case of Indicator export item. Fixed Preview problem.
modified:
local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportItem.java
local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/GenericItem.java
local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportItem.hbm.xml
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/AddExportItemAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/UpdateExportItemAction.java
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm
local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.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/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportItem.java'
--- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportItem.java 2011-10-13 03:03:58 +0000
+++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/ExportItem.java 2011-12-22 07:43:18 +0000
@@ -58,11 +58,21 @@
public ExportItem( String name, String itemType, int row, int column, String expression )
{
- this.itemType = itemType;
- this.row = row;
- this.column = column;
- this.expression = expression;
- this.name = name;
+ this.name = name;
+ this.row = row;
+ this.column = column;
+ this.itemType = itemType;
+ this.expression = expression;
+ }
+
+ public ExportItem( String name, String itemType, int row, int column, String expression, String extraExpression )
+ {
+ this.name = name;
+ this.row = row;
+ this.column = column;
+ this.expression = expression;
+ this.extraExpression = extraExpression;
+ this.itemType = itemType;
}
// -------------------------------------------------------------------------
@@ -168,7 +178,7 @@
public static final String DAILY = "daily";
public static final String SO_FAR_THIS_MONTH = "so_far_this_month";
-
+
public static final String SO_FAR_THIS_QUARTER = "so_far_this_quarter";
// Used for other report
=== modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/GenericItem.java'
--- local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/GenericItem.java 2011-07-28 09:50:39 +0000
+++ local/vn/dhis-service-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/GenericItem.java 2011-12-22 07:43:18 +0000
@@ -73,6 +73,11 @@
*/
protected String expression;
+ /**
+ * The extraExpression for this Object.
+ */
+ protected String extraExpression;
+
// -------------------------------------------------------------------------
// Getters & setters
// -------------------------------------------------------------------------
@@ -137,4 +142,14 @@
this.expression = expression;
}
+ public String getExtraExpression()
+ {
+ return extraExpression;
+ }
+
+ public void setExtraExpression( String extraExpression )
+ {
+ this.extraExpression = extraExpression;
+ }
+
}
=== modified file 'local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportItem.hbm.xml'
--- local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportItem.hbm.xml 2011-07-28 09:50:39 +0000
+++ local/vn/dhis-service-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/hibernate/ExportItem.hbm.xml 2011-12-22 07:43:18 +0000
@@ -21,6 +21,7 @@
<property name="row" column="excelrow" not-null="true"/>
<property name="column" column="excelcolumn" not-null="true"/>
<property name="expression" column="itemexpression" not-null="true"/>
+ <property name="extraExpression" column="itemextraexpression"/>
<property name="periodType" column="periodtype" not-null="true"/>
</class>
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2011-11-09 07:34:53 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2011-12-22 07:43:18 +0000
@@ -109,6 +109,7 @@
for ( ExportItem reportItem : exportReportItems )
{
int run = 0;
+ int next = 0;
int chapperNo = 0;
int firstRow = reportItem.getRow();
int rowBegin = firstRow + 1;
@@ -148,9 +149,8 @@
else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.SERIAL )
&& (!organisationUnits.isEmpty()) )
{
- ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo], ExcelUtils.TEXT,
- sheet, this.csText12BoldCenter );
- chapperNo++;
+ ExcelUtils.writeValueByPOI( rowBegin, reportItem.getColumn(), chappter[chapperNo++],
+ ExcelUtils.TEXT, sheet, this.csText12BoldCenter );
}
run++;
@@ -195,27 +195,45 @@
serial++;
}
- if ( (reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) || reportItem
- .getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ))
- && (!organisationUnits.isEmpty()) )
+ if ( !organisationUnits.isEmpty() )
{
- String columnName = ExcelUtils.convertColumnNumberToName( reportItem.getColumn() );
- String formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")";
-
- ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet, this.csFormula );
-
- totalFormula += columnName + beginChapter + ",";
+ String formula = "";
+
+ if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
+ {
+ String columnName = ExcelUtils.convertColumnNumberToName( reportItem.getColumn() );
+ formula = "SUM(" + columnName + (beginChapter + 1) + ":" + columnName + (rowBegin - 1) + ")";
+
+ ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet,
+ this.csFormula );
+
+ totalFormula += columnName + beginChapter + ",";
+ }
+ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
+ {
+ formula = ExcelUtils.generateExcelFormula( reportItem.getExtraExpression(), next + 1, 0 );
+
+ ExcelUtils.writeFormulaByPOI( beginChapter, reportItem.getColumn(), formula, sheet,
+ this.csFormula );
+ }
}
+
+ next = run;
}
- if ( (reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) || reportItem.getItemType()
- .equalsIgnoreCase( ExportItem.TYPE.INDICATOR ))
+ if ( (reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ))
&& !totalFormula.equals( PREFIX_FORMULA_SUM ) )
{
totalFormula = totalFormula.substring( 0, totalFormula.length() - 1 ) + ")";
ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula );
}
+ else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
+ {
+ totalFormula = ExcelUtils.generateExcelFormula( reportItem.getExtraExpression(), 0, 0 );
+
+ ExcelUtils.writeFormulaByPOI( firstRow, reportItem.getColumn(), totalFormula, sheet, this.csFormula );
+ }
}
}
}
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/AddExportItemAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/AddExportItemAction.java 2011-08-04 08:39:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/AddExportItemAction.java 2011-12-22 07:43:18 +0000
@@ -75,6 +75,13 @@
this.expression = expression;
}
+ private String extraExpression;
+
+ public void setExtraExpression( String extraExpression )
+ {
+ this.extraExpression = extraExpression;
+ }
+
private String periodType;
public void setPeriodType( String periodType )
@@ -129,6 +136,7 @@
exportItem.setRow( row );
exportItem.setColumn( column );
exportItem.setExpression( expression );
+ exportItem.setExtraExpression( extraExpression );
exportItem.setPeriodType( periodType );
exportItem.setSheetNo( (sheetNo) );
exportItem.setExportReport( exportReportService.getExportReport( exportReportId ) );
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/UpdateExportItemAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/UpdateExportItemAction.java 2011-08-04 08:39:55 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exportitem/action/UpdateExportItemAction.java 2011-12-22 07:43:18 +0000
@@ -82,6 +82,13 @@
this.expression = expression;
}
+ private String extraExpression;
+
+ public void setExtraExpression( String extraExpression )
+ {
+ this.extraExpression = extraExpression;
+ }
+
private String periodType;
public void setPeriodType( String periodType )
@@ -126,12 +133,13 @@
throws Exception
{
ExportItem exportItem = exportReportService.getExportItem( id );
-
+
exportItem.setName( name );
exportItem.setItemType( itemType );
exportItem.setRow( row );
exportItem.setColumn( column );
exportItem.setExpression( expression );
+ exportItem.setExtraExpression( extraExpression );
exportItem.setPeriodType( periodType );
exportItem.setSheetNo( (sheetNo) );
exportItem.setExportReport( exportReportService.getExportReport( exportReportId ) );
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java 2011-11-09 07:34:53 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponse.java 2011-12-22 07:43:18 +0000
@@ -254,33 +254,25 @@
xml.append( "<sheet id='" + (sheetNo) + "'>" );
xml.append( "<name><![CDATA[" + s.getSheetName() + "]]></name>" );
- int i = 0;
- int j = 0;
-
for ( Row row : s )
{
- j = 0;
-
- xml.append( "<row index='" + i + "'>" );
+ xml.append( "<row index='" + row.getRowNum() + "'>" );
for ( Cell cell : row )
{
// Remember that empty cells can contain format information
if ( (cell.getCellStyle() != null) || cell.getCellType() != Cell.CELL_TYPE_BLANK )
{
- xml.append( "<col no='" + j + "'><data>" );
- xml.append( "<![CDATA[" + readValueByPOI( i + 1, j + 1, s, evaluatorFormula ) + "]]></data>" );
+ xml.append( "<col no='" + cell.getColumnIndex() + "'>" );
+ xml.append( "<data><![CDATA["
+ + readValueByPOI( row.getRowNum() + 1, cell.getColumnIndex() + 1, s, evaluatorFormula )
+ + "]]></data>" );
this.readingDetailsFormattedCell( cell, bDetailed );
xml.append( "</col>" );
}
-
- j++;
}
-
- i++;
-
xml.append( "</row>" );
}
xml.append( "</sheet>" );
@@ -294,8 +286,9 @@
if ( format != null )
{
xml.append( "<format align='" + convertAlignmentString( format.getAlignment() ) + "'" );
- xml.append( " border='" + format.getBorderBottom() + format.getBorderLeft() + format.getBorderRight()
- + format.getBorderTop() + "'" );
+ xml.append( " border='"
+ + (format.getBorderBottom() + format.getBorderLeft() + format.getBorderRight() + format.getBorderTop())
+ + "'" );
Font font = WORKBOOK.getFontAt( format.getFontIndex() );
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm 2011-07-28 09:50:39 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/addExportItemForm.vm 2011-12-22 07:43:18 +0000
@@ -57,11 +57,17 @@
</tr>
<tr>
<td><label>$i18n.getString('expression')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td>
- <input type="button" id="expression-button" value="$i18n.getString('expression')" style="width:20em"/>
+ <td>
+ <input type="button" id="expression-button" value="$i18n.getString('expression')" style="width:20em"/>
<input type="hidden" id="expression" name="expression" style="width:15em" class="{validate:{required:true}}"/>
</td>
- </tr>
+ </tr>
+ <tr>
+ <td><label>$i18n.getString('extra_expression')</label></td>
+ <td>
+ <input type="text" id="extraExpression" name="extraExpression" style="width:20em"/>
+ </td>
+ </tr>
<tr>
<td><label>$i18n.getString('sheet_no')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><input type="text" id="sheetNo" name="sheetNo" style="width:20em" class="{validate:{required:true,number:true}}"/></td>
=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.vm'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.vm 2011-07-28 09:50:39 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/report/updateExportItemForm.vm 2011-12-22 07:43:18 +0000
@@ -59,12 +59,17 @@
</tr>
<tr>
<td><label>$i18n.getString('expression')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td>
- <input type="button" id="expression-button" value="$i18n.getString('expression')" style="width:20em"/>
- <input type="hidden" id="expression" name="expression" value="$exportItem.expression" style="width:15em" class="{validate:{required:true}}"/>
- </td>
-
- </tr>
+ <td>
+ <input type="button" id="expression-button" value="$i18n.getString('expression')" style="width:20em"/>
+ <input type="hidden" id="expression" name="expression" value="$exportItem.expression" style="width:15em" class="{validate:{required:true}}"/>
+ </td>
+ </tr>
+ <tr>
+ <td><label>$i18n.getString('extra_expression')</label></td>
+ <td>
+ <input type="text" id="extraExpression" name="extraExpression" style="width:20em" value="$!exportItem.extraExpression"/>
+ </td>
+ </tr>
<tr>
<td><label>$i18n.getString('sheet_no')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><input type="text" id="sheetNo" name="sheetNo" value="$exportItem.sheetNo" style="width:20em" class="{validate:{required:true,number:true}}"/></td>