Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1027 → Rev 1028

/hostadmiral/trunk/src/ak/hostadmiral/core/model/InetDomainManager.java
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;
266,14 → 267,39
public Collection listInetDomains(User editor)
throws ModelException
{
return listInetDomains(null, 0, 0, null, editor);
}
 
public Collection listInetDomains(CollectionInfo info, int rowsPerPage, int pageNumber,
Integer[] sortingKeys, User editor)
throws ModelException
{
try {
if(editor.isSuperuser())
return HibernateUtil.currentSession().find(
"select d from InetDomain d left join fetch d.owner");
else
return HibernateUtil.currentSession().find(
"select d from InetDomain d where d.owner=?",
editor, Hibernate.entity(User.class));
if(editor.isSuperuser()) {
if(info != null) {
info.init(((Integer)HibernateUtil.currentSession().iterate(
"select count(*) from InetDomain").next()).intValue(),
pageNumber, rowsPerPage);
}
 
 
return HibernateUtil.pageableList(rowsPerPage, pageNumber,
"select d from InetDomain d left join fetch d.owner"
+ HibernateUtil.formOrderClause(sortingKeys, sortKeys), null, null);
}
else {
if(info != null) {
info.init(((Integer)HibernateUtil.currentSession().iterate(
"select count(*) from InetDomain where d.owner=?",
editor, Hibernate.entity(User.class)).next()).intValue(),
pageNumber, rowsPerPage);
}
 
return HibernateUtil.pageableList(rowsPerPage, pageNumber,
"select d from InetDomain d where d.owner=?"
+ HibernateUtil.formOrderClause(sortingKeys, sortKeys),
new Object[] { editor }, new Type[] { Hibernate.entity(User.class) } );
}
}
catch(HibernateException ex)
{
352,6 → 378,14
}
}
 
public static final Integer SORT_NAME = new Integer(1);
 
protected static Map sortKeys = new HashMap();
 
static {
sortKeys.put(SORT_NAME, "d.name");
}
 
public static final Comparator NAME_COMPARATOR = new NameComparator();
 
private static class NameComparator