=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java 2012-01-04 09:10:17 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java 2012-01-19 12:19:18 +0000 @@ -27,7 +27,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.dataentryform.DataEntryFormService.IDENTIFIER_PATTERN; +import static org.hisp.dhis.dataentryform.DataEntryFormService.*; import static org.hisp.dhis.dataentryform.DataEntryFormService.INDICATOR_PATTERN; import static org.hisp.dhis.dataentryform.DataEntryFormService.INPUT_PATTERN; import static org.hisp.dhis.options.SystemSettingManager.AGGREGATION_STRATEGY_REAL_TIME; @@ -395,6 +395,17 @@ map.put( dataElement.getId() + SEPARATOR + categoryOptionCombo.getId(), value ); } } + + Double aggregatedValue = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? + aggregationService.getAggregatedDataValue( dataElement, null, period.getStartDate(), period.getEndDate(), unit ) : + aggregatedDataValueService.getAggregatedValue( dataElement, period, unit ); + + String value = format.formatValue( aggregatedValue ); + + if ( value != null ) + { + map.put( String.valueOf( dataElement.getId() ), value ); + } } return map; @@ -464,6 +475,7 @@ String inputHtml = inputMatcher.group( 1 ); Matcher identifierMatcher = IDENTIFIER_PATTERN.matcher( inputHtml ); + Matcher dataElementTotalMatcher = DATAELEMENT_TOTAL_PATTERN.matcher( inputHtml ); Matcher indicatorMatcher = INDICATOR_PATTERN.matcher( inputHtml ); // ----------------------------------------------------------------- @@ -481,6 +493,16 @@ inputMatcher.appendReplacement( buffer, dataValue ); } + else if ( dataElementTotalMatcher.find() && dataElementTotalMatcher.groupCount() > 0 ) + { + Integer dataElementId = Integer.parseInt( dataElementTotalMatcher.group( 1 ) ); + + String dataValue = dataValues.get( String.valueOf( dataElementId ) ); + + dataValue = dataValue != null ? dataValue : NULL_REPLACEMENT; + + inputMatcher.appendReplacement( buffer, dataValue ); + } else if ( indicatorMatcher.find() && indicatorMatcher.groupCount() > 0 ) { Integer indicatorId = Integer.parseInt( indicatorMatcher.group( 1 ) );