use of org.nextprot.api.solr.QueryRequest in project nextprot-api by calipho-sib.
the class SolrServiceTest method shouldReturnEmptyResultsFromEmptyAccessionSet.
@Test
public void shouldReturnEmptyResultsFromEmptyAccessionSet() throws Exception {
QueryRequest qr = new QueryRequest();
qr.setQuality("GOLD");
qr.setEntryAccessionSet(new HashSet<>());
Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
SearchResult result = service.executeQuery(q);
assertEquals(0, result.getFound());
}
use of org.nextprot.api.solr.QueryRequest in project nextprot-api by calipho-sib.
the class SolrServiceTest method shouldReturnResultsFromAdvancedQueryId.
@Ignore
// Explanation: SparqlQueryDictionary was not able to find the .rq files via getSparqlQueryList() method (because of classpath ???)
@Test
public void shouldReturnResultsFromAdvancedQueryId() throws Exception {
QueryRequest qr = new QueryRequest();
qr.setMode("advanced");
qr.setQuality("gold");
qr.setSparqlEngine("Jena");
qr.setQueryId("NXQ_00001");
Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
SearchResult result = service.executeQuery(q);
assertEquals(5618, result.getFound());
}
use of org.nextprot.api.solr.QueryRequest in project nextprot-api by calipho-sib.
the class EntryPublicationController method getEntryPublicationsByPubId.
@ApiMethod(path = "/entry-publications/pubid/{pubid}", verb = ApiVerb.GET, description = "Exports identified publication associated with neXtProt entries", produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/entry-publications/pubid/{pubid}", method = { RequestMethod.GET })
@ResponseBody
public PublicationView getEntryPublicationsByPubId(@ApiPathParam(name = "pubid", description = "A publication id", allowedvalues = { "630194" }) @PathVariable("pubid") long publicationId, @ApiQueryParam(name = "limit", description = "The maximum number of returned results", allowedvalues = { "500" }) @RequestParam(value = "limit", required = false) String limit) {
List<EntryPublication> eps = publicationService.getEntryPublications(publicationId);
QueryRequest qr = new QueryRequest();
qr.setQuality("gold");
qr.setRows((limit != null) ? limit : "500");
PublicationView view = new PublicationView();
view.setPublication(publicationService.findPublicationById(publicationId));
// return the n first results
view.addEntryPublicationList(eps.stream().limit(Integer.parseInt(qr.getRows())).collect(Collectors.toList()));
qr.setEntryAccessionSet(view.getEntryPublicationMap().keySet());
Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
try {
SearchResult searchResult = solrService.executeQuery(q);
view.setRelatedEntryCount(eps.size());
searchResult.getResults().forEach(result -> view.putEntrySolrResult(result));
} catch (SearchQueryException e) {
throw new NextProtException(e.getMessage());
}
return view;
}
use of org.nextprot.api.solr.QueryRequest in project nextprot-api by calipho-sib.
the class ExportController method buildQueryRequest.
private static QueryRequest buildQueryRequest(HttpServletRequest request, String query, String listId, String queryId, String sparql, String chromosome, String filter, String quality, String sort, String order) {
QueryRequest qr = new QueryRequest();
qr.setQuery(query);
if (listId != null) {
qr.setListId(listId);
}
if (sparql != null) {
qr.setSparql(sparql);
}
if (chromosome != null) {
qr.setChromosome(chromosome);
}
qr.setQueryId(queryId);
qr.setRows("50");
qr.setFilter(filter);
qr.setSort(sort);
qr.setOrder(order);
qr.setQuality(quality);
qr.setReferer(request.getHeader("referer"));
qr.setUrl(request.getRequestURL().toString() + "?" + request.getQueryString());
return qr;
}
use of org.nextprot.api.solr.QueryRequest in project nextprot-api by calipho-sib.
the class ExpasySearchController method expasySearch.
@RequestMapping(value = "/expasy-search", method = { RequestMethod.POST, RequestMethod.GET })
public String expasySearch(@RequestParam String query, @RequestParam(required = false) String type, Model model, HttpServletResponse response) {
try {
QueryRequest qr = new QueryRequest();
qr.setQuality("gold-and-silver");
qr.setQuery(query);
Query bq = queryBuilderService.buildQueryForSearch(qr, "entry");
SearchResult result = queryService.executeQuery(bq);
model.addAttribute("count", result.getFound());
model.addAttribute("url", "https://www.nextprot.org/proteins/search?quality=gold-and-silver&query=" + query);
model.addAttribute("description", "Entries matching the query " + query + " in neXtProt");
} catch (NextProtException e) {
LOGGER.error(e.getLocalizedMessage());
e.printStackTrace();
response.setStatus(500);
model.addAttribute("count", -1);
model.addAttribute("url", "error message " + e.getMessage());
} catch (Exception e) {
LOGGER.error(e.getLocalizedMessage());
e.printStackTrace();
response.setStatus(500);
model.addAttribute("count", -1);
}
return "expasy-search";
}
Aggregations