← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18107: Added missing deletion handler

 

------------------------------------------------------------
revno: 18107
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-01-22 18:53:46 +0100
message:
  Added missing deletion handler
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalDeletionHandler.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DefaultDeletionManager.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/dataapproval/DataApprovalDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalDeletionHandler.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DataApprovalDeletionHandler.java	2015-01-22 17:53:46 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.system.deletion.DeletionHandler;
 import org.springframework.jdbc.core.JdbcTemplate;
 
@@ -61,8 +62,16 @@
     @Override
     public String allowDeleteDataApprovalLevel( DataApprovalLevel dataApprovalLevel )
     {
-        String sql = "SELECT COUNT(*) FROM dataapproval where dataapprovallevelid=" + dataApprovalLevel.getId();
-
+        String sql = "select count(*) from dataapproval where dataapprovallevelid=" + dataApprovalLevel.getId();
+
+        return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR;
+    }
+
+    @Override
+    public String allowDeleteDataElementCategoryOptionCombo( DataElementCategoryOptionCombo optionCombo )
+    {
+        String sql = "select count(*) from dataapproval where attributeoptioncomboid=" + optionCombo.getId();
+        
         return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR;
     }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DefaultDeletionManager.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DefaultDeletionManager.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DefaultDeletionManager.java	2015-01-22 17:53:46 +0000
@@ -40,8 +40,10 @@
 import java.util.List;
 
 /**
+ * TODO: Add support for failed allow tests on "transitive" deletion handlers which
+ * are called as part of delete methods.
+ * 
  * @author Lars Helge Overland
- * @version $Id$
  */
 public class DefaultDeletionManager
     implements DeletionManager
@@ -102,6 +104,8 @@
 
                     String message = handler.getClassName() + (hint.isEmpty() ? "" : (" (" + hint + ")"));
 
+                    log.info( "Delete was not allowed by " + currentHandler + ": " + message );
+                    
                     throw new DeleteNotAllowedException( DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS, message );
                 }
             }