← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4039: Fixed delete handle for concept object and added some implement methods for constant (WIP).

 

------------------------------------------------------------
revno: 4039
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-06-30 15:03:19 +0700
message:
  Fixed delete handle for concept object and added some implement methods for constant (WIP).
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDeletionHandler.java
  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-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDeletionHandler.java	2011-01-07 11:38:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryDeletionHandler.java	2011-06-30 08:03:19 +0000
@@ -28,6 +28,7 @@
  */
 
 import org.hisp.dhis.concept.Concept;
+import org.hisp.dhis.concept.ConceptService;
 import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.system.deletion.DeletionHandler;
@@ -50,6 +51,13 @@
         this.categoryService = categoryService;
     }
 
+    private ConceptService conceptService;
+
+    public void setConceptService( ConceptService conceptService )
+    {
+        this.conceptService = conceptService;
+    }
+
     // -------------------------------------------------------------------------
     // DeletionHandler implementation
     // -------------------------------------------------------------------------
@@ -82,6 +90,8 @@
     @Override
     public void deleteConcept( Concept concept )
     {
+        Concept conceptDefault = conceptService.getConceptByName( Concept.DEFAULT_CONCEPT_NAME );
+
         for ( DataElementCategory category : categoryService.getAllDataElementCategories() )
         {
             Concept categoryConcept = category.getConcept();
@@ -90,7 +100,7 @@
             {
                 if ( categoryConcept.equals( concept ) )
                 {
-                    category.setConcept( null );
+                    category.setConcept( conceptDefault );
                     categoryService.updateDataElementCategory( category );
                 }
             }

=== 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	2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java	2011-06-30 08:03:19 +0000
@@ -29,6 +29,7 @@
 
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.concept.Concept;
+import org.hisp.dhis.constant.Constant;
 import org.hisp.dhis.datadictionary.DataDictionary;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategory;
@@ -582,7 +583,6 @@
     {
     }
     
-    
     public boolean allowDeletePatientDataValue( PatientDataValue patientDataValue )
     {
         return true;
@@ -609,4 +609,13 @@
     public void deleteProgramAttributeValue( ProgramAttributeValue programAttributeValue )
     {
     }
+    
+    public boolean allowDeleteConstant( Constant constant )
+    {
+        return true;
+    }
+    
+    public void deleteConstant( Constant constant )
+    {
+    }
 }