← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13666: Improved deletion handlers. Atttempted fix for problem with ghost data set in cache.

 

------------------------------------------------------------
revno: 13666
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-01-09 11:09:43 +0100
message:
  Improved deletion handlers. Atttempted fix for problem with ghost data set in cache.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementGroupDeletionHandler.java
  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/indicator/IndicatorDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorGroupDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRuleDeletionHandler.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/DataElementGroupController.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/dataset/DataSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2014-01-02 13:13:21 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSet.java	2014-01-09 10:09:43 +0000
@@ -270,10 +270,10 @@
         organisationUnit.getDataSets().add( this );
     }
 
-    public void removeOrganisationUnit( OrganisationUnit organisationUnit )
+    public boolean removeOrganisationUnit( OrganisationUnit organisationUnit )
     {
         sources.remove( organisationUnit );
-        organisationUnit.getDataSets().remove( this );
+        return organisationUnit.getDataSets().remove( this );
     }
 
     public void removeAllOrganisationUnits()
@@ -308,10 +308,10 @@
         group.getDataSets().add( this );
     }
 
-    public void removeOrganisationUnitGroup( OrganisationUnitGroup group )
+    public boolean removeOrganisationUnitGroup( OrganisationUnitGroup group )
     {
         organisationUnitGroups.remove( group );
-        group.getDataSets().remove( this );
+        return group.getDataSets().remove( this );
     }
 
     public void removeAllOrganisationUnitGroups()
@@ -346,10 +346,10 @@
         dataElement.getDataSets().add( this );
     }
 
-    public void removeDataElement( DataElement dataElement )
+    public boolean removeDataElement( DataElement dataElement )
     {
         dataElements.remove( dataElement );
-        dataElement.getDataSets().remove( dataElement );
+        return dataElement.getDataSets().remove( dataElement );
     }
 
     public void updateDataElements( Set<DataElement> updates )
@@ -374,10 +374,10 @@
         indicator.getDataSets().add( this );
     }
 
-    public void removeIndicator( Indicator indicator )
+    public boolean removeIndicator( Indicator indicator )
     {
         indicators.remove( indicator );
-        indicator.getDataSets().remove( this );
+        return indicator.getDataSets().remove( this );
     }
 
     public void addCompulsoryDataElementOperand( DataElementOperand dataElementOperand )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java	2013-12-20 12:15:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java	2014-01-09 10:09:43 +0000
@@ -103,7 +103,7 @@
         while ( iterator.hasNext() )
         {
             DataElement element = iterator.next();
-            element.getDataSets().remove( dataSet );
+            element.removeDataSet( dataSet );
             dataElementService.updateDataElement( element );            
         }
     }
@@ -116,7 +116,7 @@
         while ( iterator.hasNext() )
         {
             DataElement element = iterator.next();
-            element.getGroups().remove( group );
+            element.removeDataElementGroup( group );
             dataElementService.updateDataElement( element );
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementGroupDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementGroupDeletionHandler.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementGroupDeletionHandler.java	2014-01-09 10:09:43 +0000
@@ -68,7 +68,7 @@
         while ( iterator.hasNext() )
         {
             DataElementGroup group = iterator.next();
-            group.getMembers().remove( dataElement );
+            group.removeDataElement( dataElement );
             dataElementService.updateDataElementGroup( group );
         }
     }

=== 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	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.java	2014-01-09 10:09:43 +0000
@@ -68,20 +68,26 @@
     @Override
     public void deleteDataElement( DataElement dataElement )
     {
+        Iterator<DataSet> iterator = dataElement.getDataSets().iterator();
+        
+        while ( iterator.hasNext() )
+        {
+            DataSet dataSet = iterator.next();
+            dataSet.removeDataElement( dataElement );
+            dataSetService.updateDataSet( dataSet );
+        }
+        
         for ( DataSet dataSet : dataSetService.getAllDataSets() )
         {
             boolean update = false;
             
-            if ( dataSet.getDataElements().remove( dataElement ) )
-            {
-                update = true;
-            }
-            
             Iterator<DataElementOperand> operands = dataSet.getCompulsoryDataElementOperands().iterator();
             
             while ( operands.hasNext() )
             {
-                if ( operands.next().getDataElement().equals( dataElement ) )
+                DataElementOperand operand = operands.next();
+                
+                if ( operand.getDataElement().equals( dataElement ) )
                 {
                     operands.remove();
                     update = true;
@@ -103,7 +109,7 @@
         while ( iterator.hasNext() )
         {
             DataSet dataSet = iterator.next();
-            dataSet.getIndicators().remove( indicator );
+            dataSet.removeIndicator( indicator );
             dataSetService.updateDataSet( dataSet );
         }
     }
@@ -128,7 +134,7 @@
         while ( iterator.hasNext() )
         {
             DataSet dataSet = iterator.next();
-            dataSet.getSources().remove( unit );
+            dataSet.removeOrganisationUnit( unit );
             dataSetService.updateDataSet( dataSet );
         }
     }
@@ -141,7 +147,7 @@
         while ( iterator.hasNext() )
         {
             DataSet dataSet = iterator.next();
-            dataSet.getOrganisationUnitGroups().remove( group );
+            dataSet.removeOrganisationUnitGroup( group );
             dataSetService.updateDataSet( dataSet );
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java	2013-12-20 12:15:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java	2014-01-09 10:09:43 +0000
@@ -96,7 +96,7 @@
         while ( iterator.hasNext() )
         {
             Indicator indicator = iterator.next();
-            indicator.getGroups().remove( group );
+            indicator.removeIndicatorGroup( group );
             indicatorService.updateIndicator( indicator );
         }
     }
@@ -109,7 +109,7 @@
         while ( iterator.hasNext() )
         {
             Indicator indicator = iterator.next();
-            indicator.getDataSets().remove( dataSet );
+            indicator.removeDataSet( dataSet );
             indicatorService.updateIndicator( indicator );
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorGroupDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorGroupDeletionHandler.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorGroupDeletionHandler.java	2014-01-09 10:09:43 +0000
@@ -67,7 +67,7 @@
         while ( iterator.hasNext() )
         {
             IndicatorGroup group = iterator.next();
-            group.getMembers().remove( indicator );
+            group.removeIndicator( indicator );
             indicatorService.updateIndicatorGroup( group );
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupDeletionHandler.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupDeletionHandler.java	2014-01-09 10:09:43 +0000
@@ -69,7 +69,7 @@
         while ( iterator.hasNext() )
         {
             OrganisationUnitGroup group = iterator.next();
-            group.getMembers().remove( unit );
+            group.removeOrganisationUnit( unit );
             organisationUnitGroupService.updateOrganisationUnitGroup( group );
         }
     }
@@ -82,7 +82,7 @@
         while ( iterator.hasNext() )
         {
             OrganisationUnitGroup group = iterator.next();
-            group.getDataSets().remove( dataSet );
+            group.removeDataSet( dataSet );
             organisationUnitGroupService.updateOrganisationUnitGroup( group );
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRuleDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRuleDeletionHandler.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidationRuleDeletionHandler.java	2014-01-09 10:09:43 +0000
@@ -35,7 +35,6 @@
 
 /**
  * @author Lars Helge Overland
- * @version $Id$
  */
 public class ValidationRuleDeletionHandler
     extends DeletionHandler
@@ -80,4 +79,17 @@
             }
         }
     }
+    
+    @Override
+    public void deleteValidationRuleGroup( ValidationRule validationRule )
+    {
+        Iterator<ValidationRuleGroup> iterator = validationRule.getGroups().iterator();
+        
+        while ( iterator.hasNext() )
+        {
+            ValidationRuleGroup group = iterator.next();
+            iterator.remove();
+            validationRuleService.updateValidationRuleGroup( group );
+        }
+    }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java	2013-12-13 11:08:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java	2014-01-09 10:09:43 +0000
@@ -339,6 +339,15 @@
     {
         return null;
     }
+    
+    public void deleteValidationRuleGroup( ValidationRule validationRule )
+    {
+    }
+    
+    public String allowDeleteValidationRuleGroup( ValidationRule validationRule )
+    {
+        return null;
+    }
 
     public void deleteValidationRuleGroup( ValidationRuleGroup validationRuleGroup )
     {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/DataElementGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/DataElementGroupController.java	2014-01-08 11:19:03 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/DataElementGroupController.java	2014-01-09 10:09:43 +0000
@@ -28,7 +28,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.hisp.dhis.api.controller.AbstractCrudController;
 import org.hisp.dhis.api.controller.WebMetaData;
 import org.hisp.dhis.api.controller.WebOptions;
@@ -38,7 +43,6 @@
 import org.hisp.dhis.common.PagerUtils;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dxf2.metadata.MetaData;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.util.StringUtils;
@@ -47,11 +51,7 @@
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import com.google.common.collect.Lists;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>