=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2015-06-18 06:57:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2015-06-18 09:23:25 +0000
@@ -46,10 +46,12 @@
* Expressions are mathematical formulas and can contain references to various
* elements.
*
- * - Data element operands on the form #{dataelementuid.categoryoptioncombouid}
- * - Data element totals on the form #{dataelementuid}
- * - Constants on the form C{constantuid}
- * - Days in aggregation period as the symbol D{}
+ *
+ * - Data element operands on the form #{dataelementuid.categoryoptioncombouid}
+ * - Data element totals on the form #{dataelementuid}
+ * - Constants on the form C{constantuid}
+ * - Days in aggregation period as the symbol D{}
+ *
*
* @author Margrethe Store
* @author Lars Helge Overland
@@ -125,6 +127,17 @@
*/
List getAllExpressions();
+ /**
+ * Generates the calculated value for the given parameters based on the values
+ * in the given maps.
+ *
+ * @param indicator the indicator for which to calculate the value.
+ * @param period the period for which to calculate the value.
+ * @param valueMap the map of data values.
+ * @param constantMap the map of constants.
+ * @param orgUnitCountMap the map of organisation unit counts.
+ * @return the calculated value as a double.
+ */
Double getIndicatorValue( Indicator indicator, Period period, Map valueMap,
Map constantMap, Map orgUnitCountMap );
@@ -138,7 +151,7 @@
* @param constantMap the mapping between the constant uid and value to use
* in the calculation.
* @param orgUnitCountMap the mapping between organisation unit group uid and
- * count of org units to use in the calculation.
+ * count of organisation units to use in the calculation.
* @param days the number of days to use in the calculation.
* @return the calculated value as a double.
*/
@@ -155,7 +168,7 @@
* @param constantMap the mapping between the constant uid and value to use
* in the calculation.
* @param orgUnitCountMap the mapping between organisation unit group uid and
- * count of org units to use in the calculation.
+ * count of organisation units to use in the calculation.
* @param days the number of days to use in the calculation.
* @param set of data element operands that have values but they are incomplete
* (for example due to aggregation from organisationUnit children where
@@ -290,7 +303,7 @@
* @return An expression string containing DataElement names and the names of
* the CategoryOptions in the CategoryOptionCombo.
* @throws IllegalArgumentException if data element id or category option combo
- * id are not numeric or data element or category option combo do not exist.
+ * id are not numeric or data element or category option combo do not exist.
*/
String getExpressionDescription( String expression );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java 2015-06-16 13:17:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramIndicatorService.java 2015-06-18 09:34:41 +0000
@@ -106,21 +106,21 @@
* Calculate a program indicator value based on program stage instance and an
* indicator.
*
+ * @param programIndicator ProgramIndicator
* @param programInstance ProgramInstance
- * @param programIndicator ProgramIndicator
* @return Indicator value
*/
- String getProgramIndicatorValue( ProgramStageInstance programStageInstance, ProgramIndicator programIndicator );
+ String getProgramIndicatorValue( ProgramIndicator programIndicator, ProgramStageInstance programStageInstance );
/**
* Calculate a program indicator value based on program instance and an
* indicator.
*
+ * @param programIndicator ProgramIndicator
* @param programInstance ProgramInstance
- * @param programIndicator ProgramIndicator
* @return Indicator value
*/
- String getProgramIndicatorValue( ProgramInstance programInstance, ProgramIndicator programIndicator );
+ String getProgramIndicatorValue( ProgramIndicator programIndicator, ProgramInstance programInstance );
/**
* Get indicator values of all program indicators defined for a TrackedEntityInstance
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-06-18 07:39:44 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2015-06-18 09:23:09 +0000
@@ -382,28 +382,6 @@
}
/**
- * Adds program data element values to the given grid based on the given data
- * query parameters.
- *
- * @param params the data query parameters.
- * @param grid the grid.
- */
- private void addProgramValues( DataQueryParams params, Grid grid )
- {
- if ( !params.getProgramDataElements().isEmpty() || !params.getProgramAttributes().isEmpty() )
- {
- DataQueryParams dataSourceParams = params.instance();
- dataSourceParams.removeDimensions( INDICATOR_DIM_ID, DATASET_DIM_ID, DATAELEMENT_DIM_ID );
-
- EventQueryParams eventQueryParams = EventQueryParams.fromDataQueryParams( dataSourceParams );
-
- Grid eventGrid = eventAnalyticsService.getAggregatedEventData( eventQueryParams );
-
- grid.addRows( eventGrid );
- }
- }
-
- /**
* Adds data set values to the given grid based on the given data query
* parameters.
*
@@ -482,6 +460,28 @@
}
/**
+ * Adds program data element values to the given grid based on the given data
+ * query parameters.
+ *
+ * @param params the data query parameters.
+ * @param grid the grid.
+ */
+ private void addProgramValues( DataQueryParams params, Grid grid )
+ {
+ if ( !params.getProgramDataElements().isEmpty() || !params.getProgramAttributes().isEmpty() )
+ {
+ DataQueryParams dataSourceParams = params.instance();
+ dataSourceParams.removeDimensions( INDICATOR_DIM_ID, DATASET_DIM_ID, DATAELEMENT_DIM_ID );
+
+ EventQueryParams eventQueryParams = EventQueryParams.fromDataQueryParams( dataSourceParams );
+
+ Grid eventGrid = eventAnalyticsService.getAggregatedEventData( eventQueryParams );
+
+ grid.addRows( eventGrid );
+ }
+ }
+
+ /**
* Adds values to the given grid based on dynamic dimensions from the given
* data query parameters. This assumes that no fixed dimensions are part of
* the query.
=== 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-06-16 13:17:59 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java 2015-06-18 09:34:41 +0000
@@ -183,17 +183,17 @@
}
@Override
- public String getProgramIndicatorValue( ProgramStageInstance programStageInstance, ProgramIndicator programIndicator )
+ public String getProgramIndicatorValue( ProgramIndicator programIndicator, ProgramStageInstance programStageInstance )
{
- Double value = getValue( null, programStageInstance, programIndicator );
+ Double value = getValue( programIndicator, null, programStageInstance );
return value != null ? String.valueOf( value ) : null;
}
@Override
- public String getProgramIndicatorValue( ProgramInstance programInstance, ProgramIndicator programIndicator )
+ public String getProgramIndicatorValue( ProgramIndicator programIndicator, ProgramInstance programInstance )
{
- Double value = getValue( programInstance, null, programIndicator );
+ Double value = getValue( programIndicator, programInstance, null );
if ( value != null )
{
@@ -230,7 +230,7 @@
for ( ProgramIndicator programIndicator : programIndicators )
{
- String value = getProgramIndicatorValue( programInstance, programIndicator );
+ String value = getProgramIndicatorValue( programIndicator, programInstance );
if ( value != null )
{
@@ -473,11 +473,11 @@
* the program stage instance will be retrieved based on the given program
* instance in combination with the program stage from the indicator expression.
*
+ * @param indicator the indicator, must be not null.
* @param programInstance the program instance, can be null.
* @param programStageInstance the program stage instance, can be null.
- * @param indicator the indicator, must be not null.
*/
- private Double getValue( ProgramInstance programInstance, ProgramStageInstance programStageInstance, ProgramIndicator indicator )
+ private Double getValue( ProgramIndicator indicator, ProgramInstance programInstance, ProgramStageInstance programStageInstance )
{
StringBuffer buffer = new StringBuffer();
=== 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-06-02 22:11:37 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-06-18 09:34:41 +0000
@@ -456,19 +456,19 @@
programIndicatorService.addProgramIndicator( indicatorI );
programIndicatorService.addProgramIndicator( indicatorJ );
- String valueINT = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorA );
+ String valueINT = programIndicatorService.getProgramIndicatorValue( indicatorA, programInstance );
assertEquals( "10.0", valueINT );
- String valueDATE = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorB );
+ String valueDATE = programIndicatorService.getProgramIndicatorValue( indicatorB, programInstance );
assertEquals( DateUtils.getMediumDateString( enrollmentDate ), valueDATE );
- String valueE = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorE );
+ String valueE = programIndicatorService.getProgramIndicatorValue( indicatorE, programInstance );
assertEquals( "9.0", valueE );
- String valueF = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorF );
+ String valueF = programIndicatorService.getProgramIndicatorValue( indicatorF, programInstance );
assertEquals( "17.0", valueF );
- String valueG = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorG );
+ String valueG = programIndicatorService.getProgramIndicatorValue( indicatorG, programInstance );
assertEquals( "29.0", valueG );
}