Need to guide about Virtual Graph via Java API

Hello.

I am trying to create virtual graph via java api.
But I don’t know how to do.
I also check this link(https://www.stardog.com/docs/java/snarl/com/complexible/stardog/virtual/api/admin/virtualgraphadminconnection).

try (final AdminConnection aConn = AdminConnectionConfiguration.toServer(url)
                .credentials(username, password)
                .connect()) {
            VirtualGraphAdminConnection vir = aConn.as(VirtualGraphAdminConnection.class);
            //How?
            //I want to change this command #stardog-admin virtual add --format r2rml test.properties test.ttl
            //vir.addGraph(....);
             aConn.close();
}

I also checked stardog-example… But I can’t find code or something about virtual graph api.
Please help me. Thanks.

You are on the right track. The arguments to addGraph() are as follows:

  • name - the name of the graph which would be test in your example command
  • properties - a Java Properties object representing the connection and configuration of the virtual graph. You can use Properties.load() to load the contents of your file.
  • mappings - a set of R2RML mappings in the form of a set of RDF triples. Perhaps you can use the Rio.parse() function here to read the contents of test.ttl. This will return a Model which will be accepted as an argument.

Hope this helps.
Jess

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.