當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphDatabaseFactory類代碼示例

本文整理匯總了Java中org.neo4j.graphdb.factory.GraphDatabaseFactory的典型用法代碼示例。如果您正苦於以下問題:Java GraphDatabaseFactory類的具體用法?Java GraphDatabaseFactory怎麽用?Java GraphDatabaseFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GraphDatabaseFactory類屬於org.neo4j.graphdb.factory包,在下文中一共展示了GraphDatabaseFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shouldTransformCypherAlbumsToJSONDoc

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@Test
	public void shouldTransformCypherAlbumsToJSONDoc() throws SQLException {
		
//		GraphDatabaseService database = new TestGraphDatabaseFactory().newImpermanentDatabase();
		GraphDatabaseService database = new GraphDatabaseFactory().newEmbeddedDatabase(new File("/Applications/Development/Neo4j-2.3.2/neo4j-community-2.3.2/data/graph.db"));
		
		database.registerTransactionEventHandler(new Neo4jEventListener(database));
		
		String cypher = "MATCH (n) "
						+ "WHERE n.name = \"Volcano\" "
						+ "WITH n "
						+ "SET n.explicit = true "
						+ "RETURN n";
		
		try (Transaction tx = database.beginTx()) {

			database.execute(cypher);
			tx.success();
		}
	}
 
開發者ID:larusba,項目名稱:neo4j-couchbase-connector,代碼行數:21,代碼來源:Neo4jEventHandlerTest.java

示例2: main

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
public static void main(String []args) {
        dbFact = new GraphDatabaseFactory();
        db= dbFact.newEmbeddedDatabase("gestionAvionsBD2");
        /*AjouterDepart ad = new AjouterDepart();
        ad.setLocationRelativeTo(null);
        ad.loadTableBD();
        ad.setVisible(true);*/
        
        MainWindow mainFen = new MainWindow();
        mainFen.setLocationRelativeTo(null);
        mainFen.setVisible(true);
            /*Node jNode = db.createNode(Tutorials.JAVAtest);
            Node jNode2 = db.createNode(Tutorials.Test2);
            jNode.setProperty("Id", "5");
            jNode2.setProperty("Id2", "10");11
            Relationship relat = jNode.createRelationshipTo(jNode2, Relations.Relation);
            relat.setProperty("Id", "15");
            tx.success();*/
}
 
開發者ID:ATF19,項目名稱:flight-management-system-java,代碼行數:20,代碼來源:Main.java

示例3: insert_node_should_succeed_with_populated_index

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@Test
public void insert_node_should_succeed_with_populated_index() throws Exception {
    Neo4jBatchInserterNode nodeInserter = getNeo4jBatchInserterNode(false);

    // populate the db
    List<String> columns = DummyTalendPojo.getColumnList();
    for (int i = 0; i < 100; i++) {
        DummyTalendPojo pojo = DummyTalendPojo.getDummyTalendPojo();
        nodeInserter.create(pojo, columns);
    }
    nodeInserter.finish();

    // check if index size
    Assert.assertEquals(100, batchDb.batchInserterIndexes.get(INDEX_NAME).query("*:*").size());

    // check the database data
    batchDb.shutdown();
    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        String result = graphDb.execute("MATCH (n:" + LABEL_NAME + ") RETURN count(n) AS count").resultAsString();
        Assert.assertEquals("+-------+\n| count |\n+-------+\n| 100   |\n+-------+\n1 row\n", result);
    }
    graphDb.shutdown();
}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:26,代碼來源:Neo4jBatchInserterNodeTest.java

示例4: update_node_should_succeed

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@Test
public void update_node_should_succeed() throws Exception {
    // populate the db
    Neo4jBatchInserterNode nodeInserter = getNeo4jBatchInserterNode(false);
    List<String> columns = DummyTalendPojo.getColumnList();
    DummyTalendPojo pojo = DummyTalendPojo.getDummyTalendPojo();
    nodeInserter.create(pojo, columns);
    nodeInserter.finish();

    // By indexing the import id, I update the last node
    pojo.propString = "A new String";
    nodeInserter = getNeo4jBatchInserterNode(true);
    nodeInserter.create(pojo, columns);
    nodeInserter.finish();

    // check the result into the database
    batchDb.shutdown();
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        String result = graphDb.execute("MATCH (n:" + LABEL_NAME + ") WHERE exists(n.id) RETURN n.propString AS string").resultAsString();
        Assert.assertEquals("+----------------+\n| string         |\n+----------------+\n| \"A new String\" |\n+----------------+\n1 row\n", result);
    }
    graphDb.shutdown();
}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:25,代碼來源:Neo4jBatchInserterNodeTest.java

示例5: create_node_uniqueness_constraint_should_work

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@Test
public void create_node_uniqueness_constraint_should_work() {
    // Test const.
    String label = "Test";
    String property = "myProp";

    // crete the schema
    batchDb.createSchema("NODE_PROPERTY_UNIQUE", label, property);
    batchDb.shutdown();

    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        Assert.assertTrue(graphDb.schema().getConstraints(DynamicLabel.label(label)).iterator().hasNext());
    }
    graphDb.shutdown();
}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:18,代碼來源:Neo4jBatchDatabaseTest.java

示例6: create_node_index_should_work

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@Test
public void create_node_index_should_work() {
    // Test const.
    String label = "Test";
    String property = "myProp";

    // crete the schema
    batchDb.createSchema("NODE_PROPERTY_INDEX", label, property);
    batchDb.shutdown();

    // Testing it with real graphdb
    GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
    try (Transaction tx = graphDb.beginTx()) {
        Assert.assertTrue(graphDb.schema().getIndexes(DynamicLabel.label(label)).iterator().hasNext());
    }
    graphDb.shutdown();

}
 
開發者ID:sim51,項目名稱:neo4j-talend-component,代碼行數:19,代碼來源:Neo4jBatchDatabaseTest.java

示例7: KnowledgeGraph

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public KnowledgeGraph(String db_path) {
	
	this.db_path = new String(db_path);

	// delete data from previous runs
	try {
		FileUtils.deleteRecursively(new File(this.db_path));
	} catch (IOException e) {
		e.printStackTrace();
	}

	// create a neo4j database
	this.graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(this.db_path);

	registerShutdownHook(graphDb);
}
 
開發者ID:sunil3590,項目名稱:artificial-guy,代碼行數:18,代碼來源:KnowledgeGraph.java

示例8: testRelReader

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@Test
public void testRelReader() throws IOException{
  
  RelReader reader = new RelReader(neo4jLocation);
  reader.batchBuildGraph(new File("my_test_umls/"), "CtakesAllTuis.txt", "SNOMEDCT_US");
  GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(new File(neo4jLocation));
  
  try ( Transaction tx = db.beginTx() ){
    TraversalDescription td = db.traversalDescription()
        .breadthFirst()
        .relationships(RelReader.RelTypes.ISA, Direction.INCOMING)
        .evaluator(Evaluators.excludeStartPosition());

    Node cuiNode = db.findNode(RelReader.DictLabels.Concept, RelReader.CUI_PROPERTY, "C0007102");
    Assert.assertNotNull(cuiNode);
    Traverser traverser = td.traverse(cuiNode);
    for(Path path : traverser){
      System.out.println("At depth " + path.length() + " => " + path.endNode().getProperty("cui"));
    }
  }
  db.shutdown();
}
 
開發者ID:tmills,項目名稱:umls-graph-api,代碼行數:23,代碼來源:TestRelReader.java

示例9: connect

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
public GraphDatabaseService connect() {
	if (null == graph) {
		graph = new GraphDatabaseFactory().newEmbeddedDatabase(path);
		try (Transaction tx = graph.beginTx()) {
			graph.schema().indexFor(LABEL).on(ID).create();
			tx.success();
		}
		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				graph.shutdown();
			}
		});
	}
	return graph;
}
 
開發者ID:stefano-bragaglia,項目名稱:NeoDD,代碼行數:17,代碼來源:BiDiDi.java

示例10: createDb

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
private void createDb() {
	graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
	registerShutdownHook(graphDb);

	try (Transaction tx = graphDb.beginTx()) {
		// Database operations go here

		firstNode = graphDb.createNode();
		firstNode.setProperty("message", "Hello, ");
		secondNode = graphDb.createNode();
		secondNode.setProperty("message", "World!");

		relationship = firstNode.createRelationshipTo(secondNode, RelTypes.KNOWS);
		relationship.setProperty("message", "brave Neo4j ");

		System.out.print(firstNode.getProperty("message"));
		System.out.print(relationship.getProperty("message"));
		System.out.print(secondNode.getProperty("message"));

		greeting = ((String) firstNode.getProperty("message")) + ((String) relationship.getProperty("message"))
				+ ((String) secondNode.getProperty("message"));

		tx.success();
	}
}
 
開發者ID:stefano-bragaglia,項目名稱:NeoDD,代碼行數:26,代碼來源:Application.java

示例11: createInstance

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@Override
protected GraphTransactionalImpl createInstance() throws Exception {
  GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(path));
  Neo4jConfiguration config = new Neo4jConfiguration();
  config.getExactNodeProperties().addAll(newHashSet(
    NodeProperties.LABEL,
    Concept.SYNONYM,
    Concept.ABREVIATION,
    Concept.ACRONYM));
  config.getIndexedNodeProperties().addAll(newHashSet(
      NodeProperties.LABEL,
      Concept.CATEGORY, Concept.SYNONYM,
      Concept.ABREVIATION,
      Concept.ACRONYM));
  Neo4jModule.setupAutoIndexing(graphDb, config);
  IdMap idMap = new IdMap();
  RelationshipMap relationahipMap = new RelationshipMap();
  return new GraphTransactionalImpl(graphDb, idMap, relationahipMap);
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:20,代碼來源:GraphOwlVisitorTransactionalGraphTest.java

示例12: test

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@Test
public void test() throws Exception {
  OwlLoadConfiguration config = new OwlLoadConfiguration();
  Neo4jConfiguration neo4jConfig = new Neo4jConfiguration();
  neo4jConfig.setLocation(folder.getRoot().getAbsolutePath());
  config.setGraphConfiguration(neo4jConfig);
  OntologySetup ontSetup = new OntologySetup();
  ontSetup.setUrl("http://127.0.0.1:10000/main.owl");
  config.getOntologies().add(ontSetup);
  BatchOwlLoader.load(config);

  GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(folder.getRoot());
  graphDb.beginTx();
  GraphvizWriter writer = new GraphvizWriter();
  Walker walker = Walker.fullGraph(graphDb);
  writer.emit(new File("/tmp/test.dot"), walker);
}
 
開發者ID:SciGraph,項目名稱:SciGraph,代碼行數:18,代碼來源:BatchOwlLoaderIT.java

示例13: WikiNerGraphConnector

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
private WikiNerGraphConnector(String dbDir) {
	graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbDir);
	IndexDefinition indexDefinition;
	Schema schema;
	Transaction tx = graphDb.beginTx();	
	
	schema = graphDb.schema();
	IndexManager index = graphDb.index();
	entities = index.forNodes(entityLabel.name());
	cities = index.forNodes(cityLabel.name());
	try{
		 indexDefinition = schema.indexFor( entityLabel ).on( "nameType" ).create();
	}catch(Exception e){
		
	}
	
	tx.success();
	tx.close();
}
 
開發者ID:drossner,項目名稱:WikiN-G-ER,代碼行數:20,代碼來源:WikiNerGraphConnector.java

示例14: DBInit

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
private void DBInit()
{
	graph_db = new GraphDatabaseFactory()
		.newEmbeddedDatabaseBuilder(db_name)
		.setConfig(GraphDatabaseSettings.keep_logical_logs, "false")
		.setConfig(GraphDatabaseSettings.use_memory_mapped_buffers, "true")
		.setConfig(ShellSettings.remote_shell_enabled, "true")
		.setConfig(ShellSettings.remote_shell_port, "1337")
		.setConfig(ShellSettings.remote_shell_read_only, "true")
		.newGraphDatabase();

	if(bootstrap)
		DoBootstrap();

	transaction = new NinjaTransaction(graph_db, Neo4jGraph.COUNT_THRESHOLD);
}
 
開發者ID:srcc-msu,項目名稱:octotron_core,代碼行數:17,代碼來源:Neo4jGraph.java

示例15: dbFactory

import org.neo4j.graphdb.factory.GraphDatabaseFactory; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private Block dbFactory(final Path dbdir, final String dbkey) {
  return unit -> {
    GraphDatabaseService dbservice = unit.registerMock(GraphDatabaseService.class);
    // unit.mockStatic(RuntimeRegistry.class);
    // expect(RuntimeRegistry.getStartedRuntime(dbservice)).andReturn(null);

    LinkedBindingBuilder<GraphDatabaseService> lbb = unit.mock(LinkedBindingBuilder.class);
    lbb.toInstance(dbservice);

    Binder binder = unit.get(Binder.class);
    expect(binder.bind(Key.get(GraphDatabaseService.class))).andReturn(lbb);

    ServiceKey keys = unit.get(ServiceKey.class);
    keys.generate(eq(GraphDatabaseService.class), eq(dbkey), unit.capture(Consumer.class));

    GraphDatabaseBuilder dbbuilder = unit.registerMock(GraphDatabaseBuilder.class);
    expect(dbbuilder.newGraphDatabase()).andReturn(dbservice);

    GraphDatabaseFactory factory = unit.constructor(GraphDatabaseFactory.class)
        .build();
    expect(factory.setUserLogProvider(isA(Slf4jLogProvider.class))).andReturn(factory);
    expect(factory.newEmbeddedDatabaseBuilder(dbdir.toFile())).andReturn(dbbuilder);
  };
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:26,代碼來源:Neo4jTest.java


注:本文中的org.neo4j.graphdb.factory.GraphDatabaseFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。