=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportService.java 2010-07-25 12:54:27 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportService.java 2011-03-20 13:57:42 +0000 @@ -30,6 +30,7 @@ import java.util.Map; import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; @@ -49,7 +50,7 @@ * @param selectedUnitOnly whether to include aggregated or regular data in the map. * @return a map. */ - Map getAggregatedValueMap( DataSet dataSet, OrganisationUnit unit, Period period, boolean selectedUnitOnly ); + Map getAggregatedValueMap( DataSet dataSet, OrganisationUnit unit, Period period, boolean selectedUnitOnly, I18nFormat format ); /** * Puts in aggregated datavalues in the custom dataentry form and returns === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java 2011-03-20 13:35:54 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java 2011-03-20 13:57:42 +0000 @@ -184,6 +184,12 @@ return Character.toUpperCase( startDate.charAt( 0 ) ) + startDate.substring( 1 ) + endDate; } + /** + * Formats value. Returns empty string if value is null. Returns NaN if value + * is not a number. + * + * @param value the value to format. + */ public String formatValue( Object value ) { if ( value == null ) === 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 2011-03-01 06:02:22 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java 2011-03-20 13:57:42 +0000 @@ -27,6 +27,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.options.SystemSettingManager.AGGREGATION_STRATEGY_REAL_TIME; +import static org.hisp.dhis.options.SystemSettingManager.DEFAULT_AGGREGATION_STRATEGY; +import static org.hisp.dhis.options.SystemSettingManager.KEY_AGGREGATION_STRATEGY; + import java.util.ArrayList; import java.util.Collection; import java.util.Map; @@ -43,14 +47,12 @@ import org.hisp.dhis.datasetreport.DataSetReportService; import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.datavalue.DataValueService; +import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.options.SystemSettingManager; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; import org.hisp.dhis.system.filter.AggregatableDataElementFilter; import org.hisp.dhis.system.util.FilterUtils; -import org.hisp.dhis.system.util.MathUtils; - -import static org.hisp.dhis.options.SystemSettingManager.*; /** * @author Abyot Asalefew @@ -100,7 +102,7 @@ // DataSetReportService implementation // ------------------------------------------------------------------------- - public Map getAggregatedValueMap( DataSet dataSet, OrganisationUnit unit, Period period, boolean selectedUnitOnly ) + public Map getAggregatedValueMap( DataSet dataSet, OrganisationUnit unit, Period period, boolean selectedUnitOnly, I18nFormat format ) { String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY, DEFAULT_AGGREGATION_STRATEGY ); @@ -128,8 +130,8 @@ Double aggregatedValue = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? aggregationService.getAggregatedDataValue( dataElement, categoryOptionCombo, period.getStartDate(), period.getEndDate(), unit ) : aggregatedDataValueService.getAggregatedValue( dataElement, categoryOptionCombo, period, unit ); - - value = ( aggregatedValue != null ) ? String.valueOf( MathUtils.getRounded( aggregatedValue, 0 ) ) : null; + + value = format.formatValue( aggregatedValue ); } if ( value != null ) === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateCustomDataSetReportAction.java' --- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateCustomDataSetReportAction.java 2011-03-11 12:35:11 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateCustomDataSetReportAction.java 2011-03-20 13:57:42 +0000 @@ -132,7 +132,7 @@ throws Exception { Map aggregatedDataValueMap = dataSetReportService.getAggregatedValueMap( selectedDataSet, selectedOrgunit, selectedPeriod, - selectedUnitOnly ); + selectedUnitOnly, format ); DataEntryForm dataEntryForm = selectedDataSet.getDataEntryForm();