← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15305: Deletion of category combination, including check for attributeoptioncombo in datavalues

 

------------------------------------------------------------
revno: 15305
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-05-19 17:19:17 +0200
message:
  Deletion of category combination, including check for attributeoptioncombo in datavalues
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionComboDeletionHandler.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.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/dataelement/DataElementCategoryOptionComboDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionComboDeletionHandler.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionComboDeletionHandler.java	2014-05-19 15:19:17 +0000
@@ -77,6 +77,9 @@
             "select count(*) from datavalue dv " +
             "where dv.categoryoptioncomboid in ( " +
                 "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " +
+                "where cc.categoryoptionid = " + categoryOption.getId() + " ) " +
+            "or dv.attributeoptioncomboid in ( " +
+                "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " +
                 "where cc.categoryoptionid = " + categoryOption.getId() + " );";
         
         return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR;
@@ -88,9 +91,13 @@
         final String sql =
             "select count(*) from datavalue dv " +
             "where dv.categoryoptioncomboid in ( " +
-              "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " +
-              "join categories_categoryoptions co on cc.categoryoptionid=co.categoryoptionid " +
-              "where co.categoryid=" + category.getId() + " );";        
+                "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " +
+                "join categories_categoryoptions co on cc.categoryoptionid=co.categoryoptionid " +
+                "where co.categoryid=" + category.getId() + " ) " +
+            "or dv.attributeoptioncomboid in ( " +
+                "select cc.categoryoptioncomboid from categoryoptioncombos_categoryoptions cc " +
+                "join categories_categoryoptions co on cc.categoryoptionid=co.categoryoptionid " +
+                "where co.categoryid=" + category.getId() + " );";
 
         return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR;
     }
@@ -101,8 +108,11 @@
         final String sql =
             "select count(*) from datavalue dv " +
             "where dv.categoryoptioncomboid in ( " +
-              "select co.categoryoptioncomboid from categorycombos_optioncombos co " +
-              "where co.categorycomboid=" + categoryCombo.getId() + " );";
+                "select co.categoryoptioncomboid from categorycombos_optioncombos co " +
+                "where co.categorycomboid=" + categoryCombo.getId() + " ) " +
+            "or dv.attributeoptioncomboid in ( " +
+                "select co.categoryoptioncomboid from categorycombos_optioncombos co " +
+                "where co.categorycomboid=" + categoryCombo.getId() + " );";
         
         return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2014-05-18 00:49:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2014-05-19 15:19:17 +0000
@@ -43,7 +43,6 @@
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataanalysis.DataAnalysisService;
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementOperand;
@@ -58,11 +57,10 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.validation.ValidationResult;
-import org.hisp.dhis.validation.ValidationRule;
 import org.hisp.dhis.validation.ValidationRuleService;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
-import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * @author Margrethe Store