Search in sources :

Example 6 with Bookmark

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);
    }
}
Also used : Bookmark(net.jforum.entities.Bookmark) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) List(java.util.List) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 7 with Bookmark

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);
    }
}
Also used : Bookmark(net.jforum.entities.Bookmark) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) List(java.util.List) ArrayList(java.util.ArrayList) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 8 with Bookmark

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);
    }
}
Also used : Bookmark(net.jforum.entities.Bookmark) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 9 with Bookmark

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;
}
Also used : Bookmark(net.jforum.entities.Bookmark)

Example 10 with Bookmark

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));
}
Also used : BookmarkDAO(net.jforum.dao.BookmarkDAO) Bookmark(net.jforum.entities.Bookmark)

Aggregations

Bookmark (net.jforum.entities.Bookmark)14 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 SQLException (java.sql.SQLException)5 DatabaseException (net.jforum.exceptions.DatabaseException)5 List (java.util.List)4 ArrayList (java.util.ArrayList)3 BookmarkDAO (net.jforum.dao.BookmarkDAO)3 User (net.jforum.entities.User)2 Iterator (java.util.Iterator)1 DataAccessDriver (net.jforum.dao.DataAccessDriver)1 UserDAO (net.jforum.dao.UserDAO)1 Forum (net.jforum.entities.Forum)1 Topic (net.jforum.entities.Topic)1 RankingRepository (net.jforum.repository.RankingRepository)1 SafeHtml (net.jforum.util.SafeHtml)1