org.eclipse.rdf4j.common.iteration.ExceptionConvertingIteration Java Examples
The following examples show how to use
org.eclipse.rdf4j.common.iteration.ExceptionConvertingIteration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SailTripleSource.java From CostFed with GNU Affero General Public License v3.0 | 6 votes |
@Override public CloseableIteration<Statement, QueryEvaluationException> getStatements(RepositoryConnection conn, Resource subj, IRI pred, Value obj, Resource... contexts) throws RepositoryException, MalformedQueryException, QueryEvaluationException { // TODO add handling for contexts RepositoryResult<Statement> repoResult = conn.getStatements(subj, pred, obj, true); // XXX implementation remark and TODO taken from Sesame // The same variable might have been used multiple times in this // StatementPattern, verify value equality in those cases. return new ExceptionConvertingIteration<Statement, QueryEvaluationException>(repoResult) { @Override protected QueryEvaluationException convert(Exception arg0) { return new QueryEvaluationException(arg0); } }; }
Example #2
Source File: SparqlTripleSource.java From CostFed with GNU Affero General Public License v3.0 | 6 votes |
@Override public CloseableIteration<Statement, QueryEvaluationException> getStatements( RepositoryConnection conn, Resource subj, IRI pred, Value obj, Resource... contexts) throws RepositoryException, MalformedQueryException, QueryEvaluationException { // TODO add handling for contexts monitorRemoteRequest(); RepositoryResult<Statement> repoResult = conn.getStatements(subj, pred, obj, true); return new ExceptionConvertingIteration<Statement, QueryEvaluationException>(repoResult) { @Override protected QueryEvaluationException convert(Exception arg0) { return new QueryEvaluationException(arg0); } }; }
Example #3
Source File: SailTripleSource.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public CloseableIteration<Statement, QueryEvaluationException> getStatements( Resource subj, IRI pred, Value obj, QueryInfo queryInfo, Resource... contexts) throws RepositoryException, MalformedQueryException, QueryEvaluationException { return withConnection((conn, resultHolder) -> { RepositoryResult<Statement> repoResult = conn.getStatements(subj, pred, obj, queryInfo.getIncludeInferred(), contexts); // XXX implementation remark and TODO taken from Sesame // The same variable might have been used multiple times in this // StatementPattern, verify value equality in those cases. resultHolder.set(new ExceptionConvertingIteration<Statement, QueryEvaluationException>(repoResult) { @Override protected QueryEvaluationException convert(Exception arg0) { return new QueryEvaluationException(arg0); } }); }); }
Example #4
Source File: SparqlTripleSource.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public CloseableIteration<Statement, QueryEvaluationException> getStatements( Resource subj, IRI pred, Value obj, QueryInfo queryInfo, Resource... contexts) throws RepositoryException, MalformedQueryException, QueryEvaluationException { return withConnection((conn, resultHolder) -> { monitorRemoteRequest(); RepositoryResult<Statement> repoResult = conn.getStatements(subj, pred, obj, queryInfo.getIncludeInferred(), contexts); resultHolder.set(new ExceptionConvertingIteration<Statement, QueryEvaluationException>(repoResult) { @Override protected QueryEvaluationException convert(Exception ex) { if (ex instanceof QueryEvaluationException) { return (QueryEvaluationException) ex; } return new QueryEvaluationException(ex); } }); }); }
Example #5
Source File: SailTripleSource.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public CloseableIteration<? extends Statement, QueryEvaluationException> getStatements(Resource subj, IRI pred, Value obj, Resource... contexts) throws QueryEvaluationException { CloseableIteration<? extends Statement, SailException> iter = null; CloseableIteration<? extends Statement, QueryEvaluationException> result = null; boolean allGood = false; try { iter = conn.getStatements(subj, pred, obj, includeInferred, contexts); result = new ExceptionConvertingIteration<Statement, QueryEvaluationException>(iter) { @Override protected QueryEvaluationException convert(Exception e) { return new QueryEvaluationException(e); } }; allGood = true; return result; } catch (SailException e) { throw new QueryEvaluationException(e); } finally { if (!allGood) { try { if (result != null) { result.close(); } } finally { if (iter != null) { iter.close(); } } } } }
Example #6
Source File: RepositoryTripleSource.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public CloseableIteration<? extends Statement, QueryEvaluationException> getStatements(Resource subj, IRI pred, Value obj, Resource... contexts) throws QueryEvaluationException { CloseableIteration<? extends Statement, RepositoryException> iter = null; CloseableIteration<? extends Statement, QueryEvaluationException> result = null; boolean allGood = false; try { iter = repo.getStatements(subj, pred, obj, includeInferred, contexts); result = new ExceptionConvertingIteration<Statement, QueryEvaluationException>(iter) { @Override protected QueryEvaluationException convert(Exception exception) { return new QueryEvaluationException(exception); } }; allGood = true; return result; } catch (RepositoryException e) { throw new QueryEvaluationException(e); } finally { if (!allGood) { try { if (result != null) { result.close(); } } finally { if (iter != null) { iter.close(); } } } } }
Example #7
Source File: SPARQLConnection.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private RepositoryResult<Statement> getStatementsQuadMode(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws MalformedQueryException, RepositoryException, QueryEvaluationException { TupleQueryResult qRes = null; RepositoryResult<Statement> result = null; boolean allGood = false; try { TupleQuery tupleQuery = prepareTupleQuery(SPARQL, EVERYTHING_WITH_GRAPH); setBindings(tupleQuery, subj, pred, obj, contexts); tupleQuery.setIncludeInferred(includeInferred); qRes = tupleQuery.evaluate(); result = new RepositoryResult<>(new ExceptionConvertingIteration<Statement, RepositoryException>( toStatementIteration(qRes, subj, pred, obj)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); allGood = true; return result; } finally { if (!allGood) { try { if (result != null) { result.close(); } } finally { if (qRes != null) { qRes.close(); } } } } }
Example #8
Source File: SPARQLConnection.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private RepositoryResult<Statement> getStatementGeneral(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException, MalformedQueryException, QueryEvaluationException { GraphQueryResult gRes = null; RepositoryResult<Statement> result = null; boolean allGood = false; try { GraphQuery query = prepareGraphQuery(SPARQL, EVERYTHING, ""); query.setIncludeInferred(includeInferred); setBindings(query, subj, pred, obj, contexts); gRes = query.evaluate(); result = new RepositoryResult<>( new ExceptionConvertingIteration<Statement, RepositoryException>(gRes) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); allGood = true; return result; } finally { if (!allGood) { try { if (result != null) { result.close(); } } finally { if (gRes != null) { gRes.close(); } } } } }
Example #9
Source File: SPARQLConnection.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public RepositoryResult<Resource> getContextIDs() throws RepositoryException { TupleQueryResult iter = null; RepositoryResult<Resource> result = null; boolean allGood = false; try { TupleQuery query = prepareTupleQuery(SPARQL, NAMEDGRAPHS, ""); iter = query.evaluate(); result = new RepositoryResult<>(new ExceptionConvertingIteration<Resource, RepositoryException>( new ConvertingIteration<BindingSet, Resource, QueryEvaluationException>(iter) { @Override protected Resource convert(BindingSet bindings) throws QueryEvaluationException { return (Resource) bindings.getValue("_"); } }) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); allGood = true; return result; } catch (MalformedQueryException | QueryEvaluationException e) { throw new RepositoryException(e); } finally { if (!allGood) { try { if (result != null) { result.close(); } } finally { if (iter != null) { iter.close(); } } } } }