=== 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-06 23:17:32 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2015-12-08 20:41:02 +0000 @@ -289,20 +289,6 @@ String expressionIsValid( String formula ); /** - * Tests whether the expression is valid. Returns a positive value if the - * expression is valid, or a negative value if not. - * - * @param formula the expression formula. - * @return VALID if the expression is valid. - * EXPRESSION_IS_EMPTY if the expression is empty. - * DATAELEMENT_DOES_NOT_EXIST if the data element does not exist. - * CATEGORYOPTIONCOMBO_DOES_NOT_EXIST if the category option combo does not exist. - * CONSTANT_DOES_NOT_EXIST if the constant does not exist. - * EXPRESSION_NOT_WELL_FORMED if the expression is not well-formed. - */ - String expressionIsValid( String formula, Set dataElements, Set categoryOptionCombos, Set constants, Set orgUnitGroups ); - - /** * Creates an expression string containing DataElement names and the names of * the CategoryOptions in the CategoryOptionCombo from a string consisting * of identifiers. === modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java' --- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2015-09-17 05:52:20 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java 2015-12-08 20:41:02 +0000 @@ -35,7 +35,6 @@ import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; import org.hisp.dhis.commons.filter.Filter; import org.hisp.dhis.commons.filter.FilterUtils; -import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementCategoryService; @@ -75,7 +74,6 @@ import java.util.SortedMap; import java.util.TreeMap; -import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids; import static org.hisp.dhis.commons.collection.ListUtils.getDuplicates; /** @@ -163,13 +161,6 @@ this.categoryService = categoryService; } - private ConstantService constantService; - - public void setConstantService( ConstantService constantService ) - { - this.constantService = constantService; - } - private PeriodService periodService; public void setPeriodService( PeriodService periodService ) @@ -419,14 +410,9 @@ { SortedMap invalids = new TreeMap<>( IdentifiableObjectNameComparator.INSTANCE ); - Set dataElements = new HashSet<>( getUids( dataElementService.getAllDataElements() ) ); - Set categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) ); - Set constants = new HashSet<>( getUids( constantService.getAllConstants() ) ); - Set orgUnitGroups = new HashSet<>( getUids( organisationUnitGroupService.getAllOrganisationUnitGroups() ) ); - for ( Indicator indicator : indicatorService.getAllIndicators() ) { - String result = expressionService.expressionIsValid( indicator.getNumerator(), dataElements, categoryOptionCombos, constants, orgUnitGroups ); + String result = expressionService.expressionIsValid( indicator.getNumerator() ); if ( !result.equals( ExpressionService.VALID ) ) { @@ -442,14 +428,9 @@ { SortedMap invalids = new TreeMap<>( IdentifiableObjectNameComparator.INSTANCE ); - Set dataElements = new HashSet<>( getUids( dataElementService.getAllDataElements() ) ); - Set categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) ); - Set constants = new HashSet<>( getUids( constantService.getAllConstants() ) ); - Set orgUnitGroups = new HashSet<>( getUids( organisationUnitGroupService.getAllOrganisationUnitGroups() ) ); - for ( Indicator indicator : indicatorService.getAllIndicators() ) { - String result = expressionService.expressionIsValid( indicator.getDenominator(), dataElements, categoryOptionCombos, constants, orgUnitGroups ); + String result = expressionService.expressionIsValid( indicator.getDenominator() ); if ( !result.equals( ExpressionService.VALID ) ) { @@ -635,14 +616,9 @@ SortedMap invalids = new TreeMap<>( IdentifiableObjectNameComparator.INSTANCE ); - Set dataElements = new HashSet<>( getUids( dataElementService.getAllDataElements() ) ); - Set categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) ); - Set constants = new HashSet<>( getUids( constantService.getAllConstants() ) ); - Set orgUnitGroups = new HashSet<>( getUids( organisationUnitGroupService.getAllOrganisationUnitGroups() ) ); - for ( ValidationRule rule : validationRuleService.getAllValidationRules() ) { - String result = expressionService.expressionIsValid( rule.getLeftSide().getExpression(), dataElements, categoryOptionCombos, constants, orgUnitGroups ); + String result = expressionService.expressionIsValid( rule.getLeftSide().getExpression() ); if ( !result.equals( ExpressionService.VALID ) ) { @@ -659,14 +635,9 @@ SortedMap invalids = new TreeMap<>( IdentifiableObjectNameComparator.INSTANCE ); - Set dataElements = new HashSet<>( getUids( dataElementService.getAllDataElements() ) ); - Set categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) ); - Set constants = new HashSet<>( getUids( constantService.getAllConstants() ) ); - Set orgUnitGroups = new HashSet<>( getUids( organisationUnitGroupService.getAllOrganisationUnitGroups() ) ); - for ( ValidationRule rule : validationRuleService.getAllValidationRules() ) { - String result = expressionService.expressionIsValid( rule.getRightSide().getExpression(), dataElements, categoryOptionCombos, constants, orgUnitGroups ); + String result = expressionService.expressionIsValid( rule.getRightSide().getExpression() ); if ( !result.equals( ExpressionService.VALID ) ) { === modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2015-10-02 17:20:28 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2015-12-08 20:41:02 +0000 @@ -32,7 +32,6 @@ - === 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-06 23:17:32 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2015-12-08 20:41:02 +0000 @@ -479,14 +479,7 @@ @Override @Transactional - public String expressionIsValid( String formula ) - { - return expressionIsValid( formula, null, null, null, null ); - } - - @Override - @Transactional - public String expressionIsValid( String expression, Set dataElements, Set categoryOptionCombos, Set orgUnitGroups, Set constants ) + public String expressionIsValid( String expression ) { if ( expression == null || expression.isEmpty() ) { @@ -505,13 +498,12 @@ String de = matcher.group( 1 ); String coc = matcher.group( 2 ); - if ( dataElements != null ? !dataElements.contains( de ) : dataElementService.getDataElement( de ) == null ) + if ( dataElementService.getDataElement( de ) == null ) { return DATAELEMENT_DOES_NOT_EXIST; } - if ( !operandIsTotal( matcher ) && ( - categoryOptionCombos != null ? !categoryOptionCombos.contains( coc ) : categoryService.getDataElementCategoryOptionCombo( coc ) == null ) ) + if ( !operandIsTotal( matcher ) && categoryService.getDataElementCategoryOptionCombo( coc ) == null ) { return CATEGORYOPTIONCOMBO_DOES_NOT_EXIST; } @@ -532,7 +524,7 @@ { String constant = matcher.group( 1 ); - if ( constants != null ? !constants.contains( constant ) : constantService.getConstant( constant ) == null ) + if ( constantService.getConstant( constant ) == null ) { return CONSTANT_DOES_NOT_EXIST; } @@ -553,7 +545,7 @@ { String group = matcher.group( 1 ); - if ( orgUnitGroups != null ? !orgUnitGroups.contains( group ) : organisationUnitGroupService.getOrganisationUnitGroup( group ) == null ) + if ( organisationUnitGroupService.getOrganisationUnitGroup( group ) == null ) { return OU_GROUP_DOES_NOT_EXIST; }