← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3454: Impl caching for most objects

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 3454 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-04-24 10:14:31 +0200
message:
  Impl caching for most objects
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultSectionService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.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/HibernateOrganisationUnitStore.java
  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/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/expression/hibernate/Expression.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/IndicatorGroupSet.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRule.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRuleGroup.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/SectionStoreTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/document/hibernate/Document.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.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/dataset/SectionStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionStore.java	2010-08-25 09:31:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/SectionStore.java	2011-04-23 18:52:44 +0000
@@ -27,54 +27,18 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
+import org.hisp.dhis.common.GenericStore;
 
 public interface SectionStore
+    extends GenericStore<Section>
 {
     String ID = SectionStore.class.getName();
 
     /**
-     * Adds a Section.
-     * 
-     * @param section the Section to add.
-     * @return the generated identifier.
-     */
-    int addSection( Section section );
-
-    /**
-     * Updates a Section.
-     * 
-     * @param section the Section to update.
-     */
-    void updateSection( Section section );
-
-    /**
-     * Deletes a Section.
-     * 
-     * @param section the Section to delete.
-     */
-    void deleteSection( Section section );   
-
-    /**
-     * Retrieves the Section with the given identifier.
-     * 
-     * @param id the identifier of the Section to retrieve.
-     * @return the Section.
-     */
-    Section getSection( int id );
-
-    /**
-     * Retrieves the Section with the given name.
+     * Retrieves the Section with the given name and the given DataSet.
      * 
      * @param name the name of the Section to retrieve.
      * @return the Section.
      */
     Section getSectionByName( String name, DataSet dataSet );
-
-    /**
-     * Retrieves all Sections.
-     * 
-     * @return a Collection of Sections.
-     */
-    Collection<Section> getAllSections();   
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java	2011-04-23 18:52:44 +0000
@@ -154,13 +154,6 @@
     OrganisationUnitLevel getOrganisationUnitLevelByName( String name );
     
     /**
-     * Gets the number of organisation units.
-     * 
-     * @return the number of units.
-     */
-    int getNumberOfOrganisationUnits();
-    
-    /**
      * Gets the maximum level from the hierarchy.
      * 
      * @return the maximum number of level.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultSectionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultSectionService.java	2010-08-25 09:31:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultSectionService.java	2011-04-23 18:52:44 +0000
@@ -69,7 +69,7 @@
 
     public int addSection( Section section )
     {
-        int id = sectionStore.addSection( section );
+        int id = sectionStore.save( section );
 
         i18nService.addObject( section );
 
@@ -80,17 +80,17 @@
     {
         i18nService.removeObject( section );
 
-        sectionStore.deleteSection( section );
+        sectionStore.delete( section );
     }
 
     public Collection<Section> getAllSections()
     {
-        return i18n( i18nService, sectionStore.getAllSections() );
+        return i18n( i18nService, sectionStore.getAll() );
     }
 
     public Section getSection( int id )
     {
-        return i18n( i18nService, sectionStore.getSection( id ) );
+        return i18n( i18nService, sectionStore.get( id ) );
     }
 
     public Section getSectionByName( String name, Integer dataSetId )
@@ -100,7 +100,7 @@
 
     public void updateSection( Section section )
     {
-        sectionStore.updateSection( section );
+        sectionStore.update( section );
 
         i18nService.verify( section );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java	2010-10-29 12:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateSectionStore.java	2011-04-23 18:52:44 +0000
@@ -23,75 +23,28 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-
 import org.hibernate.Criteria;
 import org.hibernate.Session;
-import org.hibernate.SessionFactory;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.Section;
 import org.hisp.dhis.dataset.SectionStore;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
 
 /**
  * @author Tri
  * @version $Id$
  */
 public class HibernateSectionStore
-    implements SectionStore
+    extends HibernateGenericStore<Section> implements SectionStore
 {
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private SessionFactory sessionFactory;
-
-    public void setSessionFactory( SessionFactory sessionFactory )
-    {
-        this.sessionFactory = sessionFactory;
-    }
-
-    // -------------------------------------------------------------------------
-    // SectionStore implementation
-    // -------------------------------------------------------------------------
-
-    public int addSection( Section section )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        return (Integer) session.save( section );
-    }
-
-    public void deleteSection( Section section )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        session.delete( section );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<Section> getAllSections()
-    {
-        Session session = sessionFactory.getCurrentSession();
-        return session.createCriteria( Section.class ).list();
-    }
-
-    public Section getSection( int id )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        return (Section) session.get( Section.class, id );
-    }
-
     public Section getSectionByName( String name, DataSet dataSet )
     {
         Session session = sessionFactory.getCurrentSession();
         Criteria criteria = session.createCriteria( Section.class );
         criteria.add( Restrictions.eq( "name", name ) );
         criteria.add( Restrictions.eq( "dataSet", dataSet ) );
+        criteria.setCacheable( true );
         return (Section) criteria.uniqueResult();
     }
-
-    public void updateSection( Section section )
-    {
-        Session session = sessionFactory.getCurrentSession();
-        session.update( section );
-    }
 }

=== 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	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2011-04-23 18:52:44 +0000
@@ -560,7 +560,7 @@
     @Override
     public int getNumberOfOrganisationUnits()
     {
-        return organisationUnitStore.getNumberOfOrganisationUnits();
+        return organisationUnitStore.getCount();
     }
 
     @Override

=== 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	2011-04-22 21:06:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2011-04-23 18:52:44 +0000
@@ -228,14 +228,6 @@
     }
 
     @Override
-    public int getNumberOfOrganisationUnits()
-    {
-        final String sql = "SELECT count(*) FROM organisationunit";
-
-        return jdbcTemplate.queryForInt( sql );
-    }
-
-    @Override
     public int getMaxOfOrganisationUnitLevels()
     {
         final String sql = "SELECT MAX(level) FROM orgunitlevel";

=== 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	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2011-04-23 18:52:44 +0000
@@ -13,6 +13,7 @@
 		class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.dataelement.DataElementOperand" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataentryform.DataEntryFormStore"
@@ -25,23 +26,26 @@
 		<property name="clazz" value="org.hisp.dhis.dataelement.DataElement"/>
 		<property name="sessionFactory" ref="sessionFactory"/>
 		<property name="statementManager" ref="statementManager"/>
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataelement.DataElementGroupStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.dataelement.DataElementGroup" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataelement.DataElementGroupSetStore"
 		class="org.hisp.dhis.hibernate.HibernateGenericStore">
-		<property name="clazz"
-			value="org.hisp.dhis.dataelement.DataElementGroupSet" />
+		<property name="clazz" value="org.hisp.dhis.dataelement.DataElementGroupSet" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.datadictionary.DataDictionaryStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.datadictionary.DataDictionary" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.datavalue.DataValueStore"
@@ -55,21 +59,25 @@
 		class="org.hisp.dhis.indicator.hibernate.HibernateIndicatorStore">
 		<property name="clazz" value="org.hisp.dhis.indicator.Indicator"/>
 		<property name="sessionFactory" ref="sessionFactory"/>
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.indicator.IndicatorTypeStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.indicator.IndicatorType" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.indicator.IndicatorGroupStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.indicator.IndicatorGroup" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.indicator.IndicatorGroupSetStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.indicator.IndicatorGroupSet" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.period.PeriodStore" class="org.hisp.dhis.period.hibernate.HibernatePeriodStore">
@@ -81,6 +89,7 @@
 		<property name="sessionFactory" ref="sessionFactory"/>
 		<property name="periodStore" ref="org.hisp.dhis.period.PeriodStore" />
 		<property name="statementManager" ref="statementManager" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataset.CompleteDataSetRegistrationStore"
@@ -98,6 +107,7 @@
 	<bean id="org.hisp.dhis.expression.ExpressionStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.expression.Expression" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.validation.ValidationRuleStore"
@@ -105,42 +115,48 @@
 		<property name="clazz" value="org.hisp.dhis.validation.ValidationRule" />
 		<property name="sessionFactory" ref="sessionFactory" />
 		<property name="periodStore" ref="org.hisp.dhis.period.PeriodStore" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.validation.ValidationRuleGroupStore"
 		class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.validation.ValidationRuleGroup" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataelement.DataElementCategoryStore"
 		class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.dataelement.DataElementCategory" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataelement.DataElementCategoryOptionStore"
 		class="org.hisp.dhis.hibernate.HibernateGenericStore">
 		<property name="clazz" value="org.hisp.dhis.dataelement.DataElementCategoryOption" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataelement.DataElementCategoryComboStore"
 		class="org.hisp.dhis.hibernate.HibernateGenericStore">
-		<property name="clazz"
-			value="org.hisp.dhis.dataelement.DataElementCategoryCombo" />
+		<property name="clazz" value="org.hisp.dhis.dataelement.DataElementCategoryCombo" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataelement.DataElementCategoryOptionComboStore"
 		class="org.hisp.dhis.hibernate.HibernateGenericStore">
-		<property name="clazz"
-			value="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" />
+		<property name="clazz" value="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataset.SectionStore" class="org.hisp.dhis.dataset.hibernate.HibernateSectionStore">
+		<property name="clazz" value="org.hisp.dhis.dataset.Section" />
 		<property name="sessionFactory" ref="sessionFactory"/>
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.organisationunit.OrganisationUnitStore"
@@ -149,20 +165,21 @@
 		<property name="sessionFactory" ref="sessionFactory"/>
 		<property name="statementManager" ref="statementManager"/>
 		<property name="jdbcTemplate" ref="jdbcTemplate"/>
+		<property name="cacheable" value="true"/>
 	</bean>
 	
 	<bean id="org.hisp.dhis.organisationunit.OrganisationUnitGroupStore"
 		class="org.hisp.dhis.hibernate.HibernateGenericStore">
-		<property name="clazz"
-			value="org.hisp.dhis.organisationunit.OrganisationUnitGroup" />
+		<property name="clazz" value="org.hisp.dhis.organisationunit.OrganisationUnitGroup" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.organisationunit.OrganisationUnitGroupSetStore"
 		class="org.hisp.dhis.hibernate.HibernateGenericStore">
-		<property name="clazz"
-			value="org.hisp.dhis.organisationunit.OrganisationUnitGroupSet" />
+		<property name="clazz" value="org.hisp.dhis.organisationunit.OrganisationUnitGroupSet" />
 		<property name="sessionFactory" ref="sessionFactory" />
+		<property name="cacheable" value="true"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.dataanalysis.jdbc.DataAnalysisStore"
@@ -207,13 +224,15 @@
 	</bean>
 	
 	<bean id="org.hisp.dhis.message.MessageStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">
-		<property name="sessionFactory" ref="sessionFactory"/>
 		<property name="clazz" value="org.hisp.dhis.message.Message"/>
+		<property name="sessionFactory" ref="sessionFactory"/>
+		<property name="cacheable" value="true"/>
 	</bean>
 	
 	<bean id="org.hisp.dhis.message.UserMessageStore" class="org.hisp.dhis.message.hibernate.HibernateUserMessageStore">
-		<property name="sessionFactory" ref="sessionFactory"/>
 		<property name="clazz" value="org.hisp.dhis.message.UserMessage"/>
+		<property name="sessionFactory" ref="sessionFactory"/>
+		<property name="cacheable" value="true"/>
 	</bean>
 	
 	<bean id="org.hisp.dhis.sequence.SequenceStore" class="org.hisp.dhis.hibernate.HibernateGenericStore">

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml	2011-04-12 13:25:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElementGroupSet.hbm.xml	2011-04-23 18:52:44 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.dataelement.DataElementGroupSet" table="dataelementgroupset">
 
+    <cache usage="read-write" />
+
     <id name="id" column="dataelementgroupsetid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/expression/hibernate/Expression.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/expression/hibernate/Expression.hbm.xml	2011-04-12 13:25:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/expression/hibernate/Expression.hbm.xml	2011-04-23 18:52:44 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.expression.Expression" table="expression">
 
+    <cache usage="read-write" />
+
     <id name="id" column="expressionid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/IndicatorGroupSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/IndicatorGroupSet.hbm.xml	2011-04-12 13:25:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/IndicatorGroupSet.hbm.xml	2011-04-23 18:52:44 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.indicator.IndicatorGroupSet" table="indicatorgroupset">
 
+    <cache usage="read-write" />
+
     <id name="id" column="indicatorgroupsetid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml	2011-04-12 13:25:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml	2011-04-23 18:52:44 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.organisationunit.OrganisationUnitGroup" table="orgunitgroup">
 
+    <cache usage="read-write" />
+
     <id name="id" column="orgunitgroupid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml	2011-04-12 13:25:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml	2011-04-23 18:52:44 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.organisationunit.OrganisationUnitGroupSet" table="orgunitgroupset">
 
+    <cache usage="read-write" />
+
     <id name="id" column="orgunitgroupsetid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRule.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRule.hbm.xml	2011-04-12 13:25:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRule.hbm.xml	2011-04-23 18:52:44 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.validation.ValidationRule" table="validationrule">
 
+    <cache usage="read-write" />
+
     <id name="id" column="validationruleid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRuleGroup.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRuleGroup.hbm.xml	2011-04-12 13:25:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/validation/hibernate/ValidationRuleGroup.hbm.xml	2011-04-23 18:52:44 +0000
@@ -5,6 +5,9 @@
 
 <hibernate-mapping>
   <class name="org.hisp.dhis.validation.ValidationRuleGroup" table="validationrulegroup">
+  
+    <cache usage="read-write" />
+      
     <id name="id" column="validationgroupid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/SectionStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/SectionStoreTest.java	2010-07-10 12:15:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/SectionStoreTest.java	2011-04-23 18:52:44 +0000
@@ -86,50 +86,50 @@
     }
     
     @Test
-    public void addGet()
+    public void testAddGet()
     {        
-        int idA = sectionStore.addSection( sectionA );
-        int idB = sectionStore.addSection( sectionB );
-        int idC = sectionStore.addSection( sectionC );
+        int idA = sectionStore.save( sectionA );
+        int idB = sectionStore.save( sectionB );
+        int idC = sectionStore.save( sectionC );
         
-        assertEquals( sectionA, sectionStore.getSection( idA ) );
-        assertEquals( sectionB, sectionStore.getSection( idB ) );
-        assertEquals( sectionC, sectionStore.getSection( idC ) );
+        assertEquals( sectionA, sectionStore.get( idA ) );
+        assertEquals( sectionB, sectionStore.get( idB ) );
+        assertEquals( sectionC, sectionStore.get( idC ) );
 
-        assertEquals( dataSet, sectionStore.getSection( idA ).getDataSet() );
-        assertNotNull( sectionStore.getSection( idA ).getDataElements() );
-        assertEquals( 2, sectionStore.getSection( idA ).getDataElements().size() );
-        assertNotNull( sectionStore.getSection( idA ).getGreyedFields() );
-        assertEquals( 2, sectionStore.getSection( idA ).getGreyedFields().size() );
+        assertEquals( dataSet, sectionStore.get( idA ).getDataSet() );
+        assertNotNull( sectionStore.get( idA ).getDataElements() );
+        assertEquals( 2, sectionStore.get( idA ).getDataElements().size() );
+        assertNotNull( sectionStore.get( idA ).getGreyedFields() );
+        assertEquals( 2, sectionStore.get( idA ).getGreyedFields().size() );
     }
     
     @Test
-    public void delete()
+    public void testDelete()
     {        
-        int idA = sectionStore.addSection( sectionA );
-        int idB = sectionStore.addSection( sectionB );
-        int idC = sectionStore.addSection( sectionC );
-
-        assertNotNull( sectionStore.getSection( idA ) );
-        assertNotNull( sectionStore.getSection( idB ) );
-        assertNotNull( sectionStore.getSection( idC ) );
-        
-        sectionStore.deleteSection( sectionA );
-        
-        assertNull( sectionStore.getSection( idA ) );
-        assertNotNull( sectionStore.getSection( idB ) );
-        assertNotNull( sectionStore.getSection( idC ) );
-        
-        sectionStore.deleteSection( sectionB );
-        
-        assertNull( sectionStore.getSection( idA ) );
-        assertNull( sectionStore.getSection( idB ) );
-        assertNotNull( sectionStore.getSection( idC ) );       
-
-        sectionStore.deleteSection( sectionC );
-        
-        assertNull( sectionStore.getSection( idA ) );
-        assertNull( sectionStore.getSection( idB ) );
-        assertNull( sectionStore.getSection( idC ) );   
+        int idA = sectionStore.save( sectionA );
+        int idB = sectionStore.save( sectionB );
+        int idC = sectionStore.save( sectionC );
+
+        assertNotNull( sectionStore.get( idA ) );
+        assertNotNull( sectionStore.get( idB ) );
+        assertNotNull( sectionStore.get( idC ) );
+        
+        sectionStore.delete( sectionA );
+        
+        assertNull( sectionStore.get( idA ) );
+        assertNotNull( sectionStore.get( idB ) );
+        assertNotNull( sectionStore.get( idC ) );
+        
+        sectionStore.delete( sectionB );
+        
+        assertNull( sectionStore.get( idA ) );
+        assertNull( sectionStore.get( idB ) );
+        assertNotNull( sectionStore.get( idC ) );       
+
+        sectionStore.delete( sectionC );
+        
+        assertNull( sectionStore.get( idA ) );
+        assertNull( sectionStore.get( idB ) );
+        assertNull( sectionStore.get( idC ) );   
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-04-12 12:15:54 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml	2011-04-23 19:09:19 +0000
@@ -39,6 +39,7 @@
     class="org.hisp.dhis.hibernate.HibernateGenericStore">
     <property name="clazz" value="org.hisp.dhis.reporttable.ReportTable"/>
     <property name="sessionFactory" ref="sessionFactory"/>
+	<property name="cacheable" value="true"/>
   </bean>
   
   <bean id="org.hisp.dhis.reporttable.ReportTableService"
@@ -65,6 +66,7 @@
     class="org.hisp.dhis.hibernate.HibernateGenericStore">
     <property name="clazz" value="org.hisp.dhis.report.Report"/>
     <property name="sessionFactory" ref="sessionFactory"/>
+	<property name="cacheable" value="true"/>
   </bean>
   
   <bean id="org.hisp.dhis.report.ReportService"
@@ -79,6 +81,7 @@
     class="org.hisp.dhis.chart.hibernate.HibernateChartStore">
     <property name="clazz" value="org.hisp.dhis.chart.Chart"/>
     <property name="sessionFactory" ref="sessionFactory"/>
+	<property name="cacheable" value="true"/>
   </bean>
   
   <bean id="org.hisp.dhis.chart.ChartService"
@@ -107,6 +110,7 @@
     class="org.hisp.dhis.hibernate.HibernateGenericStore">
     <property name="clazz" value="org.hisp.dhis.document.Document"/>
     <property name="sessionFactory" ref="sessionFactory"/>
+	<property name="cacheable" value="true"/>
   </bean>
   
   <bean id="org.hisp.dhis.document.DocumentService"

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2011-04-14 13:06:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2011-04-23 19:09:19 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.chart.Chart" table="chart">
 
+    <cache usage="read-write" />
+
     <id name="id" column="chartid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/document/hibernate/Document.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/document/hibernate/Document.hbm.xml	2011-04-12 13:30:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/document/hibernate/Document.hbm.xml	2011-04-23 19:09:19 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.document.Document" table="document">
 
+    <cache usage="read-write" />
+
     <id name="id" column="documentid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml	2011-04-12 13:30:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/report/hibernate/Report.hbm.xml	2011-04-23 19:09:19 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.report.Report" table="report">
 
+    <cache usage="read-write" />
+
     <id name="id" column="reportid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2011-04-12 13:30:10 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2011-04-23 19:09:19 +0000
@@ -6,6 +6,8 @@
 <hibernate-mapping>
   <class name="org.hisp.dhis.reporttable.ReportTable" table="reporttable">
 
+    <cache usage="read-write" />
+
     <id name="id" column="reporttableid">
       <generator class="native" />
     </id>

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2011-04-02 09:48:38 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2011-04-23 18:52:44 +0000
@@ -102,9 +102,7 @@
      */
     protected final Query getQuery( String hql )
     {
-        Query query =  sessionFactory.getCurrentSession().createQuery( hql );
-        query.setCacheable( cacheable );
-        return query;
+        return sessionFactory.getCurrentSession().createQuery( hql ).setCacheable( cacheable );
     }
     
     /**
@@ -127,9 +125,7 @@
      */
     protected final Criteria getCriteria()
     {
-        Criteria criteria = sessionFactory.getCurrentSession().createCriteria( getClazz() );
-        criteria.setCacheable( cacheable );
-        return criteria;
+        return sessionFactory.getCurrentSession().createCriteria( getClazz() ).setCacheable( cacheable );
     }
     
     /**
@@ -288,7 +284,7 @@
     public int getCount()
     {
         Criteria criteria = getCriteria();
-        criteria.setProjection( Projections.rowCount() );        
+        criteria.setProjection( Projections.rowCount() );
         return ((Number) criteria.uniqueResult()).intValue();
     }
 
@@ -297,7 +293,7 @@
     {
         Criteria criteria = getCriteria();
         criteria.setProjection( Projections.rowCount() );
-        criteria.add( Restrictions.ilike( "name", "%" + name + "%" ) );        
+        criteria.add( Restrictions.ilike( "name", "%" + name + "%" ) );
         return ((Number) criteria.uniqueResult()).intValue();
     }    
 }

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/resources/ehcache.xml	2011-04-23 19:09:19 +0000
@@ -11,110 +11,118 @@
     overflowToDisk="false"
     diskPersistent="false"
     diskExpiryThreadIntervalSeconds="720"
-    memoryStoreEvictionPolicy="LRU"
-  />
+    memoryStoreEvictionPolicy="LRU"/>
 
   <!-- Hibernate entities -->
 
   <cache name="org.hisp.dhis.dataelement.DataElement"
-    maxElementsInMemory="4000"
-  />
+    maxElementsInMemory="4000"/>
 
   <cache name="org.hisp.dhis.dataelement.DataElementCategoryCombo"
-    maxElementsInMemory="100"
-  />
+    maxElementsInMemory="100"/>
   
   <cache name="org.hisp.dhis.dataelement.DataElementCategory"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
   
   <cache name="org.hisp.dhis.dataelement.DataElementCategoryOption"
-    maxElementsInMemory="400"
-  />
+    maxElementsInMemory="400"/>
   
   <cache name="org.hisp.dhis.dataelement.DataElementCategoryOptionCombo"
-    maxElementsInMemory="800"
-  />
+    maxElementsInMemory="800"/>
   
   <cache name="org.hisp.dhis.dataelement.DataElementGroup"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
+
+  <cache name="org.hisp.dhis.dataelement.DataElementGroupSet"
+    maxElementsInMemory="100"/>
 
   <cache name="org.hisp.dhis.indicator.Indicator"
-    maxElementsInMemory="1000"
-  />
+    maxElementsInMemory="1000"/>
   
   <cache name="org.hisp.dhis.indicator.IndicatorGroup"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
+  
+  <cache name="org.hisp.dhis.indicator.IndicatorGroupSet"
+    maxElementsInMemory="100"/>
   
   <cache name="org.hisp.dhis.indicator.IndicatorType"
-    maxElementsInMemory="100"
-  />
+    maxElementsInMemory="100"/>
   
   <cache name="org.hisp.dhis.datadictionary.DataDictionary"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
   
   <cache name="org.hisp.dhis.period.Period"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
   
   <cache name="org.hisp.dhis.period.PeriodType"
-    maxElementsInMemory="50"
-  />
+    maxElementsInMemory="50"/>
   
   <cache name="org.hisp.dhis.dataset.DataSet"
-    maxElementsInMemory="100"
-  />
+    maxElementsInMemory="100"/>
   
   <cache name="org.hisp.dhis.dataset.Section"
-    maxElementsInMemory="400"
-  />
+    maxElementsInMemory="400"/>
+  
+  <cache name="org.hisp.dhis.expression.Expression"
+    maxElementsInMemory="200"/>
+  
+  <cache name="org.hisp.dhis.validation.ValidationRule"
+    maxElementsInMemory="200"/>
+  
+  <cache name="org.hisp.dhis.validation.ValidationRuleGroup"
+    maxElementsInMemory="50"/>
   
   <cache name="org.hisp.dhis.organisationunit.OrganisationUnit"
-    maxElementsInMemory="20000"
-  />
+    maxElementsInMemory="20000"/>
+  
+  <cache name="org.hisp.dhis.organisationunit.OrganisationUnitGroup"
+    maxElementsInMemory="100"/>
+  
+  <cache name="org.hisp.dhis.organisationunit.OrganisationUnitGroupSet"
+    maxElementsInMemory="50"/>
   
   <cache name="org.hisp.dhis.user.User"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
 
   <cache name="org.hisp.dhis.user.UserSetting"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
 
   <cache name="org.hisp.dhis.user.UserCredentials"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
 
   <cache name="org.hisp.dhis.user.UserCredentials.userAuthorityGroups"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
 
   <cache name="org.hisp.dhis.options.SystemSetting"
-    maxElementsInMemory="200"
-  />
+    maxElementsInMemory="200"/>
   
   <cache name="org.hisp.dhis.translation.Translation"
-    maxElementsInMemory="8000"
-  />
+    maxElementsInMemory="8000"/>
   
   <cache name="org.hisp.dhis.message.Message"
-    maxElementsInMemory="500"
-  />
+    maxElementsInMemory="500"/>
   
   <cache name="org.hisp.dhis.message.UserMessage"
     maxElementsInMemory="50000"/>
   
+  <cache name="org.hisp.dhis.chart.Chart"
+    maxElementsInMemory="100"/>
+  
+  <cache name="org.hisp.dhis.reporttable.ReportTable"
+    maxElementsInMemory="100"/>
+  
+  <cache name="org.hisp.dhis.report.Report"
+    maxElementsInMemory="100"/>
+    
+  <cache name="org.hisp.dhis.document.Document"
+    maxElementsInMemory="100"/>
+  
   <!-- Hibernate Query Cache -->
   
   <cache name="org.hibernate.cache.StandardQueryCache"
-    maxElementsInMemory="200000"
-  />
+    maxElementsInMemory="200000"/>
 
   <cache name="org.hibernate.cache.UpdateTimestampsCache"
-    maxElementsInMemory="1000"
-  />
+    maxElementsInMemory="1000"/>
 
 </ehcache>

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java	2011-04-07 12:42:11 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java	2011-04-23 18:52:44 +0000
@@ -81,10 +81,7 @@
             throw new IllegalArgumentException( "Root OrganisationUnit cannot be null" );
         }
 
-        Collection<OrganisationUnit> rootUnits = new HashSet<OrganisationUnit>();
-        rootUnits.addAll( organisationUnits );
-
-        saveToSession( SESSION_KEY_ROOT_ORG_UNITS, rootUnits );
+        saveToSession( SESSION_KEY_ROOT_ORG_UNITS, new HashSet<OrganisationUnit>( organisationUnits ) );
 
         clearSelectedOrganisationUnits();
     }