Search in sources :

Example 16 with GraphServiceFactoryProxy

use of org.eol.globi.db.GraphServiceFactoryProxy in project eol-globi-data by jhpoelen.

the class LinkerTaxonIndexTest method linking.

@Test
public void linking() 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("Homo sapiens also", "FOO:444");
    taxon1.setPathIds("BARZ:111 | FOOZ:777");
    TaxonImpl taxon2 = new TaxonImpl("Homo sapiens also2", "FOO:444");
    taxon1.setPathIds("BARZ:111 | FOOZ:777");
    NodeUtil.connectTaxa(taxon1, (TaxonNode) taxon, getGraphDb(), RelTypes.SAME_AS);
    NodeUtil.connectTaxa(taxon2, (TaxonNode) taxon, getGraphDb(), RelTypes.SAME_AS);
    taxon = taxonIndex.getOrCreateTaxon(new TaxonImpl("Bla blaus", null));
    taxon.setExternalId("FOO 1234");
    resolveNames();
    new LinkerTaxonIndex(new GraphServiceFactoryProxy(getGraphDb())).index();
    IndexHits<Node> hits = getGraphDb().index().forNodes(LinkerTaxonIndex.INDEX_TAXON_NAMES_AND_IDS).query("*:*");
    Node next = hits.next();
    assertThat(new TaxonNode(next).getName(), is("Homo sapiens"));
    assertThat(hits.hasNext(), is(true));
    hits.close();
    assertSingleHit(PropertyAndValueDictionary.PATH + ":BAR\\:123");
    assertSingleHit(PropertyAndValueDictionary.PATH + ":FOO\\:444");
    assertSingleHit(PropertyAndValueDictionary.PATH + ":FOO\\:444 " + PropertyAndValueDictionary.PATH + ":BAR\\:123");
    assertSingleHit(PropertyAndValueDictionary.PATH + ":BAR\\:*");
    assertSingleHit(PropertyAndValueDictionary.PATH + ":Homo");
    assertSingleHit(PropertyAndValueDictionary.PATH + ":\"Homo sapiens\"");
    Taxon node = taxonIndex.findTaxonByName("Homo sapiens");
    assertThat(((NodeBacked) node).getUnderlyingNode().getProperty(PropertyAndValueDictionary.EXTERNAL_IDS).toString(), is("Animalia | BARZ:111 | Bar:123 | FOO:444 | FOOZ:777 | Homo sapiens | Homo sapiens also | Homo sapiens also2 | Mammalia"));
    assertThat(((NodeBacked) node).getUnderlyingNode().getProperty(PropertyAndValueDictionary.NAME_IDS).toString(), is("Bar:123 | FOO:444"));
    assertThat(new TaxonFuzzySearchIndex(getGraphDb()).query("name:sapienz~").size(), is(1));
    assertThat(new TaxonFuzzySearchIndex(getGraphDb()).query("name:sapienz").size(), is(0));
}
Also used : TaxonNode(org.eol.globi.domain.TaxonNode) Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl) Node(org.neo4j.graphdb.Node) TaxonNode(org.eol.globi.domain.TaxonNode) GraphServiceFactoryProxy(org.eol.globi.db.GraphServiceFactoryProxy) TaxonFuzzySearchIndex(org.eol.globi.taxon.TaxonFuzzySearchIndex) ResolvingTaxonIndexTest(org.eol.globi.taxon.ResolvingTaxonIndexTest) Test(org.junit.Test)

Aggregations

GraphServiceFactoryProxy (org.eol.globi.db.GraphServiceFactoryProxy)16 TaxonImpl (org.eol.globi.domain.TaxonImpl)13 Test (org.junit.Test)12 Taxon (org.eol.globi.domain.Taxon)11 StudyImpl (org.eol.globi.domain.StudyImpl)7 TaxonNode (org.eol.globi.domain.TaxonNode)7 Node (org.neo4j.graphdb.Node)7 NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)6 Specimen (org.eol.globi.domain.Specimen)5 ResolvingTaxonIndexTest (org.eol.globi.taxon.ResolvingTaxonIndexTest)4 StudyNode (org.eol.globi.domain.StudyNode)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Map (java.util.Map)2 GraphDBTestCase (org.eol.globi.data.GraphDBTestCase)2 NodeFactoryException (org.eol.globi.data.NodeFactoryException)2 NodeFactoryNeo4j2 (org.eol.globi.data.NodeFactoryNeo4j2)2 RelTypes (org.eol.globi.domain.RelTypes)2 Study (org.eol.globi.domain.Study)2 PropertyEnricher (org.eol.globi.service.PropertyEnricher)2