private void loadTermVectors() { List<SearchResult> searchResults = search(); if (searchResults != null) { termsVectors = new ArrayList<TermFrequency>(); termList = null; for (Iterator<SearchResult> i = searchResults.iterator(); i.hasNext(); ) { SearchResult sr = (SearchResult) i.next(); try { TermFrequency tf = sr.getTerms(); if (tf != null) { termsVectors.add(sr.getTerms()); } } catch (IOException e) { log.warn("Failed to get term vector ", e); } } } }
/* * (non-Javadoc) * * @see org.sakaiproject.search.tool.SearchBean#getResults() */ @SuppressWarnings("unchecked") public List<SearchOutputItem> getResults() { if (outputItems == null) { outputItems = new ArrayList<SearchOutputItem>(); SearchList sl = search(); for (Iterator<SearchResult> i = sl.iterator(); i.hasNext(); ) { final SearchResult sr = (SearchResult) i.next(); if (!sr.isCensored()) { outputItems.add( new SearchOutputItem() { public String getSearchResult() { try { return sr.getSearchResult(); } catch (Exception ex) { return ""; } } public String getTitle() { try { return FormattedText.escapeHtml(sr.getTitle(), false); } catch (Exception ex) { return ""; } } public String getTool() { try { return FormattedText.escapeHtml(sr.getTool(), false); } catch (Exception ex) { return ""; } } public String getUrl() { try { return FormattedText.escapeHtml(sr.getUrl(), false); } catch (Exception ex) { return ""; } } private Site site = null; public String getSiteURL() { if (site == null) site = getSite(); return (site != null) ? site.getUrl() : null; } public String getSiteTitle() { if (site == null) site = getSite(); if (site != null) return FormattedText.escapeHtml(site.getTitle(), false); return ""; } private Site getSite() { try { Site s = siteService.getSite(sr.getSiteId()); return s; } catch (IdUnusedException e) { log.warn( "site: " + sr.getSiteId() + "referenced in search results doesn't exits"); } return null; } public boolean isVisible() { if (sr.isCensored()) return false; else return true; } public boolean hasPortalUrl() { return sr.hasPortalUrl(); } }); } else { censoredResults++; } } } return outputItems; }