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();
}
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;
}
Aggregations