← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5560: WIP organisation unit groups in report table

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 5560 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-22 21:48:03 +0100
message:
  WIP organisation unit groups in report table
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java
  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/jdbc/JDBCReportTableManager.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-hibernate/src/main/resources/ehcache.xml
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.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/organisationunit/OrganisationUnitGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java	2011-12-13 16:47:13 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java	2011-12-22 20:12:15 +0000
@@ -30,6 +30,7 @@
 import org.codehaus.jackson.annotate.JsonProperty;
 import org.codehaus.jackson.map.annotate.JsonSerialize;
 import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.BaseNameableObject;
 import org.hisp.dhis.common.Dxf2Namespace;
 import org.hisp.dhis.common.adapter.OrganisationUnitGroupSetXmlAdapter;
 import org.hisp.dhis.common.adapter.OrganisationUnitXmlAdapter;
@@ -45,7 +46,7 @@
 @XmlRootElement( name = "organisationUnitGroup", namespace = Dxf2Namespace.NAMESPACE )
 @XmlAccessorType( value = XmlAccessType.NONE )
 public class OrganisationUnitGroup 
-    extends BaseIdentifiableObject
+    extends BaseNameableObject
 {
     /**
      * Determines if a de-serialized file is compatible with this class.
@@ -73,6 +74,18 @@
     // Logic
     // -------------------------------------------------------------------------
 
+    @Override
+    public String getShortName()
+    {
+        return name;
+    }
+    
+    @Override
+    public String getCode()
+    {
+        return name;
+    }
+    
     public void addOrganisationUnit( OrganisationUnit organisationUnit )
     {
         members.add( organisationUnit );

=== 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-22 19:41:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2011-12-22 20:12:15 +0000
@@ -54,6 +54,7 @@
 import org.hisp.dhis.common.adapter.DataElementXmlAdapter;
 import org.hisp.dhis.common.adapter.DataSetXmlAdapter;
 import org.hisp.dhis.common.adapter.IndicatorXmlAdapter;
+import org.hisp.dhis.common.adapter.OrganisationUnitGroupXmlAdapter;
 import org.hisp.dhis.common.adapter.OrganisationUnitXmlAdapter;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
@@ -63,6 +64,7 @@
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.RelativePeriods;
@@ -98,6 +100,9 @@
     public static final String ORGANISATIONUNIT_ID = "organisationunitid";
     public static final String ORGANISATIONUNIT_NAME = "organisationunitname";
     public static final String ORGANISATIONUNIT_CODE = "organisationunitcode";
+    public static final String ORGANISATIONUNITGROUP_ID = "organisationunitgroupid";
+    public static final String ORGANISATIONUNITGROUP_NAME = "organisationunitgroupname";
+    public static final String ORGANISATIONUNITGROUP_CODE = "organisationunitgroupcode";
     public static final String REPORTING_MONTH_COLUMN_NAME = "reporting_month_name";
     public static final String PARAM_ORGANISATIONUNIT_COLUMN_NAME = "param_organisationunit_name";
     public static final String ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME = "organisation_unit_is_parent";
@@ -126,6 +131,9 @@
             put( ORGANISATIONUNIT_ID, "Organisation unit ID" );
             put( ORGANISATIONUNIT_NAME, "Organisation unit" );
             put( ORGANISATIONUNIT_CODE, "Organisation unit code" );
+            put( ORGANISATIONUNITGROUP_ID, "Organisation unit group ID" );
+            put( ORGANISATIONUNITGROUP_NAME, "Organisation unit group" );
+            put( ORGANISATIONUNITGROUP_CODE, "Organisation unit group code" );
             put( REPORTING_MONTH_COLUMN_NAME, "Reporting month" );
             put( PARAM_ORGANISATIONUNIT_COLUMN_NAME, "Organisation unit parameter" );
             put( ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME, "Organisation unit is parent" );
@@ -142,6 +150,7 @@
             put( DataSet.class, DATASET_ID );
             put( Period.class, PERIOD_ID );
             put( OrganisationUnit.class, ORGANISATIONUNIT_ID );
+            put( OrganisationUnitGroup.class, ORGANISATIONUNITGROUP_ID );
         }
     };
 
@@ -188,6 +197,11 @@
     private List<OrganisationUnit> units = new ArrayList<OrganisationUnit>();
 
     /**
+     * The list of OrganisationUnitGroups the ReportTable contains.
+     */
+    private List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
+    
+    /**
      * The DataElementCategoryCombo for the ReportTable.
      */
     private DataElementCategoryCombo categoryCombo;
@@ -340,7 +354,8 @@
      */
     public ReportTable( String name, boolean regression, List<DataElement> dataElements, List<Indicator> indicators,
                         List<DataSet> dataSets, List<Period> periods, List<Period> relativePeriods, List<OrganisationUnit> units,
-                        List<OrganisationUnit> relativeUnits, DataElementCategoryCombo categoryCombo, boolean doIndicators,
+                        List<OrganisationUnit> relativeUnits, List<OrganisationUnitGroup> organisationUnitGroups,
+                        DataElementCategoryCombo categoryCombo, boolean doIndicators,
                         boolean doPeriods, boolean doUnits, RelativePeriods relatives, ReportParams reportParams,
                         I18nFormat i18nFormat, String reportingPeriodName )
     {
@@ -353,6 +368,7 @@
         this.relativePeriods = relativePeriods;
         this.units = units;
         this.relativeUnits = relativeUnits;
+        this.organisationUnitGroups = organisationUnitGroups;
         this.categoryCombo = categoryCombo;
         this.doIndicators = doIndicators;
         this.doPeriods = doPeriods;
@@ -401,10 +417,17 @@
 
         Collections.sort( allPeriods, new AscendingPeriodComparator() );
         setNames( allPeriods ); // Set names on periods
-
-        allUnits.addAll( units );
-        allUnits.addAll( relativeUnits );
-        allUnits = removeDuplicates( allUnits );
+        
+        if ( isOrganisationUnitGroupBased() )
+        {
+            allUnits.addAll( organisationUnitGroups );
+        }
+        else
+        {
+            allUnits.addAll( units );
+            allUnits.addAll( relativeUnits );
+            allUnits = removeDuplicates( allUnits );
+        }
 
         columns = new CombinationGenerator<NameableObject>( getArrays( true ) ).getCombinations();
         rows = new CombinationGenerator<NameableObject>( getArrays( false ) ).getCombinations();
@@ -665,6 +688,15 @@
     {
         return parentOrganisationUnit != null ? parentOrganisationUnit.getName() : EMPTY;
     }
+    
+    /**
+     * Indicates whether this report table is based on organisation unit groups
+     * or the organisation unit hierarchy.
+     */
+    public boolean isOrganisationUnitGroupBased()
+    {
+        return organisationUnitGroups != null && organisationUnitGroups.size() > 0;
+    }
 
     // -------------------------------------------------------------------------
     // Supportive methods
@@ -912,6 +944,21 @@
         this.units = units;
     }
 
+    @XmlElementWrapper( name = "organisationUnitGroups" )
+    @XmlElement( name = "organisationUnitGroup" )
+    @XmlJavaTypeAdapter( OrganisationUnitGroupXmlAdapter.class )
+    @JsonProperty
+    @JsonSerialize( contentAs = BaseNameableObject.class )
+    public List<OrganisationUnitGroup> getOrganisationUnitGroups()
+    {
+        return organisationUnitGroups;
+    }
+
+    public void setOrganisationUnitGroups( List<OrganisationUnitGroup> organisationUnitGroups )
+    {
+        this.organisationUnitGroups = organisationUnitGroups;
+    }
+
     @XmlElement
     @XmlJavaTypeAdapter( CategoryComboXmlAdapter.class )
     @JsonProperty

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2011-12-22 17:00:08 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/jdbc/JDBCReportTableManager.java	2011-12-22 20:05:07 +0000
@@ -35,12 +35,14 @@
 import org.amplecode.quick.StatementManager;
 import org.hisp.dhis.aggregation.AggregationService;
 import org.hisp.dhis.chart.Chart;
+import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.system.util.ConversionUtils;
@@ -86,6 +88,71 @@
 
     public Map<String, Double> getAggregatedValueMap( ReportTable reportTable )
     {
+        if ( reportTable.isOrganisationUnitGroupBased() )
+        {
+            return getAggregatedValueMapOrgUnitGroups( reportTable );
+        }
+        else
+        {
+            return getAggregatedValueMapOrgUnitHierarchy( reportTable );
+        }
+    }
+    
+    public Map<String, Double> getAggregatedValueMapOrgUnitGroups( ReportTable reportTable )
+    {
+        Map<String, Double> map = new HashMap<String, Double>();
+        
+        String dataElementIds = TextUtils.getCommaDelimitedString( 
+            ConversionUtils.getIdentifiers( DataElement.class, reportTable.getDataElements() ) );
+        String indicatorIds = TextUtils.getCommaDelimitedString( 
+            ConversionUtils.getIdentifiers( Indicator.class, reportTable.getIndicators() ) );
+        String periodIds = TextUtils.getCommaDelimitedString( 
+            ConversionUtils.getIdentifiers( Period.class, reportTable.getAllPeriods() ) );
+        String unitIds = TextUtils.getCommaDelimitedString( 
+            ConversionUtils.getIdentifiers( NameableObject.class, reportTable.getAllUnits() ) );
+
+        if ( reportTable.hasDataElements() )
+        {
+            final String sql = "SELECT dataelementid, periodid, organisationunitgroupid, SUM(value) FROM aggregatedorgunitdatavalue " + 
+                "WHERE dataelementid IN (" + dataElementIds + ") AND periodid IN (" + periodIds + ") AND organisationunitgroupid IN (" + unitIds + ") " + 
+                "AND organisationunitid = " + reportTable.getParentOrganisationUnit().getId() + " " +
+                "GROUP BY dataelementid, periodid, organisationunitgroupid"; // Sum of category option combos
+
+            SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
+            
+            while ( rowSet.next() )
+            {
+                String id = getIdentifier( getIdentifier( DataElement.class, rowSet.getInt( 1 ) ),
+                    getIdentifier( Period.class, rowSet.getInt( 2 ) ),
+                    getIdentifier( OrganisationUnitGroup.class, rowSet.getInt( 3 ) ) );
+
+                map.put( id, rowSet.getDouble( 4 ) );
+            }
+        }
+
+        if ( reportTable.hasIndicators() )
+        {
+            final String sql = "SELECT indicatorid, periodid, organisationunitgroupid, value FROM aggregatedorgunitindicatorvalue " + 
+                "WHERE indicatorid IN (" + indicatorIds + ") AND periodid IN (" + periodIds + ") AND organisationunitgroupid IN (" + unitIds + ") " +
+                "AND organisationunitid = " + reportTable.getParentOrganisationUnit().getId();
+
+            SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
+            
+            while ( rowSet.next() )
+            {
+                String id = getIdentifier( getIdentifier( Indicator.class, rowSet.getInt( 1 ) ),
+                    getIdentifier( Period.class, rowSet.getInt( 2 ) ),
+                    getIdentifier( OrganisationUnitGroup.class, rowSet.getInt( 3 ) ) );
+
+                map.put( id, rowSet.getDouble( 4 ) );
+            }
+        }
+
+        return map;
+    }
+    
+    public Map<String, Double> getAggregatedValueMapOrgUnitHierarchy( ReportTable reportTable )
+    {
         Map<String, Double> map = new HashMap<String, Double>();
 
         String dataElementIds = TextUtils.getCommaDelimitedString( 
@@ -97,7 +164,7 @@
         String periodIds = TextUtils.getCommaDelimitedString( 
             ConversionUtils.getIdentifiers( Period.class, reportTable.getAllPeriods() ) );
         String unitIds = TextUtils.getCommaDelimitedString( 
-            ConversionUtils.getIdentifiers( OrganisationUnit.class, reportTable.getAllUnits() ) );
+            ConversionUtils.getIdentifiers( NameableObject.class, reportTable.getAllUnits() ) );
 
         if ( reportTable.hasDataElements() )
         {

=== 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-22 17:28:35 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2011-12-22 19:59:19 +0000
@@ -55,6 +55,13 @@
       <many-to-many column="organisationunitid" class="org.hisp.dhis.organisationunit.OrganisationUnit" foreign-key="fk_reporttable_organisationunits_organisationunitid" />
     </list>
 
+    <list name="organisationUnitGroups" table="reporttable_organisationunitgroups">
+      <cache usage="read-write" />
+      <key column="reporttableid" foreign-key="fk_reporttable_organisationunitgroups_reporttableid" />
+      <list-index column="sort_order" base="0" />
+      <many-to-many column="orgunitgroupid" class="org.hisp.dhis.organisationunit.OrganisationUnitGroup" foreign-key="fk_reporttable_organisationunitgroups_orgunitgroupid" />
+    </list>
+
     <property name="doIndicators" />
 
     <property name="doPeriods" />

=== 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-22 15:07:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableGridTest.java	2011-12-22 19:59:19 +0000
@@ -62,6 +62,7 @@
 import org.hisp.dhis.jdbc.batchhandler.DataSetCompletenessResultBatchHandler;
 import org.hisp.dhis.mock.MockI18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
@@ -337,7 +338,7 @@
     {
         ReportTable reportTable = new ReportTable( "Prescriptions", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -359,7 +360,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -383,7 +384,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -405,7 +406,7 @@
     {
         ReportTable reportTable = new ReportTable( "Prescriptions", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -427,7 +428,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -451,7 +452,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -473,7 +474,7 @@
     {
         ReportTable reportTable = new ReportTable( "Prescriptions", false,
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -495,7 +496,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -519,7 +520,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -554,7 +555,7 @@
         
         ReportTable reportTable = new ReportTable( "Prescriptions", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            categoryComboA, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), categoryComboA, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -597,7 +598,7 @@
         
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            categoryComboA, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), categoryComboA, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -642,7 +643,7 @@
         
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            categoryComboA, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), categoryComboA, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -685,7 +686,7 @@
         
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            categoryComboA, false, false, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), categoryComboA, false, false, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -729,7 +730,7 @@
     {
         ReportTable reportTable = new ReportTable( "Prescriptions", false,
             dataElements, indicators, dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -767,7 +768,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             dataElements, indicators, dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -815,7 +816,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             dataElements, indicators, dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -853,7 +854,7 @@
     {
         ReportTable reportTable = new ReportTable( "Prescriptions", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, true, true, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -874,7 +875,7 @@
     {
         ReportTable reportTable = new ReportTable( "Prescriptions", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(),
-            null, false, false, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, false, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 
@@ -895,7 +896,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
         reportTable.setTopLimit( 2 );
         
         int id = reportTableService.saveReportTable( reportTable );
@@ -916,7 +917,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
         reportTable.setSortOrder( ReportTable.DESC );
         
         int id = reportTableService.saveReportTable( reportTable );
@@ -941,7 +942,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", true, 
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, false, true, new RelativePeriods(), null, i18nFormat, "january_2000" );
 
         int id = reportTableService.saveReportTable( reportTable );
 

=== 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-02-17 15:37:19 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableStoreTest.java	2011-12-22 19:59:19 +0000
@@ -48,6 +48,7 @@
 import org.hisp.dhis.indicator.IndicatorType;
 import org.hisp.dhis.mock.MockI18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
@@ -182,13 +183,13 @@
     {
         ReportTable reportTableA = new ReportTable( "Immunization", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
         ReportTable reportTableB = new ReportTable( "Prescriptions", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
         ReportTable reportTableC = new ReportTable( "Assualt", false,
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
         
         int idA = reportTableStore.save( reportTableA );
         int idB = reportTableStore.save( reportTableB );
@@ -234,10 +235,10 @@
     {
         ReportTable reportTableA = new ReportTable( "Immunization", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
         ReportTable reportTableB = new ReportTable( "Prescriptions", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
         
         int idA = reportTableStore.save( reportTableA );
         int idB = reportTableStore.save( reportTableB );
@@ -261,10 +262,10 @@
     {
         ReportTable reportTableA = new ReportTable( "Immunization", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
         ReportTable reportTableB = new ReportTable( "Prescriptions", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
         
         reportTableStore.save( reportTableA );
         reportTableStore.save( reportTableB );
@@ -280,10 +281,10 @@
     {
         ReportTable reportTableA = new ReportTable( "Immunization", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );        
         ReportTable reportTableB = new ReportTable( "Prescriptions", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
         
         reportTableStore.save( reportTableA );
         reportTableStore.save( reportTableB );

=== 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-04-01 11:00:44 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java	2011-12-22 20:46:37 +0000
@@ -33,6 +33,8 @@
 import static junit.framework.Assert.assertTrue;
 import static org.hisp.dhis.reporttable.ReportTable.DATAELEMENT_ID;
 import static org.hisp.dhis.reporttable.ReportTable.INDICATOR_ID;
+import static org.hisp.dhis.reporttable.ReportTable.PERIOD_ID;
+import static org.hisp.dhis.reporttable.ReportTable.ORGANISATIONUNITGROUP_ID;
 import static org.hisp.dhis.reporttable.ReportTable.getColumnName;
 import static org.hisp.dhis.reporttable.ReportTable.getIdentifier;
 
@@ -53,6 +55,7 @@
 import org.hisp.dhis.indicator.IndicatorType;
 import org.hisp.dhis.mock.MockI18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
@@ -73,6 +76,8 @@
     private List<Period> periods;
     private List<Period> relativePeriods;
     private List<OrganisationUnit> units;
+    private List<OrganisationUnit> relativeUnits;
+    private List<OrganisationUnitGroup> groups;
 
     private PeriodType montlyPeriodType;
 
@@ -100,6 +105,9 @@
     private OrganisationUnit unitA;
     private OrganisationUnit unitB;
     
+    private OrganisationUnitGroup groupA;
+    private OrganisationUnitGroup groupB;
+    
     private RelativePeriods relatives;
 
     private I18nFormat i18nFormat;
@@ -119,6 +127,8 @@
         periods = new ArrayList<Period>();
         relativePeriods = new ArrayList<Period>();
         units = new ArrayList<OrganisationUnit>();
+        relativeUnits = new ArrayList<OrganisationUnit>();
+        groups = new ArrayList<OrganisationUnitGroup>();
         
         montlyPeriodType = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME );
 
@@ -193,6 +203,16 @@
         
         units.add( unitA );
         units.add( unitB );
+        relativeUnits.add( unitA );
+        
+        groupA = createOrganisationUnitGroup( 'A' );
+        groupB = createOrganisationUnitGroup( 'B' );
+        
+        groupA.setId( 'A' );
+        groupB.setId( 'B' );
+        
+        groups.add( groupA );
+        groups.add( groupB );
         
         relatives = new RelativePeriods();
         
@@ -232,8 +252,12 @@
         List<NameableObject> b1 = getList( periodA );
         List<NameableObject> b2 = getList( indicatorA, unitA );
         
+        List<NameableObject> c1 = getList( groupA, periodA );
+        List<NameableObject> c2 = getList( indicatorA );
+        
         assertNotNull( getIdentifier( a1, a2 ) );
         assertNotNull( getIdentifier( b1, b2 ) );
+        assertNotNull( getIdentifier( c1, c2 ) );
         assertEquals( getIdentifier( a1, a2 ), getIdentifier( b1, b2 ) );
         
         String identifier = getIdentifier( getIdentifier( unitA.getClass(), unitA.getId() ), 
@@ -245,6 +269,11 @@
             getIdentifier( indicatorA.getClass(), indicatorA.getId() ), getIdentifier( unitA.getClass(), unitA.getId() ) );
         
         assertEquals( getIdentifier( b1, b2 ), identifier );
+        
+        identifier = getIdentifier( getIdentifier( groupA.getClass(), groupA.getId() ),
+            getIdentifier( periodA.getClass(), periodA.getId() ), getIdentifier( indicatorA.getClass(), indicatorA.getId() ) );
+        
+        assertEquals( getIdentifier( c1, c2 ), identifier );
     }
 
     @Test
@@ -262,6 +291,12 @@
         assertEquals( INDICATOR_ID + 2, b1 );
         assertEquals( DATAELEMENT_ID + 1, b2 );
         
+        String c1 = getIdentifier( OrganisationUnitGroup.class, 1 );
+        String c2 = getIdentifier( Period.class, 2 );
+        
+        assertEquals( getIdentifier( ORGANISATIONUNITGROUP_ID + 1 ), c1 );
+        assertEquals( getIdentifier( PERIOD_ID + 2 ), c2 );
+        
         assertFalse( getIdentifier( a1, a2 ).equals( getIdentifier( b1, b2 ) ) );        
     }
     
@@ -271,7 +306,7 @@
         List<NameableObject> a1 = getList( dataElementA, periodA, categoryOptionComboA );
         List<NameableObject> a2 = getList( unitA );
         
-        String b1 = getIdentifier( DataElement.class,'A' );
+        String b1 = getIdentifier( DataElement.class, 'A' );
         String b2 = getIdentifier( Period.class, 'A' );
         String b3 = getIdentifier( DataElementCategoryOptionCombo.class, 'A' );
         String b4 = getIdentifier( OrganisationUnit.class, 'A' );
@@ -281,6 +316,23 @@
         
         assertEquals( a, b );
     }
+
+    @Test
+    public void testGetIdentifierD()
+    {
+        List<NameableObject> a1 = getList( dataElementA, periodA, categoryOptionComboA );
+        List<NameableObject> a2 = getList( groupA );
+        
+        String b1 = getIdentifier( DataElement.class, 'A' );
+        String b2 = getIdentifier( Period.class, 'A' );
+        String b3 = getIdentifier( DataElementCategoryOptionCombo.class, 'A' );
+        String b4 = getIdentifier( OrganisationUnitGroup.class, 'A' );
+        
+        String a = getIdentifier( a1, a2 );
+        String b = getIdentifier( b1, b2, b3, b4 );
+        
+        assertEquals( a, b );
+    }
     
     @Test
     public void testGetColumnName()
@@ -293,7 +345,126 @@
         List<NameableObject> a2 = getList( unitB, periodD );
 
         assertNotNull( getColumnName( a2 ) );
-        assertEquals( "organisationunitshortb_year", getColumnName( a2 ) );        
+        assertEquals( "organisationunitshortb_year", getColumnName( a2 ) );
+        
+        List<NameableObject> a3 = getList( groupA, indicatorA );
+        
+        assertNotNull( getColumnName( a3 ) );
+        assertEquals( "organisationunitgroupa_indicatorshorta", getColumnName( a3 ) );
+    }
+
+    @Test
+    public void testOrganisationUnitGroupReportTableA()
+    {
+        ReportTable reportTable = new ReportTable( "Embezzlement", false,
+            new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), relativeUnits, 
+            groups, null, true, true, false, relatives, null, i18nFormat, "january_2000" );
+
+        reportTable.init();
+        
+        List<String> indexColumns = reportTable.getIndexColumns();
+        
+        assertNotNull( indexColumns );
+        assertEquals( 1, indexColumns.size() );
+        assertTrue( indexColumns.contains( ReportTable.ORGANISATIONUNIT_ID ) );
+        
+        List<String> indexNameColumns = reportTable.getIndexNameColumns();
+
+        assertNotNull( indexNameColumns );
+        assertEquals( 1, indexNameColumns.size() );
+        assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
+        
+        List<List<NameableObject>> columns = reportTable.getColumns();
+
+        assertNotNull( columns ); 
+        assertEquals( 8, columns.size() );
+        
+        Iterator<List<NameableObject>> iterator = columns.iterator();
+        
+        assertEquals( getList( indicatorA, periodA ), iterator.next() );
+        assertEquals( getList( indicatorA, periodB ), iterator.next() );
+        assertEquals( getList( indicatorA, periodC ), iterator.next() );
+        assertEquals( getList( indicatorA, periodD ), iterator.next() );
+        assertEquals( getList( indicatorB, periodA ), iterator.next() );
+        assertEquals( getList( indicatorB, periodB ), iterator.next() );
+        assertEquals( getList( indicatorB, periodC ), iterator.next() );
+        assertEquals( getList( indicatorB, periodD ), iterator.next() );
+            
+        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        
+        assertNotNull( columnNames );        
+        assertEquals( 8, columnNames.size() );
+        
+        assertTrue( columnNames.contains( "indicatorshorta_reporting_month" ) );
+        assertTrue( columnNames.contains( "indicatorshorta_year" ) );
+        assertTrue( columnNames.contains( "indicatorshortb_reporting_month" ) );
+        assertTrue( columnNames.contains( "indicatorshortb_year" ) );
+        
+        List<List<NameableObject>> rows = reportTable.getRows();
+        
+        assertNotNull( rows );
+        assertEquals( 2, rows.size() );
+        
+        iterator = rows.iterator();
+        
+        assertEquals( getList( groupA ), iterator.next() );
+        assertEquals( getList( groupB ), iterator.next() );
+    }
+
+    @Test
+    public void testOrganisationUnitGroupReportTableB()
+    {        
+        ReportTable reportTable = new ReportTable( "Embezzlement", false, 
+            new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, new ArrayList<OrganisationUnit>(), relativeUnits, 
+            groups, null, true, false, true, relatives, null, i18nFormat, "january_2000" );
+
+        reportTable.init();
+        
+        List<String> indexColumns = reportTable.getIndexColumns();
+
+        assertNotNull( indexColumns );
+        assertEquals( 1, indexColumns.size() );
+        assertTrue( indexColumns.contains( ReportTable.PERIOD_ID ) );
+
+        List<String> indexNameColumns = reportTable.getIndexNameColumns();
+
+        assertNotNull( indexNameColumns );
+        assertEquals( 1, indexNameColumns.size() );
+        assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
+
+        List<List<NameableObject>> columns = reportTable.getColumns();
+        
+        assertNotNull( columns );
+        assertEquals( 4, columns.size() );
+
+        Iterator<List<NameableObject>> iterator = columns.iterator();
+        
+        assertEquals( getList( indicatorA, groupA ), iterator.next() );
+        assertEquals( getList( indicatorA, groupB ), iterator.next() );
+        assertEquals( getList( indicatorB, groupA ), iterator.next() );
+        assertEquals( getList( indicatorB, groupB ), iterator.next() );
+        
+        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        
+        assertNotNull( columnNames );
+        assertEquals( 4, columnNames.size() );
+        
+        assertTrue( columnNames.contains( "indicatorshorta_organisationunitgroupa" ) );
+        assertTrue( columnNames.contains( "indicatorshorta_organisationunitgroupb" ) );
+        assertTrue( columnNames.contains( "indicatorshortb_organisationunitgroupa" ) );
+        assertTrue( columnNames.contains( "indicatorshortb_organisationunitgroupb" ) );
+        
+        List<List<NameableObject>> rows = reportTable.getRows();
+        
+        assertNotNull( rows );
+        assertEquals( 4, rows.size() );
+
+        iterator = rows.iterator();
+        
+        assertEquals( getList( periodA ), iterator.next() );
+        assertEquals( getList( periodB ), iterator.next() );
+        assertEquals( getList( periodC ), iterator.next() );
+        assertEquals( getList( periodD ), iterator.next() );
     }
     
     @Test
@@ -301,7 +472,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -359,7 +530,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -417,7 +588,7 @@
     {        
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, false, true, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -473,7 +644,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, true, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -503,7 +674,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             new ArrayList<DataElement>(), indicators, new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, false, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, false, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -533,7 +704,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -575,7 +746,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -617,7 +788,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, false, true, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -659,7 +830,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            categoryCombo, true, true, false, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), categoryCombo, true, true, false, relatives, null, i18nFormat, "january_2000" );
         
         reportTable.init();
         
@@ -720,7 +891,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            categoryCombo, false, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), categoryCombo, false, false, true, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -777,7 +948,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             dataElements, new ArrayList<Indicator>(), new ArrayList<DataSet>(), periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            categoryCombo, true, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), categoryCombo, true, false, true, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -832,7 +1003,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, true, false, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, true, false, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -874,7 +1045,7 @@
     {
         ReportTable reportTable = new ReportTable( "Embezzlement", false,
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, false, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, false, false, true, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         
@@ -916,7 +1087,7 @@
     {        
         ReportTable reportTable = new ReportTable( "Embezzlement", false, 
             new ArrayList<DataElement>(), new ArrayList<Indicator>(), dataSets, periods, relativePeriods, units, new ArrayList<OrganisationUnit>(), 
-            null, true, false, true, relatives, null, i18nFormat, "january_2000" );
+            new ArrayList<OrganisationUnitGroup>(), null, true, false, true, relatives, null, i18nFormat, "january_2000" );
 
         reportTable.init();
         

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2011-12-22 19:56:05 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2011-12-22 19:59:19 +0000
@@ -76,16 +76,10 @@
 
   <cache name="org.hisp.dhis.chart.Chart" maxElementsInMemory="100" />
 
-  <cache name="org.hisp.dhis.chart.ChartGroup" maxElementsInMemory="100" />
-
   <cache name="org.hisp.dhis.reporttable.ReportTable" maxElementsInMemory="100" />
 
-  <cache name="org.hisp.dhis.reporttable.ReportTableGroup" maxElementsInMemory="100" />
-
   <cache name="org.hisp.dhis.report.Report" maxElementsInMemory="100" />
 
-  <cache name="org.hisp.dhis.report.ReportGroup" maxElementsInMemory="100" />
-
   <cache name="org.hisp.dhis.document.Document" maxElementsInMemory="100" />
 
   <cache name="org.hisp.dhis.dashboard.DashboardContent" maxElementsInMemory="1000" />
@@ -159,8 +153,6 @@
   <cache name="org.hisp.dhis.organisationunit.OrganisationUnitGroupSet.organisationUnitGroups"
     maxElementsInMemory="400" />
 
-  <cache name="org.hisp.dhis.report.ReportGroup.members" maxElementsInMemory="400" />
-
   <cache name="org.hisp.dhis.reporttable.ReportTable.dataElements" maxElementsInMemory="1500" />
 
   <cache name="org.hisp.dhis.reporttable.ReportTable.indicators" maxElementsInMemory="500" />
@@ -170,8 +162,8 @@
   <cache name="org.hisp.dhis.reporttable.ReportTable.periods" maxElementsInMemory="200" />
 
   <cache name="org.hisp.dhis.reporttable.ReportTable.units" maxElementsInMemory="2000" />
-
-  <cache name="org.hisp.dhis.reporttable.ReportTableGroup.members" maxElementsInMemory="500" />
+  
+  <cache name="org.hisp.dhis.reporttable.ReportTable.organisationUnitGroups" maxElementsInMemory="500" />
 
   <cache name="org.hisp.dhis.chart.Chart.dataElements" maxElementsInMemory="1500" />
 
@@ -183,8 +175,6 @@
   
   <cache name="org.hisp.dhis.chart.Chart.dataSets" maxElementsInMemory="200" />
 
-  <cache name="org.hisp.dhis.chart.ChartGroup.members" maxElementsInMemory="500" />
-
   <cache name="org.hisp.dhis.user.User.organisationUnits" maxElementsInMemory="20000" />
 
   <cache name="org.hisp.dhis.attribute.Attribute.attributeOptions" maxElementsInMemory="500" />

=== 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-19 19:58:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2011-12-22 19:59:19 +0000
@@ -42,6 +42,7 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -408,7 +409,7 @@
         if ( tableId == null )
         {
             reportTable = new ReportTable( tableName, regression,
-                dataElements, indicators, dataSets, periods, null, units, null,
+                dataElements, indicators, dataSets, periods, null, units, null, new ArrayList<OrganisationUnitGroup>(),
                 categoryCombo, doIndicators, doPeriods, doOrganisationUnits, relatives, reportParams, 
                 null, null );
             reportTable.setSortOrder( sortOrder );