Commit 3cbe0fbb authored by Matija Obreza's avatar Matija Obreza

Added filtering on COLLMISSID

parent 3300aee0
......@@ -94,6 +94,10 @@ public class DirectMysqlQuery {
innerJoin("accessionalias", "accename", "accename.accessionId=a.id");
}
if (hasFilter(jsonTree, "collMissId")) {
innerJoin("accessioncollect", "col", "col.accessionId=a.id");
}
return this;
}
......@@ -123,6 +127,7 @@ public class DirectMysqlQuery {
createQuery(whereBuffer, "geo.elevation", jsonTree.get("elevation"), params);
createQuery(whereBuffer, "crop.shortName", jsonTree.get("crop"), params);
createQuery(whereBuffer, "accename.name", jsonTree.get("acceName"), params);
createQuery(whereBuffer, "col.collMissId", jsonTree.get("collMissId"), params);
for (final Iterator<String> it = jsonTree.fieldNames(); it.hasNext();) {
final String fieldName = it.next();
......
......@@ -127,6 +127,7 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
this.availableFilters.add(new GenesysFilterImpl("mlsStat", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("inTrust", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("available", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("collMissId", DataType.STRING));
}
@Override
......@@ -216,14 +217,18 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
final Long totalCount = this.jdbcTemplate.queryForObject(directQuery.getCountQuery("a.id"), directQuery.getParameters(), Long.class);
LOG.info("Total count: " + totalCount);
final List<Long> results = this.jdbcTemplate.queryForList(directQuery.getQuery("a.id"), directQuery.getParameters(), Long.class);
LOG.info("Getting accessions");
if (totalCount > 0 && pageable.getPageNumber() * pageable.getPageSize() <= totalCount) {
final List<Long> results = this.jdbcTemplate.queryForList(directQuery.getQuery("a.id"), directQuery.getParameters(), Long.class);
LOG.info("Getting accessions " + results.size());
return new PageImpl<Accession>(results.size() == 0 ? new ArrayList<Accession>() : accessionRepository.listById(results,
// TODO Consider processing the pageable.getSort
new Sort("accessionName")),
// -- TODO
pageable, totalCount);
return new PageImpl<Accession>(results.size() == 0 ? new ArrayList<Accession>() : accessionRepository.listById(results,
// TODO Consider processing the pageable.getSort
new Sort("accessionName")),
// -- TODO
pageable, totalCount);
} else {
return new PageImpl<Accession>(new ArrayList<Accession>(), pageable, totalCount);
}
}
/**
......
......@@ -349,7 +349,7 @@ filter.apply=Apply
filter.close=Close
filter.remove=Remove filter
filter.autocomplete-placeholder=Type more than 3 characters...
filter.collMissId=Collecting mission ID
search.page.title=Full-text Search
search.no-results=No matches found for your query.
......
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