dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39051
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19819: Program indicator, renamed some variables
------------------------------------------------------------
revno: 19819
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-08-22 11:04:37 -0400
message:
Program indicator, renamed some variables
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.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-08-22 13:42:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicator.java 2015-08-22 15:04:37 +0000
@@ -30,12 +30,6 @@
import java.util.regex.Pattern;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-
import org.hisp.dhis.analytics.AggregationType;
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseNameableObject;
@@ -45,6 +39,12 @@
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.ExportView;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+
/**
* @author Chau Thu Tran
*/
@@ -53,22 +53,21 @@
extends BaseNameableObject
{
public static final String SEPARATOR_ID = "\\.";
+ public static final String SEP_OBJECT = ":";
public static final String KEY_DATAELEMENT = "#";
public static final String KEY_ATTRIBUTE = "A";
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 ENROLLMENT_DATE = "enrollment_date";
- public static final String CURRENT_DATE = "current_date";
+ public static final String VAR_INCIDENT_DATE = "incident_date";
+ public static final String VAR_ENROLLMENT_DATE = "enrollment_date";
+ public static final String VAR_CURRENT_DATE = "current_date";
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 VALUE_TYPE_DATE = "date";
public static final String VALUE_TYPE_INT = "int";
- public static String SEP_OBJECT = ":";
-
private static final String EXPRESSION_REGEXP = "(" + KEY_DATAELEMENT + "|" + KEY_ATTRIBUTE + "|" + KEY_PROGRAM_VARIABLE + "|" + KEY_CONSTANT + ")\\{(\\w+|" +
- INCIDENT_DATE + "|" + ENROLLMENT_DATE + "|" + CURRENT_DATE + ")" + SEPARATOR_ID + "?(\\w*)\\}";
+ VAR_INCIDENT_DATE + "|" + VAR_ENROLLMENT_DATE + "|" + VAR_CURRENT_DATE + ")" + SEPARATOR_ID + "?(\\w*)\\}";
private 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/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-08-22 13:42:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-08-22 15:04:37 +0000
@@ -147,7 +147,7 @@
}
// -------------------------------------------------------------------------
- // Implementation methods
+ // ProgramIndicatorService implementation
// -------------------------------------------------------------------------
@Override
@@ -218,11 +218,11 @@
{
Date baseDate = new Date();
- if ( ProgramIndicator.INCIDENT_DATE.equals( programIndicator.getRootDate() ) )
+ if ( ProgramIndicator.VAR_INCIDENT_DATE.equals( programIndicator.getRootDate() ) )
{
baseDate = programInstance.getDateOfIncident();
}
- else if ( ProgramIndicator.ENROLLMENT_DATE.equals( programIndicator.getRootDate() ) )
+ else if ( ProgramIndicator.VAR_ENROLLMENT_DATE.equals( programIndicator.getRootDate() ) )
{
baseDate = programInstance.getEnrollmentDate();
}
@@ -313,15 +313,15 @@
}
else if ( ProgramIndicator.KEY_PROGRAM_VARIABLE.equals( key ) )
{
- if ( ProgramIndicator.CURRENT_DATE.equals( uid ) )
+ if ( ProgramIndicator.VAR_CURRENT_DATE.equals( uid ) )
{
matcher.appendReplacement( description, "Current date" );
}
- else if ( ProgramIndicator.ENROLLMENT_DATE.equals( uid ) )
+ else if ( ProgramIndicator.VAR_ENROLLMENT_DATE.equals( uid ) )
{
matcher.appendReplacement( description, "Enrollment date" );
}
- else if ( ProgramIndicator.INCIDENT_DATE.equals( uid ) )
+ else if ( ProgramIndicator.VAR_INCIDENT_DATE.equals( uid ) )
{
matcher.appendReplacement( description, "Incident date" );
}
@@ -714,15 +714,15 @@
Date currentDate = new Date();
Date date = null;
- if ( ProgramIndicator.ENROLLMENT_DATE.equals( uid ) )
+ if ( ProgramIndicator.VAR_ENROLLMENT_DATE.equals( uid ) )
{
date = programInstance.getEnrollmentDate();
}
- else if ( ProgramIndicator.INCIDENT_DATE.equals( uid ) )
+ else if ( ProgramIndicator.VAR_INCIDENT_DATE.equals( uid ) )
{
date = programInstance.getDateOfIncident();
}
- else if ( ProgramIndicator.CURRENT_DATE.equals( uid ) )
+ else if ( ProgramIndicator.VAR_CURRENT_DATE.equals( uid ) )
{
date = currentDate;
}
=== 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-08-22 13:42:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-08-22 15:04:37 +0000
@@ -293,8 +293,8 @@
// ProgramIndicator
// ---------------------------------------------------------------------
- String expressionA = "( " + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.ENROLLMENT_DATE + "} - " + KEY_PROGRAM_VARIABLE + "{"
- + ProgramIndicator.INCIDENT_DATE + "} ) / " + ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}";
+ String expressionA = "( " + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.VAR_ENROLLMENT_DATE + "} - " + KEY_PROGRAM_VARIABLE + "{"
+ + ProgramIndicator.VAR_INCIDENT_DATE + "} ) / " + ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}";
indicatorA = createProgramIndicator( 'A', programA, expressionA, null );
programA.getProgramIndicators().add( indicatorA );
@@ -305,7 +305,7 @@
indicatorC = createProgramIndicator( 'C', programA, "0", null );
programA.getProgramIndicators().add( indicatorC );
- String expressionD = "0 + A + 4 + " + ProgramIndicator.KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.INCIDENT_DATE + "}";
+ String expressionD = "0 + A + 4 + " + ProgramIndicator.KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.VAR_INCIDENT_DATE + "}";
indicatorD = createProgramIndicator( 'D', programB, expressionD, null );
String expressionE = KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "} + " + KEY_DATAELEMENT + "{"
@@ -324,19 +324,19 @@
+ KEY_ATTRIBUTE + "{" + atB.getUid() + "} * " + KEY_CONSTANT + "{" + constantA.getUid() + "}";
indicatorG = createProgramIndicator( 'G', programB, expressionG, null );
- String expressionH = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - "
+ String expressionH = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.VAR_CURRENT_DATE + "} - "
+ KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " + KEY_DATAELEMENT + "{"
+ psA.getUid() + "." + deA.getUid() + "}";
indicatorH = createProgramIndicator( 'H', programB, expressionH, null );
- String expressionI = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - "
+ String expressionI = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.VAR_CURRENT_DATE + "} - "
+ KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " + KEY_DATAELEMENT + "{"
+ psA.getUid() + "." + deA.getUid() + "}";
indicatorI = createProgramIndicator( 'I', programB, expressionI, null );
indicatorI.setValueType( VALUE_TYPE_DATE );
String expressionJ = "(" + KEY_ATTRIBUTE + "{" + atC.getUid() + "} - " + KEY_PROGRAM_VARIABLE + "{"
- + ProgramIndicator.ENROLLMENT_DATE + "} ) + " + KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid()
+ + ProgramIndicator.VAR_ENROLLMENT_DATE + "} ) + " + KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid()
+ "} * " + ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}";
indicatorJ = createProgramIndicator( 'J', programB, expressionJ, null );
indicatorJ.setValueType( VALUE_TYPE_DATE );
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-07-21 14:07:09 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-08-22 15:04:37 +0000
@@ -1261,7 +1261,7 @@
indicator.setValueType( ProgramIndicator.VALUE_TYPE_INT );
indicator.setExpression( expression );
indicator.setFilter( filter );
- indicator.setRootDate( ProgramIndicator.INCIDENT_DATE );
+ indicator.setRootDate( ProgramIndicator.VAR_INCIDENT_DATE );
return indicator;
}