=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 2015-02-26 11:19:31 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java 2015-03-19 12:24:51 +0000 @@ -376,4 +376,26 @@ return map; } + + /** + * Returns a mapping between the uid and the name of the given identifiable + * objects. + * + * @param objects the identifiable objects. + * @return mapping between the uid and the name of the given objects. + */ + public static Map getUidObjectMap( Collection objects ) + { + Map map = new HashMap<>(); + + if ( objects != null ) + { + for ( T object : objects ) + { + map.put( object.getUid(), object ); + } + } + + return map; + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2015-02-26 15:21:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java 2015-03-19 12:24:51 +0000 @@ -417,6 +417,11 @@ return aggregationLevels != null && aggregationLevels.size() > 0; } + public boolean hasCategoryCombo() + { + return categoryCombo != null; + } + /** * Tests whether the DataElement is associated with a * DataElementCategoryCombo with more than one DataElementCategory, or any === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2015-02-26 15:21:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java 2015-03-19 12:24:51 +0000 @@ -49,6 +49,7 @@ import org.hisp.dhis.dataelement.DataElementCategory; import org.hisp.dhis.dataelement.DataElementCategoryCombo; import org.hisp.dhis.dataelement.DataElementCategoryOption; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataentryform.DataEntryForm; import org.hisp.dhis.indicator.Indicator; @@ -400,6 +401,21 @@ return dataElements; } + public Set getDataElementOptionCombos() + { + Set optionCombos = new HashSet<>(); + + for ( DataElement element : dataElements ) + { + if ( element.hasCategoryCombo() ) + { + optionCombos.addAll( element.getCategoryCombo().getOptionCombos() ); + } + } + + return optionCombos; + } + public int increaseVersion() { return ++version; @@ -435,7 +451,7 @@ { return categoryCombo != null && !DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME.equals( categoryCombo.getName() ); } - + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2015-03-19 00:30:31 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2015-03-19 12:24:51 +0000 @@ -44,6 +44,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.common.IdentifiableObjectManager; +import org.hisp.dhis.common.IdentifiableObjectUtils; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementOperand; @@ -287,9 +288,11 @@ // --------------------------------------------------------------------- Map dataElementMap = getDataElementMap( dataSet ); - + CachingMap optionComboMap = new CachingMap<>(); + optionComboMap.putAll( IdentifiableObjectUtils.getUidObjectMap( dataSet.getDataElementOptionCombos() ) ); + IdentifiableObjectCallable optionComboCallabel = new IdentifiableObjectCallable( idObjectManager, DataElementCategoryOptionCombo.class, null ); === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-02-24 09:53:30 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-03-19 12:24:51 +0000 @@ -914,12 +914,15 @@ $.safeEach( dataSetList, function( idx, item ) { - addOptionById( 'selectedDataSetId', item.id, item.name ); - - if ( dataSetId == item.id ) - { - dataSetValid = true; - } + if ( item ) + { + addOptionById( 'selectedDataSetId', item.id, item.name ); + + if ( dataSetId == item.id ) + { + dataSetValid = true; + } + } } ); if ( children )