Commit 03f59281 authored by Matija Obreza's avatar Matija Obreza

Institute API v1: Get passport data coverage info

parent 68cb2131
/*
* Copyright 2018 Global Crop Diversity Trust
* Copyright 2019 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -149,6 +149,27 @@ public class InstituteController {
return details;
}
/**
* Gets the passport data coverage for the institute.
*
* @param code the institute WIEWS code
* @return the coverage
*/
@JsonView({ JsonViews.Protected.class })
@GetMapping(value = "/{code:[A-Z]+[0-9]+}/coverage", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("hasRole('USER')")
public Map<String, Long> getCoverage(@PathVariable(value = "code") String code) {
FaoInstitute faoInstitute = instituteService.getInstitute(code);
if (faoInstitute == null) {
throw new NotFoundElement();
}
AccessionFilter filter = new AccessionFilter();
filter.holder().id().add(faoInstitute.getId());
return elasticsearchService.countMissingValues(Accession.class, filter);
}
@RequestMapping(value = "/{wiewsCode}/download", method = RequestMethod.POST, params = { "dwca" })
public void downloadDwca(@PathVariable(value = "wiewsCode", required = true) String wiewsCode, HttpServletResponse response) throws Exception {
final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
......
......@@ -80,7 +80,6 @@ import org.genesys.blocks.model.VersionedModel;
import org.genesys.blocks.model.filters.BasicModelFilter;
import org.genesys.custom.elasticsearch.CustomMapping;
import org.genesys2.server.component.elastic.ElasticQueryBuilder;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.service.ElasticsearchService;
import org.genesys2.spring.config.ElasticsearchConfig;
import org.slf4j.Logger;
......@@ -813,7 +812,7 @@ public class ElasticsearchServiceImpl implements ElasticsearchService, Initializ
results.put(agg.getName(), missingCount);
}
}
results.put("totalCount", response.getHits().getTotalHits());
results.put("_totalCount", response.getHits().getTotalHits());
return results;
}
......
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