← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21380: Using enum ExpressionValidationOutcome to indicate outcome of expression validation

 

------------------------------------------------------------
revno: 21380
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-12-08 22:44:36 +0100
message:
  Using enum ExpressionValidationOutcome to indicate outcome of expression validation
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionValidationOutcome.java
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-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ExpressionController.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetTextualExpressionAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationRuleAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowUpdateValidationRuleFormAction.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties


--
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-08 20:41:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java	2015-12-08 21:44:36 +0000
@@ -65,14 +65,6 @@
 {
     String ID = ExpressionService.class.getName();
     
-    String VALID = "valid";
-    String EXPRESSION_IS_EMPTY = "expression_is_empty";
-    String DATAELEMENT_DOES_NOT_EXIST = "data_element_does_not_exist";
-    String CATEGORYOPTIONCOMBO_DOES_NOT_EXIST = "category_option_combo_does_not_exist";
-    String CONSTANT_DOES_NOT_EXIST = "constant_does_not_exist";
-    String OU_GROUP_DOES_NOT_EXIST = "org_unit_group_does_not_exist";
-    String EXPRESSION_NOT_WELL_FORMED = "expression_not_well_formed";
-
     String DAYS_DESCRIPTION = "[Number of days]";
     String NULL_REPLACEMENT = "0";
     String SPACE = " ";
@@ -279,14 +271,9 @@
      * 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.
+     * @return the ExpressionValidationOutcome of the validation.
      */
-    String expressionIsValid( String formula );
+    ExpressionValidationOutcome expressionIsValid( String formula );
 
     /**
      * Creates an expression string containing DataElement names and the names of

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionValidationOutcome.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionValidationOutcome.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionValidationOutcome.java	2015-12-08 21:44:36 +0000
@@ -0,0 +1,61 @@
+package org.hisp.dhis.expression;
+
+/*
+ * Copyright (c) 2004-2015, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+* @author Lars Helge Overland
+*/
+public enum ExpressionValidationOutcome
+{
+    VALID( "expression_is_empty" ), 
+    EXPRESSION_IS_EMPTY( "data_element_does_not_exist"),
+    DIMENSIONA_ITEM_OBJECT_DOES_NOT_EXIST( "dimensional_item_object_does_not_exist" ),
+    DATAELEMENT_DOES_NOT_EXIST( "data_element_does_not_exist" ),
+    CATEGORYOPTIONCOMBO_DOES_NOT_EXIST( "category_option_combo_does_not_exist"),
+    CONSTANT_DOES_NOT_EXIST( "constant_does_not_exist"),
+    ORG_UNIT_GROUP_DOES_NOT_EXIST( "org_unit_group_does_not_exist"),
+    EXPRESSION_IS_NOT_WELL_FORMED( "expression_is_not_well_formed");
+    
+    private final String key;
+    
+    ExpressionValidationOutcome( String key )
+    {
+        this.key = key;
+    }
+    
+    public boolean isValid()
+    {
+        return this == VALID;
+    }
+    
+    public String getKey()
+    {
+        return key;
+    }
+}

=== 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-12-08 20:41:02 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/dataintegrity/DefaultDataIntegrityService.java	2015-12-08 21:44:36 +0000
@@ -48,6 +48,7 @@
 import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.dataset.SectionService;
 import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.expression.ExpressionValidationOutcome;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.indicator.IndicatorGroupSet;
@@ -412,11 +413,11 @@
 
         for ( Indicator indicator : indicatorService.getAllIndicators() )
         {
-            String result = expressionService.expressionIsValid( indicator.getNumerator() );
+            ExpressionValidationOutcome result = expressionService.expressionIsValid( indicator.getNumerator() );
 
-            if ( !result.equals( ExpressionService.VALID ) )
+            if ( !result.isValid() )
             {
-                invalids.put( indicator, result );
+                invalids.put( indicator, result.getKey() );
             }
         }
 
@@ -430,11 +431,11 @@
 
         for ( Indicator indicator : indicatorService.getAllIndicators() )
         {
-            String result = expressionService.expressionIsValid( indicator.getDenominator() );
+            ExpressionValidationOutcome result = expressionService.expressionIsValid( indicator.getDenominator() );
 
-            if ( !result.equals( ExpressionService.VALID ) )
+            if ( !result.isValid() )
             {
-                invalids.put( indicator, result );
+                invalids.put( indicator, result.getKey() );
             }
         }
 
@@ -618,11 +619,11 @@
 
         for ( ValidationRule rule : validationRuleService.getAllValidationRules() )
         {
-            String result = expressionService.expressionIsValid( rule.getLeftSide().getExpression() );
+            ExpressionValidationOutcome result = expressionService.expressionIsValid( rule.getLeftSide().getExpression() );
 
-            if ( !result.equals( ExpressionService.VALID ) )
+            if ( !result.isValid() )
             {
-                invalids.put( rule, result );
+                invalids.put( rule, result.getKey() );
             }
         }
 
@@ -637,11 +638,11 @@
 
         for ( ValidationRule rule : validationRuleService.getAllValidationRules() )
         {
-            String result = expressionService.expressionIsValid( rule.getRightSide().getExpression() );
+            ExpressionValidationOutcome result = expressionService.expressionIsValid( rule.getRightSide().getExpression() );
 
-            if ( !result.equals( ExpressionService.VALID ) )
+            if ( !result.isValid() )
             {
-                invalids.put( rule, result );
+                invalids.put( rule, result.getKey() );
             }
         }
 

=== 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-08 20:41:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java	2015-12-08 21:44:36 +0000
@@ -467,8 +467,8 @@
             {
                 Indicator indicator = iterator.next();
                 
-                if ( !expressionIsValid( indicator.getNumerator() ).equals( VALID ) ||
-                    !expressionIsValid( indicator.getDenominator() ).equals( VALID ) )
+                if ( !expressionIsValid( indicator.getNumerator() ).isValid() ||
+                    !expressionIsValid( indicator.getDenominator() ).isValid() )
                 {
                     iterator.remove();
                     log.warn( "Indicator is invalid: " + indicator + ", " + indicator.getNumerator() + ", " + indicator.getDenominator() );
@@ -479,11 +479,11 @@
 
     @Override
     @Transactional
-    public String expressionIsValid( String expression )
+    public ExpressionValidationOutcome expressionIsValid( String expression )
     {
         if ( expression == null || expression.isEmpty() )
         {
-            return EXPRESSION_IS_EMPTY;
+            return ExpressionValidationOutcome.EXPRESSION_IS_EMPTY;
         }
 
         // ---------------------------------------------------------------------
@@ -500,12 +500,12 @@
             
             if ( dataElementService.getDataElement( de ) == null )
             {
-                return DATAELEMENT_DOES_NOT_EXIST;
+                return ExpressionValidationOutcome.DATAELEMENT_DOES_NOT_EXIST;
             }
 
             if ( !operandIsTotal( matcher ) && categoryService.getDataElementCategoryOptionCombo( coc ) == null )
             {
-                return CATEGORYOPTIONCOMBO_DOES_NOT_EXIST;
+                return ExpressionValidationOutcome.CATEGORYOPTIONCOMBO_DOES_NOT_EXIST;
             }
                     
             matcher.appendReplacement( sb, "1.1" );
@@ -526,7 +526,7 @@
             
             if ( constantService.getConstant( constant ) == null )
             {
-                return CONSTANT_DOES_NOT_EXIST;
+                return ExpressionValidationOutcome.CONSTANT_DOES_NOT_EXIST;
             }
             
             matcher.appendReplacement( sb, "1.1" );
@@ -547,7 +547,7 @@
             
             if ( organisationUnitGroupService.getOrganisationUnitGroup( group ) == null )
             {
-                return OU_GROUP_DOES_NOT_EXIST;
+                return ExpressionValidationOutcome.ORG_UNIT_GROUP_DOES_NOT_EXIST;
             }
 
             matcher.appendReplacement( sb, "1.1" );
@@ -567,10 +567,10 @@
 
         if ( MathUtils.expressionHasErrors( expression ) )
         {
-            return EXPRESSION_NOT_WELL_FORMED;
+            return ExpressionValidationOutcome.EXPRESSION_IS_NOT_WELL_FORMED;
         }
 
-        return VALID;
+        return ExpressionValidationOutcome.VALID;
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2015-11-17 17:23:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2015-12-08 21:44:36 +0000
@@ -755,7 +755,7 @@
 constant_does_not_exist=Constant does not exist
 org_unit_group_does_not_exist=Organisation unit group does not exist
 id_not_numeric=Identifier is not numeric
-expression_not_well_formed=Expression is not well-formed
+expression_is_not_well_formed=Expression is not well-formed
 valid=Valid
 
 #-- Validation Rule -----------------------------------------------------------#

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java	2015-12-05 15:33:48 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java	2015-12-08 21:44:36 +0000
@@ -375,37 +375,37 @@
     @Test
     public void testExpressionIsValid()
     {
-        assertEquals( ExpressionService.VALID, expressionService.expressionIsValid( expressionA ) );
-        assertEquals( ExpressionService.VALID, expressionService.expressionIsValid( expressionB ) );
-        assertEquals( ExpressionService.VALID, expressionService.expressionIsValid( expressionC ) );
-        assertEquals( ExpressionService.VALID, expressionService.expressionIsValid( expressionD ) );
-        assertEquals( ExpressionService.VALID, expressionService.expressionIsValid( expressionE ) );
-        assertEquals( ExpressionService.VALID, expressionService.expressionIsValid( expressionH ) );
+        assertTrue( expressionService.expressionIsValid( expressionA ).isValid() );
+        assertTrue( expressionService.expressionIsValid( expressionB ).isValid() );
+        assertTrue( expressionService.expressionIsValid( expressionC ).isValid() );
+        assertTrue( expressionService.expressionIsValid( expressionD ).isValid() );
+        assertTrue( expressionService.expressionIsValid( expressionE ).isValid() );
+        assertTrue( expressionService.expressionIsValid( expressionH ).isValid() );
 
         expressionA = "#{nonExisting" + SEPARATOR + categoryOptionCombo.getUid() + "} + 12";
 
-        assertEquals( ExpressionService.DATAELEMENT_DOES_NOT_EXIST, expressionService.expressionIsValid( expressionA ) );
+        assertEquals( ExpressionValidationOutcome.DATAELEMENT_DOES_NOT_EXIST, expressionService.expressionIsValid( expressionA ) );
 
         expressionA = "#{" + dataElementA.getUid() + SEPARATOR + 999 + "} + 12";
 
-        assertEquals( ExpressionService.CATEGORYOPTIONCOMBO_DOES_NOT_EXIST, expressionService
+        assertEquals( ExpressionValidationOutcome.CATEGORYOPTIONCOMBO_DOES_NOT_EXIST, expressionService
             .expressionIsValid( expressionA ) );
 
         expressionA = "#{" + dataElementA.getUid() + SEPARATOR + categoryOptionCombo.getUid() + "} + ( 12";
 
-        assertEquals( ExpressionService.EXPRESSION_NOT_WELL_FORMED, expressionService.expressionIsValid( expressionA ) );
+        assertEquals( ExpressionValidationOutcome.EXPRESSION_IS_NOT_WELL_FORMED, expressionService.expressionIsValid( expressionA ) );
 
         expressionA = "12 x 4";
 
-        assertEquals( ExpressionService.EXPRESSION_NOT_WELL_FORMED, expressionService.expressionIsValid( expressionA ) );
+        assertEquals( ExpressionValidationOutcome.EXPRESSION_IS_NOT_WELL_FORMED, expressionService.expressionIsValid( expressionA ) );
         
         expressionA = "12 + C{nonExisting}";
 
-        assertEquals( ExpressionService.CONSTANT_DOES_NOT_EXIST, expressionService.expressionIsValid( expressionA ) );
+        assertEquals( ExpressionValidationOutcome.CONSTANT_DOES_NOT_EXIST, expressionService.expressionIsValid( expressionA ) );
         
         expressionA = "12 + OUG{nonExisting}";
         
-        assertEquals( ExpressionService.OU_GROUP_DOES_NOT_EXIST, expressionService.expressionIsValid( expressionA ) );
+        assertEquals( ExpressionValidationOutcome.ORG_UNIT_GROUP_DOES_NOT_EXIST, expressionService.expressionIsValid( expressionA ) );
     }
 
     @Test

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ExpressionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ExpressionController.java	2015-09-08 15:56:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ExpressionController.java	2015-12-08 21:44:36 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.dxf2.webmessage.DescriptiveWebMessage;
 import org.hisp.dhis.dxf2.webmessage.WebMessageStatus;
 import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.expression.ExpressionValidationOutcome;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.webapi.service.WebMessageService;
@@ -67,13 +68,13 @@
     {
         I18n i18n = i18nManager.getI18n();
 
-        String result = expressionService.expressionIsValid( expression );
+        ExpressionValidationOutcome result = expressionService.expressionIsValid( expression );
         
         DescriptiveWebMessage message = new DescriptiveWebMessage();
-        message.setStatus( ExpressionService.VALID.equals( result ) ? WebMessageStatus.OK : WebMessageStatus.ERROR );
-        message.setMessage( i18n.getString( result ) );
+        message.setStatus( result.isValid() ? WebMessageStatus.OK : WebMessageStatus.ERROR );
+        message.setMessage( i18n.getString( result.getKey() ) );
         
-        if ( result.equals( ExpressionService.VALID ) )
+        if ( result.isValid() )
         {
             message.setDescription( expressionService.getExpressionDescription( expression ) );
         }

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetTextualExpressionAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetTextualExpressionAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetTextualExpressionAction.java	2015-12-08 21:44:36 +0000
@@ -29,6 +29,7 @@
  */
 
 import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.expression.ExpressionValidationOutcome;
 import org.hisp.dhis.i18n.I18n;
 
 import com.opensymphony.xwork2.Action;
@@ -86,15 +87,15 @@
     {
         if ( expression != null )
         {
-            String result = expressionService.expressionIsValid( expression );
+            ExpressionValidationOutcome result = expressionService.expressionIsValid( expression );
             
-            if ( result.equals( ExpressionService.VALID ) )
+            if ( result.isValid() )
             {
                 textualExpression = expressionService.getExpressionDescription( expression );
             }
             else
             {
-                textualExpression = i18n.getString( result );
+                textualExpression = i18n.getString( result.getKey() );
             }
         }
         

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationRuleAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationRuleAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationRuleAction.java	2015-12-08 21:44:36 +0000
@@ -29,6 +29,7 @@
  */
 
 import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.expression.ExpressionValidationOutcome;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.validation.ValidationRule;
@@ -36,8 +37,6 @@
 
 import com.opensymphony.xwork2.Action;
 
-import static org.hisp.dhis.expression.ExpressionService.VALID;
-
 /**
  * @author Margrethe Store
  * @version $Id: GetValidationRuleAction.java 4438 2008-01-26 16:35:24Z abyot $
@@ -120,11 +119,11 @@
         String leftSideFormula = validationRule.getLeftSide().getExpression();
         String rightSideFormula = validationRule.getRightSide().getExpression();
         
-        String leftSideResult = expressionService.expressionIsValid( leftSideFormula );
-        String rightSideResult = expressionService.expressionIsValid( rightSideFormula );
+        ExpressionValidationOutcome leftSideResult = expressionService.expressionIsValid( leftSideFormula );
+        ExpressionValidationOutcome rightSideResult = expressionService.expressionIsValid( rightSideFormula );
         
-        leftSideTextualExpression = VALID.equals( leftSideResult ) ? expressionService.getExpressionDescription( leftSideFormula ) : i18n.getString( leftSideResult );
-        rightSideTextualExpression = VALID.equals( rightSideResult ) ? expressionService.getExpressionDescription( rightSideFormula ) : i18n.getString( rightSideResult );
+        leftSideTextualExpression = leftSideResult.isValid() ? expressionService.getExpressionDescription( leftSideFormula ) : i18n.getString( leftSideResult.getKey() );
+        rightSideTextualExpression = rightSideResult.isValid() ? expressionService.getExpressionDescription( rightSideFormula ) : i18n.getString( rightSideResult.getKey() );
         
         periodType = validationRule.getPeriodType();
         

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowUpdateValidationRuleFormAction.java'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowUpdateValidationRuleFormAction.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/ShowUpdateValidationRuleFormAction.java	2015-12-08 21:44:36 +0000
@@ -28,12 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.expression.ExpressionService.VALID;
-
 import java.util.Collection;
 import java.util.List;
 
 import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.expression.ExpressionValidationOutcome;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -166,13 +165,13 @@
         String leftSideFormula = validationRule.getLeftSide().getExpression();
         String rightSideFormula = validationRule.getRightSide().getExpression();
 
-        String leftSideResult = expressionService.expressionIsValid( leftSideFormula );
-        String rightSideResult = expressionService.expressionIsValid( rightSideFormula );
+        ExpressionValidationOutcome leftSideResult = expressionService.expressionIsValid( leftSideFormula );
+        ExpressionValidationOutcome rightSideResult = expressionService.expressionIsValid( rightSideFormula );
 
-        leftSideTextualExpression = VALID.equals( leftSideResult ) ? expressionService
-            .getExpressionDescription( leftSideFormula ) : i18n.getString( leftSideResult );
-        rightSideTextualExpression = VALID.equals( rightSideResult ) ? expressionService
-            .getExpressionDescription( rightSideFormula ) : i18n.getString( rightSideResult );
+        leftSideTextualExpression = leftSideResult.isValid() ? expressionService
+            .getExpressionDescription( leftSideFormula ) : i18n.getString( leftSideResult.getKey() );
+        rightSideTextualExpression = rightSideResult.isValid() ? expressionService
+            .getExpressionDescription( rightSideFormula ) : i18n.getString( rightSideResult.getKey() );
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties	2015-09-26 16:08:33 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties	2015-12-08 21:44:36 +0000
@@ -55,7 +55,6 @@
 category_option_combo_id_not_numeric=Category option combo identifier must be a number
 data_element_does_not_exist=Identifier does not reference a data element
 category_option_combo_does_not_exist=Identifier does not reference a category option combo
-expression_not_well_formed=Expression is not well formed
 everything_is_ok=Everything is OK
 validation_rule_group_management=Validation rule group management
 validation_rule_management=Validation rule management