Refine search
protected void assertOpenConn() throws SailException { if(!openConn) { throw new SailException("Closed"); } }
public boolean hasNext() { try { if (this.statements.hasNext()) return true; else { this.statements.close(); return false; } } catch (SailException e) { throw new RuntimeException(e.getMessage(), e); } }
protected SailConnection initialValue() { SailConnection sc = null; try { sc = createConnection(); } catch (SailException e) { e.printStackTrace(System.err); } return sc; } };
/** * Get all the prefix-to-namespace mappings of the graph. * * @return a map of the prefix-to-namespace mappings */ public Map<String, String> getNamespaces() { Map<String, String> namespaces = new HashMap<String, String>(); try { final CloseableIteration<? extends Namespace, SailException> results = this.sailConnection.get().getNamespaces(); while (results.hasNext()) { Namespace namespace = results.next(); namespaces.put(namespace.getPrefix(), namespace.getName()); } results.close(); } catch (SailException e) { throw new RuntimeException(e.getMessage(), e); } return namespaces; }
@Override protected void removeStatementsInternal(Resource subj, URI pred, Value obj, Resource... contexts) throws SailException { try { CloseableIteration<? extends Statement, SailException> triples = getStatementsInternal(subj,pred,obj,true,contexts); while(triples.hasNext()) { KiWiTriple triple = (KiWiTriple)triples.next(); if(triple.getId() >= 0) { databaseConnection.deleteTriple(triple); triplesRemoved = true; notifyStatementRemoved(triple); } valueFactory.removeStatement(triple); } triples.close(); } catch(SQLException ex) { throw new SailException("database error while deleting statement",ex); } }
@Override public void close() throws SailException { try { iter.close(); } catch (RippleException e) { throw new SailException(e); } }
@Override public boolean hasNext() throws SailException { try { return evaluate.hasNext(); } catch (final QueryEvaluationException e) { throw new SailException(e); } }
public Edge next() { try { return new SailEdge(this.statements.next(), graph); } catch (SailException e) { throw new RuntimeException(e.getMessage()); } catch (NoSuchElementException e) { try { this.statements.close(); } catch (SailException e2) { throw new RuntimeException(e2.getMessage(), e2); } throw e; } } }
public Resource next() throws SailException { try { return innerIter.next(); } catch (RepositoryException e) { throw new SailException(e); } }
public void remove() throws SailException { try { innerIter.remove(); } catch (RepositoryException e) { throw new SailException(e); } }
/** * Remove a prefix-to-namespace mapping from the Sail connection of this graph. * * @param prefix the prefix of the prefix-to-namespace mapping to remove */ public void removeNamespace(final String prefix) { try { this.sailConnection.get().removeNamespace(prefix); } catch (SailException e) { throw new RuntimeException(e.getMessage(), e); } }
@Override public ConcurrencyException getCause() { return (ConcurrencyException) super.getCause(); }
/** * Given a URI, compress it to its prefixed URI. * * @param uri the expanded URI (e.g. http://tinkerpop.com#knows) * @return the prefixed URI (e.g. tg:knows) */ public String prefixNamespace(String uri) { try { CloseableIteration<? extends Namespace, SailException> namespaces = this.sailConnection.get().getNamespaces(); while (namespaces.hasNext()) { Namespace namespace = namespaces.next(); if (uri.contains(namespace.getName())) uri = uri.replace(namespace.getName(), namespace.getPrefix() + SailTokens.NAMESPACE_SEPARATOR); } namespaces.close(); } catch (SailException e) { throw new RuntimeException(e.getMessage(), e); } return uri; }
@Override protected void removeStatementsInternal(Resource subj, URI pred, Value obj, Resource... contexts) throws SailException { try { CloseableIteration<? extends Statement, SailException> triples = getStatementsInternal(subj,pred,obj,true,contexts); while(triples.hasNext()) { KiWiTriple triple = (KiWiTriple)triples.next(); if(triple.getId() >= 0) { databaseConnection.deleteTriple(triple); triplesRemoved = true; notifyStatementRemoved(triple); } valueFactory.removeStatement(triple); } triples.close(); } catch(SQLException ex) { throw new SailException("database error while deleting statement",ex); } }
public void close() throws SailException { try { innerIter.close(); } catch (RepositoryException e) { throw new SailException(e); } }
public boolean hasNext() throws SailException { try { return innerIter.hasNext(); } catch (RepositoryException e) { throw new SailException(e); } }
public Statement next() throws SailException { try { return innerIter.next(); } catch (RepositoryException e) { throw new SailException(e); } }
public void remove() throws SailException { try { innerIter.remove(); } catch (RepositoryException e) { throw new SailException(e); } } }
/** * Add a prefix-to-namespace mapping to the Sail connection of this graph. * * @param prefix the prefix (e.g. tg) * @param namespace the namespace (e.g. http://tinkerpop.com#) */ public void addNamespace(final String prefix, final String namespace) { try { this.sailConnection.get().setNamespace(prefix, namespace); } catch (SailException e) { throw new RuntimeException(e.getMessage(), e); } }
private void updateLiteral(final Literal oldLiteral, final Literal newLiteral) { try { final Set<Statement> statements = new HashSet<Statement>(); final CloseableIteration<? extends Statement, SailException> results = this.graph.getSailConnection().get().getStatements(null, null, oldLiteral, false); while (results.hasNext()) { statements.add(results.next()); } results.close(); this.graph.getSailConnection().get().removeStatements(null, null, oldLiteral); for (Statement statement : statements) { SailHelper.addStatement(statement.getSubject(), statement.getPredicate(), newLiteral, statement.getContext(), this.graph.getSailConnection().get()); } } catch (SailException e) { throw new RuntimeException(e.getMessage(), e); } }