Revision 8311a989
Added by Katja Luther over 7 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java | ||
---|---|---|
26 | 26 |
import org.apache.log4j.Logger; |
27 | 27 |
import org.apache.lucene.index.CorruptIndexException; |
28 | 28 |
import org.apache.lucene.queryparser.classic.ParseException; |
29 |
import org.apache.lucene.sandbox.queries.DuplicateFilter; |
|
29 | 30 |
import org.apache.lucene.search.BooleanClause.Occur; |
30 | 31 |
import org.apache.lucene.search.BooleanQuery; |
31 | 32 |
import org.apache.lucene.search.BooleanQuery.Builder; |
... | ... | |
641 | 642 |
List<UuidAndTitleCache<IdentifiableEntity>> results = new ArrayList<UuidAndTitleCache<IdentifiableEntity>>(); |
642 | 643 |
|
643 | 644 |
|
644 |
if (configurator.isDoSynonyms() || configurator.isDoTaxa() || configurator.isDoNamesWithoutTaxa()){ |
|
645 |
results = dao.getTaxaByNameForEditor(configurator.isDoTaxa(), configurator.isDoSynonyms(), configurator.isDoNamesWithoutTaxa(), configurator.isDoMisappliedNames(),configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas()); |
|
646 |
} |
|
647 |
if (configurator.isDoTaxaByCommonNames()) { |
|
648 |
//if(configurator.getPageSize() == null ){ |
|
649 |
List<UuidAndTitleCache<IdentifiableEntity>> commonNameResults = dao.getTaxaByCommonNameForEditor(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas()); |
|
650 |
if(commonNameResults != null){ |
|
651 |
results.addAll(commonNameResults); |
|
652 |
} |
|
653 |
// } |
|
645 |
if (configurator.isDoSynonyms() || configurator.isDoTaxa() || configurator.isDoNamesWithoutTaxa() || configurator.isDoTaxaByCommonNames()){ |
|
646 |
results = dao.getTaxaByNameForEditor(configurator.isDoTaxa(), configurator.isDoSynonyms(), configurator.isDoNamesWithoutTaxa(), configurator.isDoMisappliedNames(), configurator.isDoTaxaByCommonNames(), configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas()); |
|
654 | 647 |
} |
648 |
// if (configurator.isDoTaxaByCommonNames()) { |
|
649 |
// //if(configurator.getPageSize() == null ){ |
|
650 |
// List<UuidAndTitleCache<IdentifiableEntity>> commonNameResults = dao.getTaxaByCommonNameForEditor(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas()); |
|
651 |
// if(commonNameResults != null){ |
|
652 |
// results.addAll(commonNameResults); |
|
653 |
// } |
|
654 |
// // } |
|
655 |
// } |
|
655 | 656 |
return results; |
656 | 657 |
} |
657 | 658 |
|
... | ... | |
672 | 673 |
} |
673 | 674 |
|
674 | 675 |
|
675 |
if (configurator.isDoMisappliedNames() || configurator.isDoSynonyms() || configurator.isDoTaxa()){ |
|
676 |
if (configurator.isDoMisappliedNames() || configurator.isDoSynonyms() || configurator.isDoTaxa() || configurator.isDoTaxaByCommonNames()){
|
|
676 | 677 |
if(configurator.getPageSize() != null){ // no point counting if we need all anyway |
677 | 678 |
numberTaxaResults = |
678 | 679 |
dao.countTaxaByName(configurator.isDoTaxa(),configurator.isDoSynonyms(), configurator.isDoMisappliedNames(), |
679 |
configurator.isDoIncludeAuthors(), configurator.getTitleSearchStringSqlized(), |
|
680 |
configurator.isDoTaxaByCommonNames(), configurator.isDoIncludeAuthors(), configurator.getTitleSearchStringSqlized(),
|
|
680 | 681 |
configurator.getClassification(), configurator.getMatchMode(), |
681 | 682 |
configurator.getNamedAreas()); |
682 | 683 |
} |
683 | 684 |
|
684 | 685 |
if(configurator.getPageSize() == null || numberTaxaResults > configurator.getPageSize() * configurator.getPageNumber()){ // no point checking again if less results |
685 | 686 |
taxa = dao.getTaxaByName(configurator.isDoTaxa(), configurator.isDoSynonyms(), |
686 |
configurator.isDoMisappliedNames(), configurator.isDoIncludeAuthors(), |
|
687 |
configurator.isDoMisappliedNames(), configurator.isDoTaxaByCommonNames(), configurator.isDoIncludeAuthors(),
|
|
687 | 688 |
configurator.getTitleSearchStringSqlized(), configurator.getClassification(), |
688 | 689 |
configurator.getMatchMode(), configurator.getNamedAreas(), configurator.getOrder(), |
689 | 690 |
configurator.getPageSize(), configurator.getPageNumber(), propertyPath); |
... | ... | |
720 | 721 |
|
721 | 722 |
// Taxa from common names |
722 | 723 |
|
723 |
if (configurator.isDoTaxaByCommonNames()) { |
|
724 |
taxa = new ArrayList<>(); |
|
725 |
numberTaxaResults = 0; |
|
726 |
if(configurator.getPageSize() != null){// no point counting if we need all anyway |
|
727 |
numberTaxaResults = dao.countTaxaByCommonName(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas()); |
|
728 |
} |
|
729 |
if(configurator.getPageSize() == null || numberTaxaResults > configurator.getPageSize() * configurator.getPageNumber()){ |
|
730 |
List<Taxon> commonNameResults = dao.getTaxaByCommonName(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas(), configurator.getPageSize(), configurator.getPageNumber(), configurator.getTaxonPropertyPath()); |
|
731 |
taxa.addAll(commonNameResults); |
|
732 |
} |
|
733 |
if(taxa != null){ |
|
734 |
results.addAll(taxa); |
|
735 |
} |
|
736 |
numberOfResults += numberTaxaResults; |
|
737 |
|
|
738 |
} |
|
724 |
// if (configurator.isDoTaxaByCommonNames()) {
|
|
725 |
// taxa = new ArrayList<>();
|
|
726 |
// numberTaxaResults = 0;
|
|
727 |
// if(configurator.getPageSize() != null){// no point counting if we need all anyway
|
|
728 |
// numberTaxaResults = dao.countTaxaByCommonName(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas());
|
|
729 |
// }
|
|
730 |
// if(configurator.getPageSize() == null || numberTaxaResults > configurator.getPageSize() * configurator.getPageNumber()){
|
|
731 |
// List<Taxon> commonNameResults = dao.getTaxaByCommonName(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas(), configurator.getPageSize(), configurator.getPageNumber(), configurator.getTaxonPropertyPath());
|
|
732 |
// taxa.addAll(commonNameResults);
|
|
733 |
// }
|
|
734 |
// if(taxa != null){
|
|
735 |
// results.addAll(taxa);
|
|
736 |
// }
|
|
737 |
// numberOfResults += numberTaxaResults;
|
|
738 |
// |
|
739 |
// }
|
|
739 | 740 |
|
740 | 741 |
return new DefaultPagerImpl<> |
741 | 742 |
(configurator.getPageNumber(), numberOfResults, configurator.getPageSize(), results); |
... | ... | |
1763 | 1764 |
byCommonNameSearch.setCdmTypRestriction(Taxon.class); |
1764 | 1765 |
byCommonNameSearch.setQuery(byCommonNameJoinQuery); |
1765 | 1766 |
byCommonNameSearch.setSortFields(sortFields); |
1767 |
|
|
1768 |
DuplicateFilter df = new DuplicateFilter("inDescription.taxon.id"); |
|
1769 |
HashSet<String> results=new HashSet(); |
|
1770 |
// ScoreDoc[] hits = searcher.search(tq,df, 1000).scoreDocs; |
|
1771 |
// |
|
1772 |
// byCommonNameSearch.setFilter(df); |
|
1766 | 1773 |
idFieldMap.put(CdmBaseType.TAXON, "id"); |
1767 | 1774 |
|
1768 | 1775 |
luceneSearches.add(byCommonNameSearch); |
... | ... | |
3063 | 3070 |
|
3064 | 3071 |
@Override |
3065 | 3072 |
public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config){ |
3066 |
List<TaxonBase> taxonList = dao.getTaxaByName(true, false, false, false, config.getTaxonNameTitle(), null, MatchMode.EXACT, null, null, 0, 0, config.getPropertyPath()); |
|
3073 |
List<TaxonBase> taxonList = dao.getTaxaByName(true, false, false, false, false, config.getTaxonNameTitle(), null, MatchMode.EXACT, null, null, 0, 0, config.getPropertyPath());
|
|
3067 | 3074 |
return taxonList; |
3068 | 3075 |
} |
3069 | 3076 |
|
Also available in: Unified diff
fix #6296: include the common name search into the search query of taxa and synonyms