dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14124
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4676: Filtering out indicators with invalid expressions in data mart
------------------------------------------------------------
revno: 4676
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-09-24 14:01:19 +0200
message:
Filtering out indicators with invalid expressions in data mart
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-09-16 07:53:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2011-09-24 12:01:19 +0000
@@ -155,6 +155,14 @@
String convertExpression( String expression, Map<Object, Integer> dataElementMapping, Map<Object, Integer> categoryOptionComboMapping );
/**
+ * Filters indicators from the given collection where the numerator and /
+ * or the denominator are invalid.
+ *
+ * @param indicators collection of Indicators.
+ */
+ void filterInvalidIndicators( Collection<Indicator> indicators );
+
+ /**
* Tests whether the expression is valid. Returns a positive value if the
* expression is valid, or a negative value if not.
*
=== 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-09-16 07:53:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2011-09-24 12:01:19 +0000
@@ -36,6 +36,7 @@
import java.util.Collection;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
@@ -283,6 +284,26 @@
return operandsInExpression;
}
+
+ public void filterInvalidIndicators( Collection<Indicator> indicators )
+ {
+ if ( indicators != null )
+ {
+ Iterator<Indicator> iterator = indicators.iterator();
+
+ while ( iterator.hasNext() )
+ {
+ Indicator indicator = iterator.next();
+
+ if ( !expressionIsValid( indicator.getNumerator() ).equals( VALID ) ||
+ !expressionIsValid( indicator.getDenominator() ).equals( VALID ) )
+ {
+ iterator.remove();
+ log.warn( "Indicator is invalid: " + indicator );
+ }
+ }
+ }
+ }
public String expressionIsValid( String formula )
{
=== 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-09-23 22:39:54 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-09-24 12:01:19 +0000
@@ -169,8 +169,10 @@
Collection<Period> periods = periodService.getPeriods( periodIds );
Collection<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnits( organisationUnitIds );
Collection<DataElement> dataElements = dataElementService.getDataElements( dataElementIds );
- dataElements = FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
-
+
+ FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
+ expressionService.filterInvalidIndicators( indicators );
+
// ---------------------------------------------------------------------
// Explode indicator expressions
// ---------------------------------------------------------------------