public ContextAwareConnection(Repository repository) throws RepositoryException { this(repository, repository.getConnection()); }
/** * Initializes this repository. A repository needs to be initialized before it can be used. * * @throws RepositoryException * If the initialization failed. * @since 2.5 */ default void init() throws RepositoryException { initialize(); }
void refreshRepository(String repositoryID, Repository repository) { logger.debug("Refreshing repository {}...", repositoryID); try { if (repository.isInitialized()) { repository.shutDown(); } } catch (RepositoryException e) { logger.error("Failed to shut down repository", e); } cleanupIfRemoved(repositoryID); }
/** * Creates, initializes and clears a repository. * * @return an initialized empty repository. * @throws Exception */ protected Repository createRepository() throws Exception { Repository repository = newRepository(); repository.initialize(); RepositoryConnection con = repository.getConnection(); con.clear(); con.clearNamespaces(); con.close(); return repository; }
/** * Construct a RDF4jStore around a <a href="http://docs.rdf4j.org/javadoc/latest/org/eclipse/rdf4j/repository/Repository.html">RDF4J Repository</a> * @param repo * @throws AtomSetException */ public RDF4jStore(Repository repo) throws AtomSetException { try { repo.initialize(); this.connection = repo.getConnection(); } catch (RepositoryException e) { throw new AtomSetException("Error while creating SailStore", e); } this.utils = new RDF4jUtils(new Prefix("rdf4j", "file://rdf4j/"),repo.getValueFactory()); }
@Test public void testAddStatement() throws Exception { testCon.add(bob, name, nameBob); assertTrue("Repository should contain newly added statement", testCon.hasStatement(bob, name, nameBob, false)); Statement statement = vf.createStatement(alice, name, nameAlice); testCon.add(statement); assertTrue("Repository should contain newly added statement", testCon.hasStatement(statement, false)); assertTrue("Repository should contain newly added statement", testCon.hasStatement(alice, name, nameAlice, false)); Repository tempRep = new SailRepository(new MemoryStore()); tempRep.initialize(); RepositoryConnection con = tempRep.getConnection(); con.add(testCon.getStatements(null, null, null, false)); assertTrue("Temp Repository should contain newly added statement", con.hasStatement(bob, name, nameBob, false)); con.close(); tempRep.shutDown(); }
@Override protected void tearDown() throws Exception { if (dataRep != null) { dataRep.shutDown(); dataRep = null; } }
public ValueFactory getValueFactory() { return repository.getValueFactory(); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { logger.debug("setting up test"); rep = createRepository(); con = rep.getConnection(); f = rep.getValueFactory(); loadDataset("/testdata-update/dataset-update.trig"); bob = f.createIRI(EX_NS, "bob"); alice = f.createIRI(EX_NS, "alice"); graph1 = f.createIRI(EX_NS, "graph1"); graph2 = f.createIRI(EX_NS, "graph2"); logger.debug("setup complete."); }
@Override protected Repository createRepository(String id) throws RepositoryConfigException, RepositoryException { Repository repository = null; RepositoryConfig repConfig = getRepositoryConfig(id); if (repConfig != null) { repConfig.validate(); repository = createRepositoryStack(repConfig.getRepositoryImplConfig()); repository.setDataDir(getRepositoryDir(id)); repository.initialize(); } return repository; }
@Override public boolean isInitialized() { return rep.isInitialized(); }
@Override public boolean isWritable() throws RepositoryException { return persistence.getRepository().isWritable(); }
/** * Tests the default dataset in a memory store. */ @Test @Category(TestSuites.NotApplicableForAgraph.class) public void testMemoryStoreDefaultDataset() throws Exception { Repository repo = new SailRepository(new MemoryStore()); repo.initialize(); RepositoryConnection conn = repo.getConnection(); testSesameDefaultDataset(conn); }
private IRI createURIOrNull(Repository repository, String graphURI) { if ("null".equals(graphURI)) return null; return repository.getValueFactory().createIRI(graphURI); }
@Override public boolean isInitialized() { return rep.isInitialized(); }
@Override public boolean isWritable() throws RepositoryException { return getProxiedRepository().isWritable(); }
protected RepositoryConnection getConnection() throws RepositoryException { // use a cache connection if possible // (TODO add mechanism to unset/close connection) if (conn == null) { conn = rep.getConnection(); } return conn; }
/** * Tests DEFAULT using a Sesame MemoryStore. */ @Test @Category(TestSuites.NotApplicableForAgraph.class) public void testMemoryStoreDEFAULT() throws Exception { Repository repo = new SailRepository(new MemoryStore()); repo.initialize(); RepositoryConnection conn = repo.getConnection(); testDEFAULT(conn); }
public void initialize() throws RepositoryException { getDelegate().initialize(); }