Search in sources :

Example 46 with Post

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

the class LuceneContentCollector method retrieveRealPosts.

private List retrieveRealPosts(int[] postIds, Query query) throws IOException {
    List posts = DataAccessDriver.getInstance().newLuceneDAO().getPostsData(postIds);
    for (Iterator iter = posts.iterator(); iter.hasNext(); ) {
        Post post = (Post) iter.next();
        Scorer scorer = new QueryScorer(query);
        Highlighter highlighter = new Highlighter(scorer);
        TokenStream tokenStream = this.settings.analyzer().tokenStream(SearchFields.Indexed.CONTENTS, new StringReader(post.getText()));
        String fragment = highlighter.getBestFragment(tokenStream, post.getText());
        post.setText(fragment != null ? fragment : post.getText());
    }
    return posts;
}
Also used : TokenStream(org.apache.lucene.analysis.TokenStream) Post(net.jforum.entities.Post) QueryScorer(org.apache.lucene.search.highlight.QueryScorer) Iterator(java.util.Iterator) StringReader(java.io.StringReader) QueryScorer(org.apache.lucene.search.highlight.QueryScorer) Scorer(org.apache.lucene.search.highlight.Scorer) List(java.util.List) Highlighter(org.apache.lucene.search.highlight.Highlighter)

Example 47 with Post

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

the class TopicPostsRSS method prepareRSS.

private void prepareRSS() {
    for (Iterator iter = this.posts.iterator(); iter.hasNext(); ) {
        Post p = (Post) iter.next();
        p.setBbCodeEnabled(false);
        p.setHtmlEnabled(false);
        p.setHtmlEnabled(false);
        RSSItem item = new RSSItem();
        item.setAuthor(p.getPostUsername());
        item.setContentType(RSSAware.CONTENT_HTML);
        item.setDescription(PostCommon.preparePostForDisplay(p).getText());
        item.setPublishDate(RSSUtils.formatDate(p.getTime()));
        item.setTitle(p.getSubject());
        item.setLink(this.forumLink + "posts/preList/" + p.getTopicId() + "/" + p.getId() + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION));
        this.rss.addItem(item);
    }
    super.setRSS(this.rss);
}
Also used : Post(net.jforum.entities.Post) Iterator(java.util.Iterator)

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