use of net.jforum.dao.PollDAO in project jforum2 by rafaelsteil.
the class GenericTopicDAO method deleteTopics.
public void deleteTopics(List topics, boolean fromModeration) {
// Topic
PreparedStatement p = null;
try {
p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.delete"));
ForumDAO forumDao = DataAccessDriver.getInstance().newForumDAO();
PostDAO postDao = DataAccessDriver.getInstance().newPostDAO();
PollDAO pollDao = DataAccessDriver.getInstance().newPollDAO();
for (Iterator iter = topics.iterator(); iter.hasNext(); ) {
Topic topic = (Topic) iter.next();
// Remove watches
this.removeSubscriptionByTopic(topic.getId());
// Remove the messages
postDao.deleteByTopic(topic.getId());
// Remove the poll
pollDao.deleteByTopicId(topic.getId());
// Delete the topic itself
p.setInt(1, topic.getId());
p.executeUpdate();
if (!fromModeration) {
forumDao.decrementTotalTopics(topic.getForumId(), 1);
}
}
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbUtils.close(p);
}
}
Aggregations