Repository

mwarnock edited this page Sep 12, 2010 · 5 revisions

The repository class is a thin layer between the adapter and the triple store to provide a common interface for ActiveSesame’s other classes. The repository class takes two parameters when instantiated. (1) An adapter module which is mixed into the repository instance and (2) an options hash to be merged with the default options of your adapter. The default options instantiate a repository using the SesameProtocol module included in ActiveSesame.

Currently, the only triple store that has been tested with is AllegroGraph. I’ll be expanding testing to Sesame soon and will make any adjustments or forks to the SesameProtocol adapter as necessary. If there is interest in a particular triple store, or if you’ve already written an adapter please send me a message on github and I’ll be happy to work with you/include it in this project.

Using The Repository

Instantiating a repository and connecting

Presuming you have a triple store up and running (for instructions see Getting Started), you’ll be able to instantiate a new repository and test your connection.

#Instantiate the repository
repo = ActiveSesame::Repository.new(ActiveSesame::SesameProtocol, {
                                   :repository_uri => "http://localhost:8111/sesame/repositories",
                                   :triple_store_id => "test",
                                   :location => "http://localhost:8111/sesame/repositories/test",
                                   :query_language => "SPARQL",
                                   :base_uri => "http://www.fakeontology.org/ontology.owl"
                                 })
repo.size # -> should return the number of triples in your triple store
#  If you can get the size your repository instance is connecting properly
repo.find_by_sparql("SELECT ?subject ?predicate ?object WHERE { ?subject ?predicate ?object }") #Query for every triple in the store
#  If you get the sparql (xml) return set you've set everything up properly

Adding Triples

Adding triples can be done in a batch or individually.

The group save method uses an xml structure specified in the sesame protocol to save and add triples tot he store.

Querying

Creating an Adapter