Search in sources :

Example 6 with NodeFactory

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

the class DatasetImportUtil method importDataset.

public static void importDataset(StudyImporterConfigurator studyImporterConfigurator, Dataset dataset, NodeFactory nodeFactory, ImportLogger logger, GeoNamesService geoNamesService) throws StudyImporterException {
    nodeFactory.getOrCreateDataset(dataset);
    NodeFactory nodeFactoryForDataset = new NodeFactoryWithDatasetContext(nodeFactory, dataset);
    DatasetImporter datasetImporter = new StudyImporterFactoryImpl(nodeFactoryForDataset).createImporter(dataset);
    datasetImporter.setDataset(dataset);
    if (studyImporterConfigurator != null) {
        studyImporterConfigurator.configure(datasetImporter);
    }
    if (logger != null) {
        datasetImporter.setLogger(logger);
    }
    if (geoNamesService != null) {
        datasetImporter.setGeoNamesService(geoNamesService);
    }
    datasetImporter.importStudy();
}
Also used : NodeFactory(org.eol.globi.data.NodeFactory) DatasetImporter(org.eol.globi.data.DatasetImporter) NodeFactoryWithDatasetContext(org.eol.globi.data.NodeFactoryWithDatasetContext) StudyImporterFactoryImpl(org.eol.globi.service.StudyImporterFactoryImpl)

Example 7 with NodeFactory

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

the class ExportUnmatchedTaxonNamesTest method exportOnePredatorNoPathButWithSameAs.

@Test
public void exportOnePredatorNoPathButWithSameAs() throws NodeFactoryException, IOException {
    taxonIndex = ExportTestUtil.taxonIndexWithEnricher(null, getGraphDb());
    String citation = "cite, study";
    NodeFactory nodeFactory = nodeFactoryWithDataset();
    StudyNode study = (StudyNode) nodeFactory.getOrCreateStudy(new StudyImpl("my, study", null, citation));
    Specimen predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapienz", null));
    Taxon humanz = taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapienz", null));
    TaxonImpl taxon = new TaxonImpl("Homo sapiens", "TESTING:123");
    taxon.setPath("one | two | Homo sapiens");
    NodeUtil.connectTaxa(taxon, (TaxonNode) humanz, getGraphDb(), RelTypes.SIMILAR_TO);
    assertNotNull(humanz);
    Specimen preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Caniz", null));
    predatorSpecimen.interactsWith(preySpecimen, InteractType.ATE);
    predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens", null));
    Node synonymNode = ((NodeBacked) taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens Synonym", null))).getUnderlyingNode();
    Node node = ((NodeBacked) taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens", null))).getUnderlyingNode();
    node.createRelationshipTo(synonymNode, NodeUtil.asNeo4j(RelTypes.SAME_AS));
    preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Canis", null));
    predatorSpecimen.ate(preySpecimen);
    resolveNames();
    StringWriter writer = new StringWriter();
    new ExportUnmatchedTaxonNames().exportStudy(study, ExportUtil.AppenderWriter.of(writer), true);
    String actual = writer.toString();
    assertThat(actual, startsWith("unmatched taxon name\tunmatched taxon id\tname status\tsimilar to taxon name\tsimilar to taxon path\tsimilar to taxon id\tstudy\tsource"));
    assertThat(actual, containsString("\nHomo sapienz\t\t\tHomo sapiens\tone | two | Homo sapiens\tTESTING:123\tcite, study\t<some:archive>"));
    assertThat(actual, containsString("\nCaniz\t\t\t\t\t\tcite, study\t<some:archive>"));
    assertThat(actual, containsString("\nCanis\t\t\t\t\t\tcite, study\t<some:archive>"));
}
Also used : Specimen(org.eol.globi.domain.Specimen) NodeFactory(org.eol.globi.data.NodeFactory) NodeBacked(org.eol.globi.domain.NodeBacked) StringWriter(java.io.StringWriter) TaxonImpl(org.eol.globi.domain.TaxonImpl) Taxon(org.eol.globi.domain.Taxon) Node(org.neo4j.graphdb.Node) StudyNode(org.eol.globi.domain.StudyNode) TaxonNode(org.eol.globi.domain.TaxonNode) StudyImpl(org.eol.globi.domain.StudyImpl) Matchers.containsString(org.hamcrest.Matchers.containsString) StudyNode(org.eol.globi.domain.StudyNode) Test(org.junit.Test)

Example 8 with NodeFactory

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

the class NodeFactoryTest method doSingleImportNeo4j2.

@Test
public void doSingleImportNeo4j2() throws StudyImporterException {
    GraphDatabaseService graphDb = getGraphDb();
    NodeFactory factory = createNeo4j2(graphDb);
    try (Transaction tx = getGraphDb().beginTx()) {
        importWithGraphDB(factory);
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) NodeFactory(org.eol.globi.data.NodeFactory) Transaction(org.neo4j.graphdb.Transaction) Test(org.junit.Test)

Example 9 with NodeFactory

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

the class NodeFactoryTest method createNeo4j2.

private NodeFactory createNeo4j2(GraphDatabaseService graphDb) {
    NodeFactory factory;
    try (Transaction tx = getGraphDb().beginTx()) {
        factory = new NodeFactoryNeo4j2(graphDb);
        tx.success();
    }
    return factory;
}
Also used : NodeFactory(org.eol.globi.data.NodeFactory) Transaction(org.neo4j.graphdb.Transaction) NodeFactoryNeo4j2(org.eol.globi.data.NodeFactoryNeo4j2)

Aggregations

NodeFactory (org.eol.globi.data.NodeFactory)9 Transaction (org.neo4j.graphdb.Transaction)6 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)5 Test (org.junit.Test)3 StringWriter (java.io.StringWriter)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 NodeFactoryNeo4j2 (org.eol.globi.data.NodeFactoryNeo4j2)2 StudyImporterException (org.eol.globi.data.StudyImporterException)2 Specimen (org.eol.globi.domain.Specimen)2 Study (org.eol.globi.domain.Study)2 StudyImpl (org.eol.globi.domain.StudyImpl)2 StudyNode (org.eol.globi.domain.StudyNode)2 Taxon (org.eol.globi.domain.Taxon)2 TaxonImpl (org.eol.globi.domain.TaxonImpl)2 Dataset (org.globalbioticinteractions.dataset.Dataset)2 DatasetRegistryException (org.globalbioticinteractions.dataset.DatasetRegistryException)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Collection (java.util.Collection)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1