Commit 08aa11fa authored by Matija Obreza's avatar Matija Obreza

Taxonomy: Allow filtering by number of accessions with Taxonomy2

parent 9ae19b06
......@@ -18,6 +18,8 @@ package org.genesys2.server.service.filter;
import java.util.List;
import com.querydsl.core.types.Predicate;
import org.genesys.blocks.model.filters.NumberFilter;
import org.genesys2.server.model.genesys.QTaxonomy2;
import org.genesys2.server.model.genesys.Taxonomy2;
......@@ -31,6 +33,8 @@ public class TaxonomyExtraFilter extends TaxonomyFilter {
/** The grin. */
public Boolean grin;
public NumberFilter<Integer> accessions;
/**
* Builds the query.
......@@ -64,6 +68,9 @@ public class TaxonomyExtraFilter extends TaxonomyFilter {
predicates.add(taxonomy2.grinTaxonomySpecies.isNull());
}
}
if (accessions != null) {
predicates.add(accessions.buildQuery(taxonomy2.accessions.size()));
}
return predicates;
}
}
......@@ -239,7 +239,7 @@ public class TaxonomyServiceImpl implements TaxonomyService {
}
List<Taxonomy2> matches = jpaQueryFactory.selectFrom(QTaxonomy2.taxonomy2).where(predicate).offset(page.getOffset()).limit(page.getPageSize()).orderBy(
QTaxonomy2.taxonomy2.accessions.size().desc()).fetch();
QTaxonomy2.taxonomy2.accessions.size().desc(), QTaxonomy2.taxonomy2.taxonName.asc(), QTaxonomy2.taxonomy2.id.asc()).fetch();
final Page<Taxonomy2> res = taxonomy2Repository.findAll(predicate, page);
final List<Taxonomy2Info> content = matches.stream().map(taxonomy2 -> {
......
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