Commit 3c50d8b5 authored by Maxym Borodenko's avatar Maxym Borodenko

TaxonomyFilter: filtering by GRIN Taxon name

parent f5333b96
......@@ -95,4 +95,10 @@ public interface Taxonomy2Repository extends JpaRepository<Taxonomy2, Long>, Que
@Query("select distinct t.id from Taxonomy2 t where t.currentTaxonomySpecies.genusSpecies in (?1)")
List<Long> findByCurrentGrinGenusAndSpecies(List<String> genusSpecies);
@Query("select distinct t.id from Taxonomy2 t where t.grinTaxonomySpecies.name in (?1)")
List<Long> findByGrinNames(List<String> names);
@Query("select distinct t.id from Taxonomy2 t where t.currentTaxonomySpecies.name in (?1)")
List<Long> findByCurrentGrinNames(List<String> names);
}
......@@ -98,4 +98,7 @@ public interface TaxonomyService {
List<Long> findTaxonomy2ByGrinSpecies(List<String> genusSpecies);
List<Long> findTaxonomy2ByCurrentGrinSpecies(List<String> genusSpecies);
List<Long> findTaxonomy2ByGrinNames(List<String> names);
List<Long> findTaxonomy2ByCurrentGrinNames(List<String> names);
}
......@@ -53,6 +53,12 @@ public class TaxonomyFilter extends AuditedVersionedModelFilter<TaxonomyFilter,
/** Full taxonomic name */
public StringFilter taxonName;
/** The GRIN Taxon name. */
public Set<String> grinTaxonName;
/** The GRIN current Taxon name. */
public Set<String> grinCurrentName;
/**
* Builds the query.
*
......@@ -132,6 +138,14 @@ public class TaxonomyFilter extends AuditedVersionedModelFilter<TaxonomyFilter,
}
predicates.add(builder);
}
if (CollectionUtils.isNotEmpty(grinTaxonName) && taxonomyService != null) {
List<Long> taxByGrinNames = taxonomyService.findTaxonomy2ByGrinNames(new ArrayList<>(grinTaxonName));
predicates.add(taxonomy.id.in(taxByGrinNames));
}
if (CollectionUtils.isNotEmpty(grinCurrentName) && taxonomyService != null) {
List<Long> taxByCurrentGrinNames = taxonomyService.findTaxonomy2ByCurrentGrinNames(new ArrayList<>(grinCurrentName));
predicates.add(taxonomy.id.in(taxByCurrentGrinNames));
}
return predicates;
}
......
......@@ -396,4 +396,14 @@ public class TaxonomyServiceImpl implements TaxonomyService {
public List<Long> findTaxonomy2ByCurrentGrinSpecies(List<String> genusSpecies) {
return taxonomy2Repository.findByCurrentGrinGenusAndSpecies(genusSpecies);
}
@Override
public List<Long> findTaxonomy2ByGrinNames(List<String> names) {
return taxonomy2Repository.findByGrinNames(names);
}
@Override
public List<Long> findTaxonomy2ByCurrentGrinNames(List<String> names) {
return taxonomy2Repository.findByCurrentGrinNames(names);
}
}
......@@ -7344,3 +7344,14 @@ databaseChangeLog:
referencedColumnNames: taxonomy_species_id
referencedTableName: grin_species
validate: true
- changeSet:
id: 1600676114058-1
author: mborodenko
changes:
- createIndex:
columns:
- column:
name: name
indexName: IX_name
tableName: grin_species
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