← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2156: Added methods for getting paginated result sets of objects to GenericIdentifiableObjectStore. Cen...

 

------------------------------------------------------------
revno: 2156
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-11-23 19:25:34 +0100
message:
  Added methods for getting paginated result sets of objects to GenericIdentifiableObjectStore. Centralizes code for pagination.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientMobileSetting.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementOperandService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/ValidateAddUpdateConceptAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetDataElementGroupListAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.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/common/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2010-11-23 18:25:34 +0000
@@ -27,6 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -73,4 +75,39 @@
      * @return the object with the given code.
      */
     T getByCode( String code );
+    
+    /**
+     * Retrieves the objects determined by the given first result and max result.
+     * 
+     * @param first the first result object to return.
+     * @param max the max number of result objects to return. 
+     * @return collection of objects.
+     */
+    Collection<T> getBetween( int first, int max );
+
+    /**
+     * Retrieves the objects determined by the given first result and max result
+     * which name is like the given name.
+     * 
+     * @param the name which result object names must be like.
+     * @param first the first result object to return.
+     * @param max the max number of result objects to return. 
+     * @return collection of objects.
+     */    
+    Collection<T> getBetweenByName( String name, int first, int max );
+    
+    /**
+     * Gets the count of objects.
+     * 
+     * @return the count of objects.
+     */
+    int getCount();
+    
+    /**
+     * Gets the count of objects which name is like the given name.
+     * 
+     * @param name the name which result object names must be like.
+     * @return the count of objects.
+     */
+    int getCountByName( String name );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2010-11-02 13:02:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2010-11-23 18:25:34 +0000
@@ -299,6 +299,14 @@
 
     Collection<DataElement> getDataElementsByDataSets( Collection<DataSet> dataSets );
     
+    Collection<DataElement> getDataElementsBetween( int first, int max );
+    
+    Collection<DataElement> getDataElementsBetweenByName( String name, int first, int max );
+    
+    int getDataElementCount();
+    
+    int getDataElementCountByName( String name );
+    
     // -------------------------------------------------------------------------
     // Calculated Data Elements
     // -------------------------------------------------------------------------
@@ -479,6 +487,14 @@
      */
     Collection<DataElement> getDataElementsByZeroIsSignificantAndGroup( boolean zeroIsSignificant, DataElementGroup dataElementGroup );
 
+    Collection<DataElementGroup> getDataElementGroupsBetween( int first, int max );
+    
+    Collection<DataElementGroup> getDataElementGroupsBetweenByName( String name, int first, int max );
+    
+    int getDataElementGroupCount();
+    
+    int getDataElementGroupCountByName( String name );
+    
     // -------------------------------------------------------------------------
     // DataElementGroupSet
     // -------------------------------------------------------------------------
@@ -518,19 +534,4 @@
      */
     Collection<DataElementOperand> getAllGeneratedOperands( Collection<DataElement> dataElements );
     
-    int getNumberOfDataElements();
-
-    Collection<DataElement> getAllDataElements( int from, int to );
-
-    Collection<DataElement> searchDataElementByName( String key, int from, int to );
-
-    int countNumberOfSearchDataElementByName( String key );
-
-    Collection<DataElementGroup> getAllDataElementGroups( int from, int to );
-    
-    int getNumberOfDataElementGroups();
-    
-    Collection<DataElementGroup> searchDataElementGroupByName( String key, int from, int to );
-    
-    int countNumberOfSearchDataElementGroupByName( String key );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2010-11-02 13:02:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2010-11-23 18:25:34 +0000
@@ -236,6 +236,14 @@
     
     Collection<DataElement> getDataElementsByDataSets( Collection<DataSet> dataSets );
 
+    Collection<DataElement> getDataElementsBetween( int first, int max );
+    
+    Collection<DataElement> getDataElementsBetweenByName( String name, int first, int max );
+    
+    int getDataElementCount();
+    
+    int getDataElementCountByName( String name );
+    
     // -------------------------------------------------------------------------
     // Calculated Data Elements
     // -------------------------------------------------------------------------
@@ -289,22 +297,5 @@
      * @param dataElements the DataElements.
      * @return a collection of all Operands.
      */
-    Collection<DataElementOperand> getAllGeneratedOperands( Collection<DataElement> dataElements );    
-
-    int getNumberOfDataElements();
-
-    Collection<DataElement> getAllDataElements( int from, int to );
-
-    Collection<DataElement> searchDataElementByName( String key, int from, int to );
-
-    int countNumberOfSearchDataElementByName( String key );
-    
-    Collection<DataElementGroup> getAllDataElementGroups( int from, int to );
-    
-    int getNumberOfDataElementGroups();
-    
-    Collection<DataElementGroup> searchDataElementGroupByName( String key, int from, int to );
-    
-    int countNumberOfSearchDataElementGroupByName( String key );
-
+    Collection<DataElementOperand> getAllGeneratedOperands( Collection<DataElement> dataElements );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientMobileSetting.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientMobileSetting.java	2010-11-23 07:16:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientMobileSetting.java	2010-11-23 18:25:34 +0000
@@ -28,7 +28,6 @@
 package org.hisp.dhis.patient;
 
 import java.util.List;
-import java.util.Set;
 
 import org.hisp.dhis.common.IdentifiableObject;
 
@@ -49,8 +48,4 @@
     {
         this.patientAttributes = patientAttributes;
     }
-    
-    
-    
-    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementOperandService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementOperandService.java	2010-07-07 10:56:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementOperandService.java	2010-11-23 18:25:34 +0000
@@ -75,7 +75,6 @@
     {
         for ( DataElementOperand operand : getAllDataElementOperands() )
         {
-
             if ( operand.getDataElement().equals( dataElementOperand.getDataElement() )
                 && operand.getCategoryOptionCombo().equalsOnName( dataElementOperand.getCategoryOptionCombo() ) )
             {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2010-11-02 13:02:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2010-11-23 18:25:34 +0000
@@ -358,6 +358,26 @@
         return dataElementStore.dataElementCategoryOptionComboExists( id );
     }
 
+    public Collection<DataElement> getDataElementsBetween( int first, int max )
+    {
+        return dataElementStore.getDataElementsBetween( first, max );
+    }
+    
+    public Collection<DataElement> getDataElementsBetweenByName( String name, int first, int max )
+    {
+        return dataElementStore.getDataElementsBetweenByName( name, first, max );
+    }
+
+    public int getDataElementCount()
+    {
+        return dataElementStore.getDataElementCount();
+    }
+    
+    public int getDataElementCountByName( String name )
+    {
+        return dataElementStore.getDataElementCountByName( name );
+    }
+    
     // -------------------------------------------------------------------------
     // CalculatedDataElement
     // -------------------------------------------------------------------------
@@ -576,6 +596,26 @@
         return i18n( i18nService, dataElementGroupStore.get( groupId ).getMembers() );
     }
 
+    public Collection<DataElementGroup> getDataElementGroupsBetween( int first, int max )
+    {
+        return dataElementGroupStore.getBetween( first, max );
+    }
+    
+    public Collection<DataElementGroup> getDataElementGroupsBetweenByName( String name, int first, int max )
+    {
+        return dataElementGroupStore.getBetweenByName( name, first, max );
+    }
+
+    public int getDataElementGroupCount()
+    {
+        return dataElementGroupStore.getCount();
+    }
+    
+    public int getDataElementGroupCountByName( String name )
+    {
+        return dataElementGroupStore.getCountByName( name );
+    }
+    
     // -------------------------------------------------------------------------
     // DataElementGroupSet
     // -------------------------------------------------------------------------
@@ -644,48 +684,4 @@
     {
         return dataElementStore.getAllGeneratedOperands( dataElements );
     }
-
-    public Collection<DataElement> getAllDataElements( int from, int to )
-    {
-        return dataElementStore.getAllDataElements( from, to );
-    }
-
-    public int getNumberOfDataElements()
-    {
-        return dataElementStore.getNumberOfDataElements();
-    }
-
-    public Collection<DataElement> searchDataElementByName( String key, int from, int to )
-    {
-        return dataElementStore.searchDataElementByName( key, from, to );
-    }
-
-    public int countNumberOfSearchDataElementByName( String key )
-    {
-        return dataElementStore.countNumberOfSearchDataElementByName( key );
-    }
-
-    @Override
-    public Collection<DataElementGroup> getAllDataElementGroups( int from, int to )
-    {
-        return dataElementStore.getAllDataElementGroups( from, to );
-    }
-
-    @Override
-    public int getNumberOfDataElementGroups()
-    {
-        return dataElementStore.getNumberOfDataElementGroups();
-    }
-
-    @Override
-    public Collection<DataElementGroup> searchDataElementGroupByName( String key, int from, int to )
-    {
-        return dataElementStore.searchDataElementGroupByName( key, from, to );
-    }
-
-    @Override
-    public int countNumberOfSearchDataElementGroupByName( String key )
-    {
-        return dataElementStore.countNumberOfSearchDataElementGroupByName( key );
-    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2010-11-10 13:49:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2010-11-23 18:25:34 +0000
@@ -38,16 +38,15 @@
 import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.Session;
-import org.hibernate.SessionFactory;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.dataelement.CalculatedDataElement;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.dataelement.DataElementStore;
 import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
 import org.hisp.dhis.hierarchy.HierarchyViolationException;
 import org.hisp.dhis.system.objectmapper.DataElementOperandMapper;
 import org.hisp.dhis.system.util.ConversionUtils;
@@ -59,19 +58,12 @@
  *          larshelg $
  */
 public class HibernateDataElementStore
-    implements DataElementStore
+    extends HibernateGenericStore<DataElement> implements DataElementStore
 {
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private SessionFactory sessionFactory;
-
-    public void setSessionFactory( SessionFactory sessionFactory )
-    {
-        this.sessionFactory = sessionFactory;
-    }
-
     private StatementManager statementManager;
 
     public void setStatementManager( StatementManager statementManager )
@@ -287,9 +279,7 @@
             query.setParameterList( "dataElementIds", dataElementIds );
 
             query.executeUpdate();
-
         }
-
     }
 
     @SuppressWarnings( "unchecked" )
@@ -389,69 +379,26 @@
 
     }
 
-    // -------------------------------------------------------------------------
-    // DataElementGroup
-    // -------------------------------------------------------------------------
-
-    public int addDataElementGroup( DataElementGroup dataElementGroup )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        return (Integer) session.save( dataElementGroup );
-    }
-
-    public void updateDataElementGroup( DataElementGroup dataElementGroup )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.update( dataElementGroup );
-    }
-
-    public void deleteDataElementGroup( DataElementGroup dataElementGroup )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        session.delete( dataElementGroup );
-    }
-
-    public DataElementGroup getDataElementGroup( int id )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        return (DataElementGroup) session.get( DataElementGroup.class, id );
-    }
-
-    public DataElementGroup getDataElementGroup( String uuid )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataElementGroup.class );
-        criteria.add( Restrictions.eq( "uuid", uuid ) );
-
-        return (DataElementGroup) criteria.uniqueResult();
-    }
-
-    public DataElementGroup getDataElementGroupByName( String name )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataElementGroup.class );
-        criteria.add( Restrictions.eq( "name", name ) );
-
-        return (DataElementGroup) criteria.uniqueResult();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<DataElementGroup> getAllDataElementGroups()
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataElementGroup.class );
-        criteria.setCacheable( true );
-
-        return criteria.list();
-    }
-
+    public Collection<DataElement> getDataElementsBetween( int first, int max )
+    {
+        return getBetween( first, max );
+    }
+
+    public Collection<DataElement> getDataElementsBetweenByName( String name, int first, int max )
+    {
+        return getBetweenByName( name, first, max );
+    }
+
+    public int getDataElementCount()
+    {
+        return getCount();
+    }
+
+    public int getDataElementCountByName( String name )
+    {
+        return getCountByName( name );
+    }
+    
     // -------------------------------------------------------------------------
     // DataElementOperand
     // -------------------------------------------------------------------------
@@ -503,98 +450,4 @@
             throw new RuntimeException( "Failed to get all operands", ex );
         }
     }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<DataElement> getAllDataElements( int from, int to )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataElement.class );
-        criteria.addOrder( Order.asc( "name" ) );
-        criteria.setFirstResult( from );
-        criteria.setMaxResults( to );
-        criteria.setCacheable( true );
-
-        return criteria.list();
-    }
-
-    public int getNumberOfDataElements()
-    {
-        String sql = "select count(*) from DataElement";
-        Query query = sessionFactory.getCurrentSession().createQuery( sql );
-        Number countResult = (Number) query.uniqueResult();
-
-        return countResult.intValue();
-    }
-
-    public int countNumberOfSearchDataElementByName( String key )
-    {
-        return searchDataElementByName( key ).size();
-    }
-
-    @SuppressWarnings("unchecked")
-    public Collection<DataElement> searchDataElementByName( String key, int from, int to )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataElement.class );
-        criteria.add( Restrictions.ilike( "name", "%" + key + "%" ) );
-        criteria.addOrder( Order.asc( "name" ) );
-        criteria.setFirstResult( from );
-        criteria.setMaxResults( to );
-
-        return criteria.list();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<DataElementGroup> getAllDataElementGroups( int from, int to )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataElementGroup.class );
-        criteria.addOrder( Order.asc( "name" ) );
-        criteria.setFirstResult( from );
-        criteria.setMaxResults( to );
-        criteria.setCacheable( true );
-
-        return criteria.list();
-    }
-
-    @Override
-    public int getNumberOfDataElementGroups()
-    {
-        String sql = "select count(*) from DataElementGroup";
-        Query query = sessionFactory.getCurrentSession().createQuery( sql );
-        Number countResult = (Number) query.uniqueResult();
-
-        return countResult.intValue();
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public Collection<DataElementGroup> searchDataElementGroupByName( String key, int from, int to )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataElementGroup.class );
-        criteria.add( Restrictions.ilike( "name", "%" + key + "%" ) );
-        criteria.addOrder( Order.asc( "name" ) );
-        criteria.setFirstResult( from );
-        criteria.setMaxResults( to );
-
-        return criteria.list();
-    }
-
-    @Override
-    public int countNumberOfSearchDataElementGroupByName( String key )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Criteria criteria = session.createCriteria( DataElementGroup.class );
-        criteria.add( Restrictions.ilike( "name", "%" + key + "%" ) );
-
-        return criteria.list().size();
-    }
 }

=== 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	2010-10-29 12:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-11-23 18:25:34 +0000
@@ -26,6 +26,7 @@
 
 	<bean id="org.hisp.dhis.dataelement.DataElementStore"
 		class="org.hisp.dhis.dataelement.hibernate.HibernateDataElementStore">
+		<property name="clazz" value="org.hisp.dhis.dataelement.DataElement"/>
 		<property name="sessionFactory" ref="sessionFactory"/>
 		<property name="statementManager" ref="statementManager"/>
 	</bean>

=== 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	2010-09-04 06:30:08 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2010-11-23 18:25:34 +0000
@@ -35,6 +35,8 @@
 import org.hibernate.SQLQuery;
 import org.hibernate.SessionFactory;
 import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 
@@ -45,6 +47,8 @@
 public class HibernateGenericStore<T>
     implements GenericIdentifiableObjectStore<T>
 {
+    //TODO cacheable
+    
     protected SessionFactory sessionFactory;
 
     public void setSessionFactory( SessionFactory sessionFactory )
@@ -150,69 +154,121 @@
     }
 
     // -------------------------------------------------------------------------
-    // GenericStore implementation
+    // GenericIdentifiableObjectStore implementation
     // -------------------------------------------------------------------------
 
+    @Override
     public final int save( T object )
     {
         return (Integer) sessionFactory.getCurrentSession().save( object );
     }
-    
+
+    @Override
     public final void update( T object )
     {
         sessionFactory.getCurrentSession().update( object );
     }
-    
+
+    @Override
     public final void saveOrUpdate( T object )
     {
         sessionFactory.getCurrentSession().saveOrUpdate( object );
     }
-    
+
+    @Override
     @SuppressWarnings( "unchecked" )
     public final T get( int id )
     {
         return (T) sessionFactory.getCurrentSession().get( getClazz(), id );
     }
 
+    @Override
     @SuppressWarnings( "unchecked" )
     public final T load( int id )
     {
         return (T) sessionFactory.getCurrentSession().load( getClazz(), id );
     }
 
+    @Override
     public final T getByUuid( String uuid )
     {
         return getObject( Restrictions.eq( "uuid", uuid ) );
     }
-    
+
+    @Override
     public final T getByName( String name )
     {
         return getObject( Restrictions.eq( "name", name ) );
     }
-    
+
+    @Override
     public final T getByAlternativeName( String alternativeName )
     {
         return getObject( Restrictions.eq( "alternativeName", alternativeName ) );
     }
-    
+
+    @Override
     public final T getByShortName( String shortName )
     {
         return getObject( Restrictions.eq( "shortName", shortName ) );
     }
-    
+
+    @Override
     public final T getByCode( String code )
     {
         return getObject( Restrictions.eq( "code", code ) );
     }
-    
+
+    @Override
     @SuppressWarnings( "unchecked" )
     public final Collection<T> getAll()
     {
         return getCriteria().list();
     }
 
+    @Override
     public final void delete( T object )
     {
         sessionFactory.getCurrentSession().delete( object );
     }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Collection<T> getBetween( int first, int max )
+    {
+        Criteria criteria = getCriteria();
+        criteria.addOrder( Order.asc( "name" ) );
+        criteria.setFirstResult( first );
+        criteria.setMaxResults( max );
+        return criteria.list();
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Collection<T> getBetweenByName( String name, int first, int max )
+    {
+        Criteria criteria = getCriteria();
+        criteria.add( Restrictions.ilike( "name", "%" + name + "%" ) );
+        criteria.addOrder( Order.asc( "name" ) );
+        criteria.setFirstResult( first );
+        criteria.setMaxResults( max );
+        return criteria.list();
+    }
+
+    @Override
+    public int getCount()
+    {
+        Criteria criteria = getCriteria();
+        criteria.setProjection( Projections.rowCount() );        
+        return ((Number) criteria.uniqueResult()).intValue();
+    }
+
+    @Override
+    public int getCountByName( String name )
+    {
+        Criteria criteria = getCriteria();
+        criteria.setProjection( Projections.rowCount() );
+        criteria.add( Restrictions.ilike( "name", "%" + name + "%" ) );        
+        return ((Number) criteria.uniqueResult()).intValue();
+    }    
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm	2010-10-05 11:04:35 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/paging/paging.vm	2010-11-23 18:25:34 +0000
@@ -1,4 +1,4 @@
-	
+<div class="paging-container">	
 	#set ( $baseLink 		= $paging.baseLink )
 	#set ( $pageSize 		= $paging.pageSize )
 	#set ( $currentPage 	= $paging.currentPage )
@@ -73,3 +73,4 @@
 		</tr>
 		</table>
 	#end
+</div>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/ValidateAddUpdateConceptAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/ValidateAddUpdateConceptAction.java	2010-09-08 10:40:26 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/concept/ValidateAddUpdateConceptAction.java	2010-11-23 18:25:34 +0000
@@ -26,8 +26,6 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-import java.util.regex.Pattern;
-
 import org.hisp.dhis.concept.Concept;
 import org.hisp.dhis.concept.ConceptService;
 import org.hisp.dhis.i18n.I18n;
@@ -41,8 +39,7 @@
 public class ValidateAddUpdateConceptAction
     extends ActionSupport
 {
-
-    private static final Pattern conceptNamePattern = Pattern.compile( "^[a-zA-Z][a-zA-Z0-9_]{0,9}$" );
+    //TODO private static final Pattern conceptNamePattern = Pattern.compile( "^[a-zA-Z][a-zA-Z0-9_]{0,9}$" );
 
     // -------------------------------------------------------------------------
     // Dependencies

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java	2010-10-21 16:27:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/GetDataElementListAction.java	2010-11-23 18:25:34 +0000
@@ -210,9 +210,9 @@
         }
         else
         {
-            this.paging = createPaging( dataElementService.getNumberOfDataElements() );
+            this.paging = createPaging( dataElementService.getDataElementCount() );
 
-            dataElements = new ArrayList<DataElement>( dataElementService.getAllDataElements( paging.getStartPos(), paging.getPageSize() ) );
+            dataElements = new ArrayList<DataElement>( dataElementService.getDataElementsBetween( paging.getStartPos(), paging.getPageSize() ) );
         }
 
         displayPropertyHandler.handle( dataElements );
@@ -266,8 +266,8 @@
         }
         else
         {
-            this.paging = createPaging( dataElementService.countNumberOfSearchDataElementByName(key) );
-            dataElements = new ArrayList<DataElement>( dataElementService.searchDataElementByName( key, this.paging.getStartPos(), this.paging.getPageSize() ) );
+            this.paging = createPaging( dataElementService.getDataElementCountByName( key ) );
+            dataElements = new ArrayList<DataElement>( dataElementService.getDataElementsBetweenByName( key, this.paging.getStartPos(), this.paging.getPageSize() ) );
         }
 
         displayPropertyHandler.handle( dataElements );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetDataElementGroupListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetDataElementGroupListAction.java	2010-11-02 13:02:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelementgroup/GetDataElementGroupListAction.java	2010-11-23 18:25:34 +0000
@@ -81,24 +81,25 @@
 
     public String execute()
     {
-        this.paging = createPaging( dataElementService.getNumberOfDataElementGroups() );
+        this.paging = createPaging( dataElementService.getDataElementGroupCount() );
 
-        dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getAllDataElementGroups( paging.getStartPos(), paging.getPageSize() ) );
+        dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getDataElementGroupsBetween( paging.getStartPos(), paging.getPageSize() ) );
 
         return SUCCESS;
     }
     
     public String searchByName()
     {
-        if(key != null && !key.trim().equals( "" )) {
-            
-            this.paging = createPaging( dataElementService.countNumberOfSearchDataElementGroupByName( key ) );
-            
-            dataElementGroups = new ArrayList<DataElementGroup>(dataElementService.searchDataElementGroupByName( key, paging.getStartPos(), paging.getPageSize() ));
+        if ( key != null && !key.trim().isEmpty() ) 
+        {   
+            this.paging = createPaging( dataElementService.getDataElementGroupCountByName( key ) );
+            
+            dataElementGroups = new ArrayList<DataElementGroup>( dataElementService.getDataElementGroupsBetweenByName( key, paging.getStartPos(), paging.getPageSize() ) );
             
             return SUCCESS;
         }
-        else {
+        else
+        {
             return execute();
         }
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2010-10-28 09:17:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2010-11-23 18:25:34 +0000
@@ -83,9 +83,7 @@
 				</tbody>
 			</table>
 			<p></p>
-	  		<div class="paging-container">
-				#parse( "/dhis-web-commons/paging/paging.vm" )
-			</div>
+	  		#parse( "/dhis-web-commons/paging/paging.vm" )
 			</div>
 			
 		</td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm	2010-11-02 13:02:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementGroup.vm	2010-11-23 18:25:34 +0000
@@ -43,9 +43,7 @@
 				</tbody>
 			</table>
 			<p></p>
-	  		<div class="paging-container">
-				#parse( "/dhis-web-commons/paging/paging.vm" )
-			</div>
+			#parse( "/dhis-web-commons/paging/paging.vm" )
 			</div>
 		</td>
 		<td style="width:20em; padding-left:2em; vertical-align:top">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js	2010-11-20 08:23:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElementGroup.js	2010-11-23 18:25:34 +0000
@@ -41,15 +41,16 @@
 // Search data element group
 // -----------------------------------------------------------------------------
 
-function searchDataElementGroup(){
+function searchDataElementGroup()
+{
+	var key = $( '#key' ).val();
 	
-	var params = 'key=' + getFieldValue( 'key' );
-    
-    var url = 'searchDataElementGroup.action?' + params;
-    
-    if( getFieldValue( 'key' ) != null && getFieldValue( 'key' ) != '' ) 
+    if ( key != null && key != '' ) 
     {
-    	$( '#content' ).load( url, null, unLockScreen );
+    	var url = 'searchDataElementGroup.action?key=' + key;
+    	
+    	$( '#content' ).load( url, unLockScreen );
+    	
     	lockScreen();
     }
     else 
@@ -58,7 +59,7 @@
     }
 }
 
-function searchDataElementGroupPaging(currentPage, pageSize) 
+function searchDataElementGroupPaging( currentPage, pageSize ) 
 {
 	var params = 'key=' + getFieldValue( 'key' );
 		params += '&currentPage=' + currentPage;
@@ -66,9 +67,10 @@
 
     var url = 'searchDataElementGroup.action?' + params;
     
-    if( getFieldValue( 'key' ) != null && getFieldValue( 'key' ) != '' ) 
+    if ( getFieldValue( 'key' ) != null && getFieldValue( 'key' ) != '' ) 
     {
     	$( '#content' ).load( url, null, unLockScreen );
+    	
     	lockScreen();
     }
     else 
@@ -79,13 +81,13 @@
 
 function changePageSizeSearch()
 {
-    var pageSize = jQuery("#sizeOfPage").val();
-    searchDataElementGroupPaging(1, pageSize);
+    var pageSize = $( '#sizeOfPage' ).val();
+    searchDataElementGroupPaging( 1, pageSize );
 }
 
 function jumpToPageSearch()
 {
-    var pageSize = jQuery("#sizeOfPage").val();
-    var currentPage = jQuery("#jumpToPage").val();
-    searchDataElementGroupPaging(currentPage, pageSize);
+    var pageSize = $( '#sizeOfPage' ).val();
+    var currentPage = $( '#jumpToPage' ).val();
+    searchDataElementGroupPaging( currentPage, pageSize );
 }