← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17939: Deletion handling, including attribute option combo

 

------------------------------------------------------------
revno: 17939
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-01-12 10:33:46 +0100
message:
  Deletion handling, including attribute option combo
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.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/datavalue/DataValueDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueDeletionHandler.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueDeletionHandler.java	2015-01-12 09:33:46 +0000
@@ -88,9 +88,9 @@
     }
     
     @Override
-    public String allowDeleteDataElementCategoryOptionCombo( DataElementCategoryOptionCombo combo )
+    public String allowDeleteDataElementCategoryOptionCombo( DataElementCategoryOptionCombo optionCombo )
     {
-        String sql = "SELECT COUNT(*) FROM datavalue where categoryoptioncomboid=" + combo.getId();
+        String sql = "SELECT COUNT(*) FROM datavalue where categoryoptioncomboid=" + optionCombo.getId() + " or attributeoptioncomboid=" + optionCombo.getId();
         
         return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java	2014-11-07 16:03:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java	2015-01-12 09:33:46 +0000
@@ -128,7 +128,7 @@
     public int deleteDataValueAuditByDataElement( DataElement dataElement )
     {
         Query query = sessionFactory.getCurrentSession()
-            .createQuery( "DELETE DataValueAudit WHERE dataElement = :dataElement" )
+            .createQuery( "delete DataValueAudit where dataElement = :dataElement" )
             .setEntity( "dataElement", dataElement );
 
         return query.executeUpdate();
@@ -140,7 +140,7 @@
         Period storedPeriod = periodStore.reloadPeriod( period );
 
         Query query = sessionFactory.getCurrentSession()
-            .createQuery( "DELETE DataValueAudit WHERE period = :period" )
+            .createQuery( "delete DataValueAudit where period = :period" )
             .setEntity( "period", storedPeriod );
 
         return query.executeUpdate();
@@ -150,7 +150,7 @@
     public int deleteDataValueAuditByOrganisationUnit( OrganisationUnit organisationUnit )
     {
         Query query = sessionFactory.getCurrentSession()
-            .createQuery( "DELETE DataValueAudit WHERE organisationUnit = :organisationUnit" )
+            .createQuery( "delete DataValueAudit where organisationUnit = :organisationUnit" )
             .setEntity( "organisationUnit", organisationUnit );
 
         return query.executeUpdate();
@@ -160,7 +160,7 @@
     public int deleteDataValueAuditByCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo )
     {
         Query query = sessionFactory.getCurrentSession()
-            .createQuery( "DELETE DataValueAudit WHERE categoryOptionCombo = :categoryOptionCombo" )
+            .createQuery( "delete DataValueAudit where categoryOptionCombo = :categoryOptionCombo or attributeOptionCombo = :categoryOptionCombo" )
             .setEntity( "categoryOptionCombo", categoryOptionCombo );
 
         return query.executeUpdate();