← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20310: Centralized code

 

------------------------------------------------------------
revno: 20310
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-09-23 12:50:30 +0200
message:
  Centralized code
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.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/organisationunit/hibernate/HibernateOrganisationUnitStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2015-09-17 13:42:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2015-09-23 10:50:30 +0000
@@ -328,22 +328,7 @@
     public void updatePaths()
     {
         List<OrganisationUnit> organisationUnits = new ArrayList<>( getQuery( "from OrganisationUnit ou where ou.path IS NULL" ).list() );
-        Session session = sessionFactory.getCurrentSession();
-        int counter = 0;
-
-        // Use session directly since we don't need to check for access
-        
-        for ( OrganisationUnit organisationUnit : organisationUnits )
-        {
-            session.update( organisationUnit );
-
-            if ( (counter % 400) == 0 )
-            {
-                dbmsManager.clearSession();
-            }
-
-            counter++;
-        }
+        updatePaths( organisationUnits );
     }
 
     @Override
@@ -351,11 +336,14 @@
     public void forceUpdatePaths()
     {
         List<OrganisationUnit> organisationUnits = new ArrayList<>( getQuery( "from OrganisationUnit" ).list() );
+        updatePaths( organisationUnits );
+    }
+    
+    private void updatePaths( List<OrganisationUnit> organisationUnits )
+    {
         Session session = sessionFactory.getCurrentSession();
         int counter = 0;
 
-        // Use session directly since we don't need to check for access
-        
         for ( OrganisationUnit organisationUnit : organisationUnits )
         {
             session.update( organisationUnit );