← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8575: Exception thrown when to run validation rules.

 

------------------------------------------------------------
revno: 8575
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-10-18 16:58:59 +0700
message:
  Exception thrown when to run validation rules.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addSingleProgramValidationForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm


--
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-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2012-09-25 09:12:30 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramValidationService.java	2012-10-18 09:58:59 +0000
@@ -66,7 +66,7 @@
     private final String regExp = "\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+["
         + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
 
-    private final String regExpComparator = "(<|>|<=|>|>=|==|!=)+";
+    private final String regExpComparator = "(<=|>=|==|!=|<|>|>)+";
 
     private final String INVALID_CONDITION = "Invalid condition";
 
@@ -358,13 +358,13 @@
         String leftSideValue = getOneSideExpressionValue( sides[0].trim(), programStageInstance );
         String rightSideValue = getOneSideExpressionValue( sides[1].trim(), programStageInstance );
 
+        if ( leftSideValue == null || rightSideValue == null )
+        {
+            return true;
+        }
+        
         if ( expression.indexOf( SUM_OPERATOR_IN_EXPRESSION ) != -1 )
         {
-            if ( leftSideValue == null || rightSideValue == null )
-            {
-                return true;
-            }
-
             String result = leftSideValue + comparetor + rightSideValue;
             final JEP parser = new JEP();
             parser.parseExpression( result );
@@ -378,9 +378,27 @@
             }
             else if ( comparetor.equals( "==" ) && leftSideValue.equals( rightSideValue ) )
             {
-                return true;
-            }
-            else if ( !comparetor.equals( "==" ) && !leftSideValue.equals( rightSideValue ) )
+                return true; 
+            }
+            else if ( comparetor.equals( "<" ) && leftSideValue.compareTo( rightSideValue )<0 )
+            {
+                return true;
+            }
+            else if ( comparetor.equals( "<=" ) && 
+                (  leftSideValue.equals( rightSideValue ) || leftSideValue.compareTo( rightSideValue )<0 ))
+            {
+                return true;
+            }
+            else if ( comparetor.equals( ">" ) && leftSideValue.compareTo( rightSideValue )>0 )
+            {
+                return true;
+            }
+            else if ( comparetor.equals( ">=" ) &&                 
+                ( leftSideValue.equals( rightSideValue ) || leftSideValue.compareTo( rightSideValue )>0 ))
+            {
+                return true;
+            }
+            else if ( comparetor.equals( "!=" ) && !leftSideValue.equals( rightSideValue ) )
             {
                 return true;
             }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-10-15 04:42:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-10-18 09:58:59 +0000
@@ -168,8 +168,6 @@
 add_multi_program_validation_rule=Add multi program validation rule
 program_validation_rule_details=Program validation rule details
 program_validation_rule_management=Program validation rule management
-create_new_single_validation_rule=Create new single validation rule
-create_new_multi_validation_rule=Create new multi validation rule
 person_attribute_group_sort_order=Person attribute group sort order
 scheduled_days_from_start=Scheduled days from start
 success_delete_program_attribute_option=Deleted program attribute option successfully
@@ -313,4 +311,6 @@
 last_12_months_daily = Last 12 months daily
 last_6_months_daily_6_to_12_months_weekly = Last 6 months daily + 6 to 12 months weekly
 execute_tasks_confirmation=Are you sure you want to execute all tasks now? Task processing might fully utilize your system resources and slow down other operations.
-executing = Executing
\ No newline at end of file
+executing = Executing
+add_single_rule = Add single rule
+add_multi_rule = Add multi rule
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addSingleProgramValidationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addSingleProgramValidationForm.vm	2012-10-15 05:12:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addSingleProgramValidationForm.vm	2012-10-18 09:58:59 +0000
@@ -1,4 +1,4 @@
-<h3>$i18n.getString( "add_single_program_rule_validation" )</h3>
+<h3>$i18n.getString( "add_single_program_validation_rule" )</h3>
 
 <form id='programValidationForm' name='programValidationForm' method='post' action='addProgramValidation.action'>
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm	2012-10-15 04:42:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/programValidationList.vm	2012-10-18 09:58:59 +0000
@@ -10,9 +10,9 @@
 			  <tr>
 				<td></td>
 				<td>
-					<input type="button" value="$i18n.getString( "create_new_single_validation" )" onclick="window.location.href='showAddSingleProgramValidationForm.action?id=$program.id'" style="width:200px">
-					<input type="button" value="$i18n.getString( "create_new_multi_validation" )" onclick="window.location.href='showAddMultiProgramValidationForm.action?id=$program.id'" style="width:200px">
-					<input type="button" value="$i18n.getString( "back" )" onclick="window.location.href='program.action'" style="width:200px">
+					<input type="button" value="$i18n.getString( "add_single_rule" )" onclick="window.location.href='showAddSingleProgramValidationForm.action?id=$program.id'" style="width:100px">
+					<input type="button" value="$i18n.getString( "add_multi_rule" )" onclick="window.location.href='showAddMultiProgramValidationForm.action?id=$program.id'" style="width:100px">
+					<input type="button" value="$i18n.getString( "back" )" onclick="window.location.href='program.action'" style="width:100px">
 				</td>
 			  </tr>
 			  <tr>