← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 517: Improved deletion management of DashboardContent.

 

------------------------------------------------------------
revno: 517
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Sat 2009-08-29 08:56:46 +0200
message:
  Improved deletion management of DashboardContent.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/DashboardContentDeletionHandler.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/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/dashboard/DashboardService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java	2009-06-17 22:06:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dashboard/DashboardService.java	2009-08-29 06:56:46 +0000
@@ -27,6 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
 import org.hisp.dhis.user.User;
 
 /**
@@ -40,4 +42,6 @@
     void saveDashboardContent( DashboardContent dashboardContent );
         
     DashboardContent getDashboardContent( User user );
+    
+    Collection<DashboardContent> getAllDashboardContent();
 }

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml	2009-07-13 11:45:16 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml	2009-08-29 06:56:46 +0000
@@ -77,7 +77,10 @@
   <aop:config>
   
     <aop:aspect ref="deletionInterceptor">      
-      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.delete*(..) )" method="intercept"/>
+      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMap(..) )" method="intercept"/>
+      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapLegendSet(..) )" method="intercept"/>
+      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapOrganisationUnitRelation(..) )" method="intercept"/>
+      <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapView(..) )" method="intercept"/>
     </aop:aspect>
       
   </aop:config>

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/DashboardContentDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/DashboardContentDeletionHandler.java	2009-06-17 22:06:54 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/DashboardContentDeletionHandler.java	2009-08-29 06:56:46 +0000
@@ -42,6 +42,13 @@
 public class DashboardContentDeletionHandler
     extends DeletionHandler
 {
+    private DashboardService dashboardService;
+
+    public void setDashboardService( DashboardService dashboardService )
+    {
+        this.dashboardService = dashboardService;
+    }
+
     // -------------------------------------------------------------------------
     // DeletionHandler implementation
     // -------------------------------------------------------------------------
@@ -54,36 +61,72 @@
     @Override
     public void deleteReport( Report report )
     {
-        
+        for ( DashboardContent content : dashboardService.getAllDashboardContent() )
+        {
+            if ( content.getReports().remove( report ) )
+            {
+                dashboardService.saveDashboardContent( content );
+            }
+        }
     }
     
     @Override
     public void deleteOlapURL( OlapURL olapURL )
     {
-        
+        for ( DashboardContent content : dashboardService.getAllDashboardContent() )
+        {
+            if ( content.getOlapUrls().remove( olapURL ) )
+            {
+                dashboardService.saveDashboardContent( content );
+            }
+        }
     }
     
     @Override
     public void deleteDataMartExport( DataMartExport dataMartExport )
     {
-        
+        for ( DashboardContent content : dashboardService.getAllDashboardContent() )
+        {
+            if ( content.getDataMartExports().remove( dataMartExport ) )
+            {
+                dashboardService.saveDashboardContent( content );
+            }
+        }
     }
     
     @Override
     public void deleteDocument( Document document )
     {
-        
+        for ( DashboardContent content : dashboardService.getAllDashboardContent() )
+        {
+            if ( content.getDocuments().remove( document ) )
+            {
+                dashboardService.saveDashboardContent( content );
+            }
+        }
     }
     
     @Override
     public void deleteReportTable( ReportTable reportTable )
     {
-        
+        for ( DashboardContent content : dashboardService.getAllDashboardContent() )
+        {
+            if ( content.getReportTables().remove( reportTable ) )
+            {
+                dashboardService.saveDashboardContent( content );
+            }
+        }
     }
     
     @Override
     public void deleteMapView( MapView mapView )
     {
-        
+        for ( DashboardContent content : dashboardService.getAllDashboardContent() )
+        {
+            if ( content.getMapViews().remove( mapView ) )
+            {
+                dashboardService.saveDashboardContent( content );
+            }
+        }
     }
 }

=== 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	2009-08-29 04:24:43 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2009-08-29 06:56:46 +0000
@@ -27,6 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
 import org.hisp.dhis.dashboard.DashboardContent;
 import org.hisp.dhis.dashboard.DashboardContentStore;
 import org.hisp.dhis.dashboard.DashboardService;
@@ -67,4 +69,9 @@
         
         return content != null ? content : new DashboardContent( user );        
     }
+    
+    public Collection<DashboardContent> getAllDashboardContent()
+    {
+        return dashboardContentStore.getAll();
+    }
 }

=== 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	2009-08-21 16:44:05 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2009-08-29 06:56:46 +0000
@@ -288,6 +288,12 @@
       ref="org.hisp.dhis.chart.ChartService"/>
   </bean>
   
+  <bean id="org.hisp.dhis.dashboard.DashboardContentDeletionHandler"
+    class="org.hisp.dhis.dashboard.DashboardContentDeletionHandler">
+    <property name="dashboardService"
+      ref="org.hisp.dhis.dashboard.DashboardService"/>  
+  </bean>
+  
   <!-- DeletionManager -->
   
   <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
@@ -299,6 +305,7 @@
           <ref local="org.hisp.dhis.report.ReportDeletionHandler"/>
           <ref local="org.hisp.dhis.reporttable.ReportTableDeletionHandler"/>
           <ref local="org.hisp.dhis.chart.ChartDeletionHandler"/>
+          <ref local="org.hisp.dhis.dashboard.DashboardContentDeletionHandler"/>
         </list>
       </list>
     </property>