← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13221: add deletionhandler support for charts, reportTables

 

------------------------------------------------------------
revno: 13221
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-13 13:02:13 +0100
message:
  add deletionhandler support for charts, reportTables
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItemStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationStore.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/DashboardItemDeletionHandler.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardItemStore.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/InterpretationDeletionHandler.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/hibernate/HibernateInterpretationStore.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.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/dashboard/DashboardItemStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItemStore.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardItemStore.java	2013-12-13 12:02:13 +0000
@@ -28,8 +28,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.reporttable.ReportTable;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -38,4 +40,8 @@
     extends GenericIdentifiableObjectStore<DashboardItem>
 {
     int countMapDashboardItems( Map map );
+
+    int countChartDashboardItems( Chart chart );
+
+    int countReportTableDashboardItems( ReportTable reportTable );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java	2013-12-13 12:02:13 +0000
@@ -1,7 +1,9 @@
 package org.hisp.dhis.dashboard;
 
+import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.interpretation.Interpretation;
 import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.user.User;
 
 import java.util.List;
@@ -66,4 +68,8 @@
     List<Dashboard> getByUser( User user );
 
     int countMapDashboardItems( Map map );
+
+    int countChartDashboardItems( Chart chart );
+
+    int countReportTableDashboardItems( ReportTable reportTable );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationService.java	2013-12-13 12:02:13 +0000
@@ -28,7 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.reporttable.ReportTable;
 
 import java.util.Date;
 import java.util.List;
@@ -61,4 +63,8 @@
     long getNewInterpretationCount();
 
     int countMapInterpretations( Map map );
+
+    int countChartInterpretations( Chart chart );
+
+    int countReportTableInterpretations( ReportTable reportTable );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationStore.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/interpretation/InterpretationStore.java	2013-12-13 12:02:13 +0000
@@ -28,8 +28,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.reporttable.ReportTable;
 
 /**
  * @author Lars Helge Overland
@@ -38,4 +40,8 @@
     extends GenericIdentifiableObjectStore<Interpretation>
 {
     int countMapInterpretations( Map map );
+
+    int countChartInterpretations( Chart chart );
+
+    int countReportTableInterpretations( ReportTable reportTable );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/DashboardItemDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/DashboardItemDeletionHandler.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/DashboardItemDeletionHandler.java	2013-12-13 12:02:13 +0000
@@ -28,7 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.system.deletion.DeletionHandler;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -51,4 +53,16 @@
     {
         return dashboardService.countMapDashboardItems( map ) == 0 ? null : ERROR;
     }
+
+    @Override
+    public String allowDeleteChart( Chart chart )
+    {
+        return dashboardService.countChartDashboardItems( chart ) == 0 ? null : ERROR;
+    }
+
+    @Override
+    public String allowDeleteReportTable( ReportTable reportTable )
+    {
+        return dashboardService.countReportTableDashboardItems( reportTable ) == 0 ? null : ERROR;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardItemStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardItemStore.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/hibernate/HibernateDashboardItemStore.java	2013-12-13 12:02:13 +0000
@@ -29,10 +29,12 @@
  */
 
 import org.hibernate.Query;
+import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.dashboard.DashboardItem;
 import org.hisp.dhis.dashboard.DashboardItemStore;
 import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.reporttable.ReportTable;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -48,4 +50,22 @@
 
         return ((Long) query.uniqueResult()).intValue();
     }
+
+    @Override
+    public int countChartDashboardItems( Chart chart )
+    {
+        Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where c.chart=:chart" );
+        query.setEntity( "chart", chart );
+
+        return ((Long) query.uniqueResult()).intValue();
+    }
+
+    @Override
+    public int countReportTableDashboardItems( ReportTable reportTable )
+    {
+        Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where c.reportTable=:reportTable" );
+        query.setEntity( "reportTable", reportTable );
+
+        return ((Long) query.uniqueResult()).intValue();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2013-12-13 12:02:13 +0000
@@ -276,6 +276,18 @@
         return dashboardItemStore.countMapDashboardItems( map );
     }
 
+    @Override
+    public int countChartDashboardItems( Chart chart )
+    {
+        return dashboardItemStore.countChartDashboardItems( chart );
+    }
+
+    @Override
+    public int countReportTableDashboardItems( ReportTable reportTable )
+    {
+        return dashboardItemStore.countReportTableDashboardItems( reportTable );
+    }
+
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/InterpretationDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/InterpretationDeletionHandler.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/InterpretationDeletionHandler.java	2013-12-13 12:02:13 +0000
@@ -28,7 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.system.deletion.DeletionHandler;
 import org.hisp.dhis.user.User;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -69,4 +71,16 @@
     {
         return interpretationService.countMapInterpretations( map ) == 0 ? null : ERROR;
     }
+
+    @Override
+    public String allowDeleteChart( Chart chart )
+    {
+        return interpretationService.countChartInterpretations( chart ) == 0 ? null : ERROR;
+    }
+
+    @Override
+    public String allowDeleteReportTable( ReportTable reportTable )
+    {
+        return interpretationService.countReportTableInterpretations( reportTable ) == 0 ? null : ERROR;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/hibernate/HibernateInterpretationStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/hibernate/HibernateInterpretationStore.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/hibernate/HibernateInterpretationStore.java	2013-12-13 12:02:13 +0000
@@ -29,10 +29,12 @@
  */
 
 import org.hibernate.Query;
+import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.interpretation.Interpretation;
 import org.hisp.dhis.interpretation.InterpretationStore;
 import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.user.User;
 
 import java.util.List;
@@ -77,4 +79,22 @@
 
         return ((Long) query.uniqueResult()).intValue();
     }
+
+    @Override
+    public int countChartInterpretations( Chart chart )
+    {
+        Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where c.chart=:chart" );
+        query.setEntity( "chart", chart );
+
+        return ((Long) query.uniqueResult()).intValue();
+    }
+
+    @Override
+    public int countReportTableInterpretations( ReportTable reportTable )
+    {
+        Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where c.reportTable=:reportTable" );
+        query.setEntity( "reportTable", reportTable );
+
+        return ((Long) query.uniqueResult()).intValue();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java	2013-12-13 11:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/interpretation/impl/DefaultInterpretationService.java	2013-12-13 12:02:13 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.interpretation.Interpretation;
 import org.hisp.dhis.interpretation.InterpretationComment;
@@ -35,6 +36,7 @@
 import org.hisp.dhis.interpretation.InterpretationStore;
 import org.hisp.dhis.mapping.Map;
 import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserService;
@@ -199,4 +201,16 @@
     {
         return interpretationStore.countMapInterpretations( map );
     }
+
+    @Override
+    public int countChartInterpretations( Chart chart )
+    {
+        return interpretationStore.countChartInterpretations( chart );
+    }
+
+    @Override
+    public int countReportTableInterpretations( ReportTable reportTable )
+    {
+        return interpretationStore.countReportTableInterpretations( reportTable );
+    }
 }