=== 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-02-19 09:18:17 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2015-03-19 00:30:31 +0000 @@ -43,15 +43,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataelement.DataElementCategoryService; import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.indicator.IndicatorService; +import org.hisp.dhis.system.callable.IdentifiableObjectCallable; +import org.hisp.dhis.system.util.CachingMap; import org.hisp.dhis.system.util.Filter; import org.hisp.dhis.system.util.FilterUtils; import org.springframework.transaction.annotation.Transactional; @@ -81,11 +83,11 @@ this.dataEntryFormStore = dataEntryFormStore; } - private DataElementCategoryService categoryService; + private IdentifiableObjectManager idObjectManager; - public void setCategoryService( DataElementCategoryService categoryService ) + public void setIdObjectManager( IdentifiableObjectManager idObjectManager ) { - this.categoryService = categoryService; + this.idObjectManager = idObjectManager; } private DataElementService dataElementService; @@ -192,6 +194,11 @@ { return null; } + + CachingMap optionComboMap = new CachingMap<>(); + + IdentifiableObjectCallable optionComboCallabel = + new IdentifiableObjectCallable( idObjectManager, DataElementCategoryOptionCombo.class, null ); StringBuffer sb = new StringBuffer(); @@ -214,8 +221,10 @@ DataElement dataElement = dataElementService.getDataElement( dataElementId ); String optionComboId = identifierMatcher.group( 2 ); - DataElementCategoryOptionCombo categegoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId ); - String optionComboName = categegoryOptionCombo != null ? escapeHtml3( categegoryOptionCombo.getName() ) : "[ " + i18n.getString( "cat_option_combo_not_exist" ) + " ]"; + + DataElementCategoryOptionCombo categoryOptionCombo = optionComboMap.get( optionComboId, optionComboCallabel.setUid( optionComboId ) ); + + String optionComboName = categoryOptionCombo != null ? escapeHtml3( categoryOptionCombo.getName() ) : "[ " + i18n.getString( "cat_option_combo_not_exist" ) + " ]"; StringBuilder title = dataElement != null ? new StringBuilder( "title=\"" ).append( dataElementId ).append( " - " ). @@ -277,14 +286,19 @@ // Inline javascript/html to add to HTML before output // --------------------------------------------------------------------- + Map dataElementMap = getDataElementMap( dataSet ); + + CachingMap optionComboMap = new CachingMap<>(); + + IdentifiableObjectCallable optionComboCallabel = + new IdentifiableObjectCallable( idObjectManager, DataElementCategoryOptionCombo.class, null ); + int i = 1; StringBuffer sb = new StringBuffer(); Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode ); - Map dataElementMap = getDataElementMap( dataSet ); - while ( inputMatcher.find() ) { // ----------------------------------------------------------------- @@ -309,8 +323,7 @@ return i18n.getString( "dataelement_with_id" ) + ": " + dataElementId + " " + i18n.getString( "does_not_exist" ); } - DataElementCategoryOptionCombo categoryOptionCombo = categoryService - .getDataElementCategoryOptionCombo( optionComboId ); + DataElementCategoryOptionCombo categoryOptionCombo = optionComboMap.get( optionComboId, optionComboCallabel.setUid( optionComboId ) ); if ( categoryOptionCombo == null ) { === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2015-03-16 15:02:40 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2015-03-19 00:30:31 +0000 @@ -492,7 +492,7 @@ - +