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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations