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();
}
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>"));
}
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);
}
}
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;
}
Aggregations