← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21378: Data integrity, simplification

 

------------------------------------------------------------
revno: 21378
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-12-08 21:41:02 +0100
message:
  Data integrity, simplification
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java
  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/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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<String> dataElements, Set<String> categoryOptionCombos, Set<String> constants, Set<String> 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<Indicator, String> invalids = new TreeMap<>( IdentifiableObjectNameComparator.INSTANCE );
 
-        Set<String> dataElements = new HashSet<>( getUids( dataElementService.getAllDataElements() ) );
-        Set<String> categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) );
-        Set<String> constants = new HashSet<>( getUids( constantService.getAllConstants() ) );
-        Set<String> 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<Indicator, String> invalids = new TreeMap<>( IdentifiableObjectNameComparator.INSTANCE );
 
-        Set<String> dataElements = new HashSet<>( getUids( dataElementService.getAllDataElements() ) );
-        Set<String> categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) );
-        Set<String> constants = new HashSet<>( getUids( constantService.getAllConstants() ) );
-        Set<String> 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<ValidationRule, String> invalids = new TreeMap<>(
             IdentifiableObjectNameComparator.INSTANCE );
 
-        Set<String> dataElements = new HashSet<>( getUids( dataElementService.getAllDataElements() ) );
-        Set<String> categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) );
-        Set<String> constants = new HashSet<>( getUids( constantService.getAllConstants() ) );
-        Set<String> 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<ValidationRule, String> invalids = new TreeMap<>(
             IdentifiableObjectNameComparator.INSTANCE );
 
-        Set<String> dataElements = new HashSet<>( getUids( dataElementService.getAllDataElements() ) );
-        Set<String> categoryOptionCombos = new HashSet<>( getUids( categoryService.getAllDataElementCategoryOptionCombos() ) );
-        Set<String> constants = new HashSet<>( getUids( constantService.getAllConstants() ) );
-        Set<String> 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 @@
     <property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
 	<property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
 	<property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
-	<property name="constantService" ref="org.hisp.dhis.constant.ConstantService" />
 	<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
   </bean>
   

=== 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<String> dataElements, Set<String> categoryOptionCombos, Set<String> orgUnitGroups, Set<String> 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;
             }