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; }
@Override public RepositoryConnection getConnection() throws RepositoryException { return getProxiedRepository().getConnection(); }
@Required public void setRepositoryConnection(Repository repo){ try { this.conn=repo.getConnection(); } catch (RepositoryException e) { log.error(e.toString()); } }
@Override public Object execute(Object repository, Map<String, Object> operationParam) { String relationName = (String) operationParam.get("relationName"); Repository repo = (Repository) repository; try { repo.getConnection().remove((Resource)null, repo.getConnection().getValueFactory().createURI(relationName), (Resource)null,(Resource)null); } catch (Exception e) { return e; } return null; }
public static void exportRepoToN3(Repository rep, String filePath) throws RepositoryException, FileNotFoundException, RDFHandlerException{ File repoFile = new File(filePath); FileOutputStream fosRepo = new FileOutputStream(repoFile); RDFWriter repoWriter = Rio.createWriter(RDFFormat.N3, fosRepo); rep.getConnection().export(repoWriter); }
public static void exportRepoToN3(Repository rep, String filePath) throws RepositoryException, FileNotFoundException, RDFHandlerException{ File repoFile = new File(filePath); FileOutputStream fosRepo = new FileOutputStream(repoFile); RDFWriter repoWriter = Rio.createWriter(RDFFormat.N3, fosRepo); rep.getConnection().export(repoWriter); }
RepositoryConnection getConnection() { if(!repository.isInitialized()) { throw new IllegalStateException("Template support has been disposed"); } try { return repository.getConnection(); } catch(RepositoryException e) { throw new QueryTemplateSupportFailure("Could not connect to the internal repository", e); } }
/** * @throws java.lang.Exception */ //@Before public void setUp() throws Exception { rep = createRepository(); con = rep.getConnection(); con.setAutoCommit(false); // f = rep.getValueFactory(); }
@Override public RDFConnection openConnection() { try { return new SesameConnection(this, repository.getConnection(), inference, serializeQueries); } catch (org.openrdf.repository.RepositoryException e) { throw new RepositoryException(e); } }
Model model = ...; // your model // create and initialize a temporary in-memory store Repository rep = new SailRepository(new MemoryStore()); rep.initialize(); try (RepositoryConnection conn = rep.getConnection()) { // load the model into the repository conn.add(model); // execute the query String query = "ASK WHERE { :s (:p1|:p2|:p3)+ :o . }"; boolean pathExists = conn.prepareBooleanQuery(query).evaluate(); }
public static SailRepository exportRepoToNativeStore(Repository rep, String dirPath) throws RepositoryException, FileNotFoundException, RDFHandlerException{ File f = new File(dirPath); if(f.exists()) f.delete(); f.mkdirs(); NativeStore nativeStore = new NativeStore(f); SailRepository nativeRepo = new SailRepository(nativeStore); nativeRepo.initialize(); RepositoryResult<Statement> rr = rep.getConnection().getStatements((Resource)null, null, null, false, (Resource)null); nativeRepo.getConnection().add(rr.asList(), (Resource)null); return nativeRepo; }
public static SailRepository exportRepoToNativeStore(Repository rep, String dirPath) throws RepositoryException, FileNotFoundException, RDFHandlerException{ File f = new File(dirPath); if(f.exists()) f.delete(); f.mkdirs(); NativeStore nativeStore = new NativeStore(f); SailRepository nativeRepo = new SailRepository(nativeStore); nativeRepo.initialize(); RepositoryResult<Statement> rr = rep.getConnection().getStatements((Resource)null, null, null, false, (Resource)null); nativeRepo.getConnection().add(rr.asList(), (Resource)null); return nativeRepo; }
@Override public RDFConnection openConnection() { try { return new SesameConnection(this, repository.getConnection(), getInferenceOptions()); } catch (StoreException e) { throw new RepositoryException(e); } }
@Override public RDFConnection openConnection() { try { return new SesameConnection(this, repository.getConnection(), getInferenceOptions()); } catch (StoreException e) { throw new RepositoryException(e); } }
private void initUnFlushedStatements() throws RepositoryException { Repository addRepo = new SailRepository(new MemoryStore()); Repository removeRepo = new SailRepository(new MemoryStore()); addRepo.initialize(); removeRepo.initialize(); added = addRepo.getConnection(); removed = removeRepo.getConnection(); }
private void initializeTripleStore() throws RepositoryException { /** Initialize an in-memory sesame triple store **/ myRepository = new SailRepository(new MemoryStore()); myRepository.initialize(); con = myRepository.getConnection(); f = myRepository.getValueFactory(); }
public void setUp() throws Exception { repo = newRepository(); repo.initialize(); con = repo.getConnection(); }
protected Repository createRepository() throws Exception { Repository repository = newRepository(); repository.initialize(); RepositoryConnection con = repository.getConnection(); con.clear(); con.clearNamespaces(); con.close(); return repository; }
public SailStore() throws AtomSetException { Repository repo = new SailRepository(new MemoryStore()); try { repo.initialize(); this.connection = repo.getConnection(); } catch (RepositoryException e) { throw new AtomSetException("Error while creating SailStore", e); } this.valueFactory = repo.getValueFactory(); }
@Test public void testMemoryRepository() throws RepositoryException { RepositoryConnection conn = repository.getConnection(); Assert.assertThat( "repository is open", conn.isOpen(), CoreMatchers.equalTo( true ) ); conn.close(); } }