dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10696
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2935: Only showing subtotals if category combo has more than one category in report table
------------------------------------------------------------
revno: 2935
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-02-28 21:10:12 +0100
message:
Only showing subtotals if category combo has more than one category in report table
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.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/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2011-02-28 17:34:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java 2011-02-28 20:10:12 +0000
@@ -394,7 +394,7 @@
// -------------------------------------------------------------------------
/**
- * Tests whether this ReportTable is multi-dimensional.
+ * Indicates whether this ReportTable is multi-dimensional.
*/
public boolean isDimensional()
{
@@ -402,7 +402,7 @@
}
/**
- * Tests whether a total column should be included.
+ * Indicates whether a total column should be included.
*/
public boolean doTotal()
{
@@ -410,6 +410,16 @@
}
/**
+ * Indicates whether subtotal columns should be included. The category combo
+ * of the report table must have more than one category if subtotal columns
+ * will contribute.
+ */
+ public boolean doSubTotals()
+ {
+ return doTotal() && categoryCombo.getCategories() != null && categoryCombo.getCategories().size() > 1;
+ }
+
+ /**
* Generates a pretty column name based on short-names of the argument objects.
* Null arguments are ignored in the name.
*/
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2011-02-28 17:34:25 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2011-02-28 20:10:12 +0000
@@ -379,13 +379,16 @@
grid.addHeader( new GridHeader( getPrettyColumnName( column ), getColumnName( column ), Double.class.getName(), false, false ) );
}
+ if ( reportTable.doSubTotals() )
+ {
+ for ( DataElementCategoryOption categoryOption : reportTable.getCategoryCombo().getCategoryOptions() )
+ {
+ grid.addHeader( new GridHeader( categoryOption.getShortName(), columnEncode( categoryOption.getShortName() ), Double.class.getName(), false, false ) );
+ }
+ }
+
if ( reportTable.doTotal() )
{
- for ( DataElementCategoryOption categoryOption : reportTable.getCategoryCombo().getCategoryOptions() ) // TOTO skip if only one category?
- {
- grid.addHeader( new GridHeader( categoryOption.getShortName(), columnEncode( categoryOption.getShortName() ), Double.class.getName(), false, false ) );
- }
-
grid.addHeader( new GridHeader( TOTAL_COLUMN_PRETTY_NAME, TOTAL_COLUMN_NAME, Double.class.getName(), false, false ) );
}
@@ -416,13 +419,16 @@
grid.addValue( map.get( getIdentifier( row, column ) ) ); // Values
}
- if ( reportTable.doTotal() )
+ if ( reportTable.doSubTotals() )
{
for ( DataElementCategoryOption categoryOption : reportTable.getCategoryCombo().getCategoryOptions() )
{
grid.addValue( map.get( getIdentifier( row, DataElementCategoryOption.class, categoryOption.getId() ) ) );
}
-
+ }
+
+ if ( reportTable.doTotal() )
+ {
grid.addValue( map.get( getIdentifier( row ) ) ); // Only category option combo is crosstab when total, row identifier will return total
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java 2011-02-23 23:26:47 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java 2011-02-28 20:10:12 +0000
@@ -690,51 +690,35 @@
assertEquals( 11.0, grid.getRow( 0 ).get( 9 ) );
assertEquals( 11.0, grid.getRow( 0 ).get( 10 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 11 ) );
- assertEquals( 11.0, grid.getRow( 0 ).get( 12 ) );
- assertEquals( 22.0, grid.getRow( 0 ).get( 13 ) );
+ assertEquals( 22.0, grid.getRow( 0 ).get( 11 ) );
assertEquals( 12.0, grid.getRow( 1 ).get( 9 ) );
assertEquals( 12.0, grid.getRow( 1 ).get( 10 ) );
- assertEquals( 12.0, grid.getRow( 1 ).get( 11 ) );
- assertEquals( 12.0, grid.getRow( 1 ).get( 12 ) );
- assertEquals( 24.0, grid.getRow( 1 ).get( 13 ) );
+ assertEquals( 24.0, grid.getRow( 1 ).get( 11 ) );
assertEquals( 13.0, grid.getRow( 2 ).get( 9 ) );
assertEquals( 13.0, grid.getRow( 2 ).get( 10 ) );
- assertEquals( 13.0, grid.getRow( 2 ).get( 11 ) );
- assertEquals( 13.0, grid.getRow( 2 ).get( 12 ) );
- assertEquals( 26.0, grid.getRow( 2 ).get( 13 ) );
+ assertEquals( 26.0, grid.getRow( 2 ).get( 11 ) );
assertEquals( 14.0, grid.getRow( 3 ).get( 9 ) );
assertEquals( 14.0, grid.getRow( 3 ).get( 10 ) );
- assertEquals( 14.0, grid.getRow( 3 ).get( 11 ) );
- assertEquals( 14.0, grid.getRow( 3 ).get( 12 ) );
- assertEquals( 28.0, grid.getRow( 3 ).get( 13 ) );
+ assertEquals( 28.0, grid.getRow( 3 ).get( 11 ) );
assertEquals( 15.0, grid.getRow( 4 ).get( 9 ) );
assertEquals( 15.0, grid.getRow( 4 ).get( 10 ) );
- assertEquals( 15.0, grid.getRow( 4 ).get( 11 ) );
- assertEquals( 15.0, grid.getRow( 4 ).get( 12 ) );
- assertEquals( 30.0, grid.getRow( 4 ).get( 13 ) );
+ assertEquals( 30.0, grid.getRow( 4 ).get( 11 ) );
assertEquals( 16.0, grid.getRow( 5 ).get( 9 ) );
assertEquals( 16.0, grid.getRow( 5 ).get( 10 ) );
- assertEquals( 16.0, grid.getRow( 5 ).get( 11 ) );
- assertEquals( 16.0, grid.getRow( 5 ).get( 12 ) );
- assertEquals( 32.0, grid.getRow( 5 ).get( 13 ) );
+ assertEquals( 32.0, grid.getRow( 5 ).get( 11 ) );
assertEquals( 17.0, grid.getRow( 6 ).get( 9 ) );
assertEquals( 17.0, grid.getRow( 6 ).get( 10 ) );
- assertEquals( 17.0, grid.getRow( 6 ).get( 11 ) );
- assertEquals( 17.0, grid.getRow( 6 ).get( 12 ) );
- assertEquals( 34.0, grid.getRow( 6 ).get( 13 ) );
+ assertEquals( 34.0, grid.getRow( 6 ).get( 11 ) );
assertEquals( 18.0, grid.getRow( 7 ).get( 9 ) );
assertEquals( 18.0, grid.getRow( 7 ).get( 10 ) );
- assertEquals( 18.0, grid.getRow( 7 ).get( 11 ) );
- assertEquals( 18.0, grid.getRow( 7 ).get( 12 ) );
- assertEquals( 36.0, grid.getRow( 7 ).get( 13 ) );
+ assertEquals( 36.0, grid.getRow( 7 ).get( 11 ) );
}
@Test