limit list of queue jobs to the latest 500 entries

This commit is contained in:
Peter Hormanns 2016-05-13 14:59:46 +02:00
parent aabb5d1781
commit f934cd3984
2 changed files with 8 additions and 1 deletions

View File

@ -92,6 +92,10 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
}
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException {
return search(entityClass, condition, orderBy, -1);
}
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy, int limit) throws HSAdminException {
UnixUser loginUser = transaction.getLoginUser();
condition = restrict(entityClass, loginUser, condition);
Entity entityAnnot = entityClass.getAnnotation(Entity.class);
@ -109,6 +113,9 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
EntityManager entityManager = transaction.getEntityManager();
entityManager.clear();
Query query = entityManager.createQuery(queryString);
if (limit > 0) {
query.setMaxResults(limit);
}
setQueryParameter(query, queryString, "loginUser", loginUser);
setQueryParameter(query, queryString, "loginUserName", loginUser.getName());
setQueryParameter(query, queryString, "loginUserPac", loginUser.getPac());

View File

@ -16,7 +16,7 @@ public class QTaskModuleImpl extends AbstractModuleImpl {
if (orderBy == null || orderBy.length() == 0) {
orderBy = "ORDER BY obj.started DESC";
}
return super.search(entityClass, condition, orderBy);
return super.search(entityClass, condition, orderBy, 500);
}
}