dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38869
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19752: Code style
------------------------------------------------------------
revno: 19752
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-08-09 15:50:34 +0200
message:
Code style
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpression.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramExpressionService.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/ProgramExpression.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpression.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramExpression.java 2015-08-09 13:50:34 +0000
@@ -51,9 +51,8 @@
public static final String REPORT_DATE = "REPORT_DATE";
public static final String RANGE_IN_DUE_DATE = "RANGE_IN_DUE_DATE";
public static final String NOT_NULL_VALUE_IN_EXPRESSION = "NOT-NULL-VALUE";
- private static final long serialVersionUID = -2807997671779497354L;
- public static String OBJECT_PROGRAM_STAGE_DATAELEMENT = "DE";
- public static String OBJECT_PROGRAM_STAGE = "PS";
+ public static final String OBJECT_PROGRAM_STAGE_DATAELEMENT = "DE";
+ public static final String OBJECT_PROGRAM_STAGE = "PS";
private int id;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramExpressionService.java 2015-06-23 15:59:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramExpressionService.java 2015-08-09 13:50:34 +0000
@@ -54,7 +54,7 @@
public class DefaultProgramExpressionService
implements ProgramExpressionService
{
- private static final String regExp = "\\[(" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PROGRAM_STAGE + ")"
+ private static final String REGEXP = "\\[(" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PROGRAM_STAGE + ")"
+ SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+[" + SEPARATOR_ID + "([a-zA-Z0-9\\- ]|" + DUE_DATE + "|" + REPORT_DATE
+ ")+]*)\\]";
@@ -116,6 +116,7 @@
ProgramStageInstance programStageInstance, Map<String, String> dataValueMap )
{
String value = "";
+
if ( programExpression.getExpression().contains( ProgramExpression.DUE_DATE ) )
{
value = DateUtils.getMediumDateString( programStageInstance.getDueDate() );
@@ -127,7 +128,7 @@
else
{
StringBuffer description = new StringBuffer();
- Pattern pattern = Pattern.compile( regExp );
+ Pattern pattern = Pattern.compile( REGEXP );
Matcher matcher = pattern.matcher( programExpression.getExpression() );
while ( matcher.find() )
@@ -135,6 +136,7 @@
String key = matcher.group().replaceAll( "[\\[\\]]", "" ).split( SEPARATOR_OBJECT )[1];
String dataValue = dataValueMap.get( key );
+
if ( dataValue == null )
{
return null;
@@ -156,9 +158,10 @@
{
StringBuffer description = new StringBuffer();
- Pattern pattern = Pattern.compile( regExp );
+ Pattern pattern = Pattern.compile( REGEXP );
Matcher matcher = pattern.matcher( programExpression );
int countFormula = 0;
+
while ( matcher.find() )
{
countFormula++;
@@ -180,7 +183,8 @@
else if ( !name.equals( DUE_DATE ) && !name.equals( REPORT_DATE ) )
{
DataElement dataElement = dataElementService.getDataElement( name );
- if( dataElement == null )
+
+ if ( dataElement == null )
{
return INVALID_CONDITION;
}
@@ -197,11 +201,10 @@
StringBuffer tail = new StringBuffer();
matcher.appendTail( tail );
- if( countFormula > 1 || !tail.toString().isEmpty() || ( countFormula == 0 && !tail.toString().isEmpty() ) )
+ if ( countFormula > 1 || !tail.toString().isEmpty() || ( countFormula == 0 && !tail.toString().isEmpty() ) )
{
return INVALID_CONDITION;
- }
-
+ }
return description.toString();
}
@@ -211,8 +214,9 @@
{
Collection<DataElement> dataElements = new HashSet<>();
- Pattern pattern = Pattern.compile( regExp );
+ Pattern pattern = Pattern.compile( REGEXP );
Matcher matcher = pattern.matcher( programExpression );
+
while ( matcher.find() )
{
String match = matcher.group();