Commit e6e2fe84 authored by Matija Obreza's avatar Matija Obreza

REST API /acn/search

parent 210d955d
......@@ -304,6 +304,13 @@ public class AccessionController extends RestController {
return new JsonDeleteResult(deleted);
}
@RequestMapping(value = "/search", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody
Page<AccessionDetails> search(@RequestParam("page") final int page, @RequestParam("query") final String query) throws SearchException {
return elasticService.search(StringUtils.defaultIfBlank(query, "*"), new PageRequest(page - 1, 20));
}
// FIXME Not using institute...
@RequestMapping(value = "/{instCode}/list", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody
Page<AccessionDetails> list(@PathVariable("instCode") String instCode, @RequestParam("page") int page, @RequestParam("query") String query)
......@@ -338,14 +345,17 @@ public class AccessionController extends RestController {
@ResponseBody
public Object getAcc(@RequestBody JsonData jsonData) throws IOException {
AppliedFilters appliedFilters=new AppliedFilters();
AppliedFilter cropFilter=new AppliedFilter().setFilterName(FilterConstants.CROPS);
AppliedFilters appliedFilters = new AppliedFilters();
AppliedFilter cropFilter = new AppliedFilter().setFilterName(FilterConstants.CROPS);
cropFilter.addFilterValue(new FilterHandler.LiteralValueFilter(jsonData.crop));
appliedFilters.add(cropFilter);
LOG.debug(appliedFilters.toString());
Page<Accession> accessions = filterService.listAccessions(appliedFilters, new PageRequest(jsonData.startAt - 1, jsonData.maxRecords, new Sort("acceNumb")));
if (LOG.isDebugEnabled()) {
LOG.debug(appliedFilters.toString());
}
Page<Accession> accessions = filterService.listAccessions(appliedFilters, new PageRequest(jsonData.startAt - 1, jsonData.maxRecords, new Sort(
"acceNumb")));
return accessions;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment