use of org.eol.globi.service.TaxonUtil in project eol-globi-data by jhpoelen.
the class ResolvingTaxonIndexNoTx method indexAndConnect.
private TaxonNode indexAndConnect(List<Map<String, String>> taxonMatches, Taxon origTaxon, Taxon primaryTaxon, TaxonNode indexedTaxon) throws NodeFactoryException {
Predicate<Taxon> selector = subj -> true;
for (Map<String, String> taxonMatch : taxonMatches) {
Taxon sameAsTaxon = TaxonUtil.mapToTaxon(taxonMatch);
if (StringUtils.equals(sameAsTaxon.getExternalId(), origTaxon.getExternalId())) {
indexedTaxon = createAndIndexTaxon(origTaxon, sameAsTaxon);
selector = new ExcludeHomonyms(sameAsTaxon);
break;
}
}
final TaxonNode resolvedTaxon = indexedTaxon == null ? createAndIndexTaxon(origTaxon, primaryTaxon) : indexedTaxon;
taxonMatches.stream().map(TaxonUtil::mapToTaxon).filter(selector).forEach(sameAsTaxon -> NodeUtil.connectTaxa(sameAsTaxon, resolvedTaxon, getGraphDbService(), RelTypes.SAME_AS));
return resolvedTaxon;
}
Aggregations