@Autowired private Map<String,String> configuration; @Bean public GraphDatabaseService graphDb() { return new EmbeddedGraphDatabase( "data/neo4j-db", configuration ); }
/** * This constructor takes care of creating the Neo4j * {@link GraphDatabaseService}. * * @param storeDir The directory where the Neo4j data is stored. */ public TheMatrix( String storeDir ) { this.graphDb = new EmbeddedGraphDatabase( storeDir ); }
public EmbeddedGraphDatabase(String storeDir){ super(new org.neo4j.kernel.EmbeddedGraphDatabase(storeDir)); }
public EmbeddedGraphDatabase(String storeDir, Map<String,String> params){ super(new org.neo4j.kernel.EmbeddedGraphDatabase(storeDir, params)); }
@Bean public Map<String,String> configuration() { return EmbeddedGraphDatabase.loadConfigurations( "neo4j_config.props" ); } @Bean public GraphDatabaseService graphDb() { return new EmbeddedGraphDatabase( "data/neo4j-db", configuration() ); }
static synchronized GraphDbContainer getGraphDbService( File file ) { String path; try { path = file.getCanonicalPath(); } catch ( IOException ex ) { path = file.getAbsolutePath(); } GraphDbContainer graphDb = instances.get( path ); if ( graphDb == null ) { graphDb = new GraphDbContainer( new EmbeddedGraphDatabase( path ), path, instances ); Runtime.getRuntime().addShutdownHook( new Thread( graphDb ) ); instances.put( path, graphDb ); } return graphDb; } }
EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase("C:\\neo4j\\data\\graph.db"); WrappingNeoServerBootstrapper srv = new WrappingNeoServerBootstrapper(graphDb); srv.start(); try { while (System.in.read() != 46) { // wait until we send a period (.) to kill the server } } catch (IOException e) {} srv.stop();
static EmbeddedGraphDatabase startGraphDbInstance( String location ) { File file = new File( location ); return new EmbeddedGraphDatabase( file.getAbsolutePath() ); }
static EmbeddedGraphDatabase startGraphDbInstance( String location, Map<String, String> configuration ) { File file = new File( location ); return new EmbeddedGraphDatabase( file.getAbsolutePath(), configuration ); }
@BeforeClass public static void setUpDb() { graphDb = new EmbeddedGraphDatabase( "target/var/examples" ); }
@Override public GraphDatabaseService newDatabase(Map<String, String> config) { config.put("ephemeral", "false"); EmbeddedGraphDatabase database = new EmbeddedGraphDatabase(path, config, state.databaseDependencies()); database.shutdown(); return new HighlyAvailableGraphDatabase(path, config, state.databaseDependencies()); } });
@BeforeClass public static void setUpDb() { String dbPath = "target/var/neo4j"; File path = new File( dbPath ); if ( path.exists() ) { for ( File file : path.listFiles() ) { file.delete(); } } graphDb = new EmbeddedGraphDatabase( dbPath ); }
public void graphDbLifecycleReplaces() { // START SNIPPET: graphDbLifecycleReplaces final GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "path/to/db" ); final IndexService indexService = new LuceneIndexService( graphDb ); Runtime.getRuntime().addShutdownHook( new Thread() { @Override public void run() { indexService.shutdown(); graphDb.shutdown(); } } ); // END SNIPPET: graphDbLifecycleReplaces }
public void graphDbLifecycleUsage() { // START SNIPPET: graphDbLifecycleUsage GraphDatabaseLifecycle graphDb = new GraphDatabaseLifecycle( new EmbeddedGraphDatabase( "path/to/db" ) ); graphDb.addLuceneIndexService(); // END SNIPPET: graphDbLifecycleUsage graphDb.manualShutdown(); }
GraphDatabaseService graphDb = new EmbeddedGraphDatabase("D://My Graph"); while (rs.next()){ String rel = rs.getString("Interface_Name"); try (Transaction tx = graphDb.beginTx()) { RelationshipType relType = DynamicRelationshipType.withName(rel); graphDb.createNode().createRelationshipTo(graphDb.createNode(), relType); tx.success(); } }
public Neo4jDataLoader( String storeDir ) { this.graphDb = new EmbeddedGraphDatabase( storeDir ); this.persons = graphDb.index().forNodes( Neo4jSocialNetwork.PERSON_INDEX ); this.interests = graphDb.index().forNodes( Neo4jSocialNetwork.INTERESTS_INDEX ); }
private static GraphDatabaseService createCleanGraphDatabase( String storeDir ) { if ( graphDb != null ) { graphDb.shutdown(); graphDb = null; } deleteFileOrDirectory( new File( storeDir ) ); return graphDb = new EmbeddedGraphDatabase( storeDir ); }
public void syncVersions() { // START SNIPPET: syncVersions GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "path/to/db" ); new MyMigration( graphDb ).syncVersion(); // END SNIPPET: syncVersions } }
/** * Creates an implementation of the Social Network service based on Neo4j. * * @param storeDir the location to store the Neo4j data. */ public Neo4jSocialNetwork( String storeDir ) { this.graphDb = new EmbeddedGraphDatabase( storeDir ); this.persons = this.graphDb.index().forNodes( PERSON_INDEX ); this.interests = this.graphDb.index().forNodes( INTERESTS_INDEX ); this.personRoot = subreference( graphDb.getReferenceNode(), PERSONS_REFERENCE ); this.interestRoot = subreference( graphDb.getReferenceNode(), INTEREST_REFERENCE ); }
@Test public void backup() throws IOException { String dest = "target/var/neo-backup"; ApplyNewLogs.main( new String[] { dest } ); GraphDatabaseService graphDb = new EmbeddedGraphDatabase( dest ); IndexService index = new LuceneIndexService( graphDb ); Transaction tx = graphDb.beginTx(); try { assertNotNull( index.getSingleNode( "backup_test", "1" ) ); assertNotNull( index.getSingleNode( "backup_test", "2" ) ); } finally { tx.finish(); } index.shutdown(); graphDb.shutdown(); } }