dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36504
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18670: Codestyle
------------------------------------------------------------
revno: 18670
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-24 10:07:34 +0100
message:
Codestyle
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
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorStoreTest.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-02-26 15:21:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2015-03-24 09:07:34 +0000
@@ -55,15 +55,15 @@
public static final String KEY_PROGRAM_VARIABLE = "V";
public static final String KEY_CONSTANT = "C";
public static final String INCIDENT_DATE = "incident_date";
- public static final String ENROLLEMENT_DATE = "enrollment_date";
+ public static final String ENROLLMENT_DATE = "enrollment_date";
public static final String CURRENT_DATE = "current_date";
public static final String VALUE_TYPE_DATE = "date";
public static final String VALUE_TYPE_INT = "int";
- private static final long serialVersionUID = 7920320128945484331L;
- public static String SEPARATOR_OBJECT = ":";
+
+ public static String SEP_OBJECT = ":";
- public static final String regExp = "("+KEY_DATAELEMENT+"|"+KEY_ATTRIBUTE+"|"+KEY_PROGRAM_VARIABLE+"|"+KEY_CONSTANT+")\\{([a-zA-Z0-9]+|" + INCIDENT_DATE + "|" + ENROLLEMENT_DATE + "|"
- + CURRENT_DATE + ")" + SEPARATOR_ID + "*([a-zA-Z0-9]*)\\}";
+ 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 String VALID = "valid";
=== 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-10 15:09:14 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-03-24 09:07:34 +0000
@@ -199,7 +199,7 @@
{
baseDate = programInstance.getDateOfIncident();
}
- else if ( ProgramIndicator.ENROLLEMENT_DATE.equals( programIndicator.getRootDate() ) )
+ else if ( ProgramIndicator.ENROLLMENT_DATE.equals( programIndicator.getRootDate() ) )
{
baseDate = programInstance.getEnrollmentDate();
}
@@ -241,7 +241,7 @@
{
StringBuffer description = new StringBuffer();
- Pattern patternCondition = Pattern.compile( ProgramIndicator.regExp );
+ Pattern patternCondition = Pattern.compile( ProgramIndicator.EXPRESSION_REGEXP );
Matcher matcher = patternCondition.matcher( expression );
@@ -287,15 +287,15 @@
}
else if ( ProgramIndicator.KEY_PROGRAM_VARIABLE.equals( key ) )
{
- if( uid1.equals( ProgramIndicator.CURRENT_DATE ) )
+ if ( uid1.equals( ProgramIndicator.CURRENT_DATE ) )
{
matcher.appendReplacement( description, "Current date" );
}
- else if( uid1.equals( ProgramIndicator.ENROLLEMENT_DATE ) )
+ else if ( uid1.equals( ProgramIndicator.ENROLLMENT_DATE ) )
{
matcher.appendReplacement( description, "Enrollment date" );
}
- else if( uid1.equals( ProgramIndicator.INCIDENT_DATE ) )
+ else if ( uid1.equals( ProgramIndicator.INCIDENT_DATE ) )
{
matcher.appendReplacement( description, "Incident date" );
}
@@ -312,7 +312,7 @@
{
StringBuffer description = new StringBuffer();
- Pattern patternCondition = Pattern.compile( ProgramIndicator.regExp );
+ Pattern patternCondition = Pattern.compile( ProgramIndicator.EXPRESSION_REGEXP );
Matcher matcher = patternCondition.matcher( expression );
@@ -369,6 +369,7 @@
matcher.appendReplacement( description, String.valueOf( 0 ) );
}
}
+
matcher.appendTail( description );
// ---------------------------------------------------------------------
@@ -391,7 +392,7 @@
{
StringBuffer description = new StringBuffer();
- Pattern pattern = Pattern.compile( ProgramIndicator.regExp );
+ Pattern pattern = Pattern.compile( ProgramIndicator.EXPRESSION_REGEXP );
Matcher matcher = pattern.matcher( indicator.getExpression() );
while ( matcher.find() )
@@ -474,7 +475,7 @@
Date currentDate = new Date();
Date date = null;
- if ( uid1.equals( ProgramIndicator.ENROLLEMENT_DATE ) )
+ if ( uid1.equals( ProgramIndicator.ENROLLMENT_DATE ) )
{
date = programInstance.getEnrollmentDate();
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-03-11 03:38:51 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-03-24 09:07:34 +0000
@@ -52,8 +52,6 @@
/**
* @author Chau Thu Tran
- *
- * @version $ ProgramIndicatorServiceTest.java Nov 13, 2013 1:34:55 PM $
*/
public class ProgramIndicatorServiceTest
extends DhisSpringTest
@@ -139,7 +137,7 @@
organisationUnit );
indicatorDate = new ProgramIndicator( "IndicatorA", "IndicatorDesA", ProgramIndicator.VALUE_TYPE_INT, "( " + ProgramIndicator.KEY_PROGRAM_VARIABLE + "{"
- + ProgramIndicator.INCIDENT_DATE + "} - " + ProgramIndicator.KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.ENROLLEMENT_DATE + "} ) / 7" );
+ + ProgramIndicator.INCIDENT_DATE + "} - " + ProgramIndicator.KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.ENROLLMENT_DATE + "} ) / 7" );
indicatorDate.setUid( "UID-DATE" );
indicatorDate.setShortName( "DATE" );
indicatorDate.setProgram( programA );
@@ -163,6 +161,10 @@
indicatorD.setProgram( programB );
}
+ // -------------------------------------------------------------------------
+ // Tests
+ // -------------------------------------------------------------------------
+
@Test
public void testAddProgramIndicator()
{
@@ -322,6 +324,5 @@
assertEquals( ProgramIndicator.VALID, programIndicatorService.expressionIsValid( indicatorDate.getExpression() ) );
assertEquals( ProgramIndicator.VALID, programIndicatorService.expressionIsValid( indicatorInt.getExpression() ) );
assertEquals( ProgramIndicator.EXPRESSION_NOT_WELL_FORMED, programIndicatorService.expressionIsValid( indicatorD.getExpression() ) );
- }
-
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorStoreTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorStoreTest.java 2015-03-24 09:07:34 +0000
@@ -45,8 +45,6 @@
/**
* @author Chau Thu Tran
- *
- * @version $ ProgramIndicatorStoreTest.java Nov 13, 2013 1:34:55 PM $
*/
public class ProgramIndicatorStoreTest
extends DhisSpringTest
@@ -109,7 +107,7 @@
programService.addProgram( programB );
indicatorDate = new ProgramIndicator( "IndicatorA", "IndicatorDesA", ProgramIndicator.VALUE_TYPE_INT, "( "
- + ProgramIndicator.INCIDENT_DATE + " - " + ProgramIndicator.ENROLLEMENT_DATE + " ) / 7" );
+ + ProgramIndicator.INCIDENT_DATE + " - " + ProgramIndicator.ENROLLMENT_DATE + " ) / 7" );
indicatorDate.setUid( "UID-DATE" );
indicatorDate.setShortName( "DATE" );
indicatorDate.setProgram( programA );
@@ -126,6 +124,10 @@
indicatorC.setProgram( programB );
}
+ // -------------------------------------------------------------------------
+ // Tests
+ // -------------------------------------------------------------------------
+
@Test
public void testGetProgramIndicatorsByProgram()
{
@@ -141,6 +143,5 @@
indicators = programIndicatorStore.getByProgram( programB );
assertEquals( 1, indicators.size() );
assertTrue( indicators.contains( indicatorC ) );
-
}
}