Search in sources :

Example 16 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class Shacl03_FusekiValidationService method main.

public static void main(String... a) throws IOException {
    FusekiLogging.setLogging();
    // If not standard registration...
    Operation op = Operation.alloc(FusekiVocab.NS + "shacl", "shacl", "SHACL valdiation");
    // FusekiExt.registerOperation(op, new SHACL_Validation());
    // FusekiExt.addDefaultEndpoint(op, "shacl");
    // Operation op = Operation.Shacl;
    FusekiServer server = FusekiServer.create().port(3030).add("/ds", DatasetGraphFactory.createTxnMem(), true).addEndpoint("/ds", "shacl", op).build();
    try {
        server.start();
        try (RDFConnection conn = RDFConnection.connect("http://localhost:3030/ds")) {
            conn.put("fu-data.ttl");
        }
        ValidationReport report = validateReport("http://localhost:3030/ds/shacl?graph=default", "fu-shapes.ttl");
        System.out.println();
        ShLib.printReport(report);
        System.out.println();
        System.out.println("- - - - - - - - - - - - - - - - - -");
        System.out.println();
        RDFDataMgr.write(System.out, report.getGraph(), Lang.TTL);
        System.out.println();
    } finally {
        server.stop();
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) ValidationReport(org.apache.jena.shacl.ValidationReport) Operation(org.apache.jena.fuseki.server.Operation) FusekiServer(org.apache.jena.fuseki.main.FusekiServer)

Example 17 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class TestFusekiShaclValidation method shacl_empty_shapes.

@Test
public void shacl_empty_shapes() {
    try (RDFConnection conn = RDFConnection.connect(serverURL + "/ds")) {
        conn.put(DIR + "data1.ttl");
        ValidationReport report = validateReport(serverURL + "/ds/shacl?graph=default", DIR + "shapes-empty.ttl");
        assertNotNull(report);
        assertEquals(0, report.getEntries().size());
        conn.update("CLEAR ALL");
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) ValidationReport(org.apache.jena.shacl.ValidationReport) Test(org.junit.Test)

Example 18 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class TestFusekiShaclValidation method shacl_named_graph.

@Test
public void shacl_named_graph() {
    try (RDFConnection conn = RDFConnection.connect(serverURL + "/ds")) {
        conn.put("urn:abc:graph", DIR + "data1.ttl");
        ValidationReport report = validateReport(serverURL + "/ds/shacl?graph=urn:abc:graph", DIR + "shapes1.ttl");
        assertNotNull(report);
        assertEquals(3, report.getEntries().size());
        conn.update("CLEAR ALL");
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) ValidationReport(org.apache.jena.shacl.ValidationReport) Test(org.junit.Test)

Example 19 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class TestFusekiShaclValidation method shacl_union_1.

@Test
public void shacl_union_1() {
    try (RDFConnection conn = RDFConnection.connect(serverURL + "/ds")) {
        conn.put(DIR + "data1.ttl");
        ValidationReport report = validateReport(serverURL + "/ds/shacl?graph=union", DIR + "shapes1.ttl");
        assertNotNull(report);
        // Union does not include the storage default graph
        assertEquals(0, report.getEntries().size());
        conn.update("CLEAR ALL");
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) ValidationReport(org.apache.jena.shacl.ValidationReport) Test(org.junit.Test)

Example 20 with ValidationReport

use of org.apache.jena.shacl.ValidationReport in project jena by apache.

the class TestFusekiShaclValidation method shacl_union_2.

@Test
public void shacl_union_2() {
    try (RDFConnection conn = RDFConnection.connect(serverURL + "/ds")) {
        conn.put("urn:abc:graph", DIR + "data1.ttl");
        ValidationReport report = validateReport(serverURL + "/ds/shacl?graph=union", DIR + "shapes1.ttl");
        assertNotNull(report);
        assertEquals(3, report.getEntries().size());
        conn.update("CLEAR ALL");
    }
}
Also used : RDFConnection(org.apache.jena.rdfconnection.RDFConnection) ValidationReport(org.apache.jena.shacl.ValidationReport) Test(org.junit.Test)

Aggregations

ValidationReport (org.apache.jena.shacl.ValidationReport)24 RDFConnection (org.apache.jena.rdfconnection.RDFConnection)9 Test (org.junit.Test)9 Graph (org.apache.jena.graph.Graph)7 Union (org.apache.jena.graph.compose.Union)5 Model (org.apache.jena.rdf.model.Model)3 Shapes (org.apache.jena.shacl.Shapes)3 IOException (java.io.IOException)2 Node (org.apache.jena.graph.Node)2 Resource (org.apache.jena.rdf.model.Resource)2 ValidationContext (org.apache.jena.shacl.engine.ValidationContext)2 MediaType (org.apache.jena.atlas.web.MediaType)1 FusekiServer (org.apache.jena.fuseki.main.FusekiServer)1 Operation (org.apache.jena.fuseki.server.Operation)1 Lang (org.apache.jena.riot.Lang)1 Shape (org.apache.jena.shacl.parser.Shape)1 ResettableErrorHandler (won.shacl2java.validation.ResettableErrorHandler)1