Search code examples
javacommand-line-interfacesparqltriplesstardog

Programatically add custom rule in Stardog


I'm able to add custom rules to a named graph in Stardog with the following CLI command:

stardog data add db_name -g "http://graph_name"/path/to/rules/test.ttl

Is there a possibility to do this via the Java API, for instance with the AdminConnection class?


Solution

  • Adding data to the database would be done using the Connection class. You can specify a named graph for the file you are adding as follows:

    conn.begin();
    conn.add().io().context(graphURI).file(new File("/path/to/rules/test.ttl"));
    conn.commit();
    

    See the connection and adder classes for more details.