dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12517
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3869: Minor improvement in aggregation engine.
------------------------------------------------------------
revno: 3869
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-06-11 09:06:18 +0200
message:
Minor improvement in aggregation engine.
modified:
dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageBoolDataElementAggregation.java
dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageIntDataElementAggregation.java
dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageIntSingleValueDataElementAggregation.java
dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/SumBoolDataElementAggregation.java
dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/SumIntDataElementAggregation.java
dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/indicator/IndicatorAggregation.java
dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregationStore.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-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageBoolDataElementAggregation.java'
--- dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageBoolDataElementAggregation.java 2011-01-06 14:56:17 +0000
+++ dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageBoolDataElementAggregation.java 2011-06-11 07:06:18 +0000
@@ -110,9 +110,9 @@
for ( DataValue dataValue : dataValues )
{
- Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
- Date currentStartDate = currentPeriod.getStartDate();
- Date currentEndDate = currentPeriod.getEndDate();
+ final Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
+ final Date currentStartDate = currentPeriod.getStartDate();
+ final Date currentEndDate = currentPeriod.getEndDate();
long relevantDays = 0;
=== modified file 'dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageIntDataElementAggregation.java'
--- dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageIntDataElementAggregation.java 2011-01-06 14:56:17 +0000
+++ dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageIntDataElementAggregation.java 2011-06-11 07:06:18 +0000
@@ -130,9 +130,9 @@
for ( DataValue dataValue : dataValues )
{
- Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
- Date currentStartDate = currentPeriod.getStartDate();
- Date currentEndDate = currentPeriod.getEndDate();
+ final Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
+ final Date currentStartDate = currentPeriod.getStartDate();
+ final Date currentEndDate = currentPeriod.getEndDate();
double value = 0;
=== modified file 'dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageIntSingleValueDataElementAggregation.java'
--- dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageIntSingleValueDataElementAggregation.java 2011-01-06 14:56:17 +0000
+++ dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/AverageIntSingleValueDataElementAggregation.java 2011-06-11 07:06:18 +0000
@@ -94,9 +94,9 @@
for ( DataValue dataValue : dataValues )
{
- Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
- Date currentStartDate = currentPeriod.getStartDate();
- Date currentEndDate = currentPeriod.getEndDate();
+ final Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
+ final Date currentStartDate = currentPeriod.getStartDate();
+ final Date currentEndDate = currentPeriod.getEndDate();
double value = 0;
=== modified file 'dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/SumBoolDataElementAggregation.java'
--- dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/SumBoolDataElementAggregation.java 2011-01-06 14:56:17 +0000
+++ dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/SumBoolDataElementAggregation.java 2011-06-11 07:06:18 +0000
@@ -90,9 +90,9 @@
for ( DataValue dataValue : dataValues )
{
- Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
- Date currentStartDate = currentPeriod.getStartDate();
- Date currentEndDate = currentPeriod.getEndDate();
+ final Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
+ final Date currentStartDate = currentPeriod.getStartDate();
+ final Date currentEndDate = currentPeriod.getEndDate();
double value = 0;
=== modified file 'dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/SumIntDataElementAggregation.java'
--- dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/SumIntDataElementAggregation.java 2011-01-06 14:56:17 +0000
+++ dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/dataelement/SumIntDataElementAggregation.java 2011-06-11 07:06:18 +0000
@@ -101,9 +101,9 @@
for ( DataValue dataValue : dataValues )
{
- Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
- Date currentStartDate = currentPeriod.getStartDate();
- Date currentEndDate = currentPeriod.getEndDate();
+ final Period currentPeriod = aggregationCache.getPeriod( dataValue.getPeriod().getId() );
+ final Date currentStartDate = currentPeriod.getStartDate();
+ final Date currentEndDate = currentPeriod.getEndDate();
double value = 0;
=== modified file 'dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/indicator/IndicatorAggregation.java'
--- dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/indicator/IndicatorAggregation.java 2011-05-20 16:00:10 +0000
+++ dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/impl/indicator/IndicatorAggregation.java 2011-06-11 07:06:18 +0000
@@ -93,27 +93,30 @@
OrganisationUnit organisationUnit )
{
int days = daysBetween( startDate, endDate );
+
+ double denominatorValue = calculateExpression( generateExpression( indicator.getDenominator(),
+ startDate, endDate, organisationUnit, days ) );
+
+ if ( denominatorValue == INVALID || denominatorValue == 0.0 )
+ {
+ return null;
+ }
double numeratorValue = calculateExpression( generateExpression( indicator.getNumerator(), startDate,
endDate, organisationUnit, days ) );
- double denominatorValue = calculateExpression( generateExpression( indicator.getDenominator(),
- startDate, endDate, organisationUnit, days ) );
-
- if ( numeratorValue == INVALID || denominatorValue == INVALID || denominatorValue == 0.0 )
+ if ( numeratorValue == INVALID )
{
return null;
}
- else
- {
- int factor = indicator.getIndicatorType().getFactor();
-
- double annualizationFactor = DateUtils.getAnnualizationFactor( indicator, startDate, endDate );
-
- double aggregatedValue = ( numeratorValue / denominatorValue ) * factor * annualizationFactor;
-
- return aggregatedValue;
- }
+
+ int factor = indicator.getIndicatorType().getFactor();
+
+ double annualizationFactor = DateUtils.getAnnualizationFactor( indicator, startDate, endDate );
+
+ double aggregatedValue = ( numeratorValue / denominatorValue ) * factor * annualizationFactor;
+
+ return aggregatedValue;
}
public double getAggregatedNumeratorValue( Indicator indicator, Date startDate, Date endDate,
=== modified file 'dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregationStore.java'
--- dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregationStore.java 2011-05-20 12:53:06 +0000
+++ dhis-2/dhis-services/dhis-service-aggregationengine-default/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregationStore.java 2011-06-11 07:06:18 +0000
@@ -66,9 +66,9 @@
{
if ( sourceIds != null && sourceIds.size() > 0 && periodIds != null && periodIds.size() > 0 )
{
- StatementHolder holder = statementManager.getHolder();
+ final StatementHolder holder = statementManager.getHolder();
- String categoryOptionComboCriteria = optionComboId != null ? "AND categoryoptioncomboid = " + optionComboId + " " : "";
+ final String categoryOptionComboCriteria = optionComboId != null ? "AND categoryoptioncomboid = " + optionComboId + " " : "";
try
{
@@ -80,7 +80,7 @@
"AND periodid IN ( " + getCommaDelimitedString( periodIds ) + " ) " +
"AND sourceid IN ( " + getCommaDelimitedString( sourceIds ) + " )";
- ResultSet resultSet = holder.getStatement().executeQuery( sql );
+ final ResultSet resultSet = holder.getStatement().executeQuery( sql );
return getDataValues( resultSet );
}
@@ -101,9 +101,9 @@
{
if ( periodIds != null && periodIds.size() > 0 )
{
- StatementHolder holder = statementManager.getHolder();
+ final StatementHolder holder = statementManager.getHolder();
- String categoryOptionComboCriteria = optionComboId != null ? "AND categoryoptioncomboid = " + optionComboId + " " : "";
+ final String categoryOptionComboCriteria = optionComboId != null ? "AND categoryoptioncomboid = " + optionComboId + " " : "";
try
{
@@ -115,7 +115,7 @@
"AND periodid IN ( " + getCommaDelimitedString( periodIds ) + " ) " +
"AND sourceid = " + sourceId;
- ResultSet resultSet = holder.getStatement().executeQuery( sql );
+ final ResultSet resultSet = holder.getStatement().executeQuery( sql );
return getDataValues( resultSet );
}
@@ -140,15 +140,15 @@
{
try
{
- Collection<DataValue> list = new ArrayList<DataValue>();
+ final Collection<DataValue> list = new ArrayList<DataValue>();
while ( resultSet.next() )
{
- Period period = new Period();
+ final Period period = new Period();
period.setId( Integer.parseInt( resultSet.getString( 1 ) ) );
- DataValue dataValue = new DataValue();
+ final DataValue dataValue = new DataValue();
dataValue.setPeriod( period );
dataValue.setValue( resultSet.getString( 2 ) );