Search in sources :

Example 1 with TaxonUtil

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;
}
Also used : Taxon(org.eol.globi.domain.Taxon) TaxonUtil(org.eol.globi.service.TaxonUtil) NodeUtil(org.eol.globi.util.NodeUtil) Predicate(java.util.function.Predicate) PropertyEnricherException(org.eol.globi.service.PropertyEnricherException) PropertyEnricher(org.eol.globi.service.PropertyEnricher) StringUtils(org.apache.commons.lang3.StringUtils) RelTypes(org.eol.globi.domain.RelTypes) List(java.util.List) TaxonImpl(org.eol.globi.domain.TaxonImpl) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) NodeFactoryException(org.eol.globi.data.NodeFactoryException) Map(java.util.Map) TaxonNode(org.eol.globi.domain.TaxonNode) TaxonNode(org.eol.globi.domain.TaxonNode) Taxon(org.eol.globi.domain.Taxon) TaxonUtil(org.eol.globi.service.TaxonUtil)

Aggregations

List (java.util.List)1 Map (java.util.Map)1 Predicate (java.util.function.Predicate)1 StringUtils (org.apache.commons.lang3.StringUtils)1 NodeFactoryException (org.eol.globi.data.NodeFactoryException)1 RelTypes (org.eol.globi.domain.RelTypes)1 Taxon (org.eol.globi.domain.Taxon)1 TaxonImpl (org.eol.globi.domain.TaxonImpl)1 TaxonNode (org.eol.globi.domain.TaxonNode)1 PropertyEnricher (org.eol.globi.service.PropertyEnricher)1 PropertyEnricherException (org.eol.globi.service.PropertyEnricherException)1 TaxonUtil (org.eol.globi.service.TaxonUtil)1 NodeUtil (org.eol.globi.util.NodeUtil)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1