Search in sources :

Example 1 with IncludedTaxon

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;
}
Also used : TaxonBase(eu.etaxonomy.cdm.model.taxon.TaxonBase) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) IncludedTaxon(eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO.IncludedTaxon) ArrayList(java.util.ArrayList) TaxonName(eu.etaxonomy.cdm.model.name.TaxonName) IncludedTaxonConfiguration(eu.etaxonomy.cdm.api.service.config.IncludedTaxonConfiguration) UUID(java.util.UUID) TaxonGraphException(eu.etaxonomy.cdm.persistence.dao.taxonGraph.TaxonGraphException) IncludedTaxaDTO(eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO)

Aggregations

IncludedTaxonConfiguration (eu.etaxonomy.cdm.api.service.config.IncludedTaxonConfiguration)1 IncludedTaxaDTO (eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO)1 IncludedTaxon (eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO.IncludedTaxon)1 TaxonName (eu.etaxonomy.cdm.model.name.TaxonName)1 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)1 TaxonBase (eu.etaxonomy.cdm.model.taxon.TaxonBase)1 TaxonGraphException (eu.etaxonomy.cdm.persistence.dao.taxonGraph.TaxonGraphException)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1