Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1021 → Rev 1022

/hostadmiral/trunk/doc/todo.txt
34,7 → 34,7
 
Show filters, search.
 
Multi-page lists.
+/- Multi-page lists.
 
Sort options for lists.
 
/hostadmiral/trunk/src/ak/hostadmiral/util/HibernateUtil.java
188,8 → 188,8
}
}
 
public static List pageableList(int pageSize, int pageNumber,
String query, Class classToLoad, String[] returnAliases, Class[] returnClasses,
public static List pageableListSql(int pageSize, int pageNumber,
String query, String[] returnAliases, Class[] returnClasses,
Object[] values, Type[] types)
throws ModelException
{
207,7 → 207,7
hq.setMaxResults(pageSize);
}
 
return selectClassColumn(classToLoad, hq.list());
return selectFirstClassColumn(hq.list());
// FIXME: really no other way in Hibernate?
}
catch(HibernateException ex)
216,47 → 216,13
}
}
 
protected static List selectClassColumn(Class classToLoad, List list)
protected static List selectFirstClassColumn(List list)
throws ModelException
{
List res = new ArrayList();
 
if(list == null || list.size() == 0) return res;
 
Object o = list.get(0);
if(o == null)
throw new ModelException(
"First element in the list is null, cannot determine it type");
 
if(!(o instanceof Object[])) {
if(classToLoad.isInstance(o))
return list;
else
throw new ModelException("First element in the list is instance of "
+ o.getClass().getName() + ", which is not java.lang.Object[] or "
+ classToLoad.getName());
}
 
Object[] oa = (Object[])o;
int pos = -1;
 
for(int i = 0; i < oa.length; i++) {
if(classToLoad.isInstance(oa[i])) {
if(pos < 0)
pos = i;
else
throw new ModelException("First row of the list has several elements of type "
+ classToLoad.getName());
}
}
if(pos < 0) {
throw new ModelException("First row of the list has no elements of type "
+ classToLoad.getName());
}
 
for(Iterator i = list.iterator(); i.hasNext(); ) {
Object[] e = (Object[])i.next();
res.add(e[pos]);
res.add(((Object[])i.next())[0]);
}
 
return res;
/hostadmiral/trunk/src/ak/hostadmiral/core/model/MailboxManager.java
297,7 → 297,7
"select count(*) from Mailbox").next()).intValue());
}
 
return HibernateUtil.pageableList(pageSize, pageNumber,
return HibernateUtil.pageableListSql(pageSize, pageNumber,
"select {mb.*}, {d.*}, {o.*}, {su.*}"
+ " from mailboxes as mb"
+ " left join domains as d on mb.domain = d.id"
304,7 → 304,6
+ " left join users as o on mb.owner = o.id"
+ " left join systemusers as su on mb.systemUser = su.id"
+ HibernateUtil.formOrderClause(sortingKeys, sortKeys),
Mailbox.class,
new String[] { "mb", "d", "o", "su" },
new Class[] { Mailbox.class, InetDomain.class, User.class, SystemUser.class },
null,
326,7 → 325,7
info.setSize(((Long)countlist.get(0)).intValue());
}
 
return HibernateUtil.pageableList(pageSize, pageNumber,
return HibernateUtil.pageableListSql(pageSize, pageNumber,
"select {mb.*}, {d.*}, {o.*}, {su.*}"
+ " from mailboxes as mb"
+ " left join domains as d on mb.domain = d.id"
341,7 → 340,6
+ " left join systemusers as su on mb.systemUser = su.id"
+ " where d.owner=?"
+ HibernateUtil.formOrderClause(sortingKeys, sortKeys),
Mailbox.class,
new String[] { "mb", "d", "o", "su" },
new Class[] { Mailbox.class, InetDomain.class, User.class, SystemUser.class },
new Object[] { editor, editor },
/hostadmiral/trunk/webapp/domain/list.jsp
1,4 → 1,4
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
77,7 → 77,7
<br>
<backpath:backlink><bean:message key="ak.hostadmiral.page.domain.list.back" /></backpath:backlink>
 
<p>
<p>
<bean:message key="ak.hostadmiral.page.general.version" />:
<bean:write name="projectVersion" />
</p>