dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27944
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13933: Impl method DataQueryParams.getPermutationOrgUnitGroupCountMap
------------------------------------------------------------
revno: 13933
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-02-04 16:46:45 +0200
message:
Impl method DataQueryParams.getPermutationOrgUnitGroupCountMap
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.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/DataQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2014-02-04 08:24:06 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2014-02-04 14:46:45 +0000
@@ -709,6 +709,37 @@
}
/**
+ * Returns a mapping of permutations keys (org unit id or null) and mappings
+ * of org unit group and counts, based on the given mapping of dimension option
+ * keys and counts.
+ */
+ public Map<String, Map<String, Integer>> getPermutationOrgUnitGroupCountMap( Map<String, Double> orgUnitCountMap )
+ {
+ MapMap<String, String, Integer> countMap = new MapMap<String, String, Integer>();
+
+ for ( String key : orgUnitCountMap.keySet() )
+ {
+ List<String> keys = new ArrayList<String>( Arrays.asList( key.split( DIMENSION_SEP ) ) );
+
+ // Org unit group always at last index, org unit potentially at first
+
+ int ougInx = keys.size() - 1;
+
+ String oug = keys.get( ougInx );
+
+ ListUtils.removeAll( keys, ougInx );
+
+ String permKey = StringUtils.join( keys, DIMENSION_SEP );
+
+ Integer count = orgUnitCountMap.get( key ).intValue();
+
+ countMap.putEntry( permKey, oug, count );
+ }
+
+ return countMap;
+ }
+
+ /**
* Retrieves the options for the given dimension identifier. Returns null if
* the dimension is not present.
*/
=== 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 2014-02-04 08:24:06 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2014-02-04 14:46:45 +0000
@@ -246,7 +246,7 @@
Map<String, Double> constantMap = constantService.getConstantMap();
Period filterPeriod = dataSourceParams.getFilterPeriod();
-
+
for ( Indicator indicator : indicators )
{
for ( List<DimensionItem> options : dimensionItemPermutations )
@@ -481,11 +481,7 @@
return getAggregatedDataValueMapping( grid );
}
- /**
- * Get a mapping between xx and count of organisation units for the given
- * indicators.
- */
- private Map<String, Double> getOrgUnitTargetMap( DataQueryParams params, Collection<Indicator> indicators )
+ private Map<String, Map<String, Integer>> getOrgUnitTargetMap( DataQueryParams params, Collection<Indicator> indicators )
{
Set<OrganisationUnitGroup> orgUnitGroups = expressionService.getOrganisationUnitGroupsInIndicators( indicators );
@@ -498,7 +494,9 @@
orgUnitTargetParams.getDimensions().add( new BaseDimensionalObject( DimensionalObject.ORGUNIT_GROUP_DIM_ID, null, new ArrayList<NameableObject>( orgUnitGroups ) ) );
orgUnitTargetParams.setSkipPartitioning( true );
- return getAggregatedOrganisationUnitTargetMap( orgUnitTargetParams );
+ Map<String, Double> orgUnitCountMap = getAggregatedOrganisationUnitTargetMap( orgUnitTargetParams );
+
+ return orgUnitTargetParams.getPermutationOrgUnitGroupCountMap( orgUnitCountMap );
}
/**