dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12934
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4054: Centralized method
------------------------------------------------------------
revno: 4054
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-07-01 09:37:16 +0200
message:
Centralized method
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.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/expression/ExpressionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2011-06-29 15:25:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2011-07-01 07:37:16 +0000
@@ -34,6 +34,7 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
@@ -217,4 +218,13 @@
* @param days The number to be substituted with the days expression in the formula.
*/
String generateExpression( String expression, Map<DataElementOperand, Double> valueMap, Map<Integer, Double> constantMap, Integer days );
+
+ /**
+ * Returns all Operands included in the formulas for the given collection of
+ * Indicators. Requires that the explodedNumerator and explodedDenominator
+ * properties have been populated.
+ *
+ * @param indicators the collection of Indicators.
+ */
+ Set<DataElementOperand> getOperandsInIndicators( Collection<Indicator> indicators );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2011-06-29 15:25:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2011-07-01 07:37:16 +0000
@@ -54,6 +54,7 @@
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.system.util.MathUtils;
@@ -567,6 +568,22 @@
return buffer != null ? buffer.toString() : null;
}
+
+ public Set<DataElementOperand> getOperandsInIndicators( Collection<Indicator> indicators )
+ {
+ final Set<DataElementOperand> operands = new HashSet<DataElementOperand>();
+
+ for ( Indicator indicator : indicators )
+ {
+ Set<DataElementOperand> temp = getOperandsInExpression( indicator.getExplodedNumerator() );
+ operands.addAll( temp != null ? temp : new HashSet<DataElementOperand>() );
+
+ temp = getOperandsInExpression( indicator.getExplodedDenominator() );
+ operands.addAll( temp != null ? temp : new HashSet<DataElementOperand>() );
+ }
+
+ return operands;
+ }
private static final String stripConstantExpression( String match )
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-07-01 07:12:30 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-07-01 07:37:16 +0000
@@ -176,7 +176,7 @@
// ---------------------------------------------------------------------
Collection<DataElementOperand> dataElementOperands = categoryService.getOperands( dataElements );
- List<DataElementOperand> indicatorOperands = new ArrayList<DataElementOperand>( categoryService.populateOperands( getOperandsInIndicators( indicators ) ) );
+ List<DataElementOperand> indicatorOperands = new ArrayList<DataElementOperand>( categoryService.populateOperands( expressionService.getOperandsInIndicators( indicators ) ) );
Set<DataElementOperand> allOperands = new HashSet<DataElementOperand>();
allOperands.addAll( dataElementOperands );
@@ -294,24 +294,4 @@
clock.logTime( "Data mart export process completed" );
}
-
- // -------------------------------------------------------------------------
- // Supportive methods
- // -------------------------------------------------------------------------
-
- private Set<DataElementOperand> getOperandsInIndicators( Collection<Indicator> indicators )
- {
- final Set<DataElementOperand> operands = new HashSet<DataElementOperand>();
-
- for ( Indicator indicator : indicators )
- {
- Set<DataElementOperand> temp = expressionService.getOperandsInExpression( indicator.getExplodedNumerator() );
- operands.addAll( temp != null ? temp : new HashSet<DataElementOperand>() );
-
- temp = expressionService.getOperandsInExpression( indicator.getExplodedDenominator() );
- operands.addAll( temp != null ? temp : new HashSet<DataElementOperand>() );
- }
-
- return operands;
- }
}