Search in sources :

Example 36 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project blueprints by tinkerpop.

the class PropertyGraphSailTest method testRDFDump.

@Test
public void testRDFDump() throws Exception {
    Repository repo = new SailRepository(sail);
    RepositoryConnection rc = repo.getConnection();
    try {
        RDFWriter w = Rio.createWriter(RDFFormat.TURTLE, System.out);
        rc.export(w);
    } finally {
        rc.close();
    }
}
Also used : RepositoryConnection(org.openrdf.repository.RepositoryConnection) SailRepository(org.openrdf.repository.sail.SailRepository) Repository(org.openrdf.repository.Repository) SailRepository(org.openrdf.repository.sail.SailRepository) RDFWriter(org.openrdf.rio.RDFWriter) Test(org.junit.Test)

Example 37 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project backstage by zepheira.

the class Database method setRepository.

public synchronized void setRepository(Repository repo) {
    // break encapsulation to simplify data upload integration
    _repository = repo;
    // all repos should be sail repos, but our Java master must be served
    try {
        SailRepository sr = (SailRepository) repo;
        _sail = sr.getSail();
    } catch (ClassCastException e) {
    // pass
    }
}
Also used : SailRepository(org.openrdf.repository.sail.SailRepository)

Example 38 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project backstage by zepheira.

the class BackstageModule method createRepository.

public Repository createRepository(HttpServletRequest request, String repoType, String slug) throws Exception {
    ExtendedProperties properties = getProperties();
    String dbDir = properties.getString("backstage.databaseDir", "databases");
    SailRepository repository = null;
    File thisDbDir = new File(new File(dbDir, repoType), slug);
    if (repoType.equals(REPOTYPE_MEM)) {
        DataLoadingUtilities.RepoSailTuple rs = DataLoadingUtilities.createMemoryRepository(thisDbDir);
        repository = (SailRepository) rs.repository;
        rs = null;
    } else if (repoType.equals(REPOTYPE_DISK)) {
        DataLoadingUtilities.RepoSailTuple rs = DataLoadingUtilities.createNativeRepository(thisDbDir);
        repository = (SailRepository) rs.repository;
        rs = null;
    } else {
        return null;
    }
    String lang = DataLoadingUtilities.contentTypeToLang(request.getContentType());
    if (lang == null) {
        throw new Exception("Unsupported content type");
    }
    DataLoadingUtilities.loadDataFromStream((InputStream) request.getInputStream(), request.getRequestURL().toString(), lang, repository.getSail());
    return repository;
}
Also used : SailRepository(org.openrdf.repository.sail.SailRepository) DataLoadingUtilities(edu.mit.simile.backstage.util.DataLoadingUtilities) File(java.io.File) ExtendedProperties(org.apache.commons.collections.ExtendedProperties) URISyntaxException(java.net.URISyntaxException) RepositoryException(org.openrdf.repository.RepositoryException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 39 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project backstage by zepheira.

the class DataLoadingUtilities method createNativeRepository.

public static RepoSailTuple createNativeRepository(File dir) {
    try {
        Sail sail = new NativeStore();
        sail.setDataDir(dir);
        ((NativeStore) sail).setTripleIndexes("spoc,posc,opsc");
        Repository r = new SailRepository(sail);
        r.initialize();
        return new RepoSailTuple(r, sail);
    } catch (Exception e) {
        _logger.error("Exception caught while creating Sesame native repository", e);
        return null;
    }
}
Also used : SailRepository(org.openrdf.repository.sail.SailRepository) Repository(org.openrdf.repository.Repository) SailRepository(org.openrdf.repository.sail.SailRepository) Sail(org.openrdf.sail.Sail) NativeStore(org.openrdf.sail.nativerdf.NativeStore) SailException(org.openrdf.sail.SailException) RepositoryException(org.openrdf.repository.RepositoryException) RDFHandlerException(org.openrdf.rio.RDFHandlerException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 40 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project backstage by zepheira.

the class DataLoadingUtilities method createMemoryRepository.

public static RepoSailTuple createMemoryRepository(File dir) {
    try {
        Repository r = null;
        Sail s = null;
        if (dir != null) {
            s = new MemoryStore(dir);
            r = new SailRepository(s);
        } else {
            s = new MemoryStore();
            r = new SailRepository(new MemoryStore());
        }
        r.initialize();
        return new RepoSailTuple(r, s);
    } catch (Exception e) {
        _logger.error("Exception caught while creating Sesame in-memory repository", e);
        return null;
    }
}
Also used : MemoryStore(org.openrdf.sail.memory.MemoryStore) SailRepository(org.openrdf.repository.sail.SailRepository) Repository(org.openrdf.repository.Repository) SailRepository(org.openrdf.repository.sail.SailRepository) Sail(org.openrdf.sail.Sail) SailException(org.openrdf.sail.SailException) RepositoryException(org.openrdf.repository.RepositoryException) RDFHandlerException(org.openrdf.rio.RDFHandlerException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

SailRepository (org.openrdf.repository.sail.SailRepository)64 Sail (org.openrdf.sail.Sail)45 SailRepositoryConnection (org.openrdf.repository.sail.SailRepositoryConnection)41 Test (org.junit.Test)27 BindingSet (org.openrdf.query.BindingSet)14 RepositoryException (org.openrdf.repository.RepositoryException)14 TupleQueryResult (org.openrdf.query.TupleQueryResult)13 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)11 TupleQuery (org.openrdf.query.TupleQuery)10 Configuration (org.apache.hadoop.conf.Configuration)9 SailException (org.openrdf.sail.SailException)9 HashSet (java.util.HashSet)8 ArrayList (java.util.ArrayList)7 AccumuloException (org.apache.accumulo.core.client.AccumuloException)7 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)7 RyaClientException (org.apache.rya.api.client.RyaClientException)7 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)7 Repository (org.openrdf.repository.Repository)7 IOException (java.io.IOException)6 RyaURI (org.apache.rya.api.domain.RyaURI)6