← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10836: Made ReportTable extend BaseAnalyticalObject

 

------------------------------------------------------------
revno: 10836
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-05-14 23:14:22 +0200
message:
  Made ReportTable extend BaseAnalyticalObject
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.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/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/ReportTableTest.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/chart/Chart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2013-05-14 10:58:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Chart.java	2013-05-14 21:14:22 +0000
@@ -156,6 +156,7 @@
         return list != null && !list.isEmpty() ? list.iterator().next() : null;
     }
 
+    @Override
     public void populateAnalyticalProperties()
     {
         columns.addAll( getDimensionalObjectList( series ) );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java	2013-05-13 15:26:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java	2013-05-14 21:14:22 +0000
@@ -124,7 +124,7 @@
     
     protected transient List<DimensionalObject> filters = new ArrayList<DimensionalObject>();
     
-    protected Map<String, String> parentGraphMap = new HashMap<String, String>();
+    protected transient Map<String, String> parentGraphMap = new HashMap<String, String>();
 
     // -------------------------------------------------------------------------
     // Logic

=== 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	2013-05-09 14:55:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2013-05-14 21:14:22 +0000
@@ -27,6 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIM_ID;
+import static org.hisp.dhis.common.DimensionalObject.ORGUNIT_DIM_ID;
+import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -36,6 +40,7 @@
 import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
+import org.hisp.dhis.common.BaseAnalyticalObject;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.BaseNameableObject;
 import org.hisp.dhis.common.CombinationGenerator;
@@ -44,9 +49,6 @@
 import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.common.adapter.JacksonMapListIdentifiableObjectSerializer;
-import org.hisp.dhis.common.adapter.JacksonPeriodDeserializer;
-import org.hisp.dhis.common.adapter.JacksonPeriodSerializer;
-import org.hisp.dhis.common.annotation.Scanned;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.ExportView;
 import org.hisp.dhis.dataelement.DataElement;
@@ -67,7 +69,6 @@
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
@@ -82,17 +83,13 @@
  */
 @JacksonXmlRootElement( localName = "reportTable", namespace = DxfNamespaces.DXF_2_0)
 public class ReportTable
-    extends BaseIdentifiableObject
+    extends BaseAnalyticalObject
 {
     /**
      * Determines if a de-serialized file is compatible with this class.
      */
     private static final long serialVersionUID = 5618655666320890565L;
     
-    public static final String DATA_X_DIM_ID = "dx"; // IN, DE, DS
-    public static final String PERIOD_DIM_ID = "pe";
-    public static final String ORGUNIT_DIM_ID = "ou";
-    
     public static final String DATAELEMENT_ID = "dataelementid";
     public static final String CATEGORYCOMBO_ID = "categoryoptioncomboid";
     public static final String CATEGORYOPTION_ID = "categoryoptionid";
@@ -222,48 +219,6 @@
     private boolean cumulative;
 
     /**
-     * The list of DataElements the ReportTable contains.
-     */
-    @Scanned
-    private List<DataElement> dataElements = new ArrayList<DataElement>();
-
-    /**
-     * The list of Indicators the ReportTable contains.
-     */
-    @Scanned
-    private List<Indicator> indicators = new ArrayList<Indicator>();
-
-    /**
-     * The list of DataSets the ReportTable contains.
-     */
-    @Scanned
-    private List<DataSet> dataSets = new ArrayList<DataSet>();
-
-    /**
-     * The list of Periods the ReportTable contains.
-     */
-    @Scanned
-    private List<Period> periods = new ArrayList<Period>();
-
-    /**
-     * The list of OrganisationUnits the ReportTable contains.
-     */
-    @Scanned
-    private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
-
-    /**
-     * The list of DataElementGroups the ReportTable contains.
-     */
-    @Scanned
-    private List<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>();
-    
-    /**
-     * The list of OrganisationUnitGroups the ReportTable contains.
-     */
-    @Scanned
-    private List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
-
-    /**
      * Dimensions to crosstabulate / use as columns.
      */
     private List<String> columnDimensions = new ArrayList<String>();
@@ -284,11 +239,6 @@
     private DataElementCategoryCombo categoryCombo;
 
     /**
-     * The RelativePeriods of the ReportTable.
-     */
-    private RelativePeriods relatives;
-
-    /**
      * The ReportParams of the ReportTable.
      */
     private ReportParams reportParams;
@@ -333,16 +283,6 @@
      */
     private String fontSize;
     
-    /**
-     * Indicates use of the organisation unit of the current user.
-     */
-    private boolean userOrganisationUnit;
-    
-    /**
-     * Indicates use of the organisation unit children of the current user.
-     */
-    private boolean userOrganisationUnitChildren;
-
     // -------------------------------------------------------------------------
     // Presentation properties
     // -------------------------------------------------------------------------
@@ -389,12 +329,12 @@
     /**
      * All crosstabulated columns.
      */
-    private List<List<NameableObject>> columns = new ArrayList<List<NameableObject>>();
+    private List<List<NameableObject>> gridColumns = new ArrayList<List<NameableObject>>();
 
     /**
      * All rows.
      */
-    private List<List<NameableObject>> rows = new ArrayList<List<NameableObject>>();
+    private List<List<NameableObject>> gridRows = new ArrayList<List<NameableObject>>();
 
     /**
      * Names of the columns used to query the datavalue table and as index
@@ -579,11 +519,11 @@
             allUnits = removeDuplicates( allUnits );
         }
 
-        columns = new CombinationGenerator<NameableObject>( getArrays( true ) ).getCombinations();
-        rows = new CombinationGenerator<NameableObject>( getArrays( false ) ).getCombinations();
+        gridColumns = new CombinationGenerator<NameableObject>( getArrays( true ) ).getCombinations();
+        gridRows = new CombinationGenerator<NameableObject>( getArrays( false ) ).getCombinations();
 
-        addIfEmpty( columns ); // Allow for all or none crosstab dimensions
-        addIfEmpty( rows );
+        addIfEmpty( gridColumns ); // Allow for all or none crosstab dimensions
+        addIfEmpty( gridRows );
 
         add( indexColumns, INDICATOR_ID, isDoIndicators() );
         add( indexColumns, PERIOD_ID, isDoPeriods() );
@@ -610,6 +550,25 @@
     // Public methods
     // -------------------------------------------------------------------------
     
+    @Override
+    public void populateAnalyticalProperties()
+    {
+        for ( String column : columnDimensions )
+        {
+            columns.addAll( getDimensionalObjectList( column ) );
+        }
+        
+        for ( String row : rowDimensions )
+        {
+            rows.addAll( getDimensionalObjectList( row ) );
+        }
+        
+        for ( String filter : filterDimensions )
+        {
+            filters.addAll( getDimensionalObjectList( filter ) );
+        }
+    }
+    
     /**
      * Indicates whether this report table can be rendered by the report table
      * service. Stopgap method until report table UI will be replaced by pivot
@@ -922,14 +881,6 @@
         return organisationUnitGroups != null && organisationUnitGroups.size() > 0;
     }
 
-    /**
-     * Indicates whether this report table has relative periods.
-     */
-    public boolean hasRelativePeriods()
-    {
-        return relatives != null && !relatives.isEmpty();
-    }
-
     public boolean isDoIndicators()
     {
         return columnDimensions.contains( DATA_X_DIM_ID );
@@ -975,56 +926,6 @@
         }
     }
 
-    public void removeAllDataElements()
-    {
-        dataElements.clear();
-    }
-
-    public void removeAllIndicators()
-    {
-        indicators.clear();
-    }
-
-    public void removeAllDataSets()
-    {
-        dataSets.clear();
-    }
-
-    public void removeAllPeriods()
-    {
-        periods.clear();
-    }
-
-    public void removeAllOrganisationUnits()
-    {
-        organisationUnits.clear();
-    }
-
-    public void removeAllDataElementGroups()
-    {
-        dataElementGroups.clear();
-    }
-    
-    public void removeAllOrganisationUnitGroups()
-    {
-        organisationUnitGroups.clear();
-    }
-    
-    public void removeAllColumnDimensions()
-    {
-        columnDimensions.clear();
-    }
-    
-    public void removeAllRowDimensions()
-    {
-        rowDimensions.clear();
-    }
-    
-    public void removeAllFilterDimensions()
-    {
-        filterDimensions.clear();
-    }
-
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
@@ -1202,112 +1103,6 @@
     }
 
     @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "dataElements", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "dataElement", namespace = DxfNamespaces.DXF_2_0)
-    public List<DataElement> getDataElements()
-    {
-        return dataElements;
-    }
-
-    public void setDataElements( List<DataElement> dataElements )
-    {
-        this.dataElements = dataElements;
-    }
-
-    @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "indicators", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "indicator", namespace = DxfNamespaces.DXF_2_0)
-    public List<Indicator> getIndicators()
-    {
-        return indicators;
-    }
-
-    public void setIndicators( List<Indicator> indicators )
-    {
-        this.indicators = indicators;
-    }
-
-    @JsonProperty
-    @JsonSerialize( contentUsing = JacksonPeriodSerializer.class )
-    @JsonDeserialize( contentUsing = JacksonPeriodDeserializer.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "periods", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "period", namespace = DxfNamespaces.DXF_2_0)
-    public List<Period> getPeriods()
-    {
-        return periods;
-    }
-
-    public void setPeriods( List<Period> periods )
-    {
-        this.periods = periods;
-    }
-
-    @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "dataSets", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "dataSet", namespace = DxfNamespaces.DXF_2_0)
-    public List<DataSet> getDataSets()
-    {
-        return dataSets;
-    }
-
-    public void setDataSets( List<DataSet> dataSets )
-    {
-        this.dataSets = dataSets;
-    }
-
-    @JsonProperty( value = "organisationUnits" )
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0)
-    public List<OrganisationUnit> getOrganisationUnits()
-    {
-        return organisationUnits;
-    }
-
-    public void setOrganisationUnits( List<OrganisationUnit> units )
-    {
-        this.organisationUnits = units;
-    }
-
-    @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "dataElementGroups", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "dataElementGroup", namespace = DxfNamespaces.DXF_2_0)
-    public List<DataElementGroup> getDataElementGroups()
-    {
-        return dataElementGroups;
-    }
-
-    public void setDataElementGroups( List<DataElementGroup> dataElementGroups )
-    {
-        this.dataElementGroups = dataElementGroups;
-    }
-
-    @JsonProperty
-    @JsonSerialize( contentAs = BaseIdentifiableObject.class )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlElementWrapper( localName = "organisationUnitGroups", namespace = DxfNamespaces.DXF_2_0)
-    @JacksonXmlProperty( localName = "organisationUnitGroup", namespace = DxfNamespaces.DXF_2_0)
-    public List<OrganisationUnitGroup> getOrganisationUnitGroups()
-    {
-        return organisationUnitGroups;
-    }
-
-    public void setOrganisationUnitGroups( List<OrganisationUnitGroup> organisationUnitGroups )
-    {
-        this.organisationUnitGroups = organisationUnitGroups;
-    }
-
-    @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlElementWrapper( localName = "columnDimensions", namespace = DxfNamespaces.DXF_2_0)
     @JacksonXmlProperty( localName = "column", namespace = DxfNamespaces.DXF_2_0)
@@ -1363,19 +1158,6 @@
         this.categoryCombo = categoryCombo;
     }
 
-    @JsonProperty( value = "relativePeriods" )
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
-    public RelativePeriods getRelatives()
-    {
-        return relatives;
-    }
-
-    public void setRelatives( RelativePeriods relatives )
-    {
-        this.relatives = relatives;
-    }
-
     @JsonProperty
     @JsonView( {DetailedView.class, ExportView.class} )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
@@ -1493,32 +1275,6 @@
         this.fontSize = fontSize;
     }
 
-    @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
-    public boolean isUserOrganisationUnit()
-    {
-        return userOrganisationUnit;
-    }
-
-    public void setUserOrganisationUnit( boolean userOrganisationUnit )
-    {
-        this.userOrganisationUnit = userOrganisationUnit;
-    }
-
-    @JsonProperty
-    @JsonView( {DetailedView.class, ExportView.class} )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
-    public boolean isUserOrganisationUnitChildren()
-    {
-        return userOrganisationUnitChildren;
-    }
-
-    public void setUserOrganisationUnitChildren( boolean userOrganisationUnitChildren )
-    {
-        this.userOrganisationUnitChildren = userOrganisationUnitChildren;
-    }
-
     // -------------------------------------------------------------------------
     // Get- and set-methods for presentation properties
     // -------------------------------------------------------------------------
@@ -1615,15 +1371,15 @@
     }
 
     @JsonIgnore
-    public List<List<NameableObject>> getColumns()
+    public List<List<NameableObject>> getGridColumns()
     {
-        return columns;
+        return gridColumns;
     }
 
     @JsonIgnore
-    public List<List<NameableObject>> getRows()
+    public List<List<NameableObject>> getGridRows()
     {
-        return rows;
+        return gridRows;
     }
 
     @JsonIgnore
@@ -1717,34 +1473,34 @@
             userOrganisationUnit = reportTable.isUserOrganisationUnit();
             userOrganisationUnitChildren = reportTable.isUserOrganisationUnitChildren();
 
-            removeAllDataElements();
+            dataElements.clear();
             dataElements.addAll( reportTable.getDataElements() );
 
-            removeAllIndicators();
+            indicators.clear();
             indicators.addAll( reportTable.getIndicators() );
 
-            removeAllDataSets();
+            dataSets.clear();
             dataSets.addAll( reportTable.getDataSets() );
 
-            removeAllOrganisationUnits();
+            organisationUnits.clear();
             organisationUnits.addAll( reportTable.getOrganisationUnits() );
 
-            removeAllPeriods();
+            periods.clear();
             periods.addAll( reportTable.getPeriods() );
 
-            removeAllDataElementGroups();
+            dataElementGroups.clear();
             dataElementGroups.addAll( reportTable.getDataElementGroups() );
             
-            removeAllOrganisationUnitGroups();
+            organisationUnitGroups.clear();
             organisationUnitGroups.addAll( reportTable.getOrganisationUnitGroups() );
             
-            removeAllColumnDimensions();
+            columnDimensions.clear();
             columnDimensions.addAll( reportTable.getColumnDimensions() );
             
-            removeAllRowDimensions();
+            rowDimensions.clear();
             rowDimensions.addAll( reportTable.getRowDimensions() );
             
-            removeAllFilterDimensions();
+            filterDimensions.clear();
             filterDimensions.addAll( reportTable.getFilterDimensions() );
         }
     }

=== 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	2013-03-19 17:09:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2013-05-14 21:14:22 +0000
@@ -386,9 +386,9 @@
         }
 
         final int startColumnIndex = grid.getHeaders().size();
-        final int numberOfColumns = reportTable.getColumns().size();
+        final int numberOfColumns = reportTable.getGridColumns().size();
 
-        for ( List<NameableObject> column : reportTable.getColumns() )
+        for ( List<NameableObject> column : reportTable.getGridColumns() )
         {
             grid.addHeader( new GridHeader( getPrettyColumnName( column ), getColumnName( column ), Double.class
                 .getName(), false, false ) );
@@ -413,7 +413,7 @@
         // Values
         // ---------------------------------------------------------------------
 
-        for ( List<NameableObject> row : reportTable.getRows() )
+        for ( List<NameableObject> row : reportTable.getGridRows() )
         {
             grid.addRow();
 
@@ -452,7 +452,7 @@
                 grid.addValue( isCurrentParent( row ) ? YES : NO );
             }
 
-            for ( List<NameableObject> column : reportTable.getColumns() ) // Values
+            for ( List<NameableObject> column : reportTable.getGridColumns() ) // Values
             {
                 grid.addValue( map.get( getIdentifier( row, column ) ) );
             }

=== 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	2013-03-26 21:06:31 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2013-05-14 21:14:22 +0000
@@ -29,6 +29,14 @@
         foreign-key="fk_reporttable_dataelements_dataelementid" />
     </list>
 
+    <list name="dataElementOperands" table="reporttable_dataelementoperands" cascade="all-delete-orphan">
+      <cache usage="read-write" />
+      <key column="reporttableid" foreign-key="fk_reporttable_dataelementoperandid_reporttableid" />
+      <list-index column="sort_order" base="0" />
+      <many-to-many column="dataelementoperandid" class="org.hisp.dhis.dataelement.DataElementOperand"
+        foreign-key="fk_reporttable_dataelementoperands_dataelementoperandid" />
+    </list>
+
     <list name="indicators" table="reporttable_indicators">
       <cache usage="read-write" />
       <key column="reporttableid" foreign-key="fk_reporttable_indicators_reporttableid" />
@@ -49,6 +57,14 @@
       column="categorycomboid"
       foreign-key="fk_reporttable_categorycombo" />
 
+    <list name="organisationUnits" table="reporttable_organisationunits">
+      <cache usage="read-write" />
+      <key column="reporttableid" foreign-key="fk_reporttable_organisationunits_reporttableid" />
+      <list-index column="sort_order" base="0" />
+      <many-to-many column="organisationunitid" class="org.hisp.dhis.organisationunit.OrganisationUnit"
+        foreign-key="fk_reporttable_organisationunits_organisationunitid" />
+    </list>
+
     <list name="periods" table="reporttable_periods">
       <cache usage="read-write" />
       <key column="reporttableid" foreign-key="fk_reporttable_periods_reporttableid" />
@@ -57,14 +73,17 @@
         foreign-key="fk_reporttable_periods_periodid" />
     </list>
 
-    <list name="organisationUnits" table="reporttable_organisationunits">
+    <many-to-one name="relatives" unique="true" class="org.hisp.dhis.period.RelativePeriods" column="relativeperiodsid"
+      cascade="all-delete-orphan" foreign-key="fk_report_relativeperiodsid" />
+
+    <list name="categoryDimensions" table="reporttable_categorydimensions" cascade="all-delete-orphan">
       <cache usage="read-write" />
-      <key column="reporttableid" foreign-key="fk_reporttable_organisationunits_reporttableid" />
+      <key column="reporttableid" foreign-key="fk_reporttable_categorydimensions_reporttableid" />
       <list-index column="sort_order" base="0" />
-      <many-to-many column="organisationunitid" class="org.hisp.dhis.organisationunit.OrganisationUnit"
-        foreign-key="fk_reporttable_organisationunits_organisationunitid" />
+      <many-to-many column="categorydimensionid" class="org.hisp.dhis.dataelement.DataElementCategoryDimension"
+        foreign-key="fk_reporttable_categorydimensions_categorydimensionid" />
     </list>
-
+    
     <list name="dataElementGroups" table="reporttable_dataelementgroups">
       <cache usage="read-write" />
       <key column="reporttableid" foreign-key="fk_reporttable_dataelementgroups_reporttableid" />
@@ -102,9 +121,6 @@
       <element type="string" column="dimension" />
     </list>
 
-    <many-to-one name="relatives" unique="true" class="org.hisp.dhis.period.RelativePeriods" column="relativeperiodsid"
-      cascade="all-delete-orphan" foreign-key="fk_report_relativeperiodsid" />
-
     <component name="reportParams">
       <property name="paramReportingMonth" />
       <property name="paramGrandParentOrganisationUnit" />

=== 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	2013-03-01 09:05:13 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/reporttable/ReportTableTest.java	2013-05-14 21:14:22 +0000
@@ -374,7 +374,7 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
         
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
 
         assertNotNull( columns ); 
         assertEquals( 8, columns.size() );
@@ -390,7 +390,7 @@
         assertEquals( getList( indicatorB, periodC ), iterator.next() );
         assertEquals( getList( indicatorB, periodD ), iterator.next() );
             
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );        
         assertEquals( 8, columnNames.size() );
@@ -400,7 +400,7 @@
         assertTrue( columnNames.contains( "indicatorshortb_reporting_month" ) );
         assertTrue( columnNames.contains( "indicatorshortb_year" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 2, rows.size() );
@@ -432,7 +432,7 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 4, columns.size() );
@@ -444,7 +444,7 @@
         assertEquals( getList( indicatorB, groupA ), iterator.next() );
         assertEquals( getList( indicatorB, groupB ), iterator.next() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 4, columnNames.size() );
@@ -454,7 +454,7 @@
         assertTrue( columnNames.contains( "indicatorshortb_organisationunitgroupshorta" ) );
         assertTrue( columnNames.contains( "indicatorshortb_organisationunitgroupshortb" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 4, rows.size() );
@@ -488,7 +488,7 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
         
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
 
         assertNotNull( columns ); 
         assertEquals( 8, columns.size() );
@@ -504,7 +504,7 @@
         assertEquals( getList( indicatorB, periodC ), iterator.next() );
         assertEquals( getList( indicatorB, periodD ), iterator.next() );
             
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );        
         assertEquals( 8, columnNames.size() );
@@ -514,7 +514,7 @@
         assertTrue( columnNames.contains( "indicatorshortb_reporting_month" ) );
         assertTrue( columnNames.contains( "indicatorshortb_year" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 2, rows.size() );
@@ -548,7 +548,7 @@
         assertTrue( indexNameColumns.contains( ReportTable.INDICATOR_NAME ) );
         assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );        
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 2, columns.size() );
@@ -558,7 +558,7 @@
         assertEquals( getList( unitA ), iterator.next() );
         assertEquals( getList( unitB ), iterator.next() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 2, columnNames.size() );
@@ -566,7 +566,7 @@
         assertTrue( columnNames.contains( "organisationunitshorta" ) );
         assertTrue( columnNames.contains( "organisationunitshortb" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 8, rows.size() );
@@ -604,7 +604,7 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 4, columns.size() );
@@ -616,7 +616,7 @@
         assertEquals( getList( indicatorB, unitA ), iterator.next() );
         assertEquals( getList( indicatorB, unitB ), iterator.next() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 4, columnNames.size() );
@@ -626,7 +626,7 @@
         assertTrue( columnNames.contains( "indicatorshortb_organisationunitshorta" ) );
         assertTrue( columnNames.contains( "indicatorshortb_organisationunitshortb" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 4, rows.size() );
@@ -658,12 +658,12 @@
         assertNotNull( indexNameColumns );
         assertEquals( 0, indexNameColumns.size() );
         
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 16, columns.size() );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
 
         assertNotNull( rows );
         assertEquals( 1, rows.size() );
@@ -688,12 +688,12 @@
         assertNotNull( indexNameColumns );
         assertEquals( 3, indexNameColumns.size() );
         
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 1, columns.size() );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
 
         assertNotNull( rows );
         assertEquals( 16, rows.size() );
@@ -720,12 +720,12 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 8, columns.size() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 8, columnNames.size() );
@@ -735,7 +735,7 @@
         assertTrue( columnNames.contains( "dataelementshortb_year" ) );
         assertTrue( columnNames.contains( "dataelementshortb_reporting_month" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 2, rows.size() );
@@ -764,12 +764,12 @@
         assertTrue( indexNameColumns.contains( ReportTable.INDICATOR_NAME ) );
         assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 2, columns.size() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 2, columnNames.size() );
@@ -777,7 +777,7 @@
         assertTrue( columnNames.contains( "organisationunitshorta" ) );
         assertTrue( columnNames.contains( "organisationunitshortb" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 8, rows.size() );        
@@ -804,12 +804,12 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 4, columns.size() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 4, columnNames.size() );
@@ -819,7 +819,7 @@
         assertTrue( columnNames.contains( "dataelementshortb_organisationunitshorta" ) );
         assertTrue( columnNames.contains( "dataelementshortb_organisationunitshortb" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 4, rows.size() );
@@ -846,7 +846,7 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 16, columns.size() );
@@ -870,12 +870,12 @@
         assertEquals( getList( dataElementB, periodD, categoryOptionComboA ), iterator.next() );
         assertEquals( getList( dataElementB, periodD, categoryOptionComboB ), iterator.next() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 16, columnNames.size() );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 2, rows.size() );
@@ -909,7 +909,7 @@
         assertTrue( indexNameColumns.contains( ReportTable.INDICATOR_NAME ) );
         assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
 
         assertNotNull( columns );
         assertEquals( 4, columns.size() );
@@ -921,12 +921,12 @@
         assertEquals( getList( unitB, categoryOptionComboA ), iterator.next() );
         assertEquals( getList( unitB, categoryOptionComboB ), iterator.next() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 4, columnNames.size() );
 
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 8, rows.size() );
@@ -964,7 +964,7 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 8, columns.size() );
@@ -980,12 +980,12 @@
         assertEquals( getList( dataElementB, unitB, categoryOptionComboA ), iterator.next() );
         assertEquals( getList( dataElementB, unitB, categoryOptionComboB ), iterator.next() );
 
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 8, columnNames.size() );
 
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 4, rows.size() );
@@ -1019,12 +1019,12 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.ORGANISATIONUNIT_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 8, columns.size() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 8, columnNames.size() );
@@ -1034,7 +1034,7 @@
         assertTrue( columnNames.contains( "datasetshortb_year" ) );
         assertTrue( columnNames.contains( "datasetshortb_reporting_month" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 2, rows.size() );
@@ -1063,12 +1063,12 @@
         assertTrue( indexNameColumns.contains( ReportTable.INDICATOR_NAME ) );
         assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );        
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 2, columns.size() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 2, columnNames.size() );
@@ -1076,7 +1076,7 @@
         assertTrue( columnNames.contains( "organisationunitshorta" ) );
         assertTrue( columnNames.contains( "organisationunitshortb" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 8, rows.size() );
@@ -1103,12 +1103,12 @@
         assertEquals( 1, indexNameColumns.size() );
         assertTrue( indexNameColumns.contains( ReportTable.PERIOD_NAME ) );
 
-        List<List<NameableObject>> columns = reportTable.getColumns();
+        List<List<NameableObject>> columns = reportTable.getGridColumns();
         
         assertNotNull( columns );
         assertEquals( 4, columns.size() );
         
-        List<String> columnNames = getColumnNames( reportTable.getColumns() );
+        List<String> columnNames = getColumnNames( reportTable.getGridColumns() );
         
         assertNotNull( columnNames );
         assertEquals( 4, columnNames.size() );
@@ -1118,7 +1118,7 @@
         assertTrue( columnNames.contains( "datasetshortb_organisationunitshorta" ) );
         assertTrue( columnNames.contains( "datasetshortb_organisationunitshortb" ) );
         
-        List<List<NameableObject>> rows = reportTable.getRows();
+        List<List<NameableObject>> rows = reportTable.getGridRows();
         
         assertNotNull( rows );
         assertEquals( 4, rows.size() );