=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2013-03-01 05:14:56 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2013-03-07 14:10:37 +0000 @@ -30,8 +30,8 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Set; +import org.hisp.dhis.common.ListMap; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.hierarchy.HierarchyViolationException; import org.hisp.dhis.period.PeriodType; @@ -286,7 +286,13 @@ int getDataElementCountByName( String name ); - Map> getDataElementCategoryOptionCombos(); + /** + * Returns a mapping of data element uid and associated category option combo + * uids. + * + * @return a ListMap. + */ + ListMap getDataElementCategoryOptionComboMap(); Map getDataElementUidIdMap(); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java 2013-01-04 18:10:25 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java 2013-03-07 14:10:37 +0000 @@ -28,10 +28,9 @@ */ import java.util.Collection; -import java.util.Map; -import java.util.Set; import org.hisp.dhis.common.GenericNameableObjectStore; +import org.hisp.dhis.common.ListMap; import org.hisp.dhis.dataset.DataSet; /** @@ -168,7 +167,13 @@ */ Collection getDataElementsByAggregationLevel( int aggregationLevel ); - Map> getDataElementCategoryOptionCombos(); + /** + * Returns a mapping of data element uid and associated category option combo + * uids. + * + * @return a ListMap. + */ + ListMap getDataElementCategoryOptionComboMap(); Collection get( DataSet dataSet, String key, Integer max ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2013-03-01 04:09:26 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2013-03-07 14:10:37 +0000 @@ -29,6 +29,7 @@ import org.hisp.dhis.common.GenericIdentifiableObjectStore; import org.hisp.dhis.common.GenericNameableObjectStore; +import org.hisp.dhis.common.ListMap; import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboSizeComparator; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.i18n.I18nService; @@ -341,11 +342,11 @@ return i18n( i18nService, dataElementStore.getDataElementsByAggregationLevel( aggregationLevel ) ); } - public Map> getDataElementCategoryOptionCombos() + public ListMap getDataElementCategoryOptionComboMap() { - return dataElementStore.getDataElementCategoryOptionCombos(); + return dataElementStore.getDataElementCategoryOptionComboMap(); } - + public Map getDataElementUidIdMap() { Map map = new HashMap(); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2013-01-28 08:50:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2013-03-07 14:10:37 +0000 @@ -30,15 +30,14 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.criterion.Restrictions; +import org.hisp.dhis.common.ListMap; import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryCombo; @@ -224,13 +223,13 @@ return getQuery( hql ).setInteger( "aggregationLevel", aggregationLevel ).list(); } - public Map> getDataElementCategoryOptionCombos() + public ListMap getDataElementCategoryOptionComboMap() { - final String sql = "select de.uid, coc.uid " + "from dataelement de " + final String sql = "select de.uid, coc.uid from dataelement de " + "join categorycombos_optioncombos cc on de.categorycomboid = cc.categorycomboid " + "join categoryoptioncombo coc on cc.categoryoptioncomboid = coc.categoryoptioncomboid"; - final Map> sets = new HashMap>(); + final ListMap map = new ListMap(); jdbcTemplate.query( sql, new RowCallbackHandler() { @@ -238,17 +237,14 @@ public void processRow( ResultSet rs ) throws SQLException { - String dataElement = rs.getString( 1 ); - String categoryOptionCombo = rs.getString( 2 ); - - Set set = sets.get( dataElement ) != null ? sets.get( dataElement ) : new HashSet(); - - set.add( categoryOptionCombo ); - sets.put( dataElement, set ); + String de = rs.getString( 1 ); + String coc = rs.getString( 2 ); + + map.putValue( de, coc ); } } ); - return sets; + return map; } @SuppressWarnings( "unchecked" ) === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2013-02-19 14:20:08 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2013-03-07 14:10:37 +0000 @@ -46,6 +46,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.common.GenericStore; +import org.hisp.dhis.common.ListMap; import org.hisp.dhis.constant.Constant; import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.dataelement.DataElement; @@ -448,7 +449,7 @@ indicator.setExplodedDenominator( substituteExpression( indicator.getDenominator(), days ) ); } - final Map> dataElementMap = dataElementService.getDataElementCategoryOptionCombos(); + final ListMap dataElementMap = dataElementService.getDataElementCategoryOptionComboMap(); for ( Indicator indicator : indicators ) { @@ -458,7 +459,7 @@ } } - private String explodeExpression( String expression, Map> dataElementMap ) + private String explodeExpression( String expression, ListMap dataElementMap ) { if ( expression == null || expression.isEmpty() ) {