=== 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 2015-12-10 11:41:13 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2015-12-10 11:56:06 +0000 @@ -188,25 +188,6 @@ Set getDataElementsInExpression( String expression ); /** - * Returns all OrganisationUnitGroups in the numerator and denominator - * expressions in the given Indicators. Returns an empty set if the given - * indicators are null or empty. - * - * @param indicators the set of indicators. - * @return a Set of OrganisationUnitGroups. - */ - Set getOrganisationUnitGroupsInIndicators( Collection indicators ); - - /** - * Returns all OrganisationUnitGroups in the given expression string. Returns - * an set list if the given indicators are null or empty. - * - * @param expression the expression string. - * @return a Set of OrganisationUnitGroups included in the expression string. - */ - Set getOrganisationUnitGroupsInExpression( String expression ); - - /** * Returns all CategoryOptionCombos in the given expression string. Only * operands with a category option combo will be included. Returns an empty * set if the given expression is null. @@ -254,6 +235,25 @@ * @return a set of data elements. */ Set getDataElementWithOptionCombosInIndicators( Collection indicators ); + + /** + * Returns all OrganisationUnitGroups in the given expression string. Returns + * an set list if the given indicators are null or empty. + * + * @param expression the expression string. + * @return a Set of OrganisationUnitGroups included in the expression string. + */ + Set getOrganisationUnitGroupsInExpression( String expression ); + + /** + * Returns all OrganisationUnitGroups in the numerator and denominator + * expressions in the given Indicators. Returns an empty set if the given + * indicators are null or empty. + * + * @param indicators the set of indicators. + * @return a Set of OrganisationUnitGroups. + */ + Set getOrganisationUnitGroupsInIndicators( Collection indicators ); /** * Filters indicators from the given collection where the numerator and / === 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 2015-12-10 11:53:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2015-12-10 11:56:06 +0000 @@ -273,46 +273,6 @@ } @Override - public Set getOrganisationUnitGroupsInIndicators( Collection indicators ) - { - Set groups = new HashSet<>(); - - if ( indicators != null ) - { - for ( Indicator indicator : indicators ) - { - groups.addAll( getOrganisationUnitGroupsInExpression( indicator.getNumerator() ) ); - groups.addAll( getOrganisationUnitGroupsInExpression( indicator.getDenominator() ) ); - } - } - - return groups; - } - - @Override - public Set getOrganisationUnitGroupsInExpression( String expression ) - { - Set groupsInExpression = new HashSet<>(); - - if ( expression != null ) - { - final Matcher matcher = OU_GROUP_PATTERN.matcher( expression ); - - while ( matcher.find() ) - { - final OrganisationUnitGroup group = organisationUnitGroupService.getOrganisationUnitGroup( matcher.group( 1 ) ); - - if ( group != null ) - { - groupsInExpression.add( group ); - } - } - } - - return groupsInExpression; - } - - @Override @Transactional public Set getOptionCombosInExpression( String expression ) { @@ -407,6 +367,46 @@ } @Override + public Set getOrganisationUnitGroupsInExpression( String expression ) + { + Set groupsInExpression = new HashSet<>(); + + if ( expression != null ) + { + final Matcher matcher = OU_GROUP_PATTERN.matcher( expression ); + + while ( matcher.find() ) + { + final OrganisationUnitGroup group = organisationUnitGroupService.getOrganisationUnitGroup( matcher.group( 1 ) ); + + if ( group != null ) + { + groupsInExpression.add( group ); + } + } + } + + return groupsInExpression; + } + + @Override + public Set getOrganisationUnitGroupsInIndicators( Collection indicators ) + { + Set groups = new HashSet<>(); + + if ( indicators != null ) + { + for ( Indicator indicator : indicators ) + { + groups.addAll( getOrganisationUnitGroupsInExpression( indicator.getNumerator() ) ); + groups.addAll( getOrganisationUnitGroupsInExpression( indicator.getDenominator() ) ); + } + } + + return groups; + } + + @Override @Transactional public void filterInvalidIndicators( List indicators ) {