dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36505
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18671: ProgramIndicatorService, centralized expression pattern.
------------------------------------------------------------
revno: 18671
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-24 10:13:12 +0100
message:
ProgramIndicatorService, centralized expression pattern.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.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-03-24 09:07:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2015-03-24 09:13:12 +0000
@@ -28,6 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.regex.Pattern;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -65,6 +67,8 @@
public static final String EXPRESSION_REGEXP = "(" + KEY_DATAELEMENT + "|" + KEY_ATTRIBUTE + "|" + KEY_PROGRAM_VARIABLE + "|" + KEY_CONSTANT + ")\\{([a-zA-Z0-9]+|" +
INCIDENT_DATE + "|" + ENROLLMENT_DATE + "|" + CURRENT_DATE + ")" + SEPARATOR_ID + "*([a-zA-Z0-9]*)\\}";
+ public static final Pattern EXPRESSION_PATTERN = Pattern.compile( EXPRESSION_REGEXP );
+
public static final String VALID = "valid";
public static final String EXPRESSION_NOT_WELL_FORMED = "expression_not_well_formed";
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-03-24 09:07:34 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-03-24 09:13:12 +0000
@@ -35,7 +35,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.hisp.dhis.constant.Constant;
import org.hisp.dhis.constant.ConstantService;
@@ -241,9 +240,7 @@
{
StringBuffer description = new StringBuffer();
- Pattern patternCondition = Pattern.compile( ProgramIndicator.EXPRESSION_REGEXP );
-
- Matcher matcher = patternCondition.matcher( expression );
+ Matcher matcher = ProgramIndicator.EXPRESSION_PATTERN.matcher( expression );
while ( matcher.find() )
{
@@ -312,9 +309,7 @@
{
StringBuffer description = new StringBuffer();
- Pattern patternCondition = Pattern.compile( ProgramIndicator.EXPRESSION_REGEXP );
-
- Matcher matcher = patternCondition.matcher( expression );
+ Matcher matcher = ProgramIndicator.EXPRESSION_PATTERN.matcher( expression );
while ( matcher.find() )
{
@@ -392,8 +387,7 @@
{
StringBuffer description = new StringBuffer();
- Pattern pattern = Pattern.compile( ProgramIndicator.EXPRESSION_REGEXP );
- Matcher matcher = pattern.matcher( indicator.getExpression() );
+ Matcher matcher = ProgramIndicator.EXPRESSION_PATTERN.matcher( indicator.getExpression() );
while ( matcher.find() )
{