use of org.apereo.portal.search.SearchResult in project uPortal by Jasig.
the class SearchPortletController method addSearchResults.
/**
* @param portletSearchResults Results from a portlet
* @param results Results collating object
* @param httpServletRequest current request
* @param portletWindowId Id of the portlet window that provided the results
*/
private void addSearchResults(SearchResults portletSearchResults, PortalSearchResults results, final HttpServletRequest httpServletRequest, final IPortletWindowId portletWindowId) {
for (SearchResult result : portletSearchResults.getSearchResult()) {
final String resultUrl = this.getResultUrl(httpServletRequest, result, portletWindowId);
this.logger.debug("Created {} with from {}", resultUrl, result.getTitle());
modifySearchResultLinkTitle(result, httpServletRequest, portletWindowId);
results.addPortletSearchResults(resultUrl, result);
}
}
use of org.apereo.portal.search.SearchResult in project uPortal by Jasig.
the class SearchPortletController method showJSONSearchResults.
/**
* Display AJAX autocomplete search results for the last query
*/
@ResourceMapping(value = "retrieveSearchJSONResults")
public ModelAndView showJSONSearchResults(PortletRequest request) {
PortletPreferences prefs = request.getPreferences();
int maxTextLength = Integer.parseInt(prefs.getValue(AUTOCOMPLETE_MAX_TEXT_LENGTH_PREF_NAME, "180"));
final Map<String, Object> model = new HashMap<>();
List<AutocompleteResultsModel> results = new ArrayList<>();
final PortletSession session = request.getPortletSession();
String queryId = (String) session.getAttribute(SEARCH_LAST_QUERY_ID);
if (queryId != null) {
final PortalSearchResults portalSearchResults = this.getPortalSearchResults(request, queryId);
if (portalSearchResults != null) {
final ConcurrentMap<String, List<Tuple<SearchResult, String>>> resultsMap = portalSearchResults.getResults();
results = collateResultsForAutoCompleteResponse(resultsMap, maxTextLength);
}
}
model.put("results", results);
model.put("count", results.size());
return new ModelAndView("json", model);
}
use of org.apereo.portal.search.SearchResult in project uPortal by Jasig.
the class PortletRegistrySearchService method getSearchResults.
@Override
public SearchResults getSearchResults(PortletRequest request, SearchRequest query) {
final String queryString = query.getSearchTerms().toLowerCase();
final List<IPortletDefinition> portlets = portletDefinitionRegistry.getAllPortletDefinitions();
final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
final SearchResults results = new SearchResults();
for (IPortletDefinition portlet : portlets) {
if (portletRegistryUtil.matches(queryString, portlet)) {
final SearchResult result = new SearchResult();
result.setTitle(portlet.getTitle());
result.setSummary(portlet.getDescription());
result.getType().add(searchResultType);
String url = portletRegistryUtil.buildPortletUrl(httpServletRequest, portlet);
if (url != null) {
result.setExternalUrl(url);
results.getSearchResult().add(result);
}
}
}
return results;
}
use of org.apereo.portal.search.SearchResult in project uPortal by Jasig.
the class MarketplaceSearchService method getSearchResults.
/**
* Returns a list of search results that pertain to the marketplace query is the query to search
* will search name, title, description, fname, and captions
*/
@Override
public SearchResults getSearchResults(PortletRequest request, SearchRequest query) {
final String queryString = query.getSearchTerms().toLowerCase();
final List<IPortletDefinition> portlets = portletDefinitionRegistry.getAllPortletDefinitions();
final HttpServletRequest httpServletRequest = this.portalRequestUtils.getPortletHttpRequest(request);
final SearchResults results = new SearchResults();
for (IPortletDefinition portlet : portlets) {
if (this.matches(queryString, new MarketplacePortletDefinition(portlet, this.marketplaceService, this.portletCategoryRegistry))) {
final SearchResult result = new SearchResult();
result.setTitle(portlet.getTitle());
result.setSummary(portlet.getDescription());
result.getType().add("marketplace");
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(httpServletRequest, portlet.getFName());
// If user does not have browse permission, exclude the portlet.
if (portletWindow != null && authorizationService.canPrincipalBrowse(authorizationService.newPrincipal(request.getRemoteUser(), EntityEnum.PERSON.getClazz()), portlet)) {
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletFName(httpServletRequest, portlet.getFName(), UrlType.RENDER);
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
portletUrlBuilder.setWindowState(PortletUtils.getWindowState("maximized"));
result.setExternalUrl(portalUrlBuilder.getUrlString());
PortletUrl url = new PortletUrl();
url.setType(PortletUrlType.RENDER);
url.setPortletMode("VIEW");
url.setWindowState("maximized");
PortletUrlParameter actionParam = new PortletUrlParameter();
actionParam.setName("action");
actionParam.getValue().add("view");
url.getParam().add(actionParam);
PortletUrlParameter fNameParam = new PortletUrlParameter();
fNameParam.setName("fName");
fNameParam.getValue().add(portlet.getFName());
url.getParam().add(fNameParam);
result.setPortletUrl(url);
// Add the result to list to return
results.getSearchResult().add(result);
}
}
}
return results;
}
Aggregations