use of org.ambraproject.wombat.service.remote.ArticleSearchQuery in project wombat by PLOS.
the class DoiToJournalResolutionService method getJournalKeyFromDoi.
public String getJournalKeyFromDoi(String doi, Site site) throws IOException {
ArticleSearchQuery explicitDoiSearchQuery = ArticleSearchQuery.builder().setSimple(false).setRows(1).setQuery("id:\"" + QueryParser.escape(doi) + "\"").build();
List<SolrArticleAdapter> solrArticleAdapters = SolrArticleAdapter.unpackSolrQuery(solrSearchApi.search(explicitDoiSearchQuery));
String journalKey = null;
if (solrArticleAdapters.size() == 1) {
journalKey = solrArticleAdapters.get(0).getJournalKey();
}
return journalKey;
}
use of org.ambraproject.wombat.service.remote.ArticleSearchQuery in project wombat by PLOS.
the class SearchController method subjectAreaSearch.
/**
* Set defaults and performs search for subject area landing page
*
* @param request HTTP request for browsing subject areas
* @param model model that will be passed to the template
* @param site site the request originates from
* @param params HTTP request params
* @param subject the subject area to be search; return all articles if no subject area is provided
* @throws IOException
*/
private void subjectAreaSearch(HttpServletRequest request, Model model, Site site, MultiValueMap<String, String> params, String subject) throws IOException {
TaxonomyGraph taxonomyGraph = modelSubjectHierarchy(model, site, subject);
String subjectName;
if (Strings.isNullOrEmpty(subject)) {
params.add("subject", "");
subjectName = "All Subject Areas";
} else {
subject = subject.replace("_", " ");
params.add("subject", subject);
subjectName = taxonomyGraph.getName(subject);
}
model.addAttribute("subjectName", subjectName);
// set defaults for subject area landing page
if (isNullOrEmpty(params.get("resultsPerPage"))) {
params.add("resultsPerPage", BROWSE_RESULTS_PER_PAGE);
}
if (isNullOrEmpty(params.get("sortOrder"))) {
params.add("sortOrder", "DATE_NEWEST_FIRST");
}
if (isNullOrEmpty(params.get("filterJournals"))) {
params.add("filterJournals", site.getJournalKey());
}
CommonParams commonParams = modelCommonParams(request, model, site, params);
ArticleSearchQuery query = commonParams.makeArticleSearchQueryBuilder().setSimple(false).build();
SolrSearchApi.Result searchResults = solrSearchApi.search(query);
model.addAttribute("articles", SolrArticleAdapter.unpackSolrQuery(searchResults));
model.addAttribute("searchResults", addArticleLinks(searchResults, request, site, siteSet));
model.addAttribute("page", commonParams.getSingleParam(params, "page", "1"));
model.addAttribute("journalKey", site.getKey());
model.addAttribute("isBrowse", true);
String authId = request.getRemoteUser();
boolean subscribed = false;
if (authId != null) {
String subjectParam = Strings.isNullOrEmpty(subject) ? "" : subjectName;
subscribed = alertService.isUserSubscribed(authId, site.getJournalKey(), subjectParam);
}
model.addAttribute("subscribed", subscribed);
}
Aggregations