dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15778
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5812: Including compulsory data elements in DataSetDeletionHandler
------------------------------------------------------------
revno: 5812
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-01-26 22:27:44 +0100
message:
Including compulsory data elements in DataSetDeletionHandler
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.java
resources/sql/div.sql
--
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 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DataSetDeletionHandler.java 2012-01-26 21:27:44 +0000
@@ -27,7 +27,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Iterator;
+
import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.system.deletion.DeletionHandler;
@@ -65,8 +68,26 @@
{
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 ) )
+ {
+ operands.remove();
+ update = true;
+ }
+ }
+
+ if ( update )
+ {
dataSetService.updateDataSet( dataSet );
}
}
=== modified file 'resources/sql/div.sql'
--- resources/sql/div.sql 2012-01-26 18:36:12 +0000
+++ resources/sql/div.sql 2012-01-26 21:27:44 +0000
@@ -44,4 +44,5 @@
select cc.categorycomboid, cc.name as categorycomboname, cn.* from _categoryoptioncomboname cn
join categorycombos_optioncombos co using(categoryoptioncomboid)
-join categorycombo cc using(categorycomboid);
+join categorycombo cc using(categorycomboid)
+order by categorycomboname;