dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21705
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10351: Analytics, fixed bug related to meta-data
------------------------------------------------------------
revno: 10351
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-03-20 14:04:15 +0100
message:
Analytics, fixed bug related to meta-data
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Timer.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 2013-03-19 17:54:54 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-03-20 13:04:15 +0000
@@ -170,17 +170,11 @@
params.conform();
// ---------------------------------------------------------------------
- // Headers and meta-data
+ // Headers
// ---------------------------------------------------------------------
Grid grid = new ListGrid();
- Map<Object, Object> metaData = new HashMap<Object, Object>();
- metaData.put( NAMES_META_KEY, getUidNameMap( params ) );
- metaData.put( PERIODS_META_KEY, getUids( params.getDimensionOrFilter( PERIOD_DIM_ID ) ) );
-
- grid.setMetaData( metaData );
-
for ( Dimension col : params.getHeaderDimensions() )
{
grid.addHeader( new GridHeader( col.getDimension(), col.getDisplayName(), String.class.getName(), false, true ) );
@@ -329,17 +323,19 @@
grid.addValue( entry.getValue() );
}
}
-
- // ---------------------------------------------------------------------
- // Category option combo meta-data
- // ---------------------------------------------------------------------
-
+
+ // ---------------------------------------------------------------------
+ // Meta-data
+ // ---------------------------------------------------------------------
+
Integer cocIndex = params.getCocIndex();
- if ( cocIndex != null )
- {
- addCocMetaData( grid, cocIndex );
- }
+ Map<Object, Object> metaData = new HashMap<Object, Object>();
+
+ metaData.put( NAMES_META_KEY, getUidNameMap( params, grid, cocIndex ) );
+ metaData.put( PERIODS_META_KEY, getUids( params.getDimensionOrFilter( PERIOD_DIM_ID ) ) );
+
+ grid.setMetaData( metaData );
return grid;
}
@@ -637,12 +633,13 @@
return params;
}
- private Map<String, String> getUidNameMap( DataQueryParams params )
+ private Map<String, String> getUidNameMap( DataQueryParams params, Grid grid, Integer cocIndex )
{
Map<String, String> map = new HashMap<String, String>();
map.putAll( getUidNameMap( params.getDimensions() ) );
map.putAll( getUidNameMap( params.getFilters() ) );
map.put( DATA_X_DIM_ID, DISPLAY_NAME_DATA_X );
+ map.putAll( getCocMetaData( grid, cocIndex ) );
return map;
}
@@ -689,15 +686,22 @@
return map;
}
- private void addCocMetaData( Grid grid, Integer cocIndex )
+ private Map<String, String> getCocMetaData( Grid grid, Integer cocIndex )
{
- Set<String> uids = new HashSet<String>( ConversionUtils.<String>cast( grid.getColumn( cocIndex ) ) );
-
- Collection<DataElementCategoryOptionCombo> cocs = categoryService.getDataElementCategoryOptionCombosByUid( uids );
-
- for ( DataElementCategoryOptionCombo coc : cocs )
+ Map<String, String> metaData = new HashMap<String, String>();
+
+ if ( grid != null && cocIndex != null )
{
- grid.addMetaData( coc.getUid(), coc.getName() );
+ Set<String> uids = new HashSet<String>( ConversionUtils.<String>cast( grid.getColumn( cocIndex ) ) );
+
+ Collection<DataElementCategoryOptionCombo> cocs = categoryService.getDataElementCategoryOptionCombosByUid( uids );
+
+ for ( DataElementCategoryOptionCombo coc : cocs )
+ {
+ metaData.put( coc.getUid(), coc.getName() );
+ }
}
+
+ return metaData;
}
}
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Timer.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Timer.java 2013-03-20 12:40:07 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/Timer.java 2013-03-20 13:04:15 +0000
@@ -55,7 +55,12 @@
long endTime = System.nanoTime();
long time = ( endTime - startTime ) / 1000;
-
+
+ if ( !printDisabled )
+ {
+ System.out.println( msg + ": " + time + " micros" );
+ }
+
return time;
}