← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13664: Added ProgramAttributeDeletionHandler

 

------------------------------------------------------------
revno: 13664
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-01-08 19:47:27 +0100
message:
  Added ProgramAttributeDeletionHandler
added:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramAttributeDeletionHandler.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/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.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/ProgramAttributeDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramAttributeDeletionHandler.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramAttributeDeletionHandler.java	2014-01-08 18:47:27 +0000
@@ -0,0 +1,65 @@
+package org.hisp.dhis.program;
+
+/*
+ * Copyright (c) 2004-2013, 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 java.util.Iterator;
+
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramPatientAttribute;
+import org.hisp.dhis.program.ProgramPatientAttributeService;
+import org.hisp.dhis.system.deletion.DeletionHandler;
+
+public class ProgramAttributeDeletionHandler
+    extends DeletionHandler
+{
+    @Override
+    public String getClassName()
+    {
+        return ProgramPatientAttribute.class.getSimpleName();
+    }
+    
+    private ProgramPatientAttributeService programAttributeService;
+    
+    public void setProgramAttributeService( ProgramPatientAttributeService programAttributeService )
+    {
+        this.programAttributeService = programAttributeService;
+    }
+
+    @Override
+    public void deleteProgram( Program program )
+    {
+        Iterator<ProgramPatientAttribute> iterator = program.getProgramPatientAttributes().iterator();
+        
+        while ( iterator.hasNext() )
+        {
+            ProgramPatientAttribute attribute = iterator.next();
+            programAttributeService.deleteProgramPatientAttribute( attribute );
+        }
+    }
+}

=== 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	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java	2014-01-08 18:47:27 +0000
@@ -74,10 +74,6 @@
     @Override
     public void deleteProgram( Program program )
     {
-        // ---------------------------------------------------------------------
-        // Delete Program Stage data elements
-        // ---------------------------------------------------------------------
-
         Set<ProgramStage> programStages = program.getProgramStages();
 
         for ( ProgramStage programStage : programStages )
@@ -90,7 +86,6 @@
                 {
                     programStageDEService.deleteProgramStageDataElement( psDataElement );
                 }
-
             }
         }
     }

=== 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	2014-01-07 15:02:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2014-01-08 18:47:27 +0000
@@ -302,88 +302,6 @@
 		<property name="patientAuditStore" ref="org.hisp.dhis.patient.PatientAuditStore" />
 	</bean>
 
-
-	<!-- DeletionHandlers -->
-
-	<bean id="org.hisp.dhis.patient.PatientIdentifierDeletionHandler"
-		class="org.hisp.dhis.patient.PatientIdentifierDeletionHandler">
-		<property name="patientIdentifierService"
-			ref="org.hisp.dhis.patient.PatientIdentifierService" />
-	</bean>
-
-	<bean id="org.hisp.dhis.program.ProgramInstanceDeletionHandler"
-		class="org.hisp.dhis.program.ProgramInstanceDeletionHandler">
-		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<property name="patientDataValueService"
-			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
-		<property name="patientCommentService"
-			ref="org.hisp.dhis.patientcomment.PatientCommentService" />
-		<property name="programStageInstanceService"
-			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
-	</bean>
-
-	<bean id="org.hisp.dhis.relationship.RelationshipDeletionHandler"
-		class="org.hisp.dhis.relationship.RelationshipDeletionHandler">
-		<property name="relationshipSevice"
-			ref="org.hisp.dhis.relationship.RelationshipService" />
-	</bean>
-
-	<bean
-		id="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler"
-		class="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler">
-		<property name="patientAttributeValueService"
-			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
-	</bean>
-
-	<bean id="org.hisp.dhis.program.ProgramDeletionHandler" class="org.hisp.dhis.program.ProgramDeletionHandler">
-		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-	</bean>
-
-	<bean id="org.hisp.dhis.patient.PatientDeletionHandler" class="org.hisp.dhis.patient.PatientDeletionHandler">
-		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-	</bean>
-
-	<bean id="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler"
-		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"
-		class="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler">
-		<property name="jdbcTemplate" ref="jdbcTemplate" />
-	</bean>
-
-	<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>
-
-	<bean id="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler"
-		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>
-
-	<bean id="org.hisp.dhis.patient.PatientAuditDeletionHandler"
-		class="org.hisp.dhis.patient.PatientAuditDeletionHandler">
-		<property name="patientAuditService" ref="org.hisp.dhis.patient.PatientAuditService" />
-	</bean>
-
 	<!-- PatientComment -->
 
 	<bean id="org.hisp.dhis.patientcomment.PatientCommentService"
@@ -522,6 +440,92 @@
 		</property>
 	</bean>
 
+    <!-- DeletionHandlers -->
+
+    <bean id="org.hisp.dhis.patient.PatientIdentifierDeletionHandler"
+        class="org.hisp.dhis.patient.PatientIdentifierDeletionHandler">
+        <property name="patientIdentifierService"
+            ref="org.hisp.dhis.patient.PatientIdentifierService" />
+    </bean>
+
+    <bean id="org.hisp.dhis.program.ProgramInstanceDeletionHandler"
+        class="org.hisp.dhis.program.ProgramInstanceDeletionHandler">
+        <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+        <property name="patientDataValueService"
+            ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+        <property name="patientCommentService"
+            ref="org.hisp.dhis.patientcomment.PatientCommentService" />
+        <property name="programStageInstanceService"
+            ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+    </bean>
+
+    <bean id="org.hisp.dhis.relationship.RelationshipDeletionHandler"
+        class="org.hisp.dhis.relationship.RelationshipDeletionHandler">
+        <property name="relationshipSevice"
+            ref="org.hisp.dhis.relationship.RelationshipService" />
+    </bean>
+
+    <bean id="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler"
+        class="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler">
+        <property name="patientAttributeValueService"
+            ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+    </bean>
+
+    <bean id="org.hisp.dhis.program.ProgramDeletionHandler" class="org.hisp.dhis.program.ProgramDeletionHandler">
+        <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+    </bean>
+
+    <bean id="org.hisp.dhis.patient.PatientDeletionHandler" class="org.hisp.dhis.patient.PatientDeletionHandler">
+        <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+    </bean>
+
+    <bean id="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler"
+        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"
+        class="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler">
+        <property name="jdbcTemplate" ref="jdbcTemplate" />
+    </bean>
+
+    <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>
+
+    <bean id="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler"
+        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>
+
+    <bean id="org.hisp.dhis.patient.PatientAuditDeletionHandler"
+        class="org.hisp.dhis.patient.PatientAuditDeletionHandler">
+        <property name="patientAuditService" ref="org.hisp.dhis.patient.PatientAuditService" />
+    </bean>
+    
+    <bean id="org.hisp.dhis.program.ProgramAttributeDeletionHandler"
+       class="org.hisp.dhis.program.ProgramAttributeDeletionHandler">
+        <property name="programAttributeService"
+            ref="org.hisp.dhis.program.ProgramPatientAttributeService" />
+    </bean>
+
 	<!-- DeletionManager -->
 
 	<bean
@@ -532,13 +536,11 @@
 			<list>
 				<list>
 					<ref local="org.hisp.dhis.patient.PatientDeletionHandler" />
-					<ref
-						local="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler" />
+					<ref local="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler" />
 					<ref local="org.hisp.dhis.patient.PatientIdentifierDeletionHandler" />
 					<ref local="org.hisp.dhis.relationship.RelationshipDeletionHandler" />
 					<ref local="org.hisp.dhis.patient.PatientAuditDeletionHandler" />
-					<ref
-						local="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler" />
+					<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" />
@@ -546,6 +548,7 @@
 					<ref local="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler" />
 					<ref local="org.hisp.dhis.program.ProgramValidationDeletionHandler" />
 					<ref local="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler" />
+					<ref local="org.hisp.dhis.program.ProgramAttributeDeletionHandler" />
 				</list>
 			</list>
 		</property>

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2014-01-07 16:28:34 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/Program.hbm.xml	2014-01-08 18:47:27 +0000
@@ -13,7 +13,7 @@
 		<id name="id" column="programid">
 			<generator class="native" />
 		</id>
-    &identifiableProperties;
+        &identifiableProperties;
 
 		<property name="name" column="name" not-null="true" length="230" />