dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15555
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5657: Made data set report service respect the aggregation strategy for indicator values
------------------------------------------------------------
revno: 5657
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-01-04 10:10:17 +0100
message:
Made data set report service respect the aggregation strategy for indicator values
modified:
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.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-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java 2012-01-03 02:59:28 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java 2012-01-04 09:10:17 +0000
@@ -79,11 +79,8 @@
implements DataSetReportService
{
private static final String NULL_REPLACEMENT = "";
-
private static final String SEPARATOR = ":";
-
private static final String DEFAULT_HEADER = "Value";
-
private static final String TOTAL_HEADER = "Total";
// -------------------------------------------------------------------------
@@ -159,21 +156,17 @@
// Grid headers
// -----------------------------------------------------------------
- grid.addHeader( new GridHeader( i18n.getString( "dataelement" ), false, true ) ); // Data
- // element
- // header
+ grid.addHeader( new GridHeader( i18n.getString( "dataelement" ), false, true ) );
List<DataElementCategoryOptionCombo> optionCombos = categoryCombo.getSortedOptionCombos();
- for ( DataElementCategoryOptionCombo optionCombo : optionCombos ) // Value
- // headers
+ for ( DataElementCategoryOptionCombo optionCombo : optionCombos )
{
grid.addHeader( new GridHeader( optionCombo.isDefault() ? DEFAULT_HEADER : optionCombo.getName(),
false, false ) );
}
if ( categoryCombo.doSubTotals() && !selectedUnitOnly ) // Sub-total
- // headers
{
for ( DataElementCategoryOption categoryOption : categoryCombo.getCategoryOptions() )
{
@@ -181,7 +174,7 @@
}
}
- if ( categoryCombo.doTotal() && !selectedUnitOnly ) // Total header
+ if ( categoryCombo.doTotal() && !selectedUnitOnly ) // Total
{
grid.addHeader( new GridHeader( TOTAL_HEADER, false, false ) );
}
@@ -219,7 +212,6 @@
}
if ( categoryCombo.doSubTotals() && !selectedUnitOnly ) // Sub-total
- // values
{
for ( DataElementCategoryOption categoryOption : categoryCombo.getCategoryOptions() )
{
@@ -232,7 +224,6 @@
}
if ( categoryCombo.doTotal() && !selectedUnitOnly ) // Total
- // value
{
Double value = realTime ? aggregationService.getAggregatedDataValue( dataElement, null, period
.getStartDate(), period.getEndDate(), unit ) : aggregatedDataValueService.getAggregatedValue(
@@ -259,7 +250,7 @@
DEFAULT_AGGREGATION_STRATEGY );
// ---------------------------------------------------------------------
- // Get the category-option-combos
+ // Get category option combos
// ---------------------------------------------------------------------
Set<DataElementCategoryOptionCombo> optionCombos = new HashSet<DataElementCategoryOptionCombo>();
@@ -275,14 +266,14 @@
Collections.sort( orderedOptionCombos, new DataElementCategoryOptionComboNameComparator() );
// ---------------------------------------------------------------------
- // Create a GRID
+ // Create a grid
// ---------------------------------------------------------------------
Grid grid = new ListGrid().setTitle( dataSet.getName() );
grid.setSubtitle( format.formatPeriod( period ) );
// ---------------------------------------------------------------------
- // Headers for GRID
+ // Headers
// ---------------------------------------------------------------------
grid.addHeader( new GridHeader( i18n.getString( "name" ), false, true ) );
@@ -293,7 +284,7 @@
}
// ---------------------------------------------------------------------
- // Values for GRID
+ // Values
// ---------------------------------------------------------------------
for ( DataElement dataElement : dataElements )
@@ -324,28 +315,26 @@
}
// ---------------------------------------------------------------------
- // Indicator-values for GRID
+ // Indicator values
// ---------------------------------------------------------------------
List<Indicator> indicators = new ArrayList<Indicator>( dataSet.getIndicators() );
-
- // ---------------------------------------------------------------------
- // Values for GRID
- // ---------------------------------------------------------------------
-
+
for ( Indicator indicator : indicators )
{
grid.addRow();
grid.addValue( indicator.getName() );
- Double value = aggregationService.getAggregatedIndicatorValue( indicator, period.getStartDate(), period.getEndDate(), unit );
+ Double value = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ?
+ aggregationService.getAggregatedIndicatorValue( indicator, period.getStartDate(), period.getEndDate(), unit ) :
+ aggregatedDataValueService.getAggregatedValue( indicator, period, unit );
grid.addValue( value );
- for (int i=1; i< orderedOptionCombos.size(); i++ )
+ for ( int i = 0; i < orderedOptionCombos.size() - 1; i++ )
{
- grid.addValue( "" );
+ grid.addValue( NULL_REPLACEMENT );
}
}
@@ -389,17 +378,14 @@
if ( selectedUnitOnly )
{
- DataValue dataValue = dataValueService
- .getDataValue( unit, dataElement, period, categoryOptionCombo );
+ DataValue dataValue = dataValueService.getDataValue( unit, dataElement, period, categoryOptionCombo );
value = (dataValue != null) ? dataValue.getValue() : null;
}
else
{
- Double aggregatedValue = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? aggregationService
- .getAggregatedDataValue( dataElement, categoryOptionCombo, period.getStartDate(), period
- .getEndDate(), unit )
- : aggregatedDataValueService
- .getAggregatedValue( dataElement, categoryOptionCombo, period, unit );
+ Double aggregatedValue = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ?
+ aggregationService.getAggregatedDataValue( dataElement, categoryOptionCombo, period.getStartDate(), period.getEndDate(), unit ) :
+ aggregatedDataValueService.getAggregatedValue( dataElement, categoryOptionCombo, period, unit );
value = format.formatValue( aggregatedValue );
}
@@ -434,9 +420,9 @@
for ( Indicator indicator : dataSet.getIndicators() )
{
- Double aggregatedValue = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? aggregationService
- .getAggregatedIndicatorValue( indicator, period.getStartDate(), period.getEndDate(), unit )
- : aggregatedDataValueService.getAggregatedValue( indicator, period, unit );
+ Double aggregatedValue = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ?
+ aggregationService.getAggregatedIndicatorValue( indicator, period.getStartDate(), period.getEndDate(), unit ) :
+ aggregatedDataValueService.getAggregatedValue( indicator, period, unit );
String value = format.formatValue( aggregatedValue );