dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39549
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20024: Program indicators, simplification of regex
------------------------------------------------------------
revno: 20024
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-07 13:47:06 +0200
message:
Program indicators, simplification of regex
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.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/program/ProgramIndicator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2015-09-07 10:45:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2015-09-07 11:47:06 +0000
@@ -71,8 +71,8 @@
public static final String VAR_VALUE_COUNT = "value_count";
public static final String VAR_ZERO_POS_VALUE_COUNT = "zero_pos_value_count";
- public static final String EXPRESSION_REGEXP = "(" + KEY_DATAELEMENT + "|" + KEY_ATTRIBUTE + "|" + KEY_PROGRAM_VARIABLE + "|" + KEY_CONSTANT + ")\\{(\\w+|" +
- VAR_INCIDENT_DATE + "|" + VAR_ENROLLMENT_DATE + "|" + VAR_CURRENT_DATE + ")" + SEPARATOR_ID + "?(\\w*)\\}";
+ public static final String EXPRESSION_PREFIX_REGEXP = KEY_DATAELEMENT + "|" + KEY_ATTRIBUTE + "|" + KEY_PROGRAM_VARIABLE + "|" + KEY_CONSTANT;
+ public static final String EXPRESSION_REGEXP = "(" + EXPRESSION_PREFIX_REGEXP + ")\\{([\\w\\_]+)" + SEPARATOR_ID + "?(\\w*)\\}";
public static final String SQL_FUNC_REGEXP = "d2:(.+?)\\(([^\\),]+),?([^,\\)]+)?,?([^,\\)]+)?\\)";
public static final Pattern EXPRESSION_PATTERN = Pattern.compile( EXPRESSION_REGEXP );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-09-07 11:33:05 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-09-07 11:47:06 +0000
@@ -577,6 +577,15 @@
}
@Test
+ public void testGetAnalyticsSqlWithVariables()
+ {
+ String expected = "\"EZq9VbPWgML\" + (executiondate - enrollmentdate)";
+ String expression = "#{OXXcwl6aPCQ.EZq9VbPWgML} + (V{execution_date} - V{enrollment_date})";
+
+ assertEquals( expected, programIndicatorService.getAnalyticsSQl( expression ) );
+ }
+
+ @Test
public void testExpressionIsValid()
{
programIndicatorService.addProgramIndicator( indicatorB );