=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2011-06-29 15:25:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2011-07-01 07:37:16 +0000 @@ -34,6 +34,7 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementOperand; +import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; @@ -217,4 +218,13 @@ * @param days The number to be substituted with the days expression in the formula. */ String generateExpression( String expression, Map valueMap, Map constantMap, Integer days ); + + /** + * Returns all Operands included in the formulas for the given collection of + * Indicators. Requires that the explodedNumerator and explodedDenominator + * properties have been populated. + * + * @param indicators the collection of Indicators. + */ + Set getOperandsInIndicators( Collection indicators ); } === 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 2011-06-29 15:25:19 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2011-07-01 07:37:16 +0000 @@ -54,6 +54,7 @@ import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.datavalue.DataValueService; +import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; import org.hisp.dhis.system.util.MathUtils; @@ -567,6 +568,22 @@ return buffer != null ? buffer.toString() : null; } + + public Set getOperandsInIndicators( Collection indicators ) + { + final Set operands = new HashSet(); + + for ( Indicator indicator : indicators ) + { + Set temp = getOperandsInExpression( indicator.getExplodedNumerator() ); + operands.addAll( temp != null ? temp : new HashSet() ); + + temp = getOperandsInExpression( indicator.getExplodedDenominator() ); + operands.addAll( temp != null ? temp : new HashSet() ); + } + + return operands; + } private static final String stripConstantExpression( String match ) { === modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java' --- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-07-01 07:12:30 +0000 +++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-07-01 07:37:16 +0000 @@ -176,7 +176,7 @@ // --------------------------------------------------------------------- Collection dataElementOperands = categoryService.getOperands( dataElements ); - List indicatorOperands = new ArrayList( categoryService.populateOperands( getOperandsInIndicators( indicators ) ) ); + List indicatorOperands = new ArrayList( categoryService.populateOperands( expressionService.getOperandsInIndicators( indicators ) ) ); Set allOperands = new HashSet(); allOperands.addAll( dataElementOperands ); @@ -294,24 +294,4 @@ clock.logTime( "Data mart export process completed" ); } - - // ------------------------------------------------------------------------- - // Supportive methods - // ------------------------------------------------------------------------- - - private Set getOperandsInIndicators( Collection indicators ) - { - final Set operands = new HashSet(); - - for ( Indicator indicator : indicators ) - { - Set temp = expressionService.getOperandsInExpression( indicator.getExplodedNumerator() ); - operands.addAll( temp != null ? temp : new HashSet() ); - - temp = expressionService.getOperandsInExpression( indicator.getExplodedDenominator() ); - operands.addAll( temp != null ? temp : new HashSet() ); - } - - return operands; - } }