dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16754
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6450: Removing dataelements from sections when removing from data set
------------------------------------------------------------
revno: 6450
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-03-30 11:25:26 +0200
message:
Removing dataelements from sections when removing from data set
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml
--
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-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2012-03-06 03:17:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/UpdateDataSetAction.java 2012-03-30 09:25:26 +0000
@@ -35,6 +35,8 @@
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.dataset.Section;
+import org.hisp.dhis.dataset.SectionService;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.period.PeriodService;
@@ -76,13 +78,20 @@
{
this.dataElementService = dataElementService;
}
-
+
private IndicatorService indicatorService;
public void setIndicatorService( IndicatorService indicatorService )
{
this.indicatorService = indicatorService;
}
+
+ private SectionService sectionService;
+
+ public void setSectionService( SectionService sectionService )
+ {
+ this.sectionService = sectionService;
+ }
// -------------------------------------------------------------------------
// Input & output
@@ -202,6 +211,18 @@
dataSetService.updateDataSet( dataSet );
+ // ---------------------------------------------------------------------
+ // Remove data elements which are removed in data set from sections
+ // ---------------------------------------------------------------------
+
+ for ( Section section : dataSet.getSections() )
+ {
+ if ( section.getDataElements().retainAll( dataSet.getDataElements() ) )
+ {
+ sectionService.updateSection( section );
+ }
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2012-01-05 20:39:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2012-03-30 09:25:26 +0000
@@ -229,6 +229,9 @@
<property name="dataSetService">
<ref bean="org.hisp.dhis.dataset.DataSetService" />
</property>
+ <property name="sectionService">
+ <ref bean="org.hisp.dhis.dataset.SectionService" />
+ </property>
<property name="periodService">
<ref bean="org.hisp.dhis.period.PeriodService" />
</property>