How can I refer my Neo4j embedded Db to getGraphDb() method?

I want to develop a piece of software that helps the user to open and close a Neo4j embedded server within my java application. Practically, I click the button and the web admin tool should be opened in the default web browser. However, I am stuck because I have a problem with the line code

InternalAbstractGraphDatabase graphdb = getGraphDb();

I don’t understand how to open my implemented db which is in the variable:

 private static GraphDatabaseService BORO_DB;

and has path:

public static String DB_PATH;

Below the code:

final Variable var = new Variable(true);

InternalAbstractGraphDatabase graphdb = getGraphDb();
final WrappingNeoServerBootstrapper srv;
srv = new WrappingNeoServerBootstrapper( graphdb );

final JButton btnNewButton = new JButton("Show Graph - Start Server");
btnNewButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {

        if (var.getVar()){
            var.setVar(false);
            btnNewButton.setText("Graph - Stop Server");
            srv.start();

               try {

                 String url = "http://localhost:7474";
                 java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
               }
               catch (java.io.IOException e) {
                   System.out.println(e.getMessage());
               }

        }else{
            var.setVar(true);
            btnNewButton.setText("Show Graph - Start Server");
            srv.stop();
        }   
    }
});

May you teach me how to link my DB (BORO_DB) to getGraphDb()?

Thank you

Answer

Using DB_PATH, you can instantiate BORO_DB like this:

BORO_DB = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);

srv=new WrappingNeoServerBootstrapper((GraphDatabaseAPI) BORO_DB);

Leave a Reply

Your email address will not be published. Required fields are marked *