* @param up ���ϵ����������µ���
*/
public static void move(SiteBean site, int cat_id, boolean up){
List objects = site.getForums();
for (int i = 0; i < objects.size(); i++) {
Orderable obj = (Orderable) objects.get(i);
int sort_order = obj.getSortOrder();
if (obj.getId() == cat_id) {
if (up) {
if (i > 0) {
try {
Orderable prev = (Orderable) objects.get(i - 1);
int prev_order = prev.getSortOrder();
beginTransaction();
executeNamedUpdate("UPDATE_FORUM_ORDER", sort_order, prev.getId());
executeNamedUpdate("UPDATE_FORUM_ORDER", prev_order, obj.getId());
commit();
} catch (HibernateException e) {
rollback();
throw e;
}
}
} else {
if (i < (objects.size() - 1)) {
try {
Orderable next = (Orderable) objects.get(i + 1);
int next_order = next.getSortOrder();
beginTransaction();
executeNamedUpdate("UPDATE_FORUM_ORDER", sort_order, next.getId());
executeNamedUpdate("UPDATE_FORUM_ORDER", next_order, obj.getId());
commit();
} catch (HibernateException e) {
rollback();
throw e;