Commit 2e9c372f authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza
Browse files

Accession APIv1: wrap Overview response

parent 415f0728
...@@ -187,7 +187,7 @@ public class AccessionController { ...@@ -187,7 +187,7 @@ public class AccessionController {
*/ */
@PostMapping(value = "/overview", produces = { MediaType.APPLICATION_JSON_VALUE }) @PostMapping(value = "/overview", produces = { MediaType.APPLICATION_JSON_VALUE })
@JsonView({ JsonViews.Public.class }) @JsonView({ JsonViews.Public.class })
public Map<String, TermResult> overview(@RequestParam(name = "f", required = false) String filterCode, @RequestBody(required = false) AccessionFilter filter) public AccessionOverview overview(@RequestParam(name = "f", required = false) String filterCode, @RequestBody(required = false) AccessionFilter filter)
throws IOException, SearchException { throws IOException, SearchException {
if (filterCode != null) { if (filterCode != null) {
...@@ -196,7 +196,9 @@ public class AccessionController { ...@@ -196,7 +196,9 @@ public class AccessionController {
filterCode = shortFilterService.getCode(filter); filterCode = shortFilterService.getCode(filter);
} }
return elasticsearchService.termStatisticsAuto(Accession.class, filter, 10, terms.toArray(new String[] {})); Map<String, TermResult> overview = elasticsearchService.termStatisticsAuto(Accession.class, filter, 10, terms.toArray(new String[] {}));
return AccessionOverview.from(filterCode, filter, overview);
} }
/** /**
...@@ -411,4 +413,19 @@ public class AccessionController { ...@@ -411,4 +413,19 @@ public class AccessionController {
public String[] tileServers; public String[] tileServers;
} }
private static class AccessionOverview {
public String filterCode;
public AccessionFilter filter;
public Map<String, TermResult> overview;
private static AccessionOverview from(String filterCode, AccessionFilter filter, Map<String, TermResult> overview) {
AccessionOverview res = new AccessionOverview();
res.filterCode = filterCode;
res.filter = filter;
res.overview = overview;
return res;
}
}
} }
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