use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class GenericLuceneDAO method getPostsData.
/**
* @see net.jforum.dao.LuceneDAO#getPostsData(int[])
*/
public List getPostsData(int[] postIds) {
if (postIds.length == 0) {
return new ArrayList();
}
List l = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
String sql = SystemGlobals.getSql("SearchModel.getPostsDataForLucene");
sql = sql.replaceAll(":posts:", this.buildInClause(postIds));
p = JForumExecutionContext.getConnection().prepareStatement(sql);
rs = p.executeQuery();
while (rs.next()) {
Post post = this.makePost(rs);
post.setPostUsername(rs.getString("username"));
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 selectHotForRSS.
public List selectHotForRSS(int limit) {
List l = new ArrayList();
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.selectHotForRSS"));
p.setInt(1, 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 makePost.
protected Post makePost(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(new Date(postTime.getTime()));
post.setUserIp(rs.getString("poster_ip"));
post.setBbCodeEnabled(rs.getInt("enable_bbcode") > 0);
post.setHtmlEnabled(rs.getInt("enable_html") > 0);
post.setSmiliesEnabled(rs.getInt("enable_smilies") > 0);
post.setSignatureEnabled(rs.getInt("enable_sig") > 0);
post.setEditCount(rs.getInt("post_edit_count"));
Timestamp editTime = rs.getTimestamp("post_edit_time");
post.setEditTime(editTime != null ? new Date(editTime.getTime()) : null);
post.setSubject(rs.getString("post_subject"));
post.setText(this.getPostTextFromResultSet(rs));
post.setPostUsername(rs.getString("username"));
post.hasAttachments(rs.getInt("attach") > 0);
post.setModerate(rs.getInt("need_moderate") == 1);
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 GenericPostDAO method removePosts.
private void removePosts(List posts) {
PreparedStatement post = null;
PreparedStatement text = null;
try {
post = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.deletePost"));
text = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.deletePostText"));
for (Iterator iter = posts.iterator(); iter.hasNext(); ) {
Post p = (Post) iter.next();
post.setInt(1, p.getId());
text.setInt(1, p.getId());
text.executeUpdate();
post.executeUpdate();
SearchFacade.delete(p);
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(post);
DbUtils.close(text);
}
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class GenericPostDAO method selectById.
/**
* @see net.jforum.dao.PostDAO#selectById(int)
*/
public Post selectById(int postId) {
PreparedStatement p = null;
ResultSet rs = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("PostModel.selectById"));
p.setInt(1, postId);
rs = p.executeQuery();
Post post = new Post();
if (rs.next()) {
post = this.makePost(rs);
}
return post;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(rs, p);
}
}
Aggregations