dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13676
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4449: Move deletion logic to the DeletionHandler (Patient module).
------------------------------------------------------------
revno: 4449
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-08-26 12:09:51 +0700
message:
Move deletion logic to the DeletionHandler (Patient module).
added:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramDataEntryFormDeletionHandler.java
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SaveDataEntryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ProgramEnrollmentSelectAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/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
=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramDataEntryFormDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramDataEntryFormDeletionHandler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramDataEntryFormDeletionHandler.java 2011-08-26 05:09:51 +0000
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.program;
+
+import java.util.Set;
+
+import org.hisp.dhis.dataentryform.DataEntryForm;
+import org.hisp.dhis.dataentryform.DataEntryFormService;
+import org.hisp.dhis.system.deletion.DeletionHandler;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ ProgramDataEntryDeletionHandler.java Aug 25, 2011 3:02:00 PM $
+ *
+ */
+public class ProgramDataEntryFormDeletionHandler
+ extends DeletionHandler
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
+ private ProgramStageService programStageService;
+
+ public void setProgramStageService( ProgramStageService programStageService )
+ {
+ this.programStageService = programStageService;
+ }
+
+ // -------------------------------------------------------------------------
+ // DeletionHandler implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String getClassName()
+ {
+ return DataEntryForm.class.getSimpleName();
+ }
+
+ @Override
+ public void deleteProgramStage( ProgramStage programStage )
+ {
+ DataEntryForm dataEntryForm = programStage.getDataEntryForm();
+
+ if ( dataEntryForm != null )
+ {
+ boolean flag = false;
+ Set<ProgramStage> programStages = programStage.getProgram().getProgramStages();
+ programStages.remove( programStage );
+ for ( ProgramStage stage : programStages )
+ {
+ if ( stage.getDataEntryForm() != null )
+ {
+ programStage.setDataEntryForm( null );
+ programStageService.updateProgramStage( programStage );
+ flag = true;
+ break;
+ }
+ }
+
+ if ( !flag )
+ {
+ dataEntryFormService.deleteDataEntryForm( dataEntryForm );
+ }
+ }
+
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2011-08-25 06:23:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2011-08-26 05:09:51 +0000
@@ -384,6 +384,11 @@
<bean id="org.hisp.dhis.program.ProgramValidationDeletionHandler" class="org.hisp.dhis.program.ProgramValidationDeletionHandler">
<property name="programValidationService" ref="org.hisp.dhis.program.ProgramValidationService" />
</bean>
+
+ <bean id="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler" class="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler">
+ <property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
+ <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+ </bean>
<!-- Startup -->
@@ -435,6 +440,7 @@
<ref local="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler"/>
<ref local="org.hisp.dhis.programattributevalue.ProgramAttributeValueDeletionHandler"/>
<ref local="org.hisp.dhis.program.ProgramValidationDeletionHandler"/>
+ <ref local="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler"/>
<ref local="org.hisp.dhis.caseaggregation.CaseAggregationConditionDeletionHandler"/>
</list>
@@ -504,6 +510,7 @@
<aop:before
pointcut="execution( * org.hisp.dhis.caseaggregation.CaseAggregationConditionService.delete*(..) )"
method="intercept"/>
+
</aop:aspect>
</aop:config>
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2011-06-02 02:34:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStage.hbm.xml 2011-08-26 05:09:51 +0000
@@ -25,7 +25,7 @@
<one-to-many class="org.hisp.dhis.program.ProgramStageDataElement" />
</set>
- <many-to-one name="dataEntryForm" class="org.hisp.dhis.dataentryform.DataEntryForm" cascade="all"
+ <many-to-one name="dataEntryForm" class="org.hisp.dhis.dataentryform.DataEntryForm"
foreign-key="fk_programstage_dataentryform" />
</class>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SaveDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SaveDataEntryFormAction.java 2011-05-08 14:16:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SaveDataEntryFormAction.java 2011-08-26 05:09:51 +0000
@@ -136,17 +136,17 @@
if ( dataEntryForm == null )
{
dataEntryForm = new DataEntryForm( name, dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
- programStage.setDataEntryForm( dataEntryForm );
- programStageService.updateProgramStage( programStage );
+ dataEntryFormService.addDataEntryForm( dataEntryForm );
}
else
{
dataEntryForm.setName( name );
dataEntryForm.setHtmlCode( dataEntryFormService.prepareDataEntryFormForSave( designTextarea ) );
-
- programStage.setDataEntryForm( dataEntryForm );
- programStageService.updateProgramStage( programStage );
- }
+ dataEntryFormService.updateDataEntryForm( dataEntryForm );
+ }
+
+ programStage.setDataEntryForm( dataEntryForm );
+ programStageService.updateProgramStage( programStage );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ProgramEnrollmentSelectAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ProgramEnrollmentSelectAction.java 2011-08-25 07:08:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ProgramEnrollmentSelectAction.java 2011-08-26 05:09:51 +0000
@@ -29,7 +29,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.program.Program;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageAction.java 2011-08-25 05:42:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageAction.java 2011-08-26 05:09:51 +0000
@@ -27,13 +27,6 @@
package org.hisp.dhis.patient.action.programstage;
-import java.util.Set;
-
-import org.hisp.dhis.dataentryform.DataEntryForm;
-import org.hisp.dhis.dataentryform.DataEntryFormService;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageDataElement;
-import org.hisp.dhis.program.ProgramStageDataElementService;
import org.hisp.dhis.program.ProgramStageService;
import com.opensymphony.xwork2.Action;
@@ -50,13 +43,6 @@
// Dependencies
// -------------------------------------------------------------------------
- private DataEntryFormService dataEntryFormService;
-
- public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
- {
- this.dataEntryFormService = dataEntryFormService;
- }
-
private ProgramStageService programStageService;
public void setProgramStageService( ProgramStageService programStageService )
@@ -64,13 +50,6 @@
this.programStageService = programStageService;
}
- private ProgramStageDataElementService programStageDataElementService;
-
- public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService )
- {
- this.programStageDataElementService = programStageDataElementService;
- }
-
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
@@ -89,50 +68,7 @@
public String execute()
throws Exception
{
- ProgramStage programStage = programStageService.getProgramStage( id );
-
- for ( ProgramStageDataElement de : programStage.getProgramStageDataElements() )
- {
- programStageDataElementService.deleteProgramStageDataElement( de );
- }
-
- // ---------------------------------------------------------------------
- // Check dataentry form of the selected programstage in other stages in
- // the program
- // ---------------------------------------------------------------------
-
- DataEntryForm dataEntryForm = programStage.getDataEntryForm();
-
- boolean flag = false;
-
- if ( dataEntryForm != null )
- {
- Set<ProgramStage> programStages = programStage.getProgram().getProgramStages();
-
- for ( ProgramStage stage : programStages )
- {
- if ( !stage.equals( programStage ) && stage.getDataEntryForm() != null )
- {
- flag = true;
- break;
- }
- }
-
- programStage.setDataEntryForm( null );
-
- programStageService.updateProgramStage( programStage );
-
- if ( !flag )
- {
- dataEntryFormService.deleteDataEntryForm( dataEntryForm );
- }
- }
-
- // ---------------------------------------------------------------------
- // Delete the selected program stage
- // ---------------------------------------------------------------------
-
- programStageService.deleteProgramStage( programStageService.getProgramStage( id ) );
+ programStageService.deleteProgramStage( programStageService.getProgramStage( id ) );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-08-25 07:08:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-08-26 05:09:51 +0000
@@ -705,10 +705,7 @@
id="org.hisp.dhis.patient.action.programstage.RemoveProgramStageAction"
class="org.hisp.dhis.patient.action.programstage.RemoveProgramStageAction"
scope="prototype">
- <property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
- <property name="programStageDataElementService"
- ref="org.hisp.dhis.program.ProgramStageDataElementService" />
</bean>
<bean