=== 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 2012-05-29 21:23:47 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java 2012-06-06 13:31:45 +0000 @@ -116,6 +116,15 @@ List getByLastUpdated( Date lastUpdated ); /** + * Returns all objects that are equal to or newer than given date. + * (sorted by name) + * + * @param lastUpdated Date to compare to. + * @return All objects equal or newer than given date. + */ + List getByLastUpdatedSorted( Date lastUpdated ); + + /** * Returns the number of objects that are equal to or newer than given date. * * @param lastUpdated Date to compare to. === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java 2012-03-22 12:34:46 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericStore.java 2012-06-06 13:31:45 +0000 @@ -96,6 +96,13 @@ Collection getAll(); /** + * Retrieves a Collection of all objects (sorted on name). + * + * @return a Collection of all objects. + */ + Collection getAllSorted(); + + /** * Removes the given object instance. * * @param object the object instance to delete. === 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 2012-05-27 21:50:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectManager.java 2012-06-06 13:31:45 +0000 @@ -53,12 +53,16 @@ Collection getAll( Class clazz ); + Collection getAllSorted( Class clazz ); + Collection getBetween( Class clazz, int first, int max ); Collection getBetweenByName( Class clazz, String name, int first, int max ); Collection getByLastUpdated( Class clazz, Date lastUpdated ); + Collection getByLastUpdatedSorted( Class clazz, Date lastUpdated ); + void delete( IdentifiableObject object ); Map getIdMap( Class clazz, IdentifiableProperty property ); === 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 2012-06-04 13:02:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultIdentifiableObjectManager.java 2012-06-06 13:31:45 +0000 @@ -203,6 +203,22 @@ @Override @SuppressWarnings( "unchecked" ) + public Collection getAllSorted( Class clazz ) + { + GenericIdentifiableObjectStore store = getIdentifiableObjectStore( clazz ); + + if ( store == null ) + { + log.warn( "No IdentifiableObject store found for " + clazz + ", returning empty collection (getAllSorted)." ); + + return new ArrayList(); + } + + return (Collection) store.getAllSorted(); + } + + @Override + @SuppressWarnings( "unchecked" ) public Collection getBetween( Class clazz, int first, int max ) { GenericIdentifiableObjectStore store = getIdentifiableObjectStore( clazz ); @@ -225,7 +241,7 @@ if ( store == null ) { - log.warn( "No IdentifiableObject store found for " + clazz + ", returning empty collection (getBetween)." ); + log.warn( "No IdentifiableObject store found for " + clazz + ", returning empty collection (getBetweenByName)." ); return new ArrayList(); } @@ -241,7 +257,7 @@ if ( store == null ) { - log.warn( "No IdentifiableObject store found for " + clazz + ", returning empty collection (getBetween)." ); + log.warn( "No IdentifiableObject store found for " + clazz + ", returning empty collection (getByLastUpdated)." ); return new ArrayList(); } @@ -251,6 +267,22 @@ @Override @SuppressWarnings( "unchecked" ) + public Collection getByLastUpdatedSorted( Class clazz, Date lastUpdated ) + { + GenericIdentifiableObjectStore store = getIdentifiableObjectStore( clazz ); + + if ( store == null ) + { + log.warn( "No IdentifiableObject store found for " + clazz + ", returning empty collection (getByLastUpdatedSorted)." ); + + return new ArrayList(); + } + + return (Collection) store.getByLastUpdatedSorted( lastUpdated ); + } + + @Override + @SuppressWarnings( "unchecked" ) public Map getIdMap( Class clazz, IdentifiableProperty property ) { Map map = new HashMap(); === 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 2012-05-29 21:23:47 +0000 +++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java 2012-06-06 13:31:45 +0000 @@ -270,6 +270,13 @@ } @Override + @SuppressWarnings( "unchecked" ) + public final Collection getAllSorted() + { + return getCriteria().addOrder( Order.asc( "name" ) ).list(); + } + + @Override public final void delete( T object ) { sessionFactory.getCurrentSession().delete( object ); @@ -353,7 +360,14 @@ { return getCriteria().add( Restrictions.ge( "lastUpdated", lastUpdated ) ).list(); } - + + @Override + @SuppressWarnings( "unchecked" ) + public List getByLastUpdatedSorted( Date lastUpdated ) + { + return getCriteria().add( Restrictions.ge( "lastUpdated", lastUpdated ) ).addOrder( Order.asc( "name" ) ).list(); + } + @Override public long getCountByLastUpdated( Date lastUpdated ) { === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-06-06 12:48:05 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java 2012-06-06 13:31:45 +0000 @@ -166,7 +166,7 @@ if ( lastUpdated != null ) { - entityList = new ArrayList( manager.getByLastUpdated( getEntityClass(), lastUpdated ) ); + entityList = new ArrayList( manager.getByLastUpdatedSorted( getEntityClass(), lastUpdated ) ); } else if ( options.hasPaging() ) { @@ -179,7 +179,7 @@ } else { - entityList = new ArrayList( manager.getAll( getEntityClass() ) ); + entityList = new ArrayList( manager.getAllSorted( getEntityClass() ) ); } return entityList;