← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14718: Changed signature of deleteDataApprovalLevel(int) to deleteDataApprovalLevel(DataApprovalLevel)

 

------------------------------------------------------------
revno: 14718
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-07 12:18:57 +0200
message:
  Changed signature of deleteDataApprovalLevel(int) to deleteDataApprovalLevel(DataApprovalLevel)
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/RemoveApprovalLevelAction.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-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelService.java	2014-04-07 09:34:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelService.java	2014-04-07 10:18:57 +0000
@@ -118,9 +118,9 @@
     /**
      * Removes a data approval level.
      *
-     * @param level the level of approval to delete.
+     * @param dataApprovalLevel the data approval level to delete.
      */
-    void deleteDataApprovalLevel( int level );
+    void deleteDataApprovalLevel( DataApprovalLevel dataApprovalLevel );
 
     /**
      * Gets the lowest data approval level that the current user may view.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java	2014-04-07 09:34:43 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java	2014-04-07 10:18:57 +0000
@@ -298,15 +298,15 @@
         return dataApprovalLevelStore.save( newLevel );
     }
     
-    public void deleteDataApprovalLevel( int level )
+    public void deleteDataApprovalLevel( DataApprovalLevel dataApprovalLevel )
     {
         List<DataApprovalLevel> dataApprovalLevels = getAllDataApprovalLevels();
 
-        int index = level - 1;
-
+        int index = dataApprovalLevel.getLevel() - 1;
+        
         if ( index >= 0 & index < dataApprovalLevels.size() )
         {
-            dataApprovalLevelStore.delete( dataApprovalLevels.get( index ) );
+            dataApprovalLevelStore.delete( dataApprovalLevel );
 
             dataApprovalLevels.remove( index );
 

=== 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	2014-04-07 06:07:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2014-04-07 10:18:57 +0000
@@ -1234,6 +1234,7 @@
   <aop:config>
 
     <aop:aspect ref="deletionInterceptor">
+      <aop:before pointcut="execution( * org.hisp.dhis.dataapproval.DataApprovalLevelService.delete*(..) )" method="intercept" />
       <aop:before pointcut="execution( * org.hisp.dhis.datadictionary.DataDictionaryService.delete*(..) )" method="intercept" />
       <aop:before pointcut="execution( * org.hisp.dhis.dataelement.DataElementService.delete*(..) )" method="intercept" />
       <aop:before pointcut="execution( * org.hisp.dhis.dataelement.DataElementCategoryService.delete*(..) )" method="intercept" />

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java	2014-04-04 16:47:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java	2014-04-07 10:18:57 +0000
@@ -231,13 +231,13 @@
 
     @Test
     public void testDeleteDataApprovalLevel() throws Exception
-    {
+    {        
         dataApprovalLevelService.addDataApprovalLevel( level1A );
         dataApprovalLevelService.addDataApprovalLevel( level2B );
         dataApprovalLevelService.addDataApprovalLevel( level3C );
         dataApprovalLevelService.addDataApprovalLevel( level4D );
 
-        List<DataApprovalLevel> levels;
+        List<DataApprovalLevel> levels = null;
 
         levels = dataApprovalLevelService.getAllDataApprovalLevels();
         assertEquals( 4, levels.size() );
@@ -246,7 +246,7 @@
         assertEquals( "3C", levels.get( 2 ).getName() );
         assertEquals( "4D", levels.get( 3 ).getName() );
 
-        dataApprovalLevelService.deleteDataApprovalLevel( 2 );
+        dataApprovalLevelService.deleteDataApprovalLevel( level2B );
 
         levels = dataApprovalLevelService.getAllDataApprovalLevels();
         assertEquals( 3, levels.size() );
@@ -254,20 +254,20 @@
         assertEquals( "3C", levels.get( 1 ).getName() );
         assertEquals( "4D", levels.get( 2 ).getName() );
 
-        dataApprovalLevelService.deleteDataApprovalLevel( 3 );
+        dataApprovalLevelService.deleteDataApprovalLevel( level4D );
 
         levels = dataApprovalLevelService.getAllDataApprovalLevels();
         assertEquals( 2, levels.size() );
         assertEquals( "1A", levels.get( 0 ).getName() );
         assertEquals( "3C", levels.get( 1 ).getName() );
 
-        dataApprovalLevelService.deleteDataApprovalLevel( 1 );
+        dataApprovalLevelService.deleteDataApprovalLevel( level1A );
 
         levels = dataApprovalLevelService.getAllDataApprovalLevels();
         assertEquals( 1, levels.size() );
         assertEquals( "3C", levels.get( 0 ).getName() );
 
-        dataApprovalLevelService.deleteDataApprovalLevel( 1 );
+        dataApprovalLevelService.deleteDataApprovalLevel( level3C );
 
         levels = dataApprovalLevelService.getAllDataApprovalLevels();
         assertEquals( 0, levels.size() );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/RemoveApprovalLevelAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/RemoveApprovalLevelAction.java	2014-03-28 10:13:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-settings/src/main/java/org/hisp/dhis/settings/action/system/RemoveApprovalLevelAction.java	2014-04-07 10:18:57 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.dataapproval.DataApprovalLevel;
 import org.hisp.dhis.dataapproval.DataApprovalLevelService;
 
 import com.opensymphony.xwork2.Action;
@@ -67,7 +68,9 @@
 
     public String execute()
     {
-        dataApprovalLevelService.deleteDataApprovalLevel( id );
+        DataApprovalLevel approvalLevel = dataApprovalLevelService.getDataApprovalLevel( id );
+        
+        dataApprovalLevelService.deleteDataApprovalLevel( approvalLevel );
 
         return SUCCESS;
     }