← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20378: Deletion handler

 

------------------------------------------------------------
revno: 20378
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-09-27 20:35:06 +0200
message:
  Deletion handler
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.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-services/dhis-service-core/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.java	2015-06-23 15:59:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.java	2015-09-27 18:35:06 +0000
@@ -28,7 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
+import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.system.deletion.DeletionHandler;
+import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * @author Chau Thu Tran
@@ -36,6 +40,9 @@
 public class ProgramStageSectionDeletionHandler
     extends DeletionHandler
 {
+    @Autowired
+    private IdentifiableObjectManager idObjectManager;
+    
     // -------------------------------------------------------------------------
     // DeletionHandler implementation
     // -------------------------------------------------------------------------
@@ -45,4 +52,18 @@
     {
         return ProgramStageSection.class.getSimpleName();
     }
+
+    @Override
+    public void deleteProgramIndicator( ProgramIndicator programIndicator )
+    {
+        Collection<ProgramStageSection> sections = idObjectManager.getAllNoAcl( ProgramStageSection.class );
+        
+        for ( ProgramStageSection section : sections )
+        {
+            if ( section.getProgramIndicators().remove( programIndicator ) )
+            {
+                idObjectManager.update( section );
+            }
+        }
+    }
 }