I am writing to ask for help with Owlim treatment of Sesame contexts.  We are 
using Owlim version 4.3 and Sesame version 2.6.5.  I noticed that when I add a 
statement to two contexts and then ask the repository for the known contexts, 
Owlim only shows one of the contexts.  The same test works  as expected on a 
local, in-memory repository.  Please see the attached Java test program, which 
exhibits different behavior when run on an in-memory repository versus a remote 
Owlim repository.  This is a pure storage/retrieval question; to the best of my 
knowledge I am not using any reasoning at all.  Thanks in advance for 
suggestions.


-=-=-=-=-=-=-=-=-



import org.openrdf.model.Resource;
import org.openrdf.model.Statement;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.openrdf.model.vocabulary.RDF;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryResult;
import org.openrdf.repository.http.HTTPRepository;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.sail.memory.MemoryStore;

/**
 * Adds a single entity with two contexts to test context implementation. Uses a
 * memory repository if the program is invoked with no arguments. If a single
 * argument is supplied, treats it as the URI of a remote repository and runs
 * the test using that repository.
 * 
 * Depends on artifacts from the OpenRDF project as specified in pom.xml.
 * 
 * @author clott
 */
public class TestOneEntityTwoContexts {

        public static void main(String[] args) {

                try {
                        // Get started
                        Repository repo = null;
                        if (args.length != 1) {
                                System.out.println("Creating an in-memory Sail 
repository");
                                repo = new SailRepository(new MemoryStore());
                                repo.initialize();
                        } else {
                                System.out.println("Using remote repository at 
" + args[0]);
                                repo = new HTTPRepository(args[0]);
                        }

                        // Open a connection.
                        RepositoryConnection con = repo.getConnection();

                        // Create some resources and literals to use in 
statements
                        ValueFactory f = repo.getValueFactory();
                        String namespace = "http://example.org/ontology#";;
                        URI personClassUri = f.createURI(namespace + "Person");

                        // Use these two contexts
                        URI context1 = 
f.createURI("http://example.org/context1";);
                        URI context2 = 
f.createURI("http://example.org/context2";);
                        URI[] contexts = new URI[] { context1, context2 };

                        // Add entity
                        System.out.println("Adding entity of type Person");
                        Resource entity = f.createBNode();
                        con.add(entity, RDF.TYPE, personClassUri, contexts);

                        // Query and show contexts
                        System.out.println("Repository contexts:");
                        RepositoryResult<Resource> repoContexts = 
con.getContextIDs();
                        int conCount = 0;
                        while (repoContexts.hasNext()) {
                                ++conCount;
                                Resource r = repoContexts.next();
                                System.out.println(r);
                        }

                        // Show results: expect two statements
                        System.out.println("Showing entities of type Person");
                        RepositoryResult<Statement> stmts = 
con.getStatements(null,
                                        RDF.TYPE, personClassUri, false);
                        int stmtCount = 0;
                        while (stmts.hasNext()) {
                                ++stmtCount;
                                System.out.println(stmts.next());
                        }
                        stmts.close();

                        // Remove the newly added statements from all context
                        con.remove(entity, RDF.TYPE, personClassUri);

                        // Shut down
                        System.out.println("Closing repository connection");
                        con.close();

                        // Check result
                        if (conCount == 2 && stmtCount == 2)
                                System.out
                                                .println("Pass, found expected 
context and statement count of 2 each");
                        else
                                System.out.println("Fail, expected 2 contexts 
but found "
                                                + conCount + "; expected 2 
statements but found "
                                                + stmtCount);

                } catch (Exception ex) {
                        ex.printStackTrace();
                }
        }
}
_______________________________________________
Owlim-discussion mailing list
[email protected]
http://ontomail.semdata.org/cgi-bin/mailman/listinfo/owlim-discussion

Reply via email to