dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11948
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3516: Made the validation rule edit function more robust re invalid expression
------------------------------------------------------------
revno: 3516
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-05-05 23:28:46 +0200
message:
Made the validation rule edit function more robust re invalid expression
modified:
dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationRuleAction.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-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 2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/GetValidationRuleAction.java 2011-05-05 21:28:46 +0000
@@ -28,12 +28,14 @@
*/
import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.validation.ValidationRule;
import org.hisp.dhis.validation.ValidationRuleService;
import com.opensymphony.xwork2.Action;
+import static org.hisp.dhis.expression.ExpressionService.VALID;
/**
* @author Margrethe Store
@@ -60,6 +62,13 @@
this.expressionService = expressionService;
}
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
@@ -112,8 +121,14 @@
{
validationRule = validationRuleService.getValidationRule( id );
- leftSideTextualExpression = expressionService.getExpressionDescription( validationRule.getLeftSide().getExpression() );
- rightSideTextualExpression = expressionService.getExpressionDescription( validationRule.getRightSide().getExpression() );
+ String leftSideFormula = validationRule.getLeftSide().getExpression();
+ String rightSideFormula = validationRule.getRightSide().getExpression();
+
+ String leftSideResult = expressionService.expressionIsValid( leftSideFormula );
+ String rightSideResult = expressionService.expressionIsValid( rightSideFormula );
+
+ leftSideTextualExpression = VALID.equals( leftSideResult ) ? expressionService.getExpressionDescription( leftSideFormula ) : i18n.getString( leftSideResult );
+ rightSideTextualExpression = VALID.equals( rightSideResult ) ? expressionService.getExpressionDescription( rightSideFormula ) : i18n.getString( rightSideResult );
validationOperator = validationRule.getOperator().toString();