From f934cd3984a995665f289d1465beee55abf44124 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 13 May 2016 14:59:46 +0200 Subject: [PATCH] limit list of queue jobs to the latest 500 entries --- hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java | 7 +++++++ hsarback/src/de/hsadmin/mods/qstat/QTaskModuleImpl.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java b/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java index 6162a4b..e1e272f 100644 --- a/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java +++ b/hsarback/src/de/hsadmin/core/model/AbstractModuleImpl.java @@ -92,6 +92,10 @@ public abstract class AbstractModuleImpl implements ModuleInterface { } public List search(Class entityClass, String condition, String orderBy) throws HSAdminException { + return search(entityClass, condition, orderBy, -1); + } + + public List search(Class 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()); diff --git a/hsarback/src/de/hsadmin/mods/qstat/QTaskModuleImpl.java b/hsarback/src/de/hsadmin/mods/qstat/QTaskModuleImpl.java index 5047489..1fe6756 100644 --- a/hsarback/src/de/hsadmin/mods/qstat/QTaskModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/qstat/QTaskModuleImpl.java @@ -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); } }