3,6 → 3,7 |
import java.util.*; |
import net.sf.hibernate.*; |
import net.sf.hibernate.type.Type; |
import ak.hostadmiral.util.CollectionInfo; |
import ak.hostadmiral.util.HibernateUtil; |
import ak.hostadmiral.util.ModelException; |
import ak.hostadmiral.util.ModelSecurityException; |
286,15 → 287,39 |
public Collection listUsers(User editor) |
throws ModelException |
{ |
return listUsers(null, 0, 0, null, editor); |
} |
|
public Collection listUsers(CollectionInfo info, int rowsPerPage, int pageNumber, |
Integer[] sortingKeys, User editor) |
throws ModelException |
{ |
try { |
if(editor.isSuperuser()) { |
return HibernateUtil.currentSession().find( |
"select u from User u left join fetch u.boss"); |
if(info != null) { |
info.init(((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from User").next()).intValue(), |
pageNumber, rowsPerPage); |
} |
|
return HibernateUtil.pageableList(rowsPerPage, pageNumber, |
"select u from User u left join fetch u.boss" |
+ HibernateUtil.formOrderClause(sortingKeys, sortKeys), null, null); |
} |
else { |
return HibernateUtil.currentSession().find( |
"select u from User u where u = ? or u.boss = ?", |
if(info != null) { |
info.init(((Integer)HibernateUtil.currentSession().iterate( |
"select count(*) from User u where u = ? or u.boss = ?", |
new Object[] { editor, editor}, |
new Type[] { Hibernate.entity(User.class), Hibernate.entity(User.class) } |
).next()).intValue(), |
pageNumber, rowsPerPage); |
} |
|
return HibernateUtil.pageableList(rowsPerPage, pageNumber, |
"select u from User u left join fetch u.boss where u = ? or u.boss = ?" |
+ HibernateUtil.formOrderClause(sortingKeys, sortKeys), |
new Object[] { editor, editor}, |
new Type[] { Hibernate.entity(User.class), Hibernate.entity(User.class) } ); |
} |
} |
419,6 → 444,14 |
} |
} |
|
public static final Integer SORT_LOGIN = new Integer(1); |
|
protected static Map sortKeys = new HashMap(); |
|
static { |
sortKeys.put(SORT_LOGIN, "u.login"); |
} |
|
public static final Comparator LOGIN_COMPARATOR = new LoginComparator(); |
public static final Comparator LOGINS_TIME_COMPARATOR = new LoginsTimeComparator(); |
|