package org.eclipse.rdf4j;

import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.repository.RepositoryResult;
import org.eclipse.rdf4j.repository.sail.SailRepository;
import org.eclipse.rdf4j.repository.sail.SailRepositoryConnection;
import org.eclipse.rdf4j.rio.RDFFormat;
import org.eclipse.rdf4j.sail.memory.MemoryStore;
import org.eclipse.rdf4j.validation.SHACLSail;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by heshanjayasinghe on 4/30/17.
 */
public class Main {

    public static final String SH = "http://www.w3.org/ns/shacl#";

    public static void main(String[] args) {


        SailRepository shaclSail = new SailRepository(new SHACLSail(new MemoryStore()));
        shaclSail.initialize();

        try (SailRepositoryConnection conn = shaclSail.getConnection()) {
            String filename = "shacl.ttl";
            try (InputStream input = SHACLSail.class.getResourceAsStream("/" + filename)) {
                // add the RDF data from the inputstream directly to our database
                conn.add(input, "", RDFFormat.TURTLE );
            } catch (IOException e) {
                e.printStackTrace();
            }

            // let's check that our data is actually in the database
            try (RepositoryResult<Statement> result = conn.getStatements(null, null, null)) {
                while (result.hasNext()) {
                    Statement st = result.next();
                    System.out.println("db contains: " + st);
                }
            }
        }
        finally {
            shaclSail.shutDown();
        }


    }
}

@@ -63,16 +63,158 @@
 tement;%0A
+import org.eclipse.rdf4j.model.vocabulary.OWL;%0Aimport org.eclipse.rdf4j.model.vocabulary.RDF;%0Aimport org.eclipse.rdf4j.model.vocabulary.RDFS;%0A
 import o
@@ -718,16 +718,17 @@
 acl#%22;%0A%0A
+%0A
     publ
@@ -790,24 +790,23 @@
 sitory s
-haclSail
+ailrepo
  = new S
@@ -867,86 +867,2129 @@
    s
-haclSail.initialize();%0A%0A        try (SailRepositoryConnection conn = shaclSail
+ailrepo.initialize();%0A        Main mainInstance = new Main();%0A        mainInstance.addStatement(sailrepo);%0A       // mainInstance.printStatements(sailrepo);%0A%0A    %7D%0A%0A    private void addStatement(SailRepository sailrepo)%7B%0A        try (SailRepositoryConnection conn = sailrepo.getConnection()) %7B%0A            String filename = %22shacl.ttl%22;%0A            try (InputStream input = SHACLSail.class.getResourceAsStream(%22/%22 + filename)) %7B%0A//                ValueFactory factory = SimpleValueFactory.getInstance();%0A//                IRI bob = factory.createIRI(%22http://example.org/bob%22);%0A//                IRI name = factory.createIRI(%22http://example.org/name%22);%0A//                Literal bobsName = factory.createLiteral(%22Bob%22);%0A//                Statement nameStatement = factory.createStatement(bob, name, bobsName);%0A//                new SHACLSailConnection((SHACLSail) sailrepo.getSail(), (NotifyingSailConnection) sailrepo.getSail().getConnection()).statementAdded(nameStatement);%0A              //  addInferredStatement(OWL.THING, RDFS.COMMENT, RDF.REST);%0A               // new SHACLSailConnection((SHACLSail) sailrepo.getSail(), (NotifyingSailConnection) sailrepo.getSail().getConnection()).statementAdded(nameStatement)%0A //               addStatement(sailrepo.getSail().getValueFactory().createStatement(OWL.THING, RDFS.COMMENT, RDF.REST));%0A                conn.begin();%0A                conn.getSailConnection().addStatement(OWL.THING, RDFS.COMMENT, RDF.REST);%0A                conn.commit();%0A            %7D catch (IOException e) %7B%0A                e.printStackTrace();%0A            %7D%0A%0A            // let's check that our data is actually in the database%0A            try (RepositoryResult%3CStatement%3E result = conn.getStatements(null, null, null)) %7B%0A                while (result.hasNext()) %7B%0A                    Statement st = result.next();%0A                    System.out.println(%22db contains: %22 + st);%0A                %7D%0A            %7D%0A        %7D%0A        finally %7B%0A            sailrepo.shutDown();%0A        %7D%0A%0A    %7D%0A%0A%0A    private void printStatements(SailRepository sailrepo)%7B%0A        try (SailRepositoryConnection conn = sailrepo
 .get
@@ -3762,16 +3762,15 @@
    s
-haclSail
+ailrepo
 .shu
@@ -3784,22 +3784,20 @@
 ;%0A        %7D%0A
-%0A%0A
     %7D%0A%7D%0A

add statement method