ArangoDB-Community / arangodb-tinkerpop-provider

An implementation of the Tinkerpop OLTP Provider for ArangoDB
Apache License 2.0
83 stars 16 forks source link

Questions about examples #33

Closed HongHuangNeu closed 5 years ago

HongHuangNeu commented 5 years ago

Hi! Is there any examples on how to use this tinkerpop provider to access ArrangoDB via java API? There are not even related test cases in the repository and the example in wiki seems quite misleading.

arcanefoam commented 5 years ago

Hi, The lack of test cases is because the implementation is tested against the official Tinkerpop Test Suite. What do you find misleading in the "Using ArangoDBGraph via the Tinkerpop API" section on the Wiki Home page? If you can tell me what are we missing we can work together to put it there.

a-marcel commented 5 years ago

Hello, i'm using ArangoDB 3.4 and your plugin from the maven repo in version 2.0.0.

        PropertiesConfiguration configuration = new PropertiesConfiguration();
        configuration.setProperty("arangodb.hosts", "127.0.0.1:8529");
        configuration.setProperty("arangodb.user", "root");
        configuration.setProperty("arangodb.password", "");

        configuration.setProperty("gremlin.graph", "com.arangodb.tinkerpop.gremlin.jsr223.ArangoDBGramlinPlugin");
        Properties arangoProperties = ConfigurationConverter.getProperties(configuration);

                // create a ArangoDB graph
        // BaseConfiguration conf = builder.build();
        Graph graph = GraphFactory.open(arangoProperties);
        gts = new GraphTraversalSource(graph);

(yes, in the 2.0.0 version there is the spelling error "Gramlin" instead of "Gremlin" - it's fixed in the master already)

and i got the error:

GraphFactory can only instantiate Graph implementations from classes that have a static open() method that takes a single Apache Commons Configuration argument - [class com.arangodb.tinkerpop.gremlin.jsr223.ArangoDBGramlinPlugin] does not seem to have one

If i don't set "gremlin.graph" i got the error:

java.lang.RuntimeException: Configuration must contain a valid 'gremlin.graph' setting And "com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph" is not working also.

do you've a working gremlin example somewhere running ?

Thanks a lot.

Marcel

arcanefoam commented 5 years ago

Hi Marcel,

Have you tried the code from the readme? I have added an ArangoDBConfigurationBuilder to facilitate the creation of the configurations. Can you try that example and let me know if it fails?

a-marcel commented 5 years ago

Hello and thanks for the fast answer. If i use the code from the Readme file in a simple junit test, i get the error:

java.lang.RuntimeException: Configuration must contain a valid 'gremlin.graph' setting

Thanks. M

arcanefoam commented 5 years ago

Thanks for spotting this. There is actually a line missing in the readme code! This is the line: conf.addProperty(Graph.GRAPH, ArangoDBGraph.class.getName()); after the configuration is built. The Graph.GRAPH constant is "gremlin.graph".

BTW, the class name you are using is for the Gremlin Console driver :).

I will add this line to the example.

a-marcel commented 5 years ago

Thanks, if i add your line:

import com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph;
conf.addProperty(Graph.GRAPH, ArangoDBGraph.class.getName());

the following error occurs:

java.lang.RuntimeException: GraphFactory could not instantiate this Graph implementation [class com.arangodb.tinkerpop.gremlin.structure.ArangoDBGraph]

It looks like, that the 2.0.0 version in the maven repo differ much from the current master.

M

arcanefoam commented 5 years ago

Interesting. I will look into this and see if I need to publish a new version with the changes. I will keep you posted.

arcanefoam commented 5 years ago

Tests are running fine in my machine. Can you post (or mail me) the complete stack trace?

a-marcel commented 5 years ago

Uhh, i read the full stack trace by myself and later on, i've seen that a 401 happens. So thanks for you help and that we figure out that a line was missing in the readme. It works now !

Thanks

arcanefoam commented 5 years ago

I think that line should be part of the configuration builder since it is always needed. I will add it and make a fix release (and then remove it from the readme which I just updated, lol)

arcanefoam commented 5 years ago

I will close this for now as the readme and wiki have been updated since.