dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27439
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13670: Added ProgramStageDeletionHandler
------------------------------------------------------------
revno: 13670
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-01-09 11:55:02 +0100
message:
Added ProgramStageDeletionHandler
added:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDeletionHandler.java
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueDeletionHandler.java
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/ProgramStageDataElementDeletionHandler.java
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/ProgramValidationDeletionHandler.java
dhis-2/dhis-services/dhis-service-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
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueDeletionHandler.java 2013-09-19 05:24:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/PatientAttributeValueDeletionHandler.java 2014-01-09 10:55:02 +0000
@@ -80,7 +80,7 @@
Collection<PatientAttributeValue> attributeValues = patientAttributeValueService
.getPatientAttributeValues( patientAttribute );
- if ( attributeValues != null && attributeValues.size() > 0 )
+ if ( attributeValues != null && !attributeValues.isEmpty() )
{
for ( PatientAttributeValue attributeValue : attributeValues )
{
=== modified 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 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramDataEntryFormDeletionHandler.java 2014-01-09 10:55:02 +0000
@@ -78,8 +78,11 @@
if ( dataEntryForm != null )
{
boolean flag = false;
+
Set<ProgramStage> programStages = programStage.getProgram().getProgramStages();
+
programStages.remove( programStage );
+
for ( ProgramStage stage : programStages )
{
if ( stage.getDataEntryForm() != null )
=== 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 2014-01-08 18:47:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java 2014-01-09 10:55:02 +0000
@@ -28,9 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
import java.util.Iterator;
-import java.util.Set;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.system.deletion.DeletionHandler;
@@ -54,13 +52,6 @@
this.programStageDEService = programStageDEService;
}
- private ProgramStageSectionService programStageSectionService;
-
- public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService )
- {
- this.programStageSectionService = programStageSectionService;
- }
-
// -------------------------------------------------------------------------
// Implementation methods
// -------------------------------------------------------------------------
@@ -72,50 +63,24 @@
}
@Override
- public void deleteProgram( Program program )
- {
- Set<ProgramStage> programStages = program.getProgramStages();
-
- for ( ProgramStage programStage : programStages )
- {
- Collection<ProgramStageDataElement> psDataElements = programStageDEService.get( programStage );
-
- if ( psDataElements != null && psDataElements.size() > 0 )
- {
- for ( ProgramStageDataElement psDataElement : psDataElements )
- {
- programStageDEService.deleteProgramStageDataElement( psDataElement );
- }
- }
- }
- }
-
- @Override
public void deleteProgramStage( ProgramStage programStage )
{
- Collection<ProgramStageDataElement> psDataElements = programStage.getProgramStageDataElements();
- for ( ProgramStageDataElement psDataElement : psDataElements )
+ Iterator<ProgramStageDataElement> iterator = programStage.getProgramStageDataElements().iterator();
+
+ while ( iterator.hasNext() )
{
- programStageDEService.deleteProgramStageDataElement( psDataElement );
+ ProgramStageDataElement de = iterator.next();
+ iterator.remove();
+ programStageDEService.deleteProgramStageDataElement( de );
}
}
@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() ) )
+ public void deleteDataElement( DataElement dataElement )
+ {
+ if ( 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() )
{
@@ -127,7 +92,5 @@
}
}
}
-
- return null;
}
}
=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDeletionHandler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDeletionHandler.java 2014-01-09 10:55:02 +0000
@@ -0,0 +1,63 @@
+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.system.deletion.DeletionHandler;
+
+public class ProgramStageDeletionHandler
+ extends DeletionHandler
+{
+ private ProgramStageService programStageService;
+
+ public void setProgramStageService( ProgramStageService programStageService )
+ {
+ this.programStageService = programStageService;
+ }
+
+ @Override
+ protected String getClassName()
+ {
+ return ProgramStage.class.getSimpleName();
+ }
+
+ @Override
+ public void deleteProgram( Program program )
+ {
+ Iterator<ProgramStage> iterator = program.getProgramStages().iterator();
+
+ while ( iterator.hasNext() )
+ {
+ ProgramStage programStage = iterator.next();
+ iterator.remove();
+ programStageService.deleteProgramStage( programStage );
+ }
+ }
+}
=== modified 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 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageSectionDeletionHandler.java 2014-01-09 10:55:02 +0000
@@ -35,6 +35,7 @@
*
* @version ProgramStageSectionDeletionHandler.java 3:14:59 PM Oct 1, 2012 $
*/
+@SuppressWarnings("unused")
public class ProgramStageSectionDeletionHandler
extends DeletionHandler
{
@@ -58,11 +59,4 @@
{
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/java/org/hisp/dhis/program/ProgramValidationDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramValidationDeletionHandler.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramValidationDeletionHandler.java 2014-01-09 10:55:02 +0000
@@ -68,7 +68,7 @@
for ( ProgramValidation validation : programValidation )
{
- if( program.equals( validation.getProgram() ) )
+ if ( program.equals( validation.getProgram() ) )
{
programValidationService.deleteProgramValidation( validation );
}
=== 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-08 18:47:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2014-01-09 10:55:02 +0000
@@ -483,8 +483,12 @@
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.program.ProgramStageDeletionHandler"
+ class="org.hisp.dhis.program.ProgramStageDeletionHandler">
+ <property name="programStageService"
+ ref="org.hisp.dhis.program.ProgramStageService" />
</bean>
<bean id="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler"
@@ -542,6 +546,7 @@
<ref local="org.hisp.dhis.patient.PatientAuditDeletionHandler" />
<ref local="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler" />
<ref local="org.hisp.dhis.program.ProgramDeletionHandler" />
+ <ref local="org.hisp.dhis.program.ProgramStageDeletionHandler" />
<ref local="org.hisp.dhis.program.ProgramStageSectionDeletionHandler" />
<ref local="org.hisp.dhis.program.ProgramInstanceDeletionHandler" />
<ref local="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler" />