dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43525
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22063: Analytics, moved util method
------------------------------------------------------------
revno: 22063
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2016-02-27 12:01:21 +0100
message:
Analytics, moved util method
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsUtils.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.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-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsUtils.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsUtils.java 2016-02-27 10:57:15 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsUtils.java 2016-02-27 11:01:21 +0000
@@ -32,6 +32,7 @@
import static org.hisp.dhis.system.util.DateUtils.getMediumDateString;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -189,4 +190,27 @@
return valueMap.entrySet().stream().collect( Collectors.toMap( e -> e.getKey().replaceFirst(
DimensionalObject.DIMENSION_SEP, DimensionalObjectUtils.COMPOSITE_DIM_OBJECT_PLAIN_SEP ), e -> e.getValue() ) );
}
+
+ /**
+ * Converts a String, Object map into a specific String, Double map.
+ *
+ * @param map the map to convert.
+ * @return a mapping between string and double values.
+ */
+ public static Map<String, Double> getDoubleMap( Map<String, Object> map )
+ {
+ Map<String, Double> typedMap = new HashMap<>();
+
+ for ( Map.Entry<String, Object> entry : map.entrySet() )
+ {
+ final Object value = entry.getValue();
+
+ if ( value != null && Double.class.equals( value.getClass() ) )
+ {
+ typedMap.put( entry.getKey(), (Double) entry.getValue() );
+ }
+ }
+
+ return typedMap;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2016-02-27 10:57:15 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2016-02-27 11:01:21 +0000
@@ -744,7 +744,7 @@
*/
private Map<String, Double> getAggregatedDataValueMap( DataQueryParams params )
{
- return getDoubleMap( getAggregatedValueMap( params, ANALYTICS_TABLE_NAME ) );
+ return AnalyticsUtils.getDoubleMap( getAggregatedValueMap( params, ANALYTICS_TABLE_NAME ) );
}
/**
@@ -770,7 +770,7 @@
*/
private Map<String, Double> getAggregatedCompletenessValueMap( DataQueryParams params )
{
- return getDoubleMap( getAggregatedValueMap( params, COMPLETENESS_TABLE_NAME ) );
+ return AnalyticsUtils.getDoubleMap( getAggregatedValueMap( params, COMPLETENESS_TABLE_NAME ) );
}
/**
@@ -783,7 +783,7 @@
*/
private Map<String, Double> getAggregatedCompletenessTargetMap( DataQueryParams params )
{
- return getDoubleMap( getAggregatedValueMap( params, COMPLETENESS_TARGET_TABLE_NAME ) );
+ return AnalyticsUtils.getDoubleMap( getAggregatedValueMap( params, COMPLETENESS_TARGET_TABLE_NAME ) );
}
/**
@@ -797,7 +797,7 @@
*/
private Map<String, Double> getAggregatedOrganisationUnitTargetMap( DataQueryParams params )
{
- return getDoubleMap( getAggregatedValueMap( params, ORGUNIT_TARGET_TABLE_NAME ) );
+ return AnalyticsUtils.getDoubleMap( getAggregatedValueMap( params, ORGUNIT_TARGET_TABLE_NAME ) );
}
/**
@@ -1007,29 +1007,6 @@
}
/**
- * Converts a String, Object map into a specific String, Double map.
- *
- * @param map the map to convert.
- * @return a mapping between string and double values.
- */
- private Map<String, Double> getDoubleMap( Map<String, Object> map )
- {
- Map<String, Double> typedMap = new HashMap<>();
-
- for ( Map.Entry<String, Object> entry : map.entrySet() )
- {
- final Object value = entry.getValue();
-
- if ( value != null && Double.class.equals( value.getClass() ) )
- {
- typedMap.put( entry.getKey(), (Double) entry.getValue() );
- }
- }
-
- return typedMap;
- }
-
- /**
* Returns the max records limit. 0 indicates no limit.
*
* @return the max records limit.