Search in sources :

Example 1 with SearchResult

use of net.jforum.search.SearchResult in project jforum2 by rafaelsteil.

the class SearchAction method search.

private void search(SearchOperation operation) {
    SearchArgs args = this.buildSearchArgs();
    int start = args.startFrom();
    int recordsPerPage = SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
    SearchResult searchResult = operation.performSearch(args);
    operation.prepareForDisplay();
    this.setTemplateName(operation.viewTemplate());
    this.context.put("results", operation.filterResults(operation.results()));
    this.context.put("categories", ForumRepository.getAllCategories());
    this.context.put("searchArgs", args);
    this.context.put("fr", new ForumRepository());
    this.context.put("pageTitle", I18n.getMessage("ForumBase.search"));
    this.context.put("openModeration", "1".equals(this.request.getParameter("openModeration")));
    this.context.put("postsPerPage", new Integer(SystemGlobals.getIntValue(ConfigKeys.POSTS_PER_PAGE)));
    ViewCommon.contextToPagination(start, searchResult.numberOfHits(), recordsPerPage);
    TopicsCommon.topicListingBase();
}
Also used : ForumRepository(net.jforum.repository.ForumRepository) SearchArgs(net.jforum.search.SearchArgs) SearchResult(net.jforum.search.SearchResult)

Example 2 with SearchResult

use of net.jforum.search.SearchResult in project jforum2 by rafaelsteil.

the class GenericTopicDAO method findTopicsByDateRange.

/**
	 * @see net.jforum.dao.TopicDAO#findTopicsByDateRange(net.jforum.search.SearchArgs)
	 */
public SearchResult findTopicsByDateRange(SearchArgs args) {
    SearchResult result = null;
    PreparedStatement p = null;
    ResultSet rs = null;
    try {
        p = JForumExecutionContext.getConnection().prepareStatement(SystemGlobals.getSql("TopicModel.findTopicsByDateRange"));
        p.setTimestamp(1, new Timestamp(args.getFromDate().getTime()));
        p.setTimestamp(2, new Timestamp(args.getToDate().getTime()));
        rs = p.executeQuery();
        List l = new ArrayList();
        int counter = 0;
        while (rs.next()) {
            if (counter >= args.startFrom() && counter < args.startFrom() + args.fetchCount()) {
                l.add(new Integer(rs.getInt(1)));
            }
            counter++;
        }
        result = new SearchResult(this.newMessages(l), counter);
    } catch (Exception e) {
        throw new DatabaseException(e);
    } finally {
        DbUtils.close(rs, p);
    }
    return result;
}
Also used : ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) SearchResult(net.jforum.search.SearchResult) PreparedStatement(java.sql.PreparedStatement) ArrayList(java.util.ArrayList) List(java.util.List) Timestamp(java.sql.Timestamp) DatabaseException(net.jforum.exceptions.DatabaseException) DatabaseException(net.jforum.exceptions.DatabaseException) SQLException(java.sql.SQLException)

Aggregations

SearchResult (net.jforum.search.SearchResult)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DatabaseException (net.jforum.exceptions.DatabaseException)1 ForumRepository (net.jforum.repository.ForumRepository)1 SearchArgs (net.jforum.search.SearchArgs)1