dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05640
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1807: Fix bug #562143, cannot delete Patient by adding DeletionHandlers.
------------------------------------------------------------
revno: 1807
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Fri 2010-04-23 20:37:06 +0700
message:
Fix bug #562143, cannot delete Patient by adding DeletionHandlers.
added:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramInstanceDeleteHandler.java
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientIdentifierDeletionHandler.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.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-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientIdentifierDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientIdentifierDeletionHandler.java 2010-04-21 14:32:54 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientIdentifierDeletionHandler.java 2010-04-23 13:37:06 +0000
@@ -68,4 +68,15 @@
patientIdentifierService.deletePatientIdentifier( patientIdentifier );
}
}
+
+ @Override
+ public void deletePatient( Patient patient )
+ {
+ PatientIdentifier patientIdentifier = patientIdentifierService.getPatientIdentifier( patient );
+
+ if ( patientIdentifier != null )
+ {
+ patientIdentifierService.deletePatientIdentifier( patientIdentifier );
+ }
+ }
}
=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramInstanceDeleteHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramInstanceDeleteHandler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramInstanceDeleteHandler.java 2010-04-23 13:37:06 +0000
@@ -0,0 +1,73 @@
+package org.hisp.dhis.program;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientIdentifier;
+import org.hisp.dhis.patient.PatientIdentifierService;
+import org.hisp.dhis.source.Source;
+import org.hisp.dhis.system.deletion.DeletionHandler;
+
+/**
+ * @author Quang Nguyen
+ * @version $Id$
+ */
+public class ProgramInstanceDeleteHandler
+ extends DeletionHandler
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramInstanceService programInstanceService;
+
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
+ // -------------------------------------------------------------------------
+ // DeletionHandler implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String getClassName()
+ {
+ return ProgramInstance.class.getSimpleName();
+ }
+
+ @Override
+ public void deletePatient( Patient patient )
+ {
+ for(ProgramInstance programInstance : programInstanceService.getProgramInstances( patient ))
+ {
+ programInstanceService.deleteProgramInstance( programInstance );
+ }
+ }
+}
=== 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 2010-04-20 13:16:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2010-04-23 13:37:06 +0000
@@ -224,6 +224,11 @@
<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService"/>
</bean>
+ <bean id="org.hisp.dhis.program.ProgramInstanceDeleteHandler"
+ class="org.hisp.dhis.program.ProgramInstanceDeleteHandler">
+ <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService"/>
+ </bean>
+
<!-- DeletionManager -->
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
@@ -233,6 +238,7 @@
<list>
<list>
<ref local="org.hisp.dhis.patient.PatientIdentifierDeletionHandler"/>
+ <ref local="org.hisp.dhis.program.ProgramInstanceDeleteHandler"/>
</list>
</list>
</property>
=== 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 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2010-04-23 13:37:06 +0000
@@ -60,6 +60,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.report.Report;
import org.hisp.dhis.reporttable.ReportTable;
@@ -481,4 +482,13 @@
{
return true;
}
+
+ public void deletePatient( Patient patient )
+ {
+ }
+
+ public boolean allowDeletePatient( Patient patient )
+ {
+ return true;
+ }
}