← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16665: finished moving from hql to criteria in hibernate generic store, added more methods to idObjectMa...

 

------------------------------------------------------------
revno: 16665
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-09-09 14:32:11 +0700
message:
  finished moving from hql to criteria in hibernate generic store, added more methods to idObjectManager to get count by created/lastUpdated, more tests
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/common/IdentifiableObjectManagerTest.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.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/common/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2014-09-09 04:59:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2014-09-09 07:32:11 +0000
@@ -215,6 +215,8 @@
      */
     List<T> getByUidNoAcl( Collection<String> uids );
 
+    int getCountGeCreated( Date created );
+
     /**
      * Returns all objects that are equal to or newer than given date.
      *
@@ -238,6 +240,15 @@
      * @param lastUpdated Date to compare to.
      * @return All objects equal or newer than given date.
      */
+    List<T> getAllGeCreatedOrderedName( Date created );
+
+    /**
+     * Returns all objects that are equal to or newer than given date.
+     * (ordered by name)
+     *
+     * @param lastUpdated Date to compare to.
+     * @return All objects equal or newer than given date.
+     */
     List<T> getAllGeLastUpdatedOrderedName( Date lastUpdated );
 
     /**
@@ -246,7 +257,7 @@
      * @param lastUpdated Date to compare to.
      * @return the number of objects equal or newer than given date.
      */
-    long getCountGeLastUpdated( Date lastUpdated );
+    int getCountGeLastUpdated( Date lastUpdated );
 
     /**
      * Retrieves objects associated with the given user.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2014-09-09 04:59:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java	2014-09-09 07:32:11 +0000
@@ -84,12 +84,16 @@
 
     <T extends IdentifiableObject> List<T> getBetween( Class<T> clazz, int first, int max );
 
-    <T extends IdentifiableObject> List<T> getBetweenByName( Class<T> clazz, String name, int first, int max );
+    <T extends IdentifiableObject> List<T> getBetweenLikeName( Class<T> clazz, String name, int first, int max );
 
     <T extends IdentifiableObject> Collection<T> getByLastUpdated( Class<T> clazz, Date lastUpdated );
 
+    <T extends IdentifiableObject> Collection<T> getByCreated( Class<T> clazz, Date created );
+
     <T extends IdentifiableObject> Collection<T> getByLastUpdatedSorted( Class<T> clazz, Date lastUpdated );
 
+    <T extends IdentifiableObject> Collection<T> getByCreatedSorted( Class<T> clazz, Date created );
+
     void delete( IdentifiableObject object );
 
     <T extends IdentifiableObject> Set<Integer> convertToId( Class<T> clazz, Collection<String> uids );
@@ -110,6 +114,10 @@
 
     <T extends IdentifiableObject> int getCountByShortName( Class<T> clazz, String shortName );
 
+    <T extends IdentifiableObject> int getCountByCreated( Class<T> clazz, Date created );
+
+    <T extends IdentifiableObject> int getCountByLastUpdated( Class<T> clazz, Date lastUpdated );
+
     <T extends IdentifiableObject> int getCountLikeName( Class<T> clazz, String name );
 
     <T extends IdentifiableObject> int getCountLikeShortName( Class<T> clazz, String shortName );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2014-09-09 04:59:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java	2014-09-09 07:32:11 +0000
@@ -117,7 +117,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> T get( String uid )
     {
         for ( GenericIdentifiableObjectStore<? extends IdentifiableObject> store : identifiableObjectStores )
@@ -134,7 +134,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> T get( Class<T> clazz, int id )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -148,7 +148,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> T get( Class<T> clazz, String uid )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -168,7 +168,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> T getByCode( Class<T> clazz, String code )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -182,7 +182,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> T getByName( Class<T> clazz, String name )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -242,7 +242,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getAll( Class<T> clazz )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -256,7 +256,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getAllByName( Class<T> clazz, String name )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -270,7 +270,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getAllByNameIgnoreCase( Class<T> clazz, String name )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -284,7 +284,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getAllSorted( Class<T> clazz )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -298,7 +298,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getAllSortedByLastUpdated( Class<T> clazz )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -312,7 +312,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> List<T> getByUid( Class<T> clazz, Collection<String> uids )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -365,6 +365,32 @@
     }
 
     @Override
+    public <T extends IdentifiableObject> int getCountByCreated( Class<T> clazz, Date created )
+    {
+        GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
+
+        if ( store != null )
+        {
+            return store.getCountGeCreated( created );
+        }
+
+        return 0;
+    }
+
+    @Override
+    public <T extends IdentifiableObject> int getCountByLastUpdated( Class<T> clazz, Date lastUpdated )
+    {
+        GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
+
+        if ( store != null )
+        {
+            return store.getCountGeLastUpdated( lastUpdated );
+        }
+
+        return 0;
+    }
+
+    @Override
     public <T extends IdentifiableObject> int getCountLikeName( Class<T> clazz, String name )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -391,7 +417,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getLikeName( Class<T> clazz, String name )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -405,7 +431,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getLikeShortName( Class<T> clazz, String shortName )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -419,7 +445,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> List<T> getBetween( Class<T> clazz, int first, int max )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -433,8 +459,8 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
-    public <T extends IdentifiableObject> List<T> getBetweenByName( Class<T> clazz, String name, int first, int max )
+    @SuppressWarnings( "unchecked" )
+    public <T extends IdentifiableObject> List<T> getBetweenLikeName( Class<T> clazz, String name, int first, int max )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
 
@@ -447,7 +473,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getByLastUpdated( Class<T> clazz, Date lastUpdated )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -461,7 +487,21 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
+    public <T extends IdentifiableObject> Collection<T> getByCreated( Class<T> clazz, Date created )
+    {
+        GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
+
+        if ( store == null )
+        {
+            return new ArrayList<>();
+        }
+
+        return (Collection<T>) store.getAllGeCreated( created );
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Collection<T> getByLastUpdatedSorted( Class<T> clazz, Date lastUpdated )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -475,6 +515,20 @@
     }
 
     @Override
+    @SuppressWarnings( "unchecked" )
+    public <T extends IdentifiableObject> Collection<T> getByCreatedSorted( Class<T> clazz, Date created )
+    {
+        GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
+
+        if ( store == null )
+        {
+            return new ArrayList<>();
+        }
+
+        return (Collection<T>) store.getAllGeCreatedOrderedName( created );
+    }
+
+    @Override
     public <T extends IdentifiableObject> Set<Integer> convertToId( Class<T> clazz, Collection<String> uids )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -495,7 +549,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> Map<String, T> getIdMap( Class<T> clazz, IdentifiableProperty property )
     {
         Map<String, T> map = new HashMap<>();
@@ -545,7 +599,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends NameableObject> Map<String, T> getIdMap( Class<T> clazz, NameableProperty property )
     {
         Map<String, T> map = new HashMap<>();
@@ -569,7 +623,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> T getObject( Class<T> clazz, IdentifiableProperty property, String id )
     {
         GenericIdentifiableObjectStore<T> store = (GenericIdentifiableObjectStore<T>) getIdentifiableObjectStore( clazz );
@@ -629,7 +683,7 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public <T extends IdentifiableObject> T getNoAcl( Class<T> clazz, String uid )
     {
         GenericIdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz );
@@ -657,7 +711,7 @@
     // Supportive methods
     //--------------------------------------------------------------------------
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     private <T extends IdentifiableObject> GenericIdentifiableObjectStore<IdentifiableObject> getIdentifiableObjectStore( Class<T> clazz )
     {
         initMaps();
@@ -677,7 +731,7 @@
         return (GenericIdentifiableObjectStore<IdentifiableObject>) store;
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     private <T extends NameableObject> GenericNameableObjectStore<NameableObject> getNameableObjectStore( Class<T> clazz )
     {
         initMaps();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java	2014-09-09 05:03:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java	2014-09-09 07:32:11 +0000
@@ -329,130 +329,61 @@
     }
 
     @Override
-    public long getCountGeLastUpdated( Date lastUpdated )
-    {
-        Query query = sharingEnabled() ? getQueryCountGeLastUpdatedAcl( lastUpdated ) : getQueryCountGeLastUpdated( lastUpdated );
-
-        return ((Long) query.uniqueResult()).intValue();
-    }
-
-    private Query getQueryCountGeLastUpdatedAcl( Date lastUpdated )
-    {
-        String hql = "select count(distinct c) from " + clazz.getName() + " c"
-            + " where c.lastUpdated >= :lastUpdated and (c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
-            + " or exists "
-            + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
-            + " )";
-
-        Query query = getQuery( hql );
-        query.setEntity( "user", currentUserService.getCurrentUser() );
-        query.setTimestamp( "lastUpdated", lastUpdated );
-
-        return query;
-    }
-
-    private Query getQueryCountGeLastUpdated( Date lastUpdated )
-    {
-        Query query = getQuery( "select count(distinct c) from " + clazz.getName() + " c where lastUpdated >= :lastUpdated" );
-        query.setTimestamp( "lastUpdated", lastUpdated );
-
-        return query;
+    public int getCountGeLastUpdated( Date lastUpdated )
+    {
+        return ((Number) getSharingCriteria()
+            .add( Restrictions.ge( "lastUpdated", lastUpdated ) )
+            .setProjection( Projections.countDistinct( "id" ) )
+            .uniqueResult()).intValue();
     }
 
     @Override
     @SuppressWarnings( "unchecked" )
     public List<T> getAllGeLastUpdated( Date lastUpdated )
     {
-        Query query = sharingEnabled() ? getQueryAllGeLastUpdatedAcl( lastUpdated ) : getQueryAllGeLastUpdated( lastUpdated );
-
-        return query.list();
-    }
-
-    private Query getQueryAllGeLastUpdatedAcl( Date lastUpdated )
-    {
-        String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where c.lastUpdated >= :lastUpdated and ( c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
-            + " or exists "
-            + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
-            + " )";
-
-        Query query = getQuery( hql );
-        query.setEntity( "user", currentUserService.getCurrentUser() );
-        query.setTimestamp( "lastUpdated", lastUpdated );
-
-        return query;
-    }
-
-    private Query getQueryAllGeLastUpdated( Date lastUpdated )
-    {
-        Query query = getQuery( "from " + clazz.getName() + " c where c.lastUpdated >= :lastUpdated" );
-        query.setTimestamp( "lastUpdated", lastUpdated );
-
-        return query;
+        return getSharingCriteria()
+            .add( Restrictions.ge( "lastUpdated", lastUpdated ) )
+            .addOrder( Order.desc( "lastUpdated" ) )
+            .list();
+    }
+
+    @Override
+    public int getCountGeCreated( Date created )
+    {
+        return ((Number) getSharingCriteria()
+            .add( Restrictions.ge( "created", created ) )
+            .setProjection( Projections.countDistinct( "id" ) )
+            .uniqueResult()).intValue();
     }
 
     @Override
     @SuppressWarnings( "unchecked" )
     public List<T> getAllGeCreated( Date created )
     {
-        Query query = sharingEnabled() ? getQueryAllGeCreatedAcl( created ) : getQueryAllGeCreated( created );
-
-        return query.list();
-    }
-
-    private Query getQueryAllGeCreatedAcl( Date created )
-    {
-        String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where c.created >= :created and ( c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
-            + " or exists "
-            + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
-            + " ) order by c.name";
-
-        Query query = getQuery( hql );
-        query.setEntity( "user", currentUserService.getCurrentUser() );
-        query.setTimestamp( "created", created );
-
-        return query;
-    }
-
-    private Query getQueryAllGeCreated( Date created )
-    {
-        Query query = getQuery( "from " + clazz.getName() + " c where c.created >= :created" );
-        query.setTimestamp( "created", created );
-
-        return query;
+        return getSharingCriteria()
+            .add( Restrictions.ge( "created", created ) )
+            .addOrder( Order.desc( "created" ) )
+            .list();
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public List<T> getAllGeCreatedOrderedName( Date created )
+    {
+        return getSharingCriteria()
+            .add( Restrictions.ge( "created", created ) )
+            .addOrder( Order.asc( "name" ) )
+            .list();
     }
 
     @Override
     @SuppressWarnings( "unchecked" )
     public List<T> getAllGeLastUpdatedOrderedName( Date lastUpdated )
     {
-        Query query = sharingEnabled() ? getQueryAllGeLastUpdatedOrderedNameAcl( lastUpdated ) : getQueryAllGeLastUpdatedOrderedName( lastUpdated );
-
-        return query.list();
-    }
-
-    private Query getQueryAllGeLastUpdatedOrderedNameAcl( Date lastUpdated )
-    {
-        String hql = "select distinct c from " + clazz.getName() + " c"
-            + " where c.lastUpdated >= :lastUpdated and ( c.publicAccess like 'r%' or c.user IS NULL or c.user=:user"
-            + " or exists "
-            + "     (from c.userGroupAccesses uga join uga.userGroup ug join ug.members ugm where ugm = :user and uga.access like 'r%')"
-            + " ) order by c.name";
-
-        Query query = getQuery( hql );
-        query.setEntity( "user", currentUserService.getCurrentUser() );
-        query.setTimestamp( "lastUpdated", lastUpdated );
-
-        return query;
-    }
-
-    private Query getQueryAllGeLastUpdatedOrderedName( Date lastUpdated )
-    {
-        Query query = getQuery( "from " + clazz.getName() + " c where c.lastUpdated >= :lastUpdated order by c.name" );
-        query.setTimestamp( "lastUpdated", lastUpdated );
-
-        return query;
+        return getSharingCriteria()
+            .add( Restrictions.ge( "lastUpdated", lastUpdated ) )
+            .addOrder( Order.asc( "name" ) )
+            .list();
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/common/IdentifiableObjectManagerTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/common/IdentifiableObjectManagerTest.java	2014-09-09 04:59:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/common/IdentifiableObjectManagerTest.java	2014-09-09 07:32:11 +0000
@@ -46,6 +46,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 
 import java.util.ArrayList;
+import java.util.GregorianCalendar;
 import java.util.List;
 
 import static org.junit.Assert.*;
@@ -114,7 +115,7 @@
     }
 
     @Test
-    public void getCountByName()
+    public void getCountLikeName()
     {
         identifiableObjectManager.save( createDataElement( 'A' ) );
         identifiableObjectManager.save( createDataElement( 'B' ) );
@@ -128,6 +129,20 @@
     }
 
     @Test
+    public void getCountLikeShortName()
+    {
+        identifiableObjectManager.save( createDataElement( 'A' ) );
+        identifiableObjectManager.save( createDataElement( 'B' ) );
+        identifiableObjectManager.save( createDataElement( 'C' ) );
+        identifiableObjectManager.save( createDataElement( 'D' ) );
+
+        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortA" ) );
+        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortA" ) );
+        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortA" ) );
+        assertEquals( 1, identifiableObjectManager.getCountLikeShortName( DataElement.class, "DataElementShortA" ) );
+    }
+
+    @Test
     public void getEqualToName()
     {
         DataElement dataElement = createDataElement( 'A' );
@@ -171,7 +186,7 @@
     }
 
     @Test
-    public void getAllLikeName()
+    public void getLikeName()
     {
         identifiableObjectManager.save( createDataElement( 'A' ) );
         identifiableObjectManager.save( createDataElement( 'B' ) );
@@ -377,4 +392,58 @@
         assertEquals( 4, identifiableObjectManager.getCount( DataElement.class ) );
         assertEquals( 4, identifiableObjectManager.getAll( DataElement.class ).size() );
     }
+
+    @Test
+    public void getAllGeCreated()
+    {
+        DataElement dataElementA = createDataElement( 'A' );
+        DataElement dataElementB = createDataElement( 'B' );
+        DataElement dataElementC = createDataElement( 'C' );
+        DataElement dataElementD = createDataElement( 'D' );
+
+        identifiableObjectManager.save( dataElementA );
+        identifiableObjectManager.save( dataElementB );
+        identifiableObjectManager.save( dataElementC );
+        identifiableObjectManager.save( dataElementD );
+
+        dataElementA.setCreated( new GregorianCalendar( 2014, 0, 1 ).getTime() );
+        dataElementB.setCreated( new GregorianCalendar( 2013, 0, 1 ).getTime() );
+        dataElementC.setCreated( new GregorianCalendar( 2012, 0, 1 ).getTime() );
+        dataElementD.setCreated( new GregorianCalendar( 2011, 0, 1 ).getTime() );
+
+        sessionFactory.getCurrentSession().update( dataElementA );
+        sessionFactory.getCurrentSession().update( dataElementB );
+        sessionFactory.getCurrentSession().update( dataElementC );
+        sessionFactory.getCurrentSession().update( dataElementD );
+
+        assertEquals( 2, identifiableObjectManager.getCountByCreated( DataElement.class, new GregorianCalendar( 2012, 5, 1 ).getTime() ) );
+        assertEquals( 2, identifiableObjectManager.getByCreated( DataElement.class, new GregorianCalendar( 2012, 5, 1 ).getTime() ).size() );
+    }
+
+    @Test
+    public void getAllGeLastUpdated()
+    {
+        DataElement dataElementA = createDataElement( 'A' );
+        DataElement dataElementB = createDataElement( 'B' );
+        DataElement dataElementC = createDataElement( 'C' );
+        DataElement dataElementD = createDataElement( 'D' );
+
+        identifiableObjectManager.save( dataElementA );
+        identifiableObjectManager.save( dataElementB );
+        identifiableObjectManager.save( dataElementC );
+        identifiableObjectManager.save( dataElementD );
+
+        dataElementA.setLastUpdated( new GregorianCalendar( 2014, 0, 1 ).getTime() );
+        dataElementB.setLastUpdated( new GregorianCalendar( 2013, 0, 1 ).getTime() );
+        dataElementC.setLastUpdated( new GregorianCalendar( 2012, 0, 1 ).getTime() );
+        dataElementD.setLastUpdated( new GregorianCalendar( 2011, 0, 1 ).getTime() );
+
+        sessionFactory.getCurrentSession().update( dataElementA );
+        sessionFactory.getCurrentSession().update( dataElementB );
+        sessionFactory.getCurrentSession().update( dataElementC );
+        sessionFactory.getCurrentSession().update( dataElementD );
+
+        assertEquals( 2, identifiableObjectManager.getCountByLastUpdated( DataElement.class, new GregorianCalendar( 2012, 5, 1 ).getTime() ) );
+        assertEquals( 2, identifiableObjectManager.getByLastUpdated( DataElement.class, new GregorianCalendar( 2012, 5, 1 ).getTime() ).size() );
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2014-07-13 18:46:24 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/dashboard/impl/DefaultDashboardService.java	2014-09-09 07:32:11 +0000
@@ -104,13 +104,13 @@
     {
         DashboardSearchResult result = new DashboardSearchResult();
 
-        result.setUsers( objectManager.getBetweenByName( User.class, query, 0, getMax( TYPE_USERS, maxTypes ) ) );
-        result.setCharts( objectManager.getBetweenByName( Chart.class, query, 0, getMax( TYPE_CHART, maxTypes ) ) );
-        result.setEventCharts( objectManager.getBetweenByName( EventChart.class, query, 0, getMax( TYPE_EVENT_CHART, maxTypes ) ) );
-        result.setMaps( objectManager.getBetweenByName( Map.class, query, 0, getMax( TYPE_MAP, maxTypes ) ) );
-        result.setReportTables( objectManager.getBetweenByName( ReportTable.class, query, 0, getMax( TYPE_REPORT_TABLE, maxTypes ) ) );
-        result.setReports( objectManager.getBetweenByName( Report.class, query, 0, getMax( TYPE_REPORTS, maxTypes ) ) );
-        result.setResources( objectManager.getBetweenByName( Document.class, query, 0, getMax( TYPE_RESOURCES, maxTypes ) ) );
+        result.setUsers( objectManager.getBetweenLikeName( User.class, query, 0, getMax( TYPE_USERS, maxTypes ) ) );
+        result.setCharts( objectManager.getBetweenLikeName( Chart.class, query, 0, getMax( TYPE_CHART, maxTypes ) ) );
+        result.setEventCharts( objectManager.getBetweenLikeName( EventChart.class, query, 0, getMax( TYPE_EVENT_CHART, maxTypes ) ) );
+        result.setMaps( objectManager.getBetweenLikeName( Map.class, query, 0, getMax( TYPE_MAP, maxTypes ) ) );
+        result.setReportTables( objectManager.getBetweenLikeName( ReportTable.class, query, 0, getMax( TYPE_REPORT_TABLE, maxTypes ) ) );
+        result.setReports( objectManager.getBetweenLikeName( Report.class, query, 0, getMax( TYPE_REPORTS, maxTypes ) ) );
+        result.setResources( objectManager.getBetweenLikeName( Document.class, query, 0, getMax( TYPE_RESOURCES, maxTypes ) ) );
 
         return result;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2014-09-09 04:59:32 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2014-09-09 07:32:11 +0000
@@ -174,7 +174,7 @@
                 Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
                 metaData.setPager( pager );
 
-                entityList = Lists.newArrayList( manager.getBetweenByName( getEntityClass(), name, pager.getOffset(), pager.getPageSize() ) );
+                entityList = Lists.newArrayList( manager.getBetweenLikeName( getEntityClass(), name, pager.getOffset(), pager.getPageSize() ) );
             }
             else
             {