← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21348: Expression service. Better UID matching in expressions.

 

------------------------------------------------------------
revno: 21348
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-12-05 16:33:48 +0100
message:
  Expression service. Better UID matching in expressions.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.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-09-16 14:49:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java	2015-12-05 15:33:48 +0000
@@ -72,12 +72,12 @@
     String NULL_REPLACEMENT = "0";
     String SPACE = " ";
 
-    String OPERAND_EXPRESSION = "#\\{(\\w+)\\.?(\\w*)\\}";
-    String OPERAND_UID_EXPRESSION = "(\\w+)\\.?(\\w*)";
-    String DATA_ELEMENT_TOTAL_EXPRESSION = "#\\{(\\w+)\\}";
-    String OPTION_COMBO_OPERAND_EXPRESSION = "#\\{(\\w+)\\.(\\w+)\\}";
-    String CONSTANT_EXPRESSION = "C\\{(\\w+)\\}";
-    String OU_GROUP_EXPRESSION = "OUG\\{(\\w+)\\}";
+    String OPERAND_EXPRESSION = "#\\{([a-zA-Z]\\w{10})\\.?(\\w*)\\}";
+    String OPERAND_UID_EXPRESSION = "([a-zA-Z]\\w{10})\\.?(\\w*)";
+    String DATA_ELEMENT_TOTAL_EXPRESSION = "#\\{([a-zA-Z]\\w{10})\\}";
+    String OPTION_COMBO_OPERAND_EXPRESSION = "#\\{([a-zA-Z]\\w{10})\\.([a-zA-Z]\\w{10})\\}";
+    String CONSTANT_EXPRESSION = "C\\{([a-zA-Z]\\w{10})\\}";
+    String OU_GROUP_EXPRESSION = "OUG\\{([a-zA-Z]\\w{10})\\}";
     String DAYS_EXPRESSION = "\\[days\\]";
 
     Pattern OPERAND_PATTERN = Pattern.compile( OPERAND_EXPRESSION );

=== 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-09-13 17:45:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/expression/ExpressionServiceTest.java	2015-12-05 15:33:48 +0000
@@ -382,7 +382,7 @@
         assertEquals( ExpressionService.VALID, expressionService.expressionIsValid( expressionE ) );
         assertEquals( ExpressionService.VALID, expressionService.expressionIsValid( expressionH ) );
 
-        expressionA = "#{NonExistingUid" + SEPARATOR + categoryOptionCombo.getUid() + "} + 12";
+        expressionA = "#{nonExisting" + SEPARATOR + categoryOptionCombo.getUid() + "} + 12";
 
         assertEquals( ExpressionService.DATAELEMENT_DOES_NOT_EXIST, expressionService.expressionIsValid( expressionA ) );
 
@@ -399,11 +399,11 @@
 
         assertEquals( ExpressionService.EXPRESSION_NOT_WELL_FORMED, expressionService.expressionIsValid( expressionA ) );
         
-        expressionA = "12 + C{999999}";
+        expressionA = "12 + C{nonExisting}";
 
         assertEquals( ExpressionService.CONSTANT_DOES_NOT_EXIST, expressionService.expressionIsValid( expressionA ) );
         
-        expressionA = "12 + OUG{999999}";
+        expressionA = "12 + OUG{nonExisting}";
         
         assertEquals( ExpressionService.OU_GROUP_DOES_NOT_EXIST, expressionService.expressionIsValid( expressionA ) );
     }