use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class NonResolvingTaxonIndexTest method assertNotIndexed.
private final void assertNotIndexed(String magicValue) throws NodeFactoryException {
Taxon taxon1 = new TaxonImpl(magicValue, null);
taxon1.setPath(null);
TaxonNode taxon = taxonService.getOrCreateTaxon(taxon1);
assertThat(taxon, is(notNullValue()));
assertThat(taxonService.findTaxonByName(magicValue), is(nullValue()));
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class NonResolvingTaxonIndexTest method createTaxonExternalIdIndex.
@Test
public final void createTaxonExternalIdIndex() throws NodeFactoryException {
Taxon taxon1 = new TaxonImpl(null, "foo:123");
taxon1.setPath(null);
TaxonNode taxon = taxonService.getOrCreateTaxon(taxon1);
assertThat(taxon, is(notNullValue()));
assertThat(taxonService.findTaxonById("foo:123"), is(notNullValue()));
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class NonResolvingTaxonIndexTest method createNullTaxon.
@Test
public final void createNullTaxon() throws NodeFactoryException {
Taxon taxon1 = new TaxonImpl(null, "EOL:1234");
taxon1.setPath(null);
TaxonNode taxon = taxonService.getOrCreateTaxon(taxon1);
assertThat(taxon, is(notNullValue()));
assertEquals("no name", taxon.getName());
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class ResolvingTaxonIndex method resolveAndIndex.
private TaxonNode resolveAndIndex(Taxon origTaxon, Taxon taxon) throws NodeFactoryException {
TaxonNode indexedTaxon = findTaxon(taxon);
while (indexedTaxon == null) {
try {
taxon = TaxonUtil.enrich(enricher, taxon);
} catch (PropertyEnricherException e) {
throw new NodeFactoryException("failed to enrich taxon with name [" + taxon.getName() + "]", e);
}
indexedTaxon = findTaxon(taxon);
if (indexedTaxon == null) {
if (TaxonUtil.isResolved(taxon)) {
indexedTaxon = createAndIndexTaxon(origTaxon, taxon);
} else {
String truncatedName = NodeUtil.truncateTaxonName(taxon.getName());
if (StringUtils.equals(truncatedName, taxon.getName())) {
if (isIndexResolvedOnly()) {
break;
} else {
indexedTaxon = addNoMatchTaxon(origTaxon);
}
} else {
taxon = new TaxonImpl();
taxon.setName(truncatedName);
indexedTaxon = findTaxonByName(taxon.getName());
}
}
}
}
return indexedTaxon;
}
use of org.eol.globi.domain.TaxonNode in project eol-globi-data by jhpoelen.
the class LinkerOpenTreeOfLife method link.
protected boolean link(GraphDatabaseService graphDb, OpenTreeTaxonIndex index, Map<String, Long> ottIds, Relationship rel) {
boolean hasPrexistingLink = false;
TaxonNode taxonNode = new TaxonNode(rel.getEndNode());
String externalId = taxonNode.getExternalId();
if (StringUtils.contains(externalId, TaxonomyProvider.OPEN_TREE_OF_LIFE.getIdPrefix())) {
ottIds.clear();
hasPrexistingLink = true;
} else {
externalId = StringUtils.replace(externalId, TaxonomyProvider.INTERIM_REGISTER_OF_MARINE_AND_NONMARINE_GENERA.getIdPrefix(), "irmng:");
externalId = StringUtils.replace(externalId, TaxonomyProvider.INDEX_FUNGORUM.getIdPrefix(), "if:");
externalId = StringUtils.replace(externalId, TaxonomyProvider.GBIF.getIdPrefix(), "gbif:");
externalId = StringUtils.replace(externalId, TaxonomyProvider.NCBI.getIdPrefix(), "ncbi:");
Long ottId = index.findOpenTreeTaxonIdFor(externalId);
if (ottId != null) {
if (ottIds.size() == 0) {
Taxon taxonCopy = copyAndLinkToOpenTreeTaxon(taxonNode, ottId);
NodeUtil.connectTaxa(taxonCopy, new TaxonNode(rel.getStartNode()), graphDb, RelTypes.SAME_AS);
}
ottIds.put(externalId, ottId);
}
}
return hasPrexistingLink;
}
Aggregations