← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19378: Analytics, code readability fix

 

------------------------------------------------------------
revno: 19378
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-06-13 14:41:24 +0200
message:
  Analytics, code readability fix
modified:
  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/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-06-13 12:11:43 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-06-13 12:41:24 +0000
@@ -470,6 +470,7 @@
             Map<String, String> uidNameMap = getUidNameMap( params );
             Map<String, String> cocNameMap = getCocNameMap( params );
             uidNameMap.putAll( cocNameMap );
+            uidNameMap.put( DATA_X_DIM_ID, DISPLAY_NAME_DATA_X );
 
             metaData.put( NAMES_META_KEY, uidNameMap );
 
@@ -1280,33 +1281,16 @@
     }
 
     /**
-     * Returns a mapping between the identifier and the name of all dimension and
-     * filter items for the given parameters.
-     *
-     * @param params the data query.
-     * @return a mapping between identifiers and names.
-     */
-    private Map<String, String> getUidNameMap( DataQueryParams params )
-    {
-        Map<String, String> map = new HashMap<>();
-        map.putAll( getUidNameMap( params.getDimensions(), params.isHierarchyMeta(), params.getDisplayProperty() ) );
-        map.putAll( getUidNameMap( params.getFilters(), params.isHierarchyMeta(), params.getDisplayProperty() ) );
-        map.put( DATA_X_DIM_ID, DISPLAY_NAME_DATA_X );
-
-        return map;
-    }
-
-    /**
      * Returns a mapping between identifiers and names for the given dimensional
      * objects.
      *
-     * @param dimensions the dimensional objects.
-     * @param hierarchyMeta indicates whether to include meta data of the
-     *        organisation unit hierarchy.
+     * @param params the data query parameters.
      * @return a mapping between identifiers and names.
      */
-    private Map<String, String> getUidNameMap( List<DimensionalObject> dimensions, boolean hierarchyMeta, DisplayProperty displayProperty )
+    private Map<String, String> getUidNameMap( DataQueryParams params )
     {
+        List<DimensionalObject> dimensions = params.getDimensionsAndFilters();
+        
         Map<String, String> map = new HashMap<>();
         
         Calendar calendar = PeriodType.getCalendar();
@@ -1325,23 +1309,23 @@
                 }
                 else
                 {
-                    map.put( object.getUid(), NameableObjectUtils.getDisplayProperty( object, displayProperty ) );
+                    map.put( object.getUid(), NameableObjectUtils.getDisplayProperty( object, params.getDisplayProperty() ) );
                 }
 
-                if ( DimensionType.ORGANISATIONUNIT.equals( dimension.getDimensionType() ) && hierarchyMeta )
+                if ( DimensionType.ORGANISATIONUNIT.equals( dimension.getDimensionType() ) && params.isHierarchyMeta() )
                 {
                     OrganisationUnit unit = (OrganisationUnit) object;
                     
-                    map.putAll( NameableObjectUtils.getUidDisplayPropertyMap( unit.getAncestors(), displayProperty ) );
+                    map.putAll( NameableObjectUtils.getUidDisplayPropertyMap( unit.getAncestors(), params.getDisplayProperty() ) );
                 }
             }
 
-            map.put( dimension.getDimension(), NameableObjectUtils.getDisplayProperty( dimension, displayProperty ) );
+            map.put( dimension.getDimension(), NameableObjectUtils.getDisplayProperty( dimension, params.getDisplayProperty() ) );
         }
 
         return map;
     }
-
+    
     /**
      * Returns a mapping between the category option combo identifiers and names
      * in the given grid.