Search code examples
graphdbshacl

Can I inspect the shape graph


I followed the instructions on https://graphdb.ontotext.com/documentation/9.4/free/shacl-validation.html, and it worked as documented. However, once this is done, I found no way to inspect the Shape graph configured for my repository.

The special graph <http://rdf4j.org/schema/rdf4j#SHACLShapeGraph> is nowhere to be found; it does not appear in the 'Graphs overview` screen, it is not accessible via SPARQL queries.


Solution

  • Shape graphs currently cannot be queried with SPARQL inside GraphDB as it is not part of the data. One way to inspect the graph is using a RDF4J Client to connect to the GraphDB repository. You can find all the statements inside the shape graph with the following code snippet:

    HTTPRepository repository = new HTTPRepository("http://address:port/", "repositoryname");
    try (RepositoryConnection connection = repository.getConnection()) {
    Model statementsCollector = new LinkedHashModel(connection.getStatements(null, null, null, RDF4J.SHACL_SHAPE_GRAPH)
            .stream()
            .collect(Collectors.toList()));
    }

    For more information regarding accessing and updating Shacl shape graphs you can also take a look here https://rdf4j.org/documentation/programming/shacl/ .