Search in sources :

Example 1 with MemoryStore

use of org.openrdf.sail.memory.MemoryStore in project frames by tinkerpop.

the class SailFramesTest method setUp.

@Before
public void setUp() throws Exception {
    sail = new MemoryStore();
    sailGraph = new SailGraph(sail);
}
Also used : MemoryStore(org.openrdf.sail.memory.MemoryStore) SailGraph(com.tinkerpop.blueprints.impls.sail.SailGraph) Before(org.junit.Before)

Example 2 with MemoryStore

use of org.openrdf.sail.memory.MemoryStore 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)

Example 3 with MemoryStore

use of org.openrdf.sail.memory.MemoryStore in project stanbol by apache.

the class RdfIndexingSource method loadRepositoryConfig.

/**
     * @param repoConfigFile
     * @return
     */
private RepositoryConfig loadRepositoryConfig(File repoConfigFile) {
    Repository configRepo = new SailRepository(new MemoryStore());
    RepositoryConnection con = null;
    try {
        configRepo.initialize();
        con = configRepo.getConnection();
        //We need to load the configuration into a context
        org.openrdf.model.URI configContext = con.getValueFactory().createURI("urn:stanbol.entityhub:indexing.source.sesame:config.context");
        RDFFormat format = Rio.getParserFormatForFileName(repoConfigFile.getName());
        try {
            con.add(new InputStreamReader(new FileInputStream(repoConfigFile), Charset.forName("UTF-8")), baseUri, format, configContext);
        } catch (RDFParseException e) {
            throw new IllegalArgumentException("Unable to parsed '" + repoConfigFile + "' using RDF format '" + format + "'!", e);
        } catch (IOException e) {
            throw new IllegalArgumentException("Unable to access '" + repoConfigFile + "'!", e);
        }
        con.commit();
    } catch (RepositoryException e) {
        throw new IllegalStateException("Unable to load '" + repoConfigFile + "' to inmemory Sail!", e);
    } finally {
        if (con != null) {
            try {
                con.close();
            } catch (RepositoryException e) {
            /* ignore */
            }
        }
    }
    Set<String> repoNames;
    RepositoryConfig repoConfig;
    try {
        repoNames = RepositoryConfigUtil.getRepositoryIDs(configRepo);
        if (repoNames.size() == 1) {
            repoConfig = RepositoryConfigUtil.getRepositoryConfig(configRepo, repoNames.iterator().next());
            repoConfig.validate();
        } else if (repoNames.size() > 1) {
            throw new IllegalArgumentException("Repository configuration file '" + repoConfigFile + "' MUST only contain a single repository configuration!");
        } else {
            throw new IllegalArgumentException("Repository configuration file '" + repoConfigFile + "' DOES NOT contain a repository configuration!");
        }
    } catch (RepositoryException e) {
        throw new IllegalStateException("Unable to read RepositoryConfiguration form the " + "in-memory Sail!", e);
    } catch (RepositoryConfigException e) {
        throw new IllegalArgumentException("Repository Configuration in '" + repoConfigFile + "is not valid!", e);
    } finally {
        try {
            configRepo.shutDown();
        } catch (RepositoryException e) {
        /* ignore */
        }
    }
    if (repoConfig.getRepositoryImplConfig() == null) {
        throw new IllegalArgumentException("Missing RepositoryImpl config for " + "config " + repoConfig.getID() + " of file " + repoConfigFile + "!");
    }
    return repoConfig;
}
Also used : RepositoryConnection(org.openrdf.repository.RepositoryConnection) RepositoryConfig(org.openrdf.repository.config.RepositoryConfig) InputStreamReader(java.io.InputStreamReader) SailRepository(org.openrdf.repository.sail.SailRepository) RepositoryException(org.openrdf.repository.RepositoryException) IOException(java.io.IOException) RepositoryConfigException(org.openrdf.repository.config.RepositoryConfigException) FileInputStream(java.io.FileInputStream) MemoryStore(org.openrdf.sail.memory.MemoryStore) Repository(org.openrdf.repository.Repository) SailRepository(org.openrdf.repository.sail.SailRepository) URI(org.openrdf.model.URI) RDFFormat(org.openrdf.rio.RDFFormat) RDFParseException(org.openrdf.rio.RDFParseException)

Example 4 with MemoryStore

use of org.openrdf.sail.memory.MemoryStore in project stanbol by apache.

the class SesameYardTest method initYard.

@BeforeClass
public static final void initYard() throws RepositoryException {
    SesameYardConfig config = new SesameYardConfig("testYardId");
    config.setName("Sesame Yard Test");
    config.setDescription("The Sesame Yard instance used to execute the Unit Tests defined for the Yard Interface");
    repo = new SailRepository(new MemoryStore());
    repo.initialize();
    yard = new SesameYard(repo, config);
}
Also used : MemoryStore(org.openrdf.sail.memory.MemoryStore) SesameYardConfig(org.apache.stanbol.entityhub.yard.sesame.SesameYardConfig) SailRepository(org.openrdf.repository.sail.SailRepository) SesameYard(org.apache.stanbol.entityhub.yard.sesame.SesameYard) BeforeClass(org.junit.BeforeClass)

Example 5 with MemoryStore

use of org.openrdf.sail.memory.MemoryStore in project gocd by gocd.

the class InMemoryRepositoryFactory method emptyRepository.

public static Repository emptyRepository() {
    try {
        Repository repo = new SailRepository(new MemoryStore());
        repo.initialize();
        return repo;
    } catch (RepositoryException ex) {
        throw new ShineRuntimeException(ex);
    }
}
Also used : MemoryStore(org.openrdf.sail.memory.MemoryStore) Repository(org.openrdf.repository.Repository) SailRepository(org.openrdf.repository.sail.SailRepository) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) SailRepository(org.openrdf.repository.sail.SailRepository) RepositoryException(org.openrdf.repository.RepositoryException)

Aggregations

MemoryStore (org.openrdf.sail.memory.MemoryStore)5 SailRepository (org.openrdf.repository.sail.SailRepository)4 Repository (org.openrdf.repository.Repository)3 RepositoryException (org.openrdf.repository.RepositoryException)3 IOException (java.io.IOException)2 ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)1 SailGraph (com.tinkerpop.blueprints.impls.sail.SailGraph)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 SesameYard (org.apache.stanbol.entityhub.yard.sesame.SesameYard)1 SesameYardConfig (org.apache.stanbol.entityhub.yard.sesame.SesameYardConfig)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 URI (org.openrdf.model.URI)1 RepositoryConnection (org.openrdf.repository.RepositoryConnection)1 RepositoryConfig (org.openrdf.repository.config.RepositoryConfig)1 RepositoryConfigException (org.openrdf.repository.config.RepositoryConfigException)1 RDFFormat (org.openrdf.rio.RDFFormat)1 RDFHandlerException (org.openrdf.rio.RDFHandlerException)1