use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class GenericBookmarkDAO method getUsers.
protected List getUsers(int userId) {
List l = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BookmarkModel.selectUserBookmarks"));
p.setInt(1, userId);
rs = p.executeQuery();
while (rs.next()) {
Bookmark b = this.getBookmark(rs);
if (b.getTitle() == null || "".equals(b.getTitle())) {
b.setTitle(rs.getString("username"));
}
l.add(b);
}
return l;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class GenericBookmarkDAO method getTopics.
protected List getTopics(int userId) {
PreparedStatement p = null;
ResultSet rs = null;
try {
List l = new ArrayList();
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BookmarkModel.selectTopicBookmarks"));
p.setInt(1, userId);
rs = p.executeQuery();
while (rs.next()) {
Bookmark b = this.getBookmark(rs);
if (b.getTitle() == null || "".equals(b.getTitle())) {
b.setTitle(rs.getString("topic_title"));
}
l.add(b);
}
return l;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class GenericBookmarkDAO method selectById.
/**
* @see net.jforum.dao.BookmarkDAO#selectById(int)
*/
public Bookmark selectById(int bookmarkId) {
Bookmark b = null;
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("BookmarkModel.selectById"));
p.setInt(1, bookmarkId);
rs = p.executeQuery();
if (rs.next()) {
b = this.getBookmark(rs);
}
return b;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class GenericBookmarkDAO method getBookmark.
protected Bookmark getBookmark(ResultSet rs) throws SQLException {
Bookmark b = new Bookmark();
b.setId(rs.getInt("bookmark_id"));
b.setDescription(rs.getString("description"));
b.setPublicVisible(rs.getInt("public_visible") == 1);
b.setRelationId(rs.getInt("relation_id"));
b.setTitle(rs.getString("title"));
b.setDescription(rs.getString("description"));
b.setUserId(rs.getInt("user_id"));
b.setRelationType(rs.getInt("relation_type"));
return b;
}
use of net.jforum.entities.Bookmark in project jforum2 by rafaelsteil.
the class BookmarkAction method delete.
public void delete() {
int id = this.request.getIntParameter("bookmark_id");
BookmarkDAO bm = DataAccessDriver.getInstance().newBookmarkDAO();
Bookmark b = bm.selectById(id);
if (!this.sanityCheck(b)) {
return;
}
bm.remove(id);
JForumExecutionContext.setRedirect(this.request.getContextPath() + "/bookmarks/list/" + b.getUserId() + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION));
}
Aggregations