← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7229: local vn - Fixed bug "Show data in Period Column Listing report".

 

------------------------------------------------------------
revno: 7229
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-06-07 13:25:18 +0700
message:
  local vn - Fixed bug "Show data in Period Column Listing report".
modified:
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java
  local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.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/GenerateExcelReportGeneric.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java	2012-05-12 15:59:33 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java	2012-06-07 06:25:18 +0000
@@ -120,12 +120,12 @@
     CurrentUserService currentUserService;
 
     @Autowired
-    IndicatorService indicatorService;
-
-    @Autowired
     InitializePOIStylesManager initPOIStylesManager;
 
     @Autowired
+    protected IndicatorService indicatorService;
+
+    @Autowired
     protected AggregationService aggregationService;
 
     @Autowired
@@ -452,7 +452,7 @@
     }
 
     // -------------------------------------------------------------------------
-    // DataElement Value
+    // DataElement Value as Text
     // -------------------------------------------------------------------------
 
     protected String getTextValue( ExportItem exportItem, OrganisationUnit organisationUnit )
@@ -484,12 +484,52 @@
         for ( Period p : periods )
         {
             result += generateExpression( exportItem, p, organisationUnit, dataElementService, categoryService,
-                dataValueService )
-                + "\n";
-        }
-
-        return result;
-    }
+                dataValueService );
+            result += "\n";
+        }
+
+        return result;
+    }
+
+    protected String getTextValue( ExportItem exportItem, OrganisationUnit organisationUnit, Date startDate, Date endDate )
+    {
+        String result = "";
+        Collection<Period> periods = new ArrayList<Period>();
+
+        if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.DAILY ) )
+        {
+            periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( DailyPeriodType.NAME ),
+                startDate, startDate );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.SELECTED_MONTH ) )
+        {
+            periods = periodService.getPeriodsBetweenDates(
+                periodService.getPeriodTypeByName( MonthlyPeriodType.NAME ), startDate, endDate );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.QUARTERLY ) )
+        {
+            periods = periodService.getPeriodsBetweenDates( periodService
+                .getPeriodTypeByName( QuarterlyPeriodType.NAME ), startDate, endDate );
+        }
+        else if ( exportItem.getPeriodType().equalsIgnoreCase( ExportItem.PERIODTYPE.YEARLY ) )
+        {
+            periods = periodService.getPeriodsBetweenDates( periodService.getPeriodTypeByName( YearlyPeriodType.NAME ),
+                startDate, endDate );
+        }
+
+        for ( Period p : periods )
+        {
+            result += generateExpression( exportItem, p, organisationUnit, dataElementService, categoryService,
+                dataValueService );
+            result += "\n";
+        }
+
+        return result;
+    }
+
+    // -------------------------------------------------------------------------
+    // DataElement Value
+    // -------------------------------------------------------------------------
 
     protected double getDataValue( ExportItem exportItem, OrganisationUnit organisationUnit )
     {

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java	2012-05-04 09:50:39 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportPeriodColumnListingAction.java	2012-06-07 06:25:18 +0000
@@ -39,6 +39,8 @@
 import org.hisp.dhis.reportsheet.PeriodColumn;
 import org.hisp.dhis.reportsheet.exporting.AbstractGenerateExcelReportSupport;
 import org.hisp.dhis.reportsheet.utils.ExcelUtils;
+import org.hisp.dhis.reportsheet.utils.ExpressionUtils;
+import org.hisp.dhis.system.util.MathUtils;
 
 /**
  * @author Tran Thanh Tri
@@ -87,18 +89,24 @@
 
                     if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT ) )
                     {
-                        value = this.getDataValue( reportItem, organisationUnit );
+                        // value = this.getDataValue( reportItem, organisationUnit );
+
+                        value = MathUtils.calculateExpression( ExpressionUtils.generateExpression( reportItem, p
+                            .getStartdate(), p.getEnddate(), organisationUnit, dataElementService, categoryService, aggregationService ) );
                     }
                     else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.DATAELEMENT_VALUETYPE_TEXT ) )
                     {
-                        String result = this.getTextValue( reportItem, organisationUnit );
+                        String result = this.getTextValue( reportItem, organisationUnit, p.getStartdate(), p.getEnddate() );
 
                         ExcelUtils.writeValueByPOI( reportItem.getRow(), reportItem.getColumn(), result,
                             ExcelUtils.TEXT, sheet, this.csText );
                     }
                     else if ( reportItem.getItemType().equalsIgnoreCase( ExportItem.TYPE.INDICATOR ) )
                     {
-                        value = this.getIndicatorValue( reportItem, organisationUnit );
+                        // value = this.getIndicatorValue( reportItem, organisationUnit );
+
+                        value = MathUtils.calculateExpression( ExpressionUtils.generateIndicatorExpression( reportItem,
+                            p.getStartdate(), p.getEnddate(), organisationUnit, indicatorService, aggregationService ) );
                     }
 
                     ExcelUtils.writeValueByPOI( reportItem.getRow(), p.getColumn(), String.valueOf( value ),

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java	2012-04-06 06:21:25 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExcelUtils.java	2012-06-07 06:25:18 +0000
@@ -370,7 +370,7 @@
             }
             else if ( type.equalsIgnoreCase( ExcelUtils.NUMBER ) )
             {
-                if ( value == null )
+                if ( value == null || Double.valueOf( value ) == 0 )
                 {
                     cellPOI.setCellType( POI_CELLSTYLE_BLANK );
                 }

=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java	2012-04-29 09:57:26 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java	2012-06-07 06:25:18 +0000
@@ -234,6 +234,6 @@
         // aggregatedDataValueService.getAggregatedValue( dataElement,
         // optionCombo, startDate, endDate, );
 
-        return (aggregatedValue == null) ? 0.0 : aggregatedValue;
+        return (aggregatedValue == null) ? 0 : aggregatedValue;
     }
 }