dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41814
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21338: bug-fix in editing program stage data elements / sections
------------------------------------------------------------
revno: 21338
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-12-04 16:47:02 +0100
message:
bug-fix in editing program stage data elements / sections
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.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-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java 2015-11-24 10:38:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/programstage/UpdateProgramStageAction.java 2015-12-04 15:47:02 +0000
@@ -29,6 +29,7 @@
*/
import com.opensymphony.xwork2.Action;
+
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.dataelement.DataElement;
@@ -38,6 +39,8 @@
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageDataElement;
import org.hisp.dhis.program.ProgramStageDataElementService;
+import org.hisp.dhis.program.ProgramStageSection;
+import org.hisp.dhis.program.ProgramStageSectionService;
import org.hisp.dhis.program.ProgramStageService;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
import org.hisp.dhis.user.UserGroup;
@@ -96,6 +99,9 @@
@Autowired
private AttributeService attributeService;
+
+ @Autowired
+ private ProgramStageSectionService programStageSectionService;
// -------------------------------------------------------------------------
// Input/Output
@@ -433,10 +439,8 @@
Set<ProgramStageDataElement> programStageDataElements = new HashSet<>(
programStage.getProgramStageDataElements() );
- programStage.getProgramStageDataElements().clear();
-
for ( int i = 0; i < this.selectedDataElementsValidator.size(); i++ )
- {
+ {
DataElement dataElement = dataElementService.getDataElement( selectedDataElementsValidator.get( i ) );
Boolean allowed = allowProvidedElsewhere.get( i ) == null ? false : allowProvidedElsewhere.get( i );
Boolean displayInReport = displayInReports.get( i ) == null ? false : displayInReports.get( i );
@@ -462,20 +466,23 @@
programStageDataElement.setDisplayInReports( displayInReport );
programStageDataElement.setAllowFutureDate( allowDate );
programStageDataElementService.updateProgramStageDataElement( programStageDataElement );
-
programStageDataElements.remove( programStageDataElement );
- }
-
- programStage.getProgramStageDataElements().add( programStageDataElement );
+ }
+ }
+
+ for ( ProgramStageSection section : programStage.getProgramStageSections() )
+ {
+ section.getProgramStageDataElements().removeAll( programStageDataElements );
+ programStageSectionService.updateProgramStageSection( section );
}
- programStageService.updateProgramStage( programStage );
-
for ( ProgramStageDataElement psdeDelete : programStageDataElements )
- {
+ {
+ programStage.getProgramStageDataElements().remove( psdeDelete );
programStageDataElementService.deleteProgramStageDataElement( psdeDelete );
}
+ programStageService.updateProgramStage( programStage );
programId = programStage.getProgram().getId();
return SUCCESS;