Package sagan.blog.support

Source Code of sagan.blog.support.PostSearchEntryMapper

package sagan.blog.support;

import sagan.blog.Post;
import sagan.search.SearchEntry;
import sagan.search.SearchEntryMapper;

import org.jsoup.Jsoup;

class PostSearchEntryMapper implements SearchEntryMapper<Post> {

    @Override
    public SearchEntry map(Post post) {
        SearchEntry entry = new SearchEntry();
        entry.setTitle(post.getTitle());
        entry.setSubTitle("Blog Post");

        String summary = Jsoup.parse(post.getRenderedSummary()).text();
        String content = Jsoup.parse(post.getRenderedContent()).text();

        entry.setSummary(summary);
        entry.setRawContent(content);
        entry.addFacetPaths("Blog", "Blog/" + post.getCategory().getDisplayName());
        entry.setPath("/blog/" + post.getPublicSlug());
        entry.setPublishAt(post.getPublishAt());
        return entry;
    }

}
TOP

Related Classes of sagan.blog.support.PostSearchEntryMapper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.