← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16884: Added category combo to DataSetDeletionHandler

 

------------------------------------------------------------
revno: 16884
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-09-30 20:04:19 +0200
message:
  Added category combo to DataSetDeletionHandler
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.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/dataset/DataSetDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.java	2014-09-29 18:29:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.java	2014-09-30 18:04:19 +0000
@@ -28,9 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
 import java.util.Iterator;
 
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -124,6 +126,21 @@
             dataSetService.updateDataSet( dataSet );
         }
     }
+    
+    @Override
+    public void deleteDataElementCategoryCombo( DataElementCategoryCombo categoryCombo )
+    {
+        Collection<DataSet> dataSets = dataSetService.getAllDataSets();
+
+        for ( DataSet dataSet : dataSets )
+        {            
+            if ( dataSet != null && categoryCombo.equals( dataSet.getCategoryCombo() ) )
+            {
+                dataSet.setCategoryCombo( null );
+                dataSetService.updateDataSet( dataSet );
+            }
+        }        
+    }
 
     @Override
     public void deleteOrganisationUnit( OrganisationUnit unit )