*/
private Collection<Taxon> doTextSearch(String pattern, boolean caseSensitive, boolean exactMatch, SearchTable searchTable) {
LOGGER.debug("Going to search for strings");
LOGGER.debug("Case sensitive? " + caseSensitive);
LOGGER.debug("Exact match? " + exactMatch);
TaxonLabelService tls = getTaxonLabelService();
Collection<Taxon> taxaFound = new ArrayList<Taxon>();
switch(searchTable) {
case TAXONLABEL :
LOGGER.debug("Will search taxon labels");
Collection<TaxonLabel> labelsFound = exactMatch
? tls.findByExactString(pattern)
: tls.findBySubstring(pattern, caseSensitive);
for ( TaxonLabel label : labelsFound ) {
if ( label.getTaxonVariant() != null && label.getTaxonVariant().getTaxon() != null ) {
taxaFound.add(label.getTaxonVariant().getTaxon());
}
}
break;
case TAXONVARIANT :
LOGGER.debug("Will search taxon variants");
Collection<TaxonVariant> variantsFound = exactMatch
? tls.findTaxonVariantByFullName(pattern)
: tls.findTaxonVariantWithSubstring(pattern, caseSensitive);
for ( TaxonVariant variant : variantsFound ) {
if ( variant.getTaxon() != null ) {
taxaFound.add(variant.getTaxon());
}
}
break;
case TAXON :
LOGGER.debug("Will search taxa");
Collection<Taxon> tmpTaxaFound = exactMatch
? tls.findTaxaByName(pattern)
: tls.findTaxaBySubstring(pattern, caseSensitive);
taxaFound.addAll(tmpTaxaFound);
break;
}
return taxaFound;
}