← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15054: Deletion handling of charts, maps, report tables. Replaced naive handling which pulled all object...

 

------------------------------------------------------------
revno: 15054
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-28 13:24:08 +0200
message:
  Deletion handling of charts, maps, report tables. Replaced naive handling which pulled all objects into memory with query. Fixed wrong naming of methods in MapViewService.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateAnalyticalObjectStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.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/META-INF/dhis/beans.xml


--
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/ChartService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/ChartService.java	2014-04-28 11:24:08 +0000
@@ -119,4 +119,6 @@
     int countIndicatorCharts( Indicator indicator );
 
     int countDataElementCharts( DataElement dataElement );
+    
+    int countOrganisationUnitCharts( OrganisationUnit organisationUnit );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectStore.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AnalyticalObjectStore.java	2014-04-28 11:24:08 +0000
@@ -31,6 +31,7 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -43,4 +44,6 @@
     int countIndicatorAnalyticalObject( Indicator indicator );
 
     int countDataElementAnalyticalObject( DataElement dataElement );
+    
+    int countOrganisationUnitAnalyticalObject( OrganisationUnit organisationUnit );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2014-04-28 11:24:08 +0000
@@ -31,6 +31,7 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 
 import java.util.Collection;
 import java.util.List;
@@ -167,11 +168,13 @@
 
     int countMapViewMaps( MapView mapView );
 
-    int countDataSetCharts( DataSet dataSet );
-
-    int countIndicatorCharts( Indicator indicator );
-
-    int countDataElementCharts( DataElement dataElement );
+    int countDataSetMapViews( DataSet dataSet );
+
+    int countIndicatorMapViews( Indicator indicator );
+
+    int countDataElementMapViews( DataElement dataElement );
+    
+    int countOrganisationUnitMapViews( OrganisationUnit organisationUnit );
 
     int countMapLegendSetMapViews( MapLegendSet mapLegendSet );
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2014-04-28 11:24:08 +0000
@@ -29,7 +29,11 @@
  */
 
 import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 
 import java.util.Collection;
 import java.util.Date;
@@ -144,4 +148,12 @@
     int getReportTableCount();
 
     int getReportTableCountByName( String name );
+    
+    int countDataSetReportTables( DataSet dataSet );
+    
+    int countIndicatorReportTables( Indicator indicator );
+    
+    int countDataElementReportTables( DataElement dataElement );
+    
+    int countOrganisationUnitReportTables( OrganisationUnit organisationUnit );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateAnalyticalObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateAnalyticalObjectStore.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateAnalyticalObjectStore.java	2014-04-28 11:24:08 +0000
@@ -34,6 +34,7 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -67,4 +68,13 @@
 
         return ((Long) query.uniqueResult()).intValue();
     }
+
+    @Override
+    public int countOrganisationUnitAnalyticalObject( OrganisationUnit organisationUnit )
+    {
+        Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where :organisationUnit in elements(c.organisationUnits)" );
+        query.setEntity( "organisationUnit", organisationUnit );
+
+        return ((Long) query.uniqueResult()).intValue();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2014-04-28 11:24:08 +0000
@@ -459,22 +459,28 @@
     }
 
     @Override
-    public int countDataSetCharts( DataSet dataSet )
+    public int countDataSetMapViews( DataSet dataSet )
     {
         return mapViewStore.countDataSetAnalyticalObject( dataSet );
     }
 
     @Override
-    public int countIndicatorCharts( Indicator indicator )
+    public int countIndicatorMapViews( Indicator indicator )
     {
         return mapViewStore.countIndicatorAnalyticalObject( indicator );
     }
 
     @Override
-    public int countDataElementCharts( DataElement dataElement )
+    public int countDataElementMapViews( DataElement dataElement )
     {
         return mapViewStore.countDataElementAnalyticalObject( dataElement );
     }
+    
+    @Override
+    public int countOrganisationUnitMapViews( OrganisationUnit organisationUnit )
+    {
+        return mapViewStore.countOrganisationUnitAnalyticalObject( organisationUnit );
+    }
 
     @Override
     public int countMapLegendSetMapViews( MapLegendSet mapLegendSet )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapViewDeletionHandler.java	2014-04-28 11:24:08 +0000
@@ -32,11 +32,8 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.Period;
 import org.hisp.dhis.system.deletion.DeletionHandler;
 
-import java.util.Iterator;
-
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -66,88 +63,6 @@
     }
 
     @Override
-    public String allowDeletePeriod( Period period )
-    {
-        for ( MapView mapView : mappingService.getAllMapViews() )
-        {
-            if ( mapView.getPeriods().contains( period ) )
-            {
-                return mapView.getName();
-            }
-        }
-
-        return null;
-    }
-
-    @Override
-    public void deleteIndicator( Indicator indicator )
-    {
-        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
-
-        while ( mapViews.hasNext() )
-        {
-            MapView mapView = mapViews.next();
-
-            if ( mapView.getIndicators() != null && mapView.getIndicators().contains( indicator ) )
-            {
-                mapViews.remove();
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-
-    @Override
-    public void deleteDataElement( DataElement dataElement )
-    {
-        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
-
-        while ( mapViews.hasNext() )
-        {
-            MapView mapView = mapViews.next();
-
-            if ( mapView.getDataElements() != null && mapView.getDataElements().contains( dataElement ) )
-            {
-                mapViews.remove();
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-
-    @Override
-    public void deleteOrganisationUnit( OrganisationUnit organisationUnit )
-    {
-        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
-
-        while ( mapViews.hasNext() )
-        {
-            MapView mapView = mapViews.next();
-
-            if ( mapView.getOrganisationUnits() != null && mapView.getOrganisationUnits().contains( organisationUnit ) )
-            {
-                mapViews.remove();
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-
-    @Override
-    public void deleteMapLegendSet( MapLegendSet mapLegendSet )
-    {
-        Iterator<MapView> mapViews = mappingService.getAllMapViews().iterator();
-
-        while ( mapViews.hasNext() )
-        {
-            MapView mapView = mapViews.next();
-
-            if ( mapView.getLegendSet() != null && mapView.getLegendSet().equals( mapLegendSet ) )
-            {
-                mapViews.remove();
-                mappingService.deleteMapView( mapView );
-            }
-        }
-    }
-
-    @Override
     public String allowDeleteMapView( MapView mapView )
     {
         return mappingService.countMapViewMaps( mapView ) == 0 ? null : ERROR;
@@ -156,19 +71,25 @@
     @Override
     public String allowDeleteDataSet( DataSet dataSet )
     {
-        return mappingService.countDataSetCharts( dataSet ) == 0 ? null : ERROR;
+        return mappingService.countDataSetMapViews( dataSet ) == 0 ? null : ERROR;
     }
 
     @Override
     public String allowDeleteIndicator( Indicator indicator )
     {
-        return mappingService.countIndicatorCharts( indicator ) == 0 ? null : ERROR;
+        return mappingService.countIndicatorMapViews( indicator ) == 0 ? null : ERROR;
     }
 
     @Override
     public String allowDeleteDataElement( DataElement dataElement )
     {
-        return mappingService.countDataElementCharts( dataElement ) == 0 ? null : ERROR;
+        return mappingService.countDataElementMapViews( dataElement ) == 0 ? null : ERROR;
+    }
+    
+    @Override
+    public String allowDeleteOrganisationUnit( OrganisationUnit organisationUnit )
+    {
+        return mappingService.countOrganisationUnitMapViews( organisationUnit ) == 0 ? null : ERROR;
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java	2014-04-28 11:24:08 +0000
@@ -29,14 +29,10 @@
  */
 
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementGroup;
 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.system.deletion.DeletionHandler;
-import org.hisp.dhis.user.User;
 
 /**
  * @author Lars Helge Overland
@@ -83,103 +79,10 @@
     {
         return chartService.countDataElementCharts( dataElement ) == 0 ? null : ERROR;
     }
-
-    @Override
-    public String allowDeletePeriod( Period period )
-    {
-        for ( Chart chart : chartService.getAllCharts() )
-        {
-            if ( chart.getPeriods().contains( period ) )
-            {
-                return chart.getName();
-            }
-        }
-
-        return null;
-    }
-
-    @Override
-    public void deleteUser( User user )
-    {
-        for ( Chart chart : chartService.getAllCharts() )
-        {
-            if ( chart.getUser() != null && chart.getUser().equals( user ) )
-            {
-                chart.setUser( null );
-                chartService.updateChart( chart );
-            }
-        }
-    }
-
-    @Override
-    public void deleteIndicator( Indicator indicator )
-    {
-        for ( Chart chart : chartService.getAllCharts() )
-        {
-            if ( chart.getIndicators().remove( indicator ) )
-            {
-                chartService.updateChart( chart );
-            }
-        }
-    }
-
-    @Override
-    public void deleteDataElement( DataElement dataElement )
-    {
-        for ( Chart chart : chartService.getAllCharts() )
-        {
-            if ( chart.getDataElements().remove( chart ) )
-            {
-                chartService.updateChart( chart );
-            }
-        }
-    }
-
-    @Override
-    public void deleteDataSet( DataSet dataSet )
-    {
-        for ( Chart chart : chartService.getAllCharts() )
-        {
-            if ( chart.getDataSets().remove( chart ) )
-            {
-                chartService.updateChart( chart );
-            }
-        }
-    }
-
-    @Override
-    public void deleteOrganisationUnit( OrganisationUnit unit )
-    {
-        for ( Chart chart : chartService.getAllCharts() )
-        {
-            if ( chart.getOrganisationUnits().remove( unit ) )
-            {
-                chartService.updateChart( chart );
-            }
-        }
-    }
-
-    @Override
-    public void deleteDataElementGroup( DataElementGroup group )
-    {
-        for ( Chart chart : chartService.getAllCharts() )
-        {
-            if ( chart.getDataElementGroups().remove( group ) )
-            {
-                chartService.updateChart( chart );
-            }
-        }
-    }
-
-    @Override
-    public void deleteOrganisationUnitGroup( OrganisationUnitGroup group )
-    {
-        for ( Chart chart : chartService.getAllCharts() )
-        {
-            if ( chart.getOrganisationUnitGroups().remove( group ) )
-            {
-                chartService.updateChart( chart );
-            }
-        }
+    
+    @Override
+    public String allowDeleteOrganisationUnit( OrganisationUnit organisationUnit )
+    {
+        return chartService.countOrganisationUnitCharts( organisationUnit ) == 0 ? null : ERROR;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2014-04-02 12:07:12 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2014-04-28 11:24:08 +0000
@@ -871,4 +871,10 @@
     {
         return chartStore.countDataElementAnalyticalObject( dataElement );
     }
+    
+    @Override
+    public int countOrganisationUnitCharts( OrganisationUnit organisationUnit )
+    {
+        return chartStore.countOrganisationUnitAnalyticalObject( organisationUnit );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java	2014-04-28 11:24:08 +0000
@@ -29,18 +29,13 @@
  */
 
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementGroup;
 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.system.deletion.DeletionHandler;
-import org.hisp.dhis.user.User;
 
 /**
  * @author Lars Helge Overland
- * @version $Id$
  */
 public class ReportTableDeletionHandler
     extends DeletionHandler
@@ -67,101 +62,26 @@
     }
     
     @Override
-    public void deleteUser( User user )
-    {
-        for ( ReportTable reportTable : reportTableService.getAllReportTables() )
-        {
-            if ( reportTable.getUser() != null && reportTable.getUser().equals( reportTable ) )
-            {
-                reportTable.setUser( user );
-                reportTableService.updateReportTable( reportTable );
-            }
-        }
-    }
-
-    @Override
-    public void deleteDataElement( DataElement dataElement )
-    {
-        for ( ReportTable reportTable : reportTableService.getAllReportTables() )
-        {
-            if ( reportTable.getDataElements().remove( dataElement ) )
-            {
-                reportTableService.updateReportTable( reportTable );
-            }
-        }
-    }
-
-    @Override
-    public void deleteIndicator( Indicator indicator )
-    {
-        for ( ReportTable reportTable : reportTableService.getAllReportTables() )
-        {
-            if ( reportTable.getIndicators().remove( indicator ) )
-            {
-                reportTableService.updateReportTable( reportTable );
-            }
-        }
-    }
-
-    @Override
-    public void deleteDataSet( DataSet dataSet )
-    {
-        for ( ReportTable reportTable : reportTableService.getAllReportTables() )
-        {
-            if ( reportTable.getDataSets().remove( dataSet ) )
-            {
-                reportTableService.updateReportTable( reportTable );
-            }
-        }
-    }
-
-    @Override
-    public String allowDeletePeriod( Period period )
-    {
-        for ( ReportTable reportTable : reportTableService.getAllReportTables() )
-        {
-            if ( reportTable.getPeriods().contains( period ) )
-            {
-                return reportTable.getName();
-            }
-        }
-
-        return null;
-    }
-
-    @Override
-    public void deleteOrganisationUnit( OrganisationUnit unit )
-    {
-        for ( ReportTable reportTable : reportTableService.getAllReportTables() )
-        {
-            if ( reportTable.getOrganisationUnits().remove( unit ) )
-            {
-                reportTableService.updateReportTable( reportTable );
-            }
-        }
-    }
-
-    @Override
-    public void deleteDataElementGroup( DataElementGroup group )
-    {
-        for ( ReportTable reportTable : reportTableService.getAllReportTables() )
-        {
-            if ( reportTable.getDataElementGroups().remove( group ) )
-            {
-                reportTableService.updateReportTable( reportTable );
-            }
-        }
-    }
-    
-    @Override
-    public void deleteOrganisationUnitGroup( OrganisationUnitGroup group )
-    {
-        for ( ReportTable reportTable : reportTableService.getAllReportTables() )
-        {
-            if ( reportTable.getOrganisationUnitGroups().remove( group ) )
-            {
-                reportTableService.updateReportTable( reportTable );
-            }
-        }
+    public String allowDeleteDataSet( DataSet dataSet )
+    {
+        return reportTableService.countDataSetReportTables( dataSet ) == 0 ? null : ERROR;
+    }
+    
+    @Override
+    public String allowDeleteIndicator( Indicator indicator )
+    {
+        return reportTableService.countIndicatorReportTables( indicator ) == 0 ? null : ERROR;
+    }
+    
+    @Override
+    public String allowDeleteDataElement( DataElement dataElement )
+    {
+        return reportTableService.countDataElementReportTables( dataElement ) == 0 ? null : ERROR;
+    }
+    
+    @Override
+    public String allowDeleteOrganisationUnit( OrganisationUnit organisationUnit )
+    {
+        return reportTableService.countOrganisationUnitReportTables( organisationUnit ) == 0 ? null : ERROR;
     }
 }

=== 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	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2014-04-28 11:24:08 +0000
@@ -37,9 +37,12 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.analytics.AnalyticsService;
-import org.hisp.dhis.common.GenericIdentifiableObjectStore;
+import org.hisp.dhis.common.AnalyticalObjectStore;
 import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.report.ReportService;
@@ -71,9 +74,9 @@
         this.analyticsService = analyticsService;
     }
 
-    private GenericIdentifiableObjectStore<ReportTable> reportTableStore;
+    private AnalyticalObjectStore<ReportTable> reportTableStore;
 
-    public void setReportTableStore( GenericIdentifiableObjectStore<ReportTable> reportTableStore )
+    public void setReportTableStore( AnalyticalObjectStore<ReportTable> reportTableStore )
     {
         this.reportTableStore = reportTableStore;
     }
@@ -227,5 +230,25 @@
     public List<ReportTable> getReportTablesBetween( int first, int max )
     {
         return reportTableStore.getAllOrderedName( first, max );
-    } 
+    }
+    
+    public int countDataSetReportTables( DataSet dataSet )
+    {
+        return reportTableStore.countDataSetAnalyticalObject( dataSet );
+    }
+    
+    public int countIndicatorReportTables( Indicator indicator )
+    {
+        return reportTableStore.countIndicatorAnalyticalObject( indicator );
+    }
+    
+    public int countDataElementReportTables( DataElement dataElement )
+    {
+        return reportTableStore.countDataElementAnalyticalObject( dataElement );
+    }
+    
+    public int countOrganisationUnitReportTables( OrganisationUnit organisationUnit )
+    {
+        return reportTableStore.countOrganisationUnitAnalyticalObject( organisationUnit );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2014-04-02 12:07:12 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2014-04-28 11:24:08 +0000
@@ -6,7 +6,7 @@
 
   <!-- ReportTable -->
 
-  <bean id="org.hisp.dhis.reporttable.ReportTableStore" class="org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore">
+  <bean id="org.hisp.dhis.reporttable.ReportTableStore" class="org.hisp.dhis.common.hibernate.HibernateAnalyticalObjectStore">
     <property name="clazz" value="org.hisp.dhis.reporttable.ReportTable" />
     <property name="sessionFactory" ref="sessionFactory" />
     <property name="cacheable" value="true" />