dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19252
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8316: DeletionHandler for program-stage-section
------------------------------------------------------------
revno: 8316
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-10-01 16:28:45 +0700
message:
DeletionHandler for program-stage-section
added:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.java
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageInstanceDeletionHandler.java
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/ProgramStageSection.hbm.xml
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageSectionAction.java
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/webapp/dhis-web-maintenance-patient/addProgramForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm
--
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-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java 2012-07-02 12:40:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java 2012-10-01 09:28:45 +0000
@@ -53,6 +53,13 @@
this.programStageDEService = programStageDEService;
}
+ private ProgramStageSectionService programStageSectionService;
+
+ public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService )
+ {
+ this.programStageSectionService = programStageSectionService;
+ }
+
// -------------------------------------------------------------------------
// Implementation methods
// -------------------------------------------------------------------------
@@ -74,13 +81,13 @@
for ( ProgramStage programStage : programStages )
{
- Collection<ProgramStageDataElement> dataElements = programStageDEService.get( programStage );
+ Collection<ProgramStageDataElement> psDataElements = programStageDEService.get( programStage );
- if ( dataElements != null && dataElements.size() > 0 )
+ if ( psDataElements != null && psDataElements.size() > 0 )
{
- for ( ProgramStageDataElement dataElement : dataElements )
+ for ( ProgramStageDataElement psDataElement : psDataElements )
{
- programStageDEService.deleteProgramStageDataElement( dataElement );
+ programStageDEService.deleteProgramStageDataElement( psDataElement );
}
}
@@ -90,34 +97,34 @@
@Override
public void deleteProgramStage( ProgramStage programStage )
{
- // ---------------------------------------------------------------------
- // Delete Program Stage data elements
- // ---------------------------------------------------------------------
-
- Collection<ProgramStageDataElement> dataElements = programStageDEService.get( programStage );
-
- if ( dataElements != null && dataElements.size() > 0 )
+ Collection<ProgramStageDataElement> psDataElements = programStage.getProgramStageDataElements();
+ for ( ProgramStageDataElement psDataElement : psDataElements )
{
- for ( ProgramStageDataElement dataElement : dataElements )
- {
- programStageDEService.deleteProgramStageDataElement( dataElement );
- }
+ programStageDEService.deleteProgramStageDataElement( psDataElement );
}
}
@Override
+ public void deleteProgramStageSection( ProgramStageSection programStageSection )
+ {
+ programStageSection.getProgramStageDataElements().clear();
+ programStageSectionService.updateProgramStageSection( programStageSection );
+ }
+
+ @Override
public String allowDeleteDataElement( DataElement dataElement )
{
if ( dataElement != null && DataElement.DOMAIN_TYPE_PATIENT.equals( dataElement.getDomainType() ) )
{
// TODO use a query which will be more efficient
- Iterator<ProgramStageDataElement> iterator = programStageDEService.getAllProgramStageDataElements().iterator();
-
+ Iterator<ProgramStageDataElement> iterator = programStageDEService.getAllProgramStageDataElements()
+ .iterator();
+
while ( iterator.hasNext() )
{
ProgramStageDataElement element = iterator.next();
-
+
if ( element.getDataElement() != null && element.getDataElement().equals( dataElement ) )
{
programStageDEService.deleteProgramStageDataElement( element );
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageInstanceDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageInstanceDeletionHandler.java 2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageInstanceDeletionHandler.java 2012-10-01 09:28:45 +0000
@@ -57,7 +57,7 @@
@Override
public String getClassName()
{
- return ProgramStageDataElement.class.getSimpleName();
+ return ProgramStageInstance.class.getSimpleName();
}
@Override
=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.java 2012-10-01 09:28:45 +0000
@@ -0,0 +1,67 @@
+/*
+ * 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 org.hisp.dhis.system.deletion.DeletionHandler;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version ProgramStageSectionDeletionHandler.java 3:14:59 PM Oct 1, 2012 $
+ */
+public class ProgramStageSectionDeletionHandler
+ extends DeletionHandler
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramStageService programStageService;
+
+ public void setProgramStageService( ProgramStageService programStageService )
+ {
+ this.programStageService = programStageService;
+ }
+
+ // -------------------------------------------------------------------------
+ // DeletionHandler implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String getClassName()
+ {
+ return ProgramStageSection.class.getSimpleName();
+ }
+
+ @Override
+ public void deleteProgramStage( ProgramStage programStage )
+ {
+ programStage.getProgramStageSections().clear();
+ programStageService.updateProgramStage( programStage );
+ }
+}
=== 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 2012-10-01 06:20:05 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-10-01 09:28:45 +0000
@@ -331,6 +331,8 @@
class="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler">
<property name="programStageDEService"
ref="org.hisp.dhis.program.ProgramStageDataElementService" />
+ <property name="programStageSectionService"
+ ref="org.hisp.dhis.program.ProgramStageSectionService" />
</bean>
<bean id="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler"
@@ -362,6 +364,11 @@
class="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler">
<property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>
+
+ <bean id="org.hisp.dhis.program.ProgramStageSectionDeletionHandler"
+ class="org.hisp.dhis.program.ProgramStageSectionDeletionHandler">
+ <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+ </bean>
<!-- PatientComment -->
@@ -449,6 +456,7 @@
<ref local="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler" />
<ref local="org.hisp.dhis.program.ProgramDeletionHandler" />
+ <ref local="org.hisp.dhis.program.ProgramStageSectionDeletionHandler" />
<ref local="org.hisp.dhis.program.ProgramInstanceDeletionHandler" />
<ref local="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler" />
<ref local="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler" />
@@ -493,6 +501,9 @@
pointcut="execution( * org.hisp.dhis.program.ProgramService.delete*(..) )"
method="intercept" />
<aop:before
+ pointcut="execution( * org.hisp.dhis.program.ProgramStageSectionService.delete*(..) )"
+ method="intercept" />
+ <aop:before
pointcut="execution( * org.hisp.dhis.program.ProgramInstanceService.delete*(..) )"
method="intercept" />
<aop:before
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml 2012-08-24 10:09:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageSection.hbm.xml 2012-10-01 09:28:45 +0000
@@ -16,11 +16,8 @@
<list name="programStageDataElements" table="programstagesection_dataelement">
<key column="programstagesectionid" />
- <list-index column="sort_order" base="1" />
- <many-to-many class="org.hisp.dhis.program.ProgramStageDataElement">
- <column name="programstageid"/>
- <column name="dataelementid" />
- </many-to-many>
+ <list-index column="section_sort_order" base="1" />
+ <one-to-many class="org.hisp.dhis.program.ProgramStageDataElement"/>
</list>
<property name="sortOrder" column="sortorder" not-null="true" />
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2012-09-23 15:49:44 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2012-10-01 09:28:45 +0000
@@ -76,6 +76,7 @@
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageDataElement;
import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageSection;
import org.hisp.dhis.program.ProgramValidation;
import org.hisp.dhis.relationship.Relationship;
import org.hisp.dhis.relationship.RelationshipType;
@@ -592,6 +593,15 @@
public void deleteProgramStage( ProgramStage programStage )
{
}
+
+ public void deleteProgramStageSection( ProgramStageSection programStageSection )
+ {
+ }
+
+ public String allowDeleteProgramStageSection( ProgramStageSection programStageSection )
+ {
+ return null;
+ }
public String allowDeleteProgramStageInstance( ProgramStageInstance programStageInstance )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageSectionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageSectionAction.java 2012-08-24 10:09:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageSectionAction.java 2012-10-01 09:28:45 +0000
@@ -27,7 +27,6 @@
package org.hisp.dhis.patient.action.programstage;
-import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageSection;
import org.hisp.dhis.program.ProgramStageSectionService;
import org.hisp.dhis.program.ProgramStageService;
@@ -86,13 +85,9 @@
public String execute()
throws Exception
{
- ProgramStage programStage = programStageService.getProgramStage( programStageId );
-
ProgramStageSection section = programStageSectionService.getProgramStageSection( id );
- programStage.getProgramStageSections().remove( section );
-
- programStageService.updateProgramStage( programStage );
+ programStageSectionService.deleteProgramStageSection( section );
return SUCCESS;
}
=== 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 2012-09-28 06:26:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2012-10-01 09:28:45 +0000
@@ -302,4 +302,5 @@
execute_success = Execute successfully
plus = Plus
diff_from = Different from
-not_null = Not null
\ No newline at end of file
+not_null = Not null
+confirm_delete_prorgam_stage_section = Are you sure you want to delete this program stage section ?
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2012-09-25 05:18:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramForm.vm 2012-10-01 09:28:45 +0000
@@ -28,7 +28,6 @@
<td><label>$i18n.getString( "type" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
<td>
<select style="width: 336px;" id="type" name="type" onchange='programOnChange();' class="{validate:{required:true}}">
- <option value=''>[$i18n.getString('please_select')]</option>
<option value='1'>$i18n.getString('multiple_events_with_registration')</option>
<option value='2'>$i18n.getString('single_event_with_registration')</option>
<option value='3'>$i18n.getString('single_event_without_registration')</option>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2012-09-25 05:18:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramForm.vm 2012-10-01 09:28:45 +0000
@@ -28,7 +28,6 @@
<td><label>$i18n.getString( "type" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
<td>
<select style="width: 336px;" id="type" name="type" onchange='programOnChange();' class="{validate:{required:true}}">
- <option value=''>[$i18n.getString('please_select')]</option>
<option value='1' #if( $program.type=='1' ) selected #end>$i18n.getString('multiple_events_with_registration')</option>
<option value='2' #if( $program.type=='2' ) selected #end>$i18n.getString('single_event_with_registration')</option>
<option value='3' #if( $program.type=='3' ) selected #end>$i18n.getString('single_event_without_registration')</option>