=== 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-01-28 19:43:36 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java 2013-02-19 16:12:47 +0000 @@ -85,6 +85,11 @@ void setMetaData( Map metaData ); /** + * Adds a key-value pair to meta-data. + */ + void addMetaData( String key, String value ); + + /** * Returns all visible headers, ie. headers which are not hidden. */ List getVisibleHeaders(); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java 2013-02-13 03:57:52 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java 2013-02-19 16:12:47 +0000 @@ -308,11 +308,10 @@ name.append( "(" ); Iterator iterator = categoryOptions.iterator(); - DataElementCategoryOption dataElementCategoryOption = iterator.next(); - - if ( dataElementCategoryOption != null ) + + if ( iterator.hasNext() ) { - name.append( dataElementCategoryOption.getDisplayName() ); + name.append( iterator.next().getDisplayName() ); } while ( iterator.hasNext() ) === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2013-01-05 15:22:55 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryService.java 2013-02-19 16:12:47 +0000 @@ -302,6 +302,8 @@ * @return a Collection of DataElementCategoryOptionCombos. */ Collection getDataElementCategoryOptionCombos( Collection identifiers ); + + Collection getDataElementCategoryOptionCombosByUid( Collection uids ); /** * Retrieves the DataElementCategoryOptionCombo with the given Collection === 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 2013-02-19 13:19:21 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-02-19 16:12:47 +0000 @@ -266,6 +266,17 @@ } /** + * Returns the index of the category option combo dimension. Returns null + * if this dimension is not present. + */ + public Integer getCocIndex() + { + int index = dimensions.indexOf( new Dimension( CATEGORYOPTIONCOMBO_DIM_ID ) ); + + return index == -1 ? null : index; + } + + /** * Indicates whether this object is of the given aggregation type. */ public boolean isAggregationType( AggregationType aggregationType ) === 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-02-19 13:19:21 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-02-19 16:12:47 +0000 @@ -45,8 +45,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -68,6 +70,8 @@ import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementCategoryService; import org.hisp.dhis.dataelement.DataElementGroupSet; import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataelement.DataElementService; @@ -86,6 +90,7 @@ import org.hisp.dhis.period.RelativePeriods; import org.hisp.dhis.period.comparator.PeriodComparator; import org.hisp.dhis.system.grid.ListGrid; +import org.hisp.dhis.system.util.ConversionUtils; import org.hisp.dhis.system.util.MathUtils; import org.hisp.dhis.system.util.SystemUtils; import org.hisp.dhis.system.util.Timer; @@ -116,6 +121,9 @@ private DataElementService dataElementService; @Autowired + private DataElementCategoryService categoryService; + + @Autowired private DataSetService dataSetService; @Autowired @@ -142,8 +150,7 @@ queryPlanner.validate( params ); params.conform(); - - + // --------------------------------------------------------------------- // Headers and meta-data // --------------------------------------------------------------------- @@ -271,6 +278,17 @@ } } + // --------------------------------------------------------------------- + // Category option combo meta-data + // --------------------------------------------------------------------- + + Integer cocIndex = params.getCocIndex(); + + if ( cocIndex != null ) + { + addCocMetaData( grid, cocIndex ); + } + return grid; } @@ -551,4 +569,16 @@ return map; } + + private void addCocMetaData( Grid grid, Integer cocIndex ) + { + Set uids = new HashSet( ConversionUtils.cast( grid.getColumn( cocIndex ) ) ); + + Collection cocs = categoryService.getDataElementCategoryOptionCombosByUid( uids ); + + for ( DataElementCategoryOptionCombo coc : cocs ) + { + grid.addMetaData( coc.getUid(), coc.getName() ); + } + } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2013-02-04 04:14:07 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2013-02-19 16:12:47 +0000 @@ -325,6 +325,11 @@ } } ); } + + public Collection getDataElementCategoryOptionCombosByUid( Collection uids ) + { + return dataElementCategoryOptionComboStore.getByUid( uids ); + } public DataElementCategoryOptionCombo getDataElementCategoryOptionCombo( Collection categoryOptions ) === modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java' --- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2013-02-07 08:40:18 +0000 +++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2013-02-19 16:12:47 +0000 @@ -392,6 +392,7 @@ } @Override + @SuppressWarnings("unchecked") public List getAllEqName( String name ) { Query query = sharingEnabled() ? getQueryAllEqNameACL( name ) : getQueryAllEqName( name ); @@ -423,6 +424,7 @@ } @Override + @SuppressWarnings("unchecked") public List getAllEqNameIgnoreCase( String name ) { Query query = sharingEnabled() ? getQueryAllEqNameACLIgnoreCase( name ) : getQueryAllEqNameIgnoreCase( name ); @@ -454,6 +456,7 @@ } @Override + @SuppressWarnings("unchecked") public List getAllEqShortName( String shortName ) { Query query = sharingEnabled() ? getQueryAllEqShortNameACL( shortName ) : getQueryAllEqShortName( shortName ); @@ -485,6 +488,7 @@ } @Override + @SuppressWarnings("unchecked") public List getAllEqShortNameIgnoreCase( String shortName ) { Query query = sharingEnabled() ? getQueryAllEqShortNameACLIgnoreCase( shortName ) : getQueryAllEqShortNameIgnoreCase( shortName ); === 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-01-28 19:43:36 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java 2013-02-19 16:12:47 +0000 @@ -229,6 +229,11 @@ this.metaData = metaData; } + public void addMetaData( String key, String value ) + { + this.metaData.put( key, value ); + } + public int getVisibleWidth() { verifyGridState(); === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java 2012-04-01 12:04:14 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java 2013-02-19 16:12:47 +0000 @@ -281,4 +281,24 @@ set.add( object ); return set; } + + /** + * Casts the elements in the given collection to the desired return type. It + * is the caller's responsibility that the types legally can be casted. + * + * @param collection the collection. + * @return a collection. + */ + @SuppressWarnings("unchecked") + public static Collection cast( Collection collection ) + { + Collection list = new ArrayList(); + + for ( Object o : collection ) + { + list.add( (T) o ); + } + + return list; + } }