use of uk.ac.rothamsted.rdf.neo4j.load.support.CyNodeLoadingProcessor in project rdf2neo by Rothamsted.
the class CypherLoaderIT method testLoading.
@Test
public void testLoading() throws Exception {
try (Driver neoDriver = GraphDatabase.driver("bolt://127.0.0.1:7687", AuthTokens.basic("neo4j", "test"));
RdfDataManager rdfMgr = new RdfDataManager(RdfDataManagerTest.TDB_PATH);
Neo4jDataManager neoMgr = new Neo4jDataManager(neoDriver);
SimpleCyLoader cyloader = new SimpleCyLoader()) {
// TODO: configurator, multiple config sets
CyNodeLoadingHandler cyNodeHandler = new CyNodeLoadingHandler();
CyRelationLoadingHandler cyRelHandler = new CyRelationLoadingHandler();
cyNodeHandler.setLabelsSparql(IOUtils.readResource("dbpedia_node_labels.sparql"));
cyNodeHandler.setNodePropsSparql(IOUtils.readResource("dbpedia_node_props.sparql"));
cyNodeHandler.setRdfDataManager(rdfMgr);
cyNodeHandler.setNeo4jDataManager(neoMgr);
cyRelHandler.setRelationTypesSparql(IOUtils.readResource("dbpedia_rel_types.sparql"));
cyRelHandler.setRelationPropsSparql(IOUtils.readResource("dbpedia_rel_props.sparql"));
cyRelHandler.setRdfDataManager(rdfMgr);
cyRelHandler.setNeo4jDataManager(neoMgr);
CyNodeLoadingProcessor cyNodeProc = new CyNodeLoadingProcessor();
cyNodeProc.setNodeIrisSparql(IOUtils.readResource("dbpedia_node_iris.sparql"));
cyNodeProc.setConsumer(cyNodeHandler);
CyRelationLoadingProcessor cyRelProc = new CyRelationLoadingProcessor();
cyRelProc.setConsumer(cyRelHandler);
cyloader.setCyNodeLoader(cyNodeProc);
cyloader.setCyRelationLoader(cyRelProc);
cyloader.load(RdfDataManagerTest.TDB_PATH);
// TODO: test!
}
// try neoDriver
}
use of uk.ac.rothamsted.rdf.neo4j.load.support.CyNodeLoadingProcessor in project rdf2neo by Rothamsted.
the class CypherLoaderIT method testMultiConfigLoading.
@Test
public void testMultiConfigLoading() throws Exception {
try (MultiConfigCyLoader cymloader = new MultiConfigCyLoader()) {
cymloader.setCypherLoaderFactory(() -> {
// This will eventually be managed by Spring
RdfDataManager rdfMgr = new RdfDataManager();
Driver neoDriver = GraphDatabase.driver("bolt://127.0.0.1:7687", AuthTokens.basic("neo4j", "test"));
Neo4jDataManager neoMgr = new Neo4jDataManager(neoDriver);
CyNodeLoadingHandler cyNodeHandler = new CyNodeLoadingHandler();
CyRelationLoadingHandler cyRelHandler = new CyRelationLoadingHandler();
cyNodeHandler.setRdfDataManager(rdfMgr);
cyNodeHandler.setNeo4jDataManager(neoMgr);
cyRelHandler.setRdfDataManager(rdfMgr);
cyRelHandler.setNeo4jDataManager(neoMgr);
CyNodeLoadingProcessor cyNodeProc = new CyNodeLoadingProcessor();
cyNodeProc.setConsumer(cyNodeHandler);
CyRelationLoadingProcessor cyRelProc = new CyRelationLoadingProcessor();
cyRelProc.setConsumer(cyRelHandler);
SimpleCyLoader cyloader = new SimpleCyLoader();
cyloader.setCyNodeLoader(cyNodeProc);
cyloader.setCyRelationLoader(cyRelProc);
cyloader.setRdfDataManager(rdfMgr);
return cyloader;
});
List<ConfigItem> config = new LinkedList<>();
config.add(new ConfigItem("places", readResource("dbpedia_node_iris.sparql"), readResource("dbpedia_node_labels.sparql"), readResource("dbpedia_node_props.sparql"), readResource("dbpedia_rel_types.sparql"), readResource("dbpedia_rel_props.sparql")));
config.add(new ConfigItem("people", readResource("dbpedia_people_iris.sparql"), readResource("dbpedia_people_labels.sparql"), readResource("dbpedia_people_props.sparql"), readResource("dbpedia_people_rel_types.sparql"), null));
cymloader.setConfigItems(config);
cymloader.load(RdfDataManagerTest.TDB_PATH);
}
// TODO: test!
}
use of uk.ac.rothamsted.rdf.neo4j.load.support.CyNodeLoadingProcessor in project rdf2neo by Rothamsted.
the class MultiConfigCyLoader method load.
/**
* Loops through {@link #getConfigItems() config items} and instantiates a {@link #getCypherLoaderFactory() new simple loader}
* for eache item, to load nodes/relations mapped by the config item.
*/
@Override
public void load(String tdbPath, Object... opts) {
//
for (int mode = 0; mode <= 1; mode++) {
for (ConfigItem cfg : this.getConfigItems()) {
try (SimpleCyLoader cypherLoader = this.getCypherLoaderFactory().getObject()) {
cypherLoader.setName(cfg.getName());
CyNodeLoadingProcessor cyNodeLoader = cypherLoader.getCyNodeLoader();
CyRelationLoadingProcessor cyRelLoader = cypherLoader.getCyRelationLoader();
CyNodeLoadingHandler cyNodehandler = (CyNodeLoadingHandler) cyNodeLoader.getConsumer();
CyRelationLoadingHandler cyRelhandler = (CyRelationLoadingHandler) cyRelLoader.getConsumer();
cyNodeLoader.setNodeIrisSparql(cfg.getNodeIrisSparql());
cyNodehandler.setLabelsSparql(cfg.getLabelsSparql());
cyNodehandler.setNodePropsSparql(cfg.getNodePropsSparql());
cyRelhandler.setRelationTypesSparql(cfg.getRelationTypesSparql());
cyRelhandler.setRelationPropsSparql(cfg.getRelationPropsSparql());
String indexesSparql = cfg.getIndexesSparql();
if (indexesSparql != null)
cypherLoader.getCypherIndexer().setIndexesSparql(indexesSparql);
cypherLoader.load(tdbPath, mode == 0, mode == 1);
}
// try
}
// for config items
}
// for mode
}
Aggregations