dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12404
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3812: Simplification
------------------------------------------------------------
revno: 3812
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-31 22:50:19 +0200
message:
Simplification
modified:
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntSingleValueAggregator.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.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-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java 2011-05-31 19:07:15 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageBoolAggregator.java 2011-05-31 20:50:19 +0000
@@ -112,26 +112,16 @@
{
final Map<DataElementOperand, double[]> totalSums = new HashMap<DataElementOperand, double[]>(); // <Operand, [total value, total relevant days]>
- Period period = null;
- Date currentStartDate = null;
- Date currentEndDate = null;
-
- double duration = 0.0;
- double value = 0.0;
- double relevantDays = 0.0;
-
- int dataValueLevel = 0;
-
for ( final CrossTabDataValue crossTabValue : crossTabValues )
{
- period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
-
- currentStartDate = period.getStartDate();
- currentEndDate = period.getEndDate();
-
- duration = getDaysInclusive( currentStartDate, currentEndDate );
+ final Period period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
+
+ final Date currentStartDate = period.getStartDate();
+ final Date currentEndDate = period.getEndDate();
+
+ final double duration = getDaysInclusive( currentStartDate, currentEndDate );
- dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
+ final int dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
if ( duration > 0 )
{
@@ -139,8 +129,8 @@
{
if ( entry.getValue() != null && entry.getKey().aggregationLevelIsValid( unitLevel, dataValueLevel ) )
{
- value = 0.0;
- relevantDays = 0.0;
+ double value = 0.0;
+ double relevantDays = 0.0;
if ( currentStartDate.compareTo( startDate ) >= 0 && currentEndDate.compareTo( endDate ) <= 0 ) // Value is within period
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java 2011-05-31 19:07:15 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntAggregator.java 2011-05-31 20:50:19 +0000
@@ -92,9 +92,6 @@
final Map<DataElementOperand, Double> values = new HashMap<DataElementOperand, Double>(); // <Operand, total value>
- double average = 0.0;
- double existingAverage = 0.0;
-
for ( final Integer unitId : unitIds )
{
final Collection<CrossTabDataValue> crossTabValues =
@@ -107,11 +104,11 @@
{
if ( entry.getValue() != null && entry.getValue()[ 1 ] > 0 )
{
- average = entry.getValue()[ 0 ] / entry.getValue()[ 1 ];
-
- existingAverage = values.containsKey( entry.getKey() ) ? values.get( entry.getKey() ) : 0;
-
- values.put( entry.getKey(), average + existingAverage );
+ double average = entry.getValue()[ 0 ] / entry.getValue()[ 1 ];
+
+ average += values.containsKey( entry.getKey() ) ? values.get( entry.getKey() ) : 0;
+
+ values.put( entry.getKey(), average );
}
}
}
@@ -124,26 +121,16 @@
{
final Map<DataElementOperand, double[]> totalSums = new HashMap<DataElementOperand, double[]>(); // <Operand, [total value, total relevant days]>
- Period period = null;
- Date currentStartDate = null;
- Date currentEndDate = null;
-
- double value = 0.0;
- double relevantDays = 0.0;
- double duration = 0.0;
-
- int dataValueLevel = 0;
-
for ( final CrossTabDataValue crossTabValue : crossTabValues )
{
- period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
+ final Period period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
- currentStartDate = period.getStartDate();
- currentEndDate = period.getEndDate();
-
- dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
-
- duration = getDaysInclusive( currentStartDate, currentEndDate );
+ final Date currentStartDate = period.getStartDate();
+ final Date currentEndDate = period.getEndDate();
+
+ final int dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
+
+ final double duration = getDaysInclusive( currentStartDate, currentEndDate );
if ( duration > 0 )
{
@@ -151,8 +138,8 @@
{
if ( entry.getValue() != null && entry.getKey().aggregationLevelIsValid( unitLevel, dataValueLevel ) )
{
- value = 0.0;
- relevantDays = 0.0;
+ double value = 0.0;
+ double relevantDays = 0.0;
try
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntSingleValueAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntSingleValueAggregator.java 2011-05-31 19:07:15 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/AverageIntSingleValueAggregator.java 2011-05-31 20:50:19 +0000
@@ -112,26 +112,16 @@
{
final Map<DataElementOperand, double[]> totalSums = new HashMap<DataElementOperand, double[]>(); // <Operand, [total value, total relevant days]>
- Period period = null;
- Date currentStartDate = null;
- Date currentEndDate = null;
-
- double value = 0.0;
- double relevantDays = 0.0;
- double duration = 0.0;
-
- int dataValueLevel = 0;
-
for ( final CrossTabDataValue crossTabValue : crossTabValues )
{
- period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
+ final Period period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
- currentStartDate = period.getStartDate();
- currentEndDate = period.getEndDate();
+ final Date currentStartDate = period.getStartDate();
+ final Date currentEndDate = period.getEndDate();
- dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
+ final int dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
- duration = getDaysInclusive( currentStartDate, currentEndDate );
+ final double duration = getDaysInclusive( currentStartDate, currentEndDate );
if ( duration > 0 )
{
@@ -139,8 +129,8 @@
{
if ( entry.getValue() != null && entry.getKey().aggregationLevelIsValid( unitLevel, dataValueLevel ) )
{
- value = 0.0;
- relevantDays = 0.0;
+ double value = 0.0;
+ double relevantDays = 0.0;
try
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java 2011-05-31 19:07:15 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumBoolAggregator.java 2011-05-31 20:50:19 +0000
@@ -109,27 +109,16 @@
{
final Map<DataElementOperand, double[]> totalSums = new HashMap<DataElementOperand, double[]>(); // <Operand, [total value, total relevant days]>
- Period period = null;
- Date currentStartDate = null;
- Date currentEndDate = null;
-
- double duration = 0.0;
- double value = 0.0;
- double relevantDays = 0.0;
- double factor = 0.0;
-
- int dataValueLevel = 0;
-
for ( final CrossTabDataValue crossTabValue : crossTabValues )
{
- period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
-
- currentStartDate = period.getStartDate();
- currentEndDate = period.getEndDate();
-
- duration = getDaysInclusive( currentStartDate, currentEndDate );
+ final Period period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
+
+ final Date currentStartDate = period.getStartDate();
+ final Date currentEndDate = period.getEndDate();
+
+ final double duration = getDaysInclusive( currentStartDate, currentEndDate );
- dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
+ final int dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
if ( duration > 0 )
{
@@ -137,9 +126,9 @@
{
if ( entry.getValue() != null && entry.getKey().aggregationLevelIsValid( unitLevel, dataValueLevel ) )
{
- value = 0.0;
- relevantDays = 0.0;
- factor = 0.0;
+ double value = 0.0;
+ double relevantDays = 0.0;
+ double factor = 0.0;
if ( currentStartDate.compareTo( startDate ) >= 0 && currentEndDate.compareTo( endDate ) <= 0 ) // Value is within period
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java 2011-05-31 19:07:15 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/aggregation/dataelement/SumIntAggregator.java 2011-05-31 20:50:19 +0000
@@ -112,27 +112,16 @@
{
final Map<DataElementOperand, double[]> totalSums = new HashMap<DataElementOperand, double[]>(); // <Operand, [total value, total relevant days]>
- Period period = null;
- Date currentStartDate = null;
- Date currentEndDate = null;
-
- double value = 0.0;
- double relevantDays = 0.0;
- double factor = 0.0;
- double duration = 0.0;
-
- int dataValueLevel = 0;
-
for ( final CrossTabDataValue crossTabValue : crossTabValues )
{
- period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
-
- currentStartDate = period.getStartDate();
- currentEndDate = period.getEndDate();
-
- duration = getDaysInclusive( currentStartDate, currentEndDate );
-
- dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
+ final Period period = aggregationCache.getPeriod( crossTabValue.getPeriodId() );
+
+ final Date currentStartDate = period.getStartDate();
+ final Date currentEndDate = period.getEndDate();
+
+ final double duration = getDaysInclusive( currentStartDate, currentEndDate );
+
+ final int dataValueLevel = aggregationCache.getLevelOfOrganisationUnit( crossTabValue.getSourceId() );
if ( duration > 0 )
{
@@ -140,9 +129,9 @@
{
if ( entry.getValue() != null && entry.getKey().aggregationLevelIsValid( unitLevel, dataValueLevel ) )
{
- value = 0.0;
- relevantDays = 0.0;
- factor = 0.0;
+ double value = 0.0;
+ double relevantDays = 0.0;
+ double factor = 0.0;
try
{