← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14630: Impl method DataApprovalLevelService.getDataApprovalLevelsByOrgUnitLevel

 

------------------------------------------------------------
revno: 14630
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-04-03 14:01:11 +0200
message:
  Impl method DataApprovalLevelService.getDataApprovalLevelsByOrgUnitLevel
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelStore.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/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalLevelStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js


--
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-03-31 11:43:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelService.java	2014-04-03 12:01:11 +0000
@@ -45,6 +45,14 @@
     List<DataApprovalLevel> getAllDataApprovalLevels();
 
     /**
+     * Gets data approval levels by org unit level.
+     * 
+     * @param orgUnitLevel the org unit level.
+     * @return a list of data approval levels.
+     */
+    List<DataApprovalLevel> getDataApprovalLevelsByOrgUnitLevel( int orgUnitLevel );
+    
+    /**
      * Tells whether a level can move down in the list (can switch places with
      * the level below.)
      *

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelStore.java	2014-03-31 10:53:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalLevelStore.java	2014-04-03 12:01:11 +0000
@@ -52,4 +52,12 @@
      * @return List of all data approval levels, ordered from 1 to n.
      */
     List<DataApprovalLevel> getAllDataApprovalLevels();
+
+    /**
+     * Gets data approval levels by org unit level.
+     * 
+     * @param orgUnitLevel the org unit level.
+     * @return a list of data approval levels.
+     */
+    List<DataApprovalLevel> getDataApprovalLevelsByOrgUnitLevel( int orgUnitLevel );
 }

=== 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-03-31 11:43:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalLevelService.java	2014-04-03 12:01:11 +0000
@@ -99,6 +99,11 @@
 
         return dataApprovalLevels;
     }
+    
+    public List<DataApprovalLevel> getDataApprovalLevelsByOrgUnitLevel( int orgUnitLevel )
+    {
+        return dataApprovalLevelStore.getDataApprovalLevelsByOrgUnitLevel( orgUnitLevel );
+    }
 
     public boolean canDataApprovalLevelMoveDown( int level )
     {
@@ -229,7 +234,7 @@
 
             // Move up from here to end, to avoid duplicate level in database.
 
-            for (int i = index; i < dataApprovalLevels.size(); i++ )
+            for ( int i = index; i < dataApprovalLevels.size(); i++ )
             {
                 update( dataApprovalLevels.get( i ), i );
             }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalLevelStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalLevelStore.java	2014-03-31 10:53:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalLevelStore.java	2014-04-03 12:01:11 +0000
@@ -31,6 +31,7 @@
 import java.util.List;
 
 import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.dataapproval.DataApprovalLevel;
 import org.hisp.dhis.dataapproval.DataApprovalLevelStore;
 import org.hisp.dhis.hibernate.HibernateGenericStore;
@@ -51,4 +52,10 @@
     {
         return getCriteria().addOrder( Order.asc( "level" ) ).list();
     }
+
+    @SuppressWarnings("unchecked")
+    public List<DataApprovalLevel> getDataApprovalLevelsByOrgUnitLevel( int orgUnitLevel )
+    {
+        return getCriteria( Restrictions.eq( "orgUnitLevel", orgUnitLevel ) ).list();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java	2014-03-28 10:13:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java	2014-04-03 12:01:11 +0000
@@ -92,7 +92,7 @@
 
         update ( dataApproval );
     }
-
+    
     public void deleteDataApproval( DataApproval dataApproval )
     {
         delete( dataApproval );

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-03-24 08:38:02 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-04-03 12:01:11 +0000
@@ -143,7 +143,7 @@
     {
         log( 'Ouwt loaded' );
         loadMetaData();
-   } );
+    } );
 
     $( document ).bind( 'dhis2.online', function( event, loggedIn )
 	{

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js	2014-04-03 11:02:16 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js	2014-04-03 12:01:11 +0000
@@ -4,6 +4,12 @@
 dhis2.appr.currentPeriodOffset = 0;
 dhis2.appr.permissions = null;
 
+$( document ).ready( function()
+{
+	$( "body" ).on( "oust.selected", dhis2.appr.orgUnitSelected );
+} );
+
+
 //------------------------------------------------------------------------------
 // Report
 //------------------------------------------------------------------------------
@@ -13,9 +19,8 @@
 	dhis2.appr.displayPeriods();
 }
 
-dhis2.appr.orgUnitSelected = function()
+dhis2.appr.orgUnitSelected = function( event, ou )
 {
-	
 }
 
 dhis2.appr.displayPeriods = function()