Bug #1486: Sort Profiles list before adding it to the combo box.

We do it in the DAO because sort operations should be faster in the DB.

FEA: ItEr76S04BugFixing
This commit is contained in:
Jacobo Aragunde Pérez 2012-07-10 10:52:30 +02:00
parent 7cef9c6c92
commit 228ca6e2b4
3 changed files with 11 additions and 1 deletions

View file

@ -54,4 +54,6 @@ public interface IProfileDAO extends IGenericDAO<Profile, Long>{
Profile findByProfileNameLoadingRoles(String profileName)
throws InstanceNotFoundException;
List<Profile> listSorted();
}

View file

@ -26,6 +26,7 @@ import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.libreplan.business.common.daos.GenericDAOHibernate;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
@ -121,4 +122,11 @@ public class ProfileDAO extends GenericDAOHibernate<Profile, Long> implements
return profile;
}
@Override
public List<Profile> listSorted() {
Criteria c = getSession().createCriteria(Profile.class).addOrder(
Order.asc("profileName"));
return c.list();
}
}

View file

@ -272,7 +272,7 @@ public class UserModel implements IUserModel {
@Override
@Transactional(readOnly = true)
public List<Profile> getAllProfiles() {
return profileDAO.list(Profile.class);
return profileDAO.listSorted();
}
}