dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13657
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4434: Cannot delete dataentry form when there are many program-stages use the same dataentry form.
------------------------------------------------------------
revno: 4434
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-08-25 12:06:11 +0700
message:
Cannot delete dataentry form when there are many program-stages use the same dataentry form.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelDataEntryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
--
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-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelDataEntryFormAction.java 2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/DelDataEntryFormAction.java 2011-08-25 05:06:11 +0000
@@ -27,8 +27,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.dataentryform.DataEntryFormService;
+import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageService;
@@ -64,11 +69,11 @@
// Getters & setters
// -------------------------------------------------------------------------
- private Integer associationId;
+ private Integer id;
- public void setAssociationId( int associationId )
+ public void setId( Integer id )
{
- this.associationId = associationId;
+ this.id = id;
}
private String message;
@@ -80,16 +85,18 @@
private Integer programStageId;
- public Integer getProgramStageId()
- {
- return programStageId;
- }
-
public void setProgramStageId( Integer programStageId )
{
this.programStageId = programStageId;
}
+ private Integer programId;
+
+ public Integer getProgramId()
+ {
+ return programId;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -97,13 +104,25 @@
public String execute()
throws Exception
{
- ProgramStage programStage = programStageService.getProgramStage( this.associationId );
-
- DataEntryForm dataEntryForm = programStage.getDataEntryForm();
-
- programStage.setDataEntryForm( null );
-
- programStageService.updateProgramStage( programStage );
+ DataEntryForm dataEntryForm = dataEntryFormService.getDataEntryForm( id );
+
+ Program currentProgram = programStageService.getProgramStage( programStageId ).getProgram();
+
+ programId = currentProgram.getId();
+
+ Set<ProgramStage> programStages = currentProgram.getProgramStages();
+
+ for ( ProgramStage programStage : programStages )
+ {
+ DataEntryForm programEntryForm = programStage.getDataEntryForm();
+
+ if ( programEntryForm != null && programEntryForm.equals( dataEntryForm ) )
+ {
+ programStage.setDataEntryForm( null );
+
+ programStageService.updateProgramStage( programStage );
+ }
+ }
dataEntryFormService.deleteDataEntryForm( dataEntryForm );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-08-03 04:48:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-08-25 05:06:11 +0000
@@ -481,4 +481,5 @@
duplicated_patient_list = Duplicated patient list
specfiy_birth_date_or_age = Specfiy birth date or age
update_this_patient = Update this beneficiary
-search_patients_by_attributes = Search beneficiaries by attributes
\ No newline at end of file
+search_patients_by_attributes = Search beneficiaries by attributes
+delete_program_data_entry_confirm = Do you want to delete program data entry ?
\ No newline at end of file