← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1936: Next trunk merge

 

Merge authors:
  Thu Tran (tran-hispvietnam)
------------------------------------------------------------
revno: 1936 [merge]
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: cbhis-mobile
timestamp: Fri 2010-10-22 10:33:12 +0530
message:
  Next trunk merge
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java
  dhis-2/dhis-services/dhis-service-core/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-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DataElementDeletionHandler.java	2010-08-24 01:48:02 +0000
@@ -27,8 +27,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.dataelement.DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME;
+
 import org.hisp.dhis.system.deletion.DeletionHandler;
-import static org.hisp.dhis.dataelement.DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME;
 
 /**
  * @author Lars Helge Overland
@@ -64,12 +65,13 @@
     {
         return DataElement.class.getSimpleName();
     }
-    
+
     @Override
     public void deleteDataElementCategoryCombo( DataElementCategoryCombo categoryCombo )
     {
-        DataElementCategoryCombo default_ = categoryService.getDataElementCategoryComboByName( DEFAULT_CATEGORY_COMBO_NAME );
-        
+        DataElementCategoryCombo default_ = categoryService
+            .getDataElementCategoryComboByName( DEFAULT_CATEGORY_COMBO_NAME );
+
         for ( DataElement dataElement : dataElementService.getAllDataElements() )
         {
             if ( dataElement.getCategoryCombo().equals( categoryCombo ) )
@@ -80,4 +82,5 @@
             }
         }
     }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java	2010-05-17 22:46:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/IndicatorDeletionHandler.java	2010-08-24 01:48:02 +0000
@@ -27,6 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Set;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.expression.ExpressionService;
 import org.hisp.dhis.system.deletion.DeletionHandler;
 
 /**
@@ -46,7 +50,14 @@
     {
         this.indicatorService = indicatorService;
     }
-    
+
+    private ExpressionService expressionService;
+
+    public void setExpressionService( ExpressionService expressionService )
+    {
+        this.expressionService = expressionService;
+    }
+
     // -------------------------------------------------------------------------
     // DeletionHandler implementation
     // -------------------------------------------------------------------------
@@ -56,7 +67,7 @@
     {
         return Indicator.class.getSimpleName();
     }
-    
+
     @Override
     public boolean allowDeleteIndicatorType( IndicatorType indicatorType )
     {
@@ -65,12 +76,12 @@
             if ( indicator.getIndicatorType().equals( indicatorType ) )
             {
                 return false;
-            }   
+            }
         }
-        
+
         return true;
     }
-    
+
     @Override
     public void deleteIndicatorType( IndicatorType indicatorType )
     {
@@ -79,7 +90,22 @@
             if ( indicator.getIndicatorType().equals( indicatorType ) )
             {
                 indicatorService.deleteIndicator( indicator );
-            }   
-        }
-    }
+            }
+        }
+    }
+
+    public boolean allowDeleteDataElement( DataElement dataElement )
+    {
+        for ( Indicator indicator : indicatorService.getAllIndicators() )
+        {
+            Set<DataElement> daels = expressionService.getDataElementsInExpression( indicator.getNumerator() );
+            if ( daels != null && daels.contains( dataElement ) ) return false;
+            
+            daels = expressionService.getDataElementsInExpression( indicator.getDenominator() );
+            if ( daels != null && daels.contains( dataElement ) ) return false;
+        }
+
+        return true;
+    }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-10-22 04:53:09 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-10-22 05:03:12 +0000
@@ -1323,6 +1323,8 @@
     class="org.hisp.dhis.indicator.IndicatorDeletionHandler">
     <property name="indicatorService"
       ref="org.hisp.dhis.indicator.IndicatorService"/>
+    <property name="expressionService"
+      ref="org.hisp.dhis.expression.ExpressionService"/>
   </bean>
   
   <bean id="org.hisp.dhis.indicator.IndicatorGroupDeletionHandler"