← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20553: updates to programstage* deletion handlers

 

------------------------------------------------------------
revno: 20553
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-10-07 11:52:14 +0700
message:
  updates to programstage* deletion handlers
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java
  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/ProgramStageDataElementDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java	2015-10-07 04:35:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java	2015-10-07 04:52:14 +0000
@@ -28,12 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementDomain;
 import org.hisp.dhis.system.deletion.DeletionHandler;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Chau Thu Tran
@@ -61,11 +64,11 @@
     @Override
     public void deleteProgramStage( ProgramStage programStage )
     {
-        Iterator<ProgramStageDataElement> programStageDataElementIterator = programStage.getProgramStageDataElements().iterator();
+        List<ProgramStageDataElement> programStageDataElements = new ArrayList<>( programStage.getProgramStageDataElements() );
 
-        while ( programStageDataElementIterator.hasNext() )
+        for ( ProgramStageDataElement programStageDataElement : programStageDataElements )
         {
-            ProgramStageDataElement programStageDataElement = programStageDataElementIterator.next();
+            programStage.getProgramStageDataElements().remove( programStageDataElement );
             programStageDataElementService.deleteProgramStageDataElement( programStageDataElement );
         }
     }

=== 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-10-07 04:35:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.java	2015-10-07 04:52:14 +0000
@@ -32,8 +32,9 @@
 import org.hisp.dhis.system.deletion.DeletionHandler;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Chau Thu Tran
@@ -74,11 +75,11 @@
     @Override
     public void deleteProgramStage( ProgramStage programStage )
     {
-        Iterator<ProgramStageSection> programStageSectionIterator = programStage.getProgramStageSections().iterator();
+        List<ProgramStageSection> programStageSections = new ArrayList<>( programStage.getProgramStageSections() );
 
-        while ( programStageSectionIterator.hasNext() )
+        for ( ProgramStageSection programStageSection : programStageSections )
         {
-            ProgramStageSection programStageSection = programStageSectionIterator.next();
+            programStage.getProgramStageSections().remove( programStageSection );
             programStageSectionService.deleteProgramStageSection( programStageSection );
         }
     }