← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11631: Simplification in OrganisationUnitStore

 

------------------------------------------------------------
revno: 11631
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-08-12 11:30:23 +0200
message:
  Simplification in OrganisationUnitStore
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevelStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitLevelStore.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/organisationunit/OrganisationUnitLevelStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevelStore.java	2012-04-23 09:49:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevelStore.java	2013-08-12 09:30:23 +0000
@@ -47,13 +47,6 @@
     void deleteAll();
 
     /**
-     * Gets all OrganisationUnitLevels.
-     *
-     * @return a Collection of all OrganisationUnitLevels.
-     */
-    Collection<OrganisationUnitLevel> getOrganisationUnitLevels();
-
-    /**
      * Gets the OrganisationUnitLevel at the given level.
      *
      * @param level the level.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2013-07-04 15:41:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2013-08-12 09:30:23 +0000
@@ -751,7 +751,7 @@
 
         return levelMap;
     }
-
+    
     @Override
     public int getNumberOfOrganisationUnits()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitLevelStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitLevelStore.java	2013-06-08 08:02:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitLevelStore.java	2013-08-12 09:30:23 +0000
@@ -27,14 +27,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import org.hibernate.Criteria;
+import java.util.Collection;
+
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevelStore;
 
-import java.util.Collection;
-
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -46,20 +45,12 @@
     {
         String hql = "delete from OrganisationUnitLevel";
 
-        sessionFactory.getCurrentSession().createQuery( hql ).executeUpdate();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<OrganisationUnitLevel> getOrganisationUnitLevels()
-    {
-        return sessionFactory.getCurrentSession().createCriteria( OrganisationUnitLevel.class ).list();
+        getQuery( hql ).executeUpdate();
     }
 
     public OrganisationUnitLevel getByLevel( int level )
     {
-        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( OrganisationUnitLevel.class );
-
-        return (OrganisationUnitLevel) criteria.add( Restrictions.eq( "level", level ) ).uniqueResult();
+        return (OrganisationUnitLevel) getCriteria().add( Restrictions.eq( "level", level ) ).uniqueResult();
     }
 
     @Override