use of eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO.IncludedTaxon in project cdmlib by cybertaxonomy.
the class TaxonGraphServiceImpl method listIncludedNames.
@Override
public List<TaxonName> listIncludedNames(String queryString, MatchMode matchMode) {
if (matchMode == null) {
matchMode = MatchMode.BEGINNING;
}
List<TaxonName> includedNames = new ArrayList<>();
IncludedTaxonConfiguration configuration = new IncludedTaxonConfiguration(null, false, false, false);
List<TaxonName> matchingNames = nameService.findNamesByTitleCache(queryString, matchMode, null);
for (TaxonName name : matchingNames) {
if (logger.isDebugEnabled()) {
logger.debug("pageIncludedNames() - matching name: " + name.getTitleCache());
}
try {
Taxon graphTaxon = taxonGraphDao.assureSingleTaxon(name, false);
if (graphTaxon != null) {
IncludedTaxaDTO includedTaxaDTO = taxonService.listIncludedTaxa(graphTaxon.getUuid(), configuration);
List<UUID> includedTaxaUUIDs = includedTaxaDTO.getIncludedTaxa().stream().map(IncludedTaxon::getTaxonUuid).collect(Collectors.toList());
List<TaxonBase> includedTaxa = taxonService.load(includedTaxaUUIDs, null);
List<TaxonName> iclNames = includedTaxa.stream().map(TaxonBase::getName).collect(Collectors.toList());
includedNames.addAll(iclNames);
}
} catch (TaxonGraphException e) {
logger.error(e.getMessage());
}
}
return includedNames;
}
Aggregations