← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1838: Returning two decimals for aggregated value in mapping service

 

------------------------------------------------------------
revno: 1838
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Sun 2010-07-11 08:05:31 +0200
message:
  Returning two decimals for aggregated value in mapping service
modified:
  dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.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-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2010-07-10 15:40:26 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2010-07-11 06:05:31 +0000
@@ -53,6 +53,7 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.util.MathUtils;
 import org.hisp.dhis.user.UserSettingService;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -164,12 +165,12 @@
             Double value = aggregationService.getAggregatedDataValue( dataElement, null, period.getStartDate(), period.getEndDate(), organisationUnit );
             
             if ( value != null )
-            {
+            { 
                 AggregatedMapValue mapValue = new AggregatedMapValue();
                 mapValue.setOrganisationUnitId( organisationUnit.getId() );
                 mapValue.setOrganisationUnitName( organisationUnit.getName() );
                 mapValue.setPeriodId( period.getId() );
-                mapValue.setValue( value );
+                mapValue.setValue( MathUtils.getRounded( value, 2 ) );
                 
                 values.add( mapValue );
             }
@@ -226,7 +227,6 @@
         OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentOrganisationUnitId );
         Indicator indicator = indicatorService.getIndicator( indicatorId );
         Period period = periodService.getPeriod( periodId );
-        int factor = indicator.getIndicatorType().getFactor();
         
         for ( OrganisationUnit organisationUnit : parent.getChildren() )
         {
@@ -235,11 +235,10 @@
             if ( value != null )
             {
                 AggregatedMapValue mapValue = new AggregatedMapValue();
-                mapValue.setFactor( factor );
                 mapValue.setOrganisationUnitId( organisationUnit.getId() );
                 mapValue.setOrganisationUnitName( organisationUnit.getName() );
                 mapValue.setPeriodId( period.getId() );
-                mapValue.setValue( value );
+                mapValue.setValue( MathUtils.getRounded( value, 2 ) );
                 
                 values.add( mapValue );
             }