Commit c7c218a4 authored by Matija Obreza's avatar Matija Obreza
Browse files

Fixed #19

parent 67e6a1e8
......@@ -104,9 +104,9 @@ public interface GenesysService {
Page<Accession> listAccessionsByInstituteAndSpecies(FaoInstitute institute, long taxSpecies, Pageable pageable);
Page<Accession> listAccessionsByTaxSpecies(long taxSpeciesId, Pageable pageable);
Page<Accession> listAccessionsByTaxGenus(long taxGenusId, Pageable pageable);
Page<Accession> listAccessionsByGenus(String genus, Pageable pageable);
Page<Accession> listAccessionsByTaxSpecies(long taxSpeciesId, Pageable pageable);
Page<Accession> listAccessions(Pageable pageable);
......
......@@ -94,7 +94,8 @@ public class DirectMysqlQuery {
}
protected DirectMysqlQuery filter(ObjectNode jsonTree, MethodResolver methodResolver) {
createQuery(whereBuffer, "a.taxSpecies", jsonTree.get("species"), params);
createQuery(whereBuffer, "a.taxGenus", jsonTree.get("genusId"), params);
createQuery(whereBuffer, "a.taxSpecies", jsonTree.get("speciesId"), params);
createQuery(whereBuffer, "a.acceNumb", jsonTree.get("acceNumb"), params);
createQuery(whereBuffer, "a.orgCty", jsonTree.get("orgCty"), params);
createQuery(whereBuffer, "a.instCode", jsonTree.get("instCode"), params);
......
......@@ -390,8 +390,7 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
}
@Override
public Page<Accession> listAccessionsByGenus(String genus, Pageable pageable) {
long taxGenusId = taxonomyService.getTaxonomy2Id(genus);
public Page<Accession> listAccessionsByTaxGenus(long taxGenusId, Pageable pageable) {
return accessionRepository.findByTaxGenus(taxGenusId, pageable);
}
......
......@@ -123,7 +123,6 @@ public class AccessionController extends BaseController {
* @param model
* @param wiewsCode
* @param genus
* @param species
* @param page
* @return
*/
......@@ -131,15 +130,25 @@ public class AccessionController extends BaseController {
public String viewDataByGenus(ModelMap model, @PathVariable(value = "genus") String genus,
@RequestParam(value = "page", required = false, defaultValue = "1") int page) {
// Taxonomy
long taxGenusId;
try {
taxGenusId = taxonomyService.getTaxonomy2Id(genus);
} catch (NullPointerException e) {
throw new ResourceNotFoundException("No taxonomy with genus=" + genus);
}
HashMap<Object, Object> filters = new HashMap<Object, Object>();
filters.put("filter.genus", genus);
model.addAttribute("filters", filters);
Page<Accession> accessions = genesysService.listAccessionsByGenus(genus, new PageRequest(page - 1, 50, new Sort("accessionName")));
Page<Accession> accessions = genesysService.listAccessionsByTaxGenus(taxGenusId, new PageRequest(page - 1, 50, new Sort("accessionName")));
_logger.info("Got: " + accessions);
model.addAttribute("pagedData", accessions);
model.addAttribute("jsonFilter", "{\"genusId\":[\"" + taxGenusId + "\"]}");
return "/accession/data";
}
......@@ -158,19 +167,24 @@ public class AccessionController extends BaseController {
@RequestParam(value = "page", required = false, defaultValue = "1") int page) {
// Taxonomy
long taxSpeciesId = taxonomyService.getTaxonomy2Id(genus, species);
long taxSpeciesId;
try {
taxSpeciesId = taxonomyService.getTaxonomy2Id(genus, species);
} catch (NullPointerException e) {
throw new ResourceNotFoundException("No taxonomy with genus=" + genus + " and species=" + species);
}
HashMap<Object, Object> filters = new HashMap<Object, Object>();
model.addAttribute("filters", filters);
filters.put("filter.taxonomy", taxSpeciesId);
filters.put("filter.taxSpecies", genus + " " + species);
Page<Accession> accessions = genesysService.listAccessionsByTaxSpecies(taxSpeciesId, new PageRequest(page - 1, 50, new Sort("accessionName")));
_logger.info("Got: " + accessions);
model.addAttribute("pagedData", accessions);
model.addAttribute("jsonFilter", "{\"species\":[\"" + taxSpeciesId + "\"]}");
model.addAttribute("jsonFilter", "{\"speciesId\":[\"" + taxSpeciesId + "\"]}");
return "/accession/data";
}
......
......@@ -319,7 +319,10 @@ public class AdminController {
public String clearTilesCache() {
Cache tileServerCache = cacheManager.getCache("tileserver");
System.err.println("tileServerCache=" + tileServerCache.getNativeCache());
@SuppressWarnings("rawtypes")
IMap hazelCache = (IMap) tileServerCache.getNativeCache();
LOG.info("Tiles cache size=" + hazelCache.size());
int count = 0;
for (Object key : hazelCache.keySet()) {
......
......@@ -326,6 +326,7 @@ filter.latitude=Latitude
filter.longitude=Longitude
filter.elevation=Elevation
filter.genus=Genus
filter.taxSpecies=Species
filter.taxon=Taxonomy name
filter.inSvalbard=In Svalbard
filter.mlsStat=In Multilateral System
......
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