=== 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 2013-08-23 15:56:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2013-10-03 10:21:15 +0000 @@ -234,14 +234,23 @@ * Populates the explodedNumerator and explodedDenominator property on all * indicators in the given collection. This method uses * explodeExpression( String ) internally to generate the exploded expressions. - * This method will perform compared to calling explodeExpression( String ) + * This method will perform better compared to calling explodeExpression( String ) * multiple times outside a transactional context as the transactional * overhead is avoided. * * @param indicators the collection of indicators. - * @param + * @param days the number of days in aggregation period. */ void explodeAndSubstituteExpressions( Collection indicators, Integer days ); + + /** + * Populates the explodedNumerator and explodedDenominator property on all + * indicators in the given collection. This method uses + * explodeExpression( String ) internally to generate the exploded expressions. + * + * @param indicators the collection of indicators. + */ + void explodeExpressions( Collection indicators ); /** * Replaces references to data element totals with references to all === 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-10-03 08:22:21 +0000 +++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2013-10-03 10:21:15 +0000 @@ -222,7 +222,7 @@ int indicatorIndex = params.getIndicatorDimensionIndex(); List indicators = asTypedList( params.getIndicators() ); - expressionService.explodeAndSubstituteExpressions( indicators, null ); + expressionService.explodeExpressions( indicators ); DataQueryParams dataSourceParams = params.instance(); dataSourceParams.removeDimension( DATAELEMENT_DIM_ID ); === 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-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2013-10-03 10:21:15 +0000 @@ -490,6 +490,15 @@ indicator.setExplodedDenominator( substituteExpression( indicator.getDenominator(), days ) ); } + explodeExpressions( indicators ); + } + } + + @Transactional + public void explodeExpressions( Collection indicators ) + { + if ( indicators != null && !indicators.isEmpty() ) + { Set dataElementTotals = new HashSet(); for ( Indicator indicator : indicators ) @@ -631,7 +640,7 @@ { return null; } - + // --------------------------------------------------------------------- // Operands // --------------------------------------------------------------------- @@ -683,7 +692,7 @@ matcher = DAYS_PATTERN.matcher( expression ); while ( matcher.find() ) - { + { String replacement = days != null ? String.valueOf( days ) : NULL_REPLACEMENT; matcher.appendReplacement( sb, replacement );