dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21676
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10327: Including period idnetifiers in meta-data response
------------------------------------------------------------
revno: 10327
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-03-19 18:54:54 +0100
message:
Including period idnetifiers in meta-data response
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java
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/grid/ListGrid.java
dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.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-api/src/main/java/org/hisp/dhis/common/Grid.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java 2013-03-04 10:30:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java 2013-03-19 17:54:54 +0000
@@ -77,17 +77,17 @@
/**
* Returns map of meta-data.
*/
- Map<Object, String> getMetaData();
+ Map<Object, Object> getMetaData();
/**
* Sets map of meta-data.
*/
- void setMetaData( Map<Object, String> metaData );
+ void setMetaData( Map<Object, Object> metaData );
/**
* Adds a key-value pair to meta-data.
*/
- void addMetaData( String key, String value );
+ void addMetaData( Object key, Object value );
/**
* Returns all visible headers, ie. headers which are not hidden.
=== 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:31:48 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-03-19 17:54:54 +0000
@@ -47,6 +47,7 @@
import static org.hisp.dhis.analytics.DataQueryParams.getDimensionItemsFromParam;
import static org.hisp.dhis.common.IdentifiableObjectUtils.asList;
import static org.hisp.dhis.common.IdentifiableObjectUtils.asTypedList;
+import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT;
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_CHILDREN;
@@ -115,7 +116,8 @@
private static final Log log = LogFactory.getLog( DefaultAnalyticsService.class );
private static final String VALUE_HEADER_NAME = "Value";
- private static final String PERIOD_META_KEY = "periods";
+ private static final String PERIODS_META_KEY = "periods";
+ private static final String NAMES_META_KEY = "names";
private static final int PERCENT = 100;
private static final int MAX_QUERIES = 8;
@@ -173,7 +175,11 @@
Grid grid = new ListGrid();
- grid.setMetaData( getUidNameMap( params ) );
+ 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() )
{
@@ -631,9 +637,9 @@
return params;
}
- private Map<Object, String> getUidNameMap( DataQueryParams params )
+ private Map<String, String> getUidNameMap( DataQueryParams params )
{
- Map<Object, String> map = new HashMap<Object, String>();
+ 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 );
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java 2013-03-12 17:07:05 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java 2013-03-19 17:54:54 +0000
@@ -79,7 +79,7 @@
/**
* A Map which can hold arbitrary meta-data.
*/
- private Map<Object, String> metaData;
+ private Map<Object, Object> metaData;
/**
* A two dimensional List which simulates a grid where the first list
@@ -108,7 +108,7 @@
public ListGrid()
{
headers = new ArrayList<GridHeader>();
- metaData = new HashMap<Object, String>();
+ metaData = new HashMap<Object, Object>();
grid = new ArrayList<List<Object>>();
}
@@ -219,17 +219,17 @@
@JsonProperty
@JsonView( { DetailedView.class } )
- public Map<Object, String> getMetaData()
+ public Map<Object, Object> getMetaData()
{
return metaData;
}
- public void setMetaData( Map<Object, String> metaData )
+ public void setMetaData( Map<Object, Object> metaData )
{
this.metaData = metaData;
}
- public void addMetaData( String key, String value )
+ public void addMetaData( Object key, Object value )
{
this.metaData.put( key, value );
}
@@ -546,11 +546,11 @@
{
// Header
- String headerMetaName = metaData.get( header.getName() );
+ Object headerMetaName = metaData.get( header.getName() );
if ( headerMetaName != null )
{
- header.setName( headerMetaName );
+ header.setName( String.valueOf( headerMetaName ) );
}
// Column cells
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java 2013-03-04 10:30:59 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java 2013-03-19 17:54:54 +0000
@@ -92,7 +92,7 @@
@Test
public void testSubstituteMetaData()
{
- Map<Object, String> metaData = new HashMap<Object, String>();
+ Map<Object, Object> metaData = new HashMap<Object, Object>();
metaData.put( 11, "Eleven" );
metaData.put( 12, "Twelve" );
metaData.put( 21, "TwentyOne" );