Search in sources :

Example 1 with Post

use of net.jforum.entities.Post in project jforum2 by rafaelsteil.

the class GenericSummaryDAO method fillPost.

private Post fillPost(ResultSet rs) throws SQLException {
    Post post = new Post();
    post.setId(rs.getInt("post_id"));
    post.setTopicId(rs.getInt("topic_id"));
    post.setForumId(rs.getInt("forum_id"));
    post.setUserId(rs.getInt("user_id"));
    Timestamp postTime = rs.getTimestamp("post_time");
    post.setTime(postTime);
    post.setSubject(rs.getString("post_subject"));
    post.setText(rs.getString("post_text"));
    post.setPostUsername(rs.getString("username"));
    SimpleDateFormat df = new SimpleDateFormat(SystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));
    post.setFormatedTime(df.format(postTime));
    post.setKarma(DataAccessDriver.getInstance().newKarmaDAO().getPostKarma(post.getId()));
    return post;
}
Also used : Post(net.jforum.entities.Post) Timestamp(java.sql.Timestamp) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with Post

use of net.jforum.entities.Post in project jforum2 by rafaelsteil.

the class GenericLuceneDAO method makePost.

private Post makePost(ResultSet rs) throws SQLException {
    Post p = new SearchPost();
    p.setId(rs.getInt("post_id"));
    p.setForumId(rs.getInt("forum_id"));
    p.setTopicId(rs.getInt("topic_id"));
    p.setUserId(rs.getInt("user_id"));
    p.setTime(new Date(rs.getTimestamp("post_time").getTime()));
    p.setText(this.readPostTextFromResultSet(rs));
    p.setBbCodeEnabled(rs.getInt("enable_bbcode") == 1);
    p.setSmiliesEnabled(rs.getInt("enable_smilies") == 1);
    String subject = rs.getString("post_subject");
    if (subject == null || subject.trim().length() == 0) {
        subject = rs.getString("topic_title");
    }
    p.setSubject(subject);
    return p;
}
Also used : Post(net.jforum.entities.Post) SearchPost(net.jforum.search.SearchPost) Date(java.util.Date) SearchPost(net.jforum.search.SearchPost)

Example 3 with Post

use of net.jforum.entities.Post in project jforum2 by rafaelsteil.

the class GenericPostDAO method deleteByTopic.

/**
	 * @see net.jforum.model.PostModel#deleteByTopic(int)
	 */
public void deleteByTopic(int topicId) {
    PreparedStatement p = null;
    ResultSet rs = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.deleteByTopic"));
        p.setInt(1, topicId);
        rs = p.executeQuery();
        List posts = new ArrayList();
        while (rs.next()) {
            Post post = new Post();
            post.setId(rs.getInt("post_id"));
            post.setUserId(rs.getInt("user_id"));
            posts.add(post);
        }
        this.removePosts(posts);
    } catch (SQLException e) {
        throw new DatabaseException(e);
    } finally {
        DbUtils.close(rs, p);
    }
}
Also used : SQLException(java.sql.SQLException) Post(net.jforum.entities.Post) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) ArrayList(java.util.ArrayList) List(java.util.List) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 4 with Post

use of net.jforum.entities.Post in project jforum2 by rafaelsteil.

the class GenericPostDAO method selectLatestByForumForRSS.

public List selectLatestByForumForRSS(int forumId, int limit) {
    List l = new ArrayList();
    PreparedStatement p = null;
    ResultSet rs = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.selectLatestByForumForRSS"));
        p.setInt(1, forumId);
        p.setInt(2, limit);
        rs = p.executeQuery();
        while (rs.next()) {
            Post post = this.buildPostForRSS(rs);
            l.add(post);
        }
    } catch (SQLException e) {
        throw new DatabaseException(e);
    } finally {
        DbUtils.close(rs, p);
    }
    return l;
}
Also used : SQLException(java.sql.SQLException) Post(net.jforum.entities.Post) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) List(java.util.List) PreparedStatement(java.sql.PreparedStatement) DatabaseException(net.jforum.exceptions.DatabaseException)

Example 5 with Post

use of net.jforum.entities.Post in project jforum2 by rafaelsteil.

the class GenericPostDAO method buildPostForRSS.

private Post buildPostForRSS(ResultSet rs) throws SQLException {
    Post post = new Post();
    post.setId(rs.getInt("post_id"));
    post.setSubject(rs.getString("subject"));
    post.setText(rs.getString("post_text"));
    post.setTopicId(rs.getInt("topic_id"));
    post.setForumId(rs.getInt("forum_id"));
    post.setUserId(rs.getInt("user_id"));
    post.setPostUsername(rs.getString("username"));
    post.setTime(new Date(rs.getTimestamp("post_time").getTime()));
    return post;
}
Also used : Post(net.jforum.entities.Post) Date(java.util.Date)

Aggregations

Post (net.jforum.entities.Post)47 List (java.util.List)20 PostDAO (net.jforum.dao.PostDAO)15 ArrayList (java.util.ArrayList)13 Date (java.util.Date)11 PreparedStatement (java.sql.PreparedStatement)9 SQLException (java.sql.SQLException)9 Iterator (java.util.Iterator)9 DatabaseException (net.jforum.exceptions.DatabaseException)9 ResultSet (java.sql.ResultSet)8 Topic (net.jforum.entities.Topic)8 User (net.jforum.entities.User)8 TopicDAO (net.jforum.dao.TopicDAO)7 AttachmentCommon (net.jforum.view.forum.common.AttachmentCommon)6 UserDAO (net.jforum.dao.UserDAO)5 SimpleDateFormat (java.text.SimpleDateFormat)4 ModerationLog (net.jforum.entities.ModerationLog)4 ForumDAO (net.jforum.dao.ForumDAO)3 AttachmentException (net.jforum.exceptions.AttachmentException)3 IOException (java.io.IOException)2