← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6048: Impl support for cumulative values in report table. A column with cumulative values will be added...

 

------------------------------------------------------------
revno: 6048
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-02-20 11:20:01 +0100
message:
  Impl support for cumulative values in report table. A column with cumulative values will be added for each data column.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.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/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
  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/ReportTableStoreTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm


--
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/common/Grid.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Grid.java	2012-02-20 10:20:01 +0000
@@ -195,4 +195,12 @@
      * @oaram addHeader indicates whether to add a grid header for the regression column.
      */
     Grid addRegressionColumn( int columnIndex, boolean addHeader );
+    
+    /**
+     * Adds a cumulative column to the grid. Column must hold numeric data.
+     * 
+     * @param columnIndex the index of the base column.
+     * @param addHeader indicates whether to add a grid header for the regression column.
+     */
+    Grid addCumulativeColumn( int columnIndex, boolean addHeader );
 }

=== 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-12-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2012-02-20 10:20:01 +0000
@@ -167,9 +167,14 @@
     // -------------------------------------------------------------------------
 
     /**
-     * Whether the ReportTable contains regression columns.
+     * Indicates whether the ReportTable contains regression columns.
      */
     private boolean regression;
+    
+    /**    
+     * Indicates whether the ReportTable contains cumulative columns.
+     */
+    private boolean cumulative;
 
     /**
      * The list of DataElements the ReportTable contains.
@@ -352,7 +357,7 @@
      * @param relatives       the relative periods.
      * @param i18nFormat      the i18n format. Not persisted.
      */
-    public ReportTable( String name, boolean regression, List<DataElement> dataElements, List<Indicator> indicators,
+    public ReportTable( String name, List<DataElement> dataElements, List<Indicator> indicators,
                         List<DataSet> dataSets, List<Period> periods, List<Period> relativePeriods, List<OrganisationUnit> units,
                         List<OrganisationUnit> relativeUnits, List<OrganisationUnitGroup> organisationUnitGroups,
                         DataElementCategoryCombo categoryCombo, boolean doIndicators,
@@ -360,7 +365,6 @@
                         I18nFormat i18nFormat, String reportingPeriodName )
     {
         this.name = name;
-        this.regression = regression;
         this.dataElements = dataElements;
         this.indicators = indicators;
         this.dataSets = dataSets;
@@ -877,6 +881,16 @@
         this.regression = regression;
     }
 
+    public boolean isCumulative()
+    {
+        return cumulative;
+    }
+
+    public void setCumulative( boolean cumulative )
+    {
+        this.cumulative = cumulative;
+    }
+
     @XmlElementWrapper( name = "dataElements" )
     @XmlElement( name = "dataElement" )
     @XmlJavaTypeAdapter( DataElementXmlAdapter.class )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2012-02-17 13:25:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2012-02-20 10:20:01 +0000
@@ -391,6 +391,7 @@
         executeSql( "update reporttable set last6bimonths = false where last6bimonths is null" );
         executeSql( "update reporttable set last4quarters = false where last4quarters is null" );
         executeSql( "update reporttable set last2sixmonths = false where last2sixmonths is null" );
+        executeSql( "update reporttable set cumulative = false where cumulative is null" );
 
         executeSql( "update chart set reportingmonth = false where reportingmonth is null" );
         executeSql( "update chart set reportingbimonth = false where reportingbimonth is null" );

=== 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	2012-02-13 17:25:28 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2012-02-20 10:20:01 +0000
@@ -347,10 +347,10 @@
      */
     private Grid getGrid( ReportTable reportTable )
     {
-        String subtitle = StringUtils.trimToEmpty( reportTable.getParentOrganisationUnitName() ) + SPACE
+        final String subtitle = StringUtils.trimToEmpty( reportTable.getParentOrganisationUnitName() ) + SPACE
             + StringUtils.trimToEmpty( reportTable.getReportingPeriodName() );
 
-        Grid grid = new ListGrid().setTitle( reportTable.getName() ).setSubtitle( subtitle );
+        final Grid grid = new ListGrid().setTitle( reportTable.getName() ).setSubtitle( subtitle );
 
         final Map<String, Double> map = reportTableManager.getAggregatedValueMap( reportTable );
 
@@ -380,6 +380,9 @@
         grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME ),
             ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME, String.class.getName(), true, true ) );
 
+        final int startColumnIndex = grid.getHeaders().size();
+        final int numberOfColumns = reportTable.getColumns().size();
+        
         for ( List<NameableObject> column : reportTable.getColumns() )
         {
             grid.addHeader( new GridHeader( getPrettyColumnName( column ), getColumnName( column ), Double.class
@@ -453,9 +456,14 @@
             }
         }
 
-        if ( reportTable.isRegression() && !reportTable.doTotal() )
-        {
-            addRegressionToGrid( grid, reportTable.getColumns().size() );
+        if ( reportTable.isRegression() )
+        {
+            addRegressionToGrid( grid, startColumnIndex, numberOfColumns );
+        }
+        
+        if ( reportTable.isCumulative() )
+        {
+            addCumulativesToGrid( grid, startColumnIndex, numberOfColumns );
         }
 
         // ---------------------------------------------------------------------
@@ -478,13 +486,12 @@
     /**
      * Adds columns with regression values to the given grid.
      *
-     * @param grid            the grid.
-     * @param numberOfColumns the number of columns.
+     * @param grid the grid.
+     * @param startColumnIndex the index of the first data column.
+     * @param numberOfColumns the number of data columns.
      */
-    private Grid addRegressionToGrid( Grid grid, int numberOfColumns )
+    private Grid addRegressionToGrid( Grid grid, int startColumnIndex, int numberOfColumns )
     {
-        int startColumnIndex = grid.getWidth() - numberOfColumns;
-
         for ( int i = 0; i < numberOfColumns; i++ )
         {
             int columnIndex = i + startColumnIndex;
@@ -494,6 +501,25 @@
 
         return grid;
     }
+    
+    /**
+     * Adds columns with cumulative values to the given grid.
+     * 
+     * @param grid the grid.
+     * @param startColumnIndex the index of the first data column.
+     * @param numberOfColumns the number of data columns.
+     */
+    private Grid addCumulativesToGrid( Grid grid, int startColumnIndex, int numberOfColumns )
+    {
+        for ( int i = 0; i < numberOfColumns; i++ )
+        {
+            int columnIndex = i + startColumnIndex;
+            
+            grid.addCumulativeColumn( columnIndex, true );
+        }
+        
+        return grid;
+    }
 
     /**
      * Checks whether the given List of IdentifiableObjects contains an object

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2011-12-23 10:50:09 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2012-02-20 10:20:01 +0000
@@ -16,6 +16,8 @@
     &identifiableProperties;
 
     <property name="regression" />
+	
+	<property name="cumulative" />
 
     <list name="dataElements" table="reporttable_dataelements">
       <cache usage="read-write" />

=== 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-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java	2012-02-20 10:20:01 +0000
@@ -387,7 +387,7 @@
     @Test
     public void testGetOrgUnitIndicatorReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
+        ReportTable reportTable = new ReportTable( "Prescriptions",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(),
             groups, null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -411,7 +411,7 @@
     @Test
     public void testGetIndicatorOrgUnitReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(), 
             groups, null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -437,7 +437,7 @@
     @Test
     public void testGetIndicatorOrgUnitReportTableC()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(), 
             groups, null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -461,7 +461,7 @@
     @Test
     public void testGetDataElementOrgUnitReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
+        ReportTable reportTable = new ReportTable( "Prescriptions",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(),
             groups, null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -485,7 +485,7 @@
     @Test
     public void testGetDataElementOrgUnitReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(), 
             groups, null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -511,7 +511,7 @@
     @Test
     public void testGetDataElementOrgUnitReportTableC()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), new ArrayList<OrganisationUnit>(), 
             groups, null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -535,7 +535,7 @@
     @Test
     public void testGetIndicatorReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
+        ReportTable reportTable = new ReportTable( "Prescriptions",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -557,7 +557,7 @@
     @Test
     public void testGetIndicatorReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -581,7 +581,7 @@
     @Test
     public void testGetIndicatorReportTableC()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -603,7 +603,7 @@
     @Test
     public void testGetDataElementReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
+        ReportTable reportTable = new ReportTable( "Prescriptions",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -625,7 +625,7 @@
     @Test
     public void testGetDataElementReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -649,7 +649,7 @@
     @Test
     public void testGetDataElementReportTableC()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -671,7 +671,7 @@
     @Test
     public void testGetDataSetReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
+        ReportTable reportTable = new ReportTable( "Prescriptions",
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -693,7 +693,7 @@
     @Test
     public void testGetDataSetReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -717,7 +717,7 @@
     @Test
     public void testGetDataSetReportTableC()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -752,7 +752,7 @@
         
         batchHandler.flush();
         
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
+        ReportTable reportTable = new ReportTable( "Prescriptions",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
             new ArrayList<OrganisationUnitGroup>(), categoryComboA, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -795,7 +795,7 @@
         
         batchHandler.flush();
         
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), categoryComboA, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -840,7 +840,7 @@
         
         batchHandler.flush();
         
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), categoryComboA, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -883,7 +883,7 @@
         
         batchHandler.flush();
         
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), categoryComboA, false, false, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -927,7 +927,7 @@
     @Test
     public void testGetMultiReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
+        ReportTable reportTable = new ReportTable( "Prescriptions",
             dataElements, indicators, dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -965,7 +965,7 @@
     @Test
     public void testGetMultiReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, indicators, dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -1013,7 +1013,7 @@
     @Test
     public void testGetMultiReportTableC()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, indicators, dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -1051,7 +1051,7 @@
     @Test
     public void testGetIndicatorReportTableColumnsOnly()
     {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
+        ReportTable reportTable = new ReportTable( "Prescriptions",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
             new ArrayList<OrganisationUnitGroup>(), null, true, true, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -1072,7 +1072,7 @@
     @Test
     public void testGetIndicatorReportTableRowsOnly()
     {
-        ReportTable reportTable = new ReportTable( "Prescriptions", false,
+        ReportTable reportTable = new ReportTable( "Prescriptions",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
             new ArrayList<OrganisationUnitGroup>(), null, false, false, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
@@ -1093,7 +1093,7 @@
     @Test
     public void testGetIndicatorReportTableTopLimit()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
         reportTable.setTopLimit( 2 );
@@ -1114,7 +1114,7 @@
     @Test
     public void testGetIndicatorReportTableSortOrder()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
         reportTable.setSortOrder( ReportTable.DESC );
@@ -1139,10 +1139,12 @@
     @Test
     public void testGetDataElementReportTableRegression()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", true, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
-
+        
+        reportTable.setRegression( true );
+        
         int id = reportTableService.saveReportTable( reportTable );
 
         Grid grid = reportTableService.getReportTableGrid( id, i18nFormat, date, 0 );

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java	2012-02-20 10:20:01 +0000
@@ -181,13 +181,13 @@
     @Test
     public void testSaveGetReportTable()
     {
-        ReportTable reportTableA = new ReportTable( "Immunization", false,
+        ReportTable reportTableA = new ReportTable( "Immunization",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
-        ReportTable reportTableB = new ReportTable( "Prescriptions", false,
+        ReportTable reportTableB = new ReportTable( "Prescriptions",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
-        ReportTable reportTableC = new ReportTable( "Assualt", false,
+        ReportTable reportTableC = new ReportTable( "Assualt",
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
         
@@ -233,10 +233,10 @@
     @Test
     public void testDeleteReportTable()
     {
-        ReportTable reportTableA = new ReportTable( "Immunization", false,
+        ReportTable reportTableA = new ReportTable( "Immunization",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
-        ReportTable reportTableB = new ReportTable( "Prescriptions", false,
+        ReportTable reportTableB = new ReportTable( "Prescriptions",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
         
@@ -260,10 +260,10 @@
     @Test
     public void testGetAllReportTables()
     {
-        ReportTable reportTableA = new ReportTable( "Immunization", false,
+        ReportTable reportTableA = new ReportTable( "Immunization",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
-        ReportTable reportTableB = new ReportTable( "Prescriptions", false,
+        ReportTable reportTableB = new ReportTable( "Prescriptions",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
         
@@ -279,10 +279,10 @@
     @Test
     public void testGetReportTableByName()
     {
-        ReportTable reportTableA = new ReportTable( "Immunization", false,
+        ReportTable reportTableA = new ReportTable( "Immunization",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
-        ReportTable reportTableB = new ReportTable( "Prescriptions", false,
+        ReportTable reportTableB = new ReportTable( "Prescriptions",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
         

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java	2012-02-20 10:20:01 +0000
@@ -356,7 +356,7 @@
     @Test
     public void testOrganisationUnitGroupReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), relativeUnits, 
             groups, null, true, true, false, relatives, null, i18nFormat, "january_2000" );
 
@@ -414,7 +414,7 @@
     @Test
     public void testOrganisationUnitGroupReportTableB()
     {        
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), relativeUnits, 
             groups, null, true, false, true, relatives, null, i18nFormat, "january_2000" );
 
@@ -470,7 +470,7 @@
     @Test
     public void testIndicatorReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
 
@@ -528,7 +528,7 @@
     @Test
     public void testIndicatorReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
 
@@ -586,7 +586,7 @@
     @Test
     public void testIndicatorReportTableC()
     {        
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, false, true, relatives, null, i18nFormat, "january_2000" );
 
@@ -642,7 +642,7 @@
     @Test
     public void testIndicatorReportTableColumnsOnly()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, true, true, relatives, null, i18nFormat, "january_2000" );
 
@@ -672,7 +672,7 @@
     @Test
     public void testIndicatorReportTableRowsOnly()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, false, relatives, null, i18nFormat, "january_2000" );
 
@@ -702,7 +702,7 @@
     @Test
     public void testDataElementReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
 
@@ -744,7 +744,7 @@
     @Test
     public void testDataElementReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
 
@@ -786,7 +786,7 @@
     @Test
     public void testDataElementReportTableC()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, false, true, relatives, null, i18nFormat, "january_2000" );
 
@@ -828,7 +828,7 @@
     @Test
     public void testCategoryComboReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), categoryCombo, true, true, false, relatives, null, i18nFormat, "january_2000" );
         
@@ -889,7 +889,7 @@
     @Test
     public void testCategoryComboReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), categoryCombo, false, false, true, relatives, null, i18nFormat, "january_2000" );
 
@@ -946,7 +946,7 @@
     @Test
     public void testCategoryComboReportTableC()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), categoryCombo, true, false, true, relatives, null, i18nFormat, "january_2000" );
 
@@ -1001,7 +1001,7 @@
     @Test
     public void testDataSetReportTableA()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
 
@@ -1043,7 +1043,7 @@
     @Test
     public void testDataSetReportTableB()
     {
-        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
 
@@ -1085,7 +1085,7 @@
     @Test
     public void testDataSetReportTableC()
     {        
-        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+        ReportTable reportTable = new ReportTable( "Embezzlement",
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
             new ArrayList<OrganisationUnitGroup>(), null, true, false, true, relatives, null, i18nFormat, "january_2000" );
 

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/ListGrid.java	2012-02-20 10:20:01 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
 import org.hisp.dhis.common.adapter.GridRowsXmlAdapter;
+import org.hisp.dhis.system.util.MathUtils;
 
 import javax.xml.bind.annotation.*;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -52,6 +53,7 @@
     implements Grid
 {
     private static final String REGRESSION_SUFFIX = "_regression";
+    private static final String CUMULATIVE_SUFFIX = "_cumulative";
 
     /**
      * The title of the grid.
@@ -386,7 +388,7 @@
 
         for ( Object value : column )
         {
-            if ( Double.parseDouble( String.valueOf( value ) ) != 0.0 ) // 0 omitted from regression
+            if ( !MathUtils.isEqual( Double.parseDouble( String.valueOf( value ) ), 0d ) ) // 0 omitted from regression
             {
                 regression.addData( index++, Double.parseDouble( String.valueOf( value ) ) );
             }
@@ -425,7 +427,44 @@
 
         return this;
     }
-
+    
+    public Grid addCumulativeColumn( int columnIndex, boolean addHeader )
+    {
+        verifyGridState();
+
+        List<Object> column = getColumn( columnIndex );
+
+        List<Object> cumulativeColumn = new ArrayList<Object>();
+        
+        double sum = 0d;
+        
+        for ( Object value : column )
+        {
+            double number = value != null ? Double.parseDouble( String.valueOf( value ) ) : 0d;
+            
+            sum += number;
+            
+            cumulativeColumn.add( sum );
+        }
+        
+        addColumn( cumulativeColumn );
+        
+        if ( addHeader && columnIndex < headers.size() )
+        {
+            GridHeader header = headers.get( columnIndex );
+
+            if ( header != null )
+            {
+                GridHeader regressionHeader = new GridHeader( header.getName() + CUMULATIVE_SUFFIX,
+                    header.getColumn() + CUMULATIVE_SUFFIX, header.getType(), header.isHidden(), header.isMeta() );
+
+                addHeader( regressionHeader );
+            }
+        }
+        
+        return this;
+    }
+    
     // -------------------------------------------------------------------------
     // JRDataSource implementation
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/grid/GridTest.java	2012-02-20 10:20:01 +0000
@@ -426,7 +426,7 @@
     @Test
     public void testAddRegressionColumn()
     {
-        grid = new ListGrid();        
+        grid = new ListGrid();
 
         grid.addRow();        
         grid.addValue( 10.0 );
@@ -447,6 +447,31 @@
         assertTrue( column.contains( 41.0 ) );
         assertTrue( column.contains( 53.0 ) );
     }
+    
+    @Test
+    public void testAddCumulativeColumn()
+    {
+        grid = new ListGrid();
+
+        grid.addRow();        
+        grid.addValue( 10.0 );
+        grid.addRow();        
+        grid.addValue( 50.0 );
+        grid.addRow();        
+        grid.addValue( 20.0 );
+        grid.addRow();        
+        grid.addValue( 60.0 );
+        
+        grid.addCumulativeColumn( 0, true );
+
+        List<Object> column = grid.getColumn( 1 );
+        
+        assertTrue( column.size() == 4 );
+        assertTrue( column.contains( 10.0 ) );
+        assertTrue( column.contains( 60.0 ) );
+        assertTrue( column.contains( 80.0 ) );
+        assertTrue( column.contains( 140.0 ) );
+    }
 
     @Test
     public void testJRDataSource() throws Exception

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2012-02-20 10:20:01 +0000
@@ -160,6 +160,13 @@
         this.regression = regression;
     }    
     
+    private boolean cumulative;
+    
+    public void setCumulative( boolean cumulative )
+    {
+        this.cumulative = cumulative;
+    }
+
     private Integer categoryComboId;
 
     public void setCategoryComboId( Integer categoryComboId )
@@ -429,20 +436,15 @@
         
         if ( tableId == null )
         {
-            reportTable = new ReportTable( tableName, regression,
+            reportTable = new ReportTable( tableName,
                 dataElements, indicators, dataSets, periods, null, units, null, organisationUnitGroups,
                 categoryCombo, doIndicators, doPeriods, doOrganisationUnits, relatives, reportParams, null, null );
-            
-            reportTable.setSortOrder( sortOrder );
-            reportTable.setTopLimit( topLimit );
         }
         else
         {
             reportTable = reportTableService.getReportTable( tableId );
             
             reportTable.setName( tableName );
-            reportTable.setSortOrder( sortOrder );
-            reportTable.setTopLimit( topLimit );
             reportTable.setRegression( regression );
             reportTable.setDataElements( dataElements );
             reportTable.setIndicators( indicators );
@@ -457,6 +459,11 @@
             reportTable.setRelatives( relatives );
             reportTable.setReportParams( reportParams );
         }
+
+        reportTable.setRegression( regression );
+        reportTable.setCumulative( cumulative );
+        reportTable.setSortOrder( sortOrder );
+        reportTable.setTopLimit( topLimit );
         
         return reportTable;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2012-02-12 19:23:31 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties	2012-02-20 10:20:01 +0000
@@ -406,4 +406,5 @@
 start_date = Start date
 end_date = End date
 start_export = Start export
-period_types = Period types
\ No newline at end of file
+period_types = Period types
+include_cumulative = Include cumulative
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2012-01-25 19:22:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm	2012-02-20 10:20:01 +0000
@@ -76,7 +76,12 @@
 		<td></td>
 		<td></td>
 	</tr>
-	
+	<tr>
+		<td><label for="cumulative">$i18n.getString( "include_cumulative" )</label></td>
+		<td><input type="checkbox" onclick="toggleCumulative()" id="cumulative" name="cumulative" value="true"#if( $reportTable.isCumulative() ) checked#end></td>
+		<td></td>
+		<td></td>
+	</tr>
 	<tr>
 		<td colspan="4" style="height:15px"></td>
 	</tr>