dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05200
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1712: Mirror fix.
------------------------------------------------------------
revno: 1712
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-03-30 17:28:18 +0700
message:
Mirror fix.
modified:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.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 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java 2010-03-30 02:59:14 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportSupport.java 2010-03-30 10:28:18 +0000
@@ -61,7 +61,6 @@
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.datamart.DataMartStore;
-import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
@@ -89,7 +88,8 @@
* @author Dang Duy Hieu
* @author Tran Thanh Tri
* @since 2009-09-18
- * @version $Id: GenerateReportSupport.java 6216 2010-03-10 13:40:42Z Chau Thu Tran$
+ * @version $Id: GenerateReportSupport.java 6216 2010-03-10 13:40:42Z Chau Thu
+ * Tran$
*/
public abstract class GenerateReportSupport
implements Action
@@ -650,19 +650,8 @@
if ( !(dataElement instanceof CalculatedDataElement) )
{
-
- double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, optionCombo,
- startDate, endDate, organisationUnit );
-
- if ( aggregatedValue == AggregationService.NO_VALUES_REGISTERED )
- {
- replaceString = NULL_REPLACEMENT;
- }
- else
- {
- replaceString = String.valueOf( aggregatedValue );
- }
-
+ replaceString = getValue( dataElement, optionCombo, organisationUnit ) + "";
+
matcher.appendReplacement( buffer, replaceString );
matcher.appendTail( buffer );
@@ -675,12 +664,12 @@
int factor = 0;
- int value = 0;
+ double value = 0.0;
Map<String, Integer> factorMap = dataElementService.getOperandFactors( calculatedDataElement );
Collection<String> operandIds = dataElementService.getOperandIds( calculatedDataElement );
-
+
for ( String operandId : operandIds )
{
factor = factorMap.get( operandId );
@@ -689,23 +678,23 @@
optionComboIdString = operandId.substring( operandId.indexOf( SEPARATOR ) + 1, operandId
.length() );
- DataElement element = dataElementService.getDataElement( Integer.parseInt( dataElementIdString ) );
+ DataElement element = dataElementService
+ .getDataElement( Integer.parseInt( dataElementIdString ) );
optionCombo = categoryService.getDataElementCategoryOptionCombo( Integer
.parseInt( optionComboIdString ) );
- DataValue dataValue = dataValueService.getDataValue( organisationUnit, element, period, optionCombo );
-
- if ( dataValue != null )
- {
- value += Integer.parseInt( dataValue.getValue() ) * factor;
- }
+
+ double dataValue = getValue( element, optionCombo, organisationUnit );
+
+ value += dataValue * factor;
+
}
-
+
buffer.append( value );
-
+
break;
}
}
-
+
return buffer.toString();
}
catch ( NumberFormatException ex )
@@ -714,6 +703,20 @@
}
}
+ private double getValue( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
+ OrganisationUnit organisationUnit )
+ {
+ double aggregatedValue = aggregationService.getAggregatedDataValue( dataElement, optionCombo, startDate,
+ endDate, organisationUnit );
+
+ if ( aggregatedValue == AggregationService.NO_VALUES_REGISTERED )
+ {
+ aggregatedValue = 0;
+ }
+
+ return aggregatedValue;
+ }
+
protected void installReadTemplateFile( ReportExcel reportExcel, Period period,
OrganisationUnitGroup organisationUnitGroup )
throws Exception