← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5344: Simplified HibernateAttributeStore

 

------------------------------------------------------------
revno: 5344
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-12-09 20:08:49 +0100
message:
  Simplified HibernateAttributeStore
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.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/attribute/hibernate/HibernateAttributeStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java	2011-11-03 01:02:13 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateAttributeStore.java	2011-12-09 19:08:49 +0000
@@ -26,8 +26,6 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.hibernate.Criteria;
-import org.hibernate.Session;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.attribute.Attribute;
 import org.hisp.dhis.attribute.AttributeStore;
@@ -43,44 +41,24 @@
     @SuppressWarnings( "unchecked" )
     public Set<Attribute> getDataElementAttributes()
     {
-        Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( Attribute.class );
-        criteria.add( Restrictions.eq( "dataElementAttribute", true ) );
-        criteria.setCacheable( true );
-
-        return new HashSet<Attribute>( criteria.list() );
+        return new HashSet<Attribute>( getCriteria( Restrictions.eq( "dataElementAttribute", true ) ).list() );
     }
 
     @SuppressWarnings( "unchecked" )
     public Set<Attribute> getIndicatorAttributes()
     {
-        Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( Attribute.class );
-        criteria.add( Restrictions.eq( "indicatorAttribute", true ) );
-        criteria.setCacheable( true );
-
-        return new HashSet<Attribute>( criteria.list() );
+        return new HashSet<Attribute>( getCriteria( Restrictions.eq( "indicatorAttribute", true ) ).list() );
     }
 
     @SuppressWarnings( "unchecked" )
     public Set<Attribute> getOrganisationUnitAttributes()
     {
-        Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( Attribute.class );
-        criteria.add( Restrictions.eq( "organisationUnitAttribute", true ) );
-        criteria.setCacheable( true );
-
-        return new HashSet<Attribute>( criteria.list() );
+        return new HashSet<Attribute>( getCriteria( Restrictions.eq( "organisationUnitAttribute", true ) ).list() );
     }
 
     @SuppressWarnings( "unchecked" )
     public Set<Attribute> getUserAttributes()
     {
-        Session session = sessionFactory.getCurrentSession();
-        Criteria criteria = session.createCriteria( Attribute.class );
-        criteria.add( Restrictions.eq( "userAttribute", true ) );
-        criteria.setCacheable( true );
-
-        return new HashSet<Attribute>( criteria.list() );
+        return new HashSet<Attribute>( getCriteria( Restrictions.eq( "userAttribute", true ) ).list() );
     }
 }