owlim-discussion  

Re: [Owlim-discussion] Programmatically creating a BigOWLIM repository

Ivan Peikov
Tue, 27 Jul 2010 01:51:16 -0700

Hi Sam,

The example you refer to is still valid, but to SwiftOWLIM, not to BigOWLIM.
Here is a complete example of programmatic initialization and usage of 
BigOWLIM repository (BigOWLIM 3.3 + Sesame 2.3, etc. dependencies).


---[code]----------------------------------------------------------------------
import java.io.File;

import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.sail.SailRepository;

import com.ontotext.trree.OwlimSchemaRepository;


public class BigOWLIMTest {
        public static void main(String[] args) throws RepositoryException {
                // initialize OWLIM's configuration Sail
                OwlimSchemaRepository owlim = new OwlimSchemaRepository();
                owlim.setDataDir(new File("/tmp")); // parent folder 
                // configuration parameters (normally read from .ttl file)
                owlim.setParameter("storage-folder", "repository"); 
                owlim.setParameter("repository-type", "file-repository");
                owlim.setParameter("ruleset", "owl-horst");
                // other parameters configuration follows here...
                
                // initialize repository
                SailRepository repository = new SailRepository(owlim);
                repository.initialize();
                
                // initialize connection to repository
                RepositoryConnection conn = repository.getConnection();
                
                // repository operations through connection here...
                
                // close connection
                conn.close();
                // shutdown repository
                repository.shutDown();
        }
}
---[edoc]----------------------------------------------------------------------


Hope this helps!


Cheers,
Ivan

On Monday 26 July 2010 14:33:04 lists lists wrote:
> Hi,
> 
> what's the best (i.e. simplest) way to create a repository without using a
> config file? I did find an example on the mailing list [1] but its no
>  longer valid with BigOWLIM 3.3, due to API changes I guess.
> 
> Thanks,
> Sam
> 
> [1] http://www.mail-archive.com/owlim-discussion@ontotext.com/msg00232.html
> 
import java.io.File;

import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.sail.SailRepository;

import com.ontotext.trree.OwlimSchemaRepository;


public class BigOWLIMTest {
	public static void main(String[] args) throws RepositoryException {
		// initialize OWLIM's configuration Sail
		OwlimSchemaRepository owlim = new OwlimSchemaRepository();
		owlim.setDataDir(new File("/tmp")); // parent folder of repository
		// configuration parameters (normally read from .ttl file)
		owlim.setParameter("storage-folder", "repository"); 
		owlim.setParameter("repository-type", "file-repository");
		owlim.setParameter("ruleset", "owl-horst");
		// other parameters configuration follows here...
		
		// initialize repository
		SailRepository repository = new SailRepository(owlim);
		repository.initialize();
		
		// initialize connection to repository
		RepositoryConnection conn = repository.getConnection();
		
		// repository operations through connection here...
		
		// close connection
		conn.close();
		// shutdown repository
		repository.shutDown();
	}
}
_______________________________________________
OWLIM-discussion mailing list
OWLIM-discussion@ontotext.com
http://ontotext.com/mailman/listinfo/owlim-discussion