use of org.eol.globi.db.GraphServiceFactoryProxy in project eol-globi-data by jhpoelen.
the class LinkerTaxonIndexTest method linkingWithIdOnlyNoPath.
@Test
public void linkingWithIdOnlyNoPath() throws NodeFactoryException {
Taxon taxonFound = new TaxonImpl(null, "some id");
taxonIndex.getOrCreateTaxon(taxonFound);
resolveNames();
new LinkerTaxonIndex(new GraphServiceFactoryProxy(getGraphDb())).index();
IndexHits<Node> hits = getGraphDb().index().forNodes(LinkerTaxonIndex.INDEX_TAXON_NAMES_AND_IDS).query("path:\"some id\"");
assertThat(hits.hasNext(), is(true));
Node next = hits.next();
assertThat(new TaxonNode(next).getExternalId(), is("some id"));
assertThat(hits.hasNext(), is(false));
hits.close();
}
use of org.eol.globi.db.GraphServiceFactoryProxy in project eol-globi-data by jhpoelen.
the class LinkerTaxonIndexTest method findByStringWithWhitespaces.
@Test
public void findByStringWithWhitespaces() throws NodeFactoryException {
NonResolvingTaxonIndex taxonService = new NonResolvingTaxonIndex(getGraphDb());
taxonService.getOrCreateTaxon(setTaxonProps(new TaxonImpl("Homo sapiens")));
resolveNames();
resolveNames();
new LinkerTaxonIndex(new GraphServiceFactoryProxy(getGraphDb())).index();
assertThat(getGraphDb().index().existsForNodes(TaxonFuzzySearchIndex.TAXON_NAME_SUGGESTIONS), is(true));
Index<Node> index = getGraphDb().index().forNodes(TaxonFuzzySearchIndex.TAXON_NAME_SUGGESTIONS);
Query query = new TermQuery(new Term("name", "name"));
IndexHits<Node> hits = index.query(query);
assertThat(hits.size(), is(1));
hits = index.query("name", "s nme~");
assertThat(hits.size(), is(1));
hits = index.query("name", "geRman~");
assertThat(hits.size(), is(1));
hits = index.query("name:geRman~ AND name:som~");
assertThat(hits.size(), is(1));
hits = index.query("name:hmo~ AND name:SApiens~");
assertThat(hits.size(), is(1));
hits = index.query("name:hmo~ AND name:sapiens~");
assertThat(hits.size(), is(1));
// queries are case sensitive . . . should all be lower cased.
hits = index.query("name:HMO~ AND name:saPIENS~");
assertThat(hits.size(), is(0));
}
use of org.eol.globi.db.GraphServiceFactoryProxy in project eol-globi-data by jhpoelen.
the class LinkerTaxonIndexTest method indexTaxaWithLiteratureLink.
private void indexTaxaWithLiteratureLink() throws NodeFactoryException {
Taxon taxonFound = new TaxonImpl("Homo sapiens", "bar:123");
taxonFound.setPath("Animalia | Mammalia | Homo sapiens");
Taxon taxon = taxonIndex.getOrCreateTaxon(taxonFound);
TaxonImpl taxon1 = new TaxonImpl("doi:10.123/456", "doi:10.123/456");
taxon1.setPath("doi:10.123/456");
taxon1.setPathIds("doi:10.123/456");
NodeUtil.connectTaxa(taxon1, (TaxonNode) taxon, getGraphDb(), RelTypes.SAME_AS);
resolveNames();
new LinkerTaxonIndex(new GraphServiceFactoryProxy(getGraphDb())).index();
}
use of org.eol.globi.db.GraphServiceFactoryProxy in project eol-globi-data by jhpoelen.
the class NameResolverTest method literatureTaxon.
@Test
public void literatureTaxon() throws NodeFactoryException {
Specimen someOtherOrganism = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null)), new TaxonImpl("foo", "foo:123"));
Specimen someOtherOrganism2 = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null)), new TaxonImpl("bar", "bar:456"));
someOtherOrganism.ate(someOtherOrganism2);
final NameResolver nameResolver = new NameResolver(new GraphServiceFactoryProxy(getGraphDb()), new ResolvingTaxonIndex(new PropertyEnricher() {
@Override
public Map<String, String> enrichFirstMatch(Map<String, String> properties) throws PropertyEnricherException {
return enrichAllMatches(properties).get(0);
}
@Override
public List<Map<String, String>> enrichAllMatches(Map<String, String> properties) throws PropertyEnricherException {
TaxonImpl literature = new TaxonImpl("doi:10.678/901", "doi:10.678/901");
literature.setPath("some | other | path");
TaxonImpl concept = new TaxonImpl("Donald duckus", "foo:XXX");
concept.setPath("some | path");
return Arrays.asList(TaxonUtil.taxonToMap(literature), TaxonUtil.taxonToMap(concept));
}
@Override
public void shutdown() {
}
}, getGraphDb()));
nameResolver.setBatchSize(1L);
nameResolver.index();
Taxon resolvedTaxon = taxonIndex.findTaxonById("foo:123");
assertThat(resolvedTaxon, is(notNullValue()));
assertThat(resolvedTaxon.getExternalId(), is("foo:XXX"));
assertThat(resolvedTaxon.getName(), is("Donald duckus"));
Taxon resolvedTaxon2 = taxonIndex.findTaxonByName("foo");
assertThat(resolvedTaxon2.getExternalId(), is("foo:XXX"));
assertThat(resolvedTaxon2.getName(), is("Donald duckus"));
}
use of org.eol.globi.db.GraphServiceFactoryProxy in project eol-globi-data by jhpoelen.
the class NameResolverTest method iNaturalistTaxon.
@Test
public void iNaturalistTaxon() throws NodeFactoryException {
Specimen someOtherOrganism = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null)), new TaxonImpl("Blaus bla", "INAT_TAXON:58831"));
Specimen someOtherOrganism2 = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null)), new TaxonImpl("Redus rha", "INAT_TAXON:126777"));
someOtherOrganism.ate(someOtherOrganism2);
GraphServiceFactory graphServiceFactory = new GraphServiceFactoryProxy(getGraphDb());
final NameResolver nameResolver = new NameResolver(graphServiceFactory, new NonResolvingTaxonIndex(getGraphDb()));
nameResolver.setBatchSize(1L);
nameResolver.index();
Taxon resolvedTaxon = taxonIndex.findTaxonById("INAT_TAXON:58831");
assertThat(resolvedTaxon, is(notNullValue()));
assertThat(resolvedTaxon.getExternalId(), is("INAT_TAXON:58831"));
assertThat(resolvedTaxon.getName(), is("Blaus bla"));
Taxon resolvedTaxon2 = taxonIndex.findTaxonByName("Blaus bla");
assertThat(resolvedTaxon2, is(notNullValue()));
assertThat(resolvedTaxon2.getExternalId(), is("INAT_TAXON:58831"));
}
Aggregations