/** * List all versions in the database; operates directly on the result set, i.e. the iteration is carried out * lazily and needs to be closed when iteration is completed. * * @return * @throws SQLException */ public RepositoryResult<Version> listVersions(final Date from, final Date to) throws SQLException { return new RepositoryResult<Version>( new ExceptionConvertingIteration<Version, RepositoryException>(listVersionsInternal(from, to)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException("database error while iterating over result set",e); } } ); }
/** * List all versions in the database affecting the given resource as subject; operates directly on the result set, * i.e. the iteration is carried out lazily and needs to be closed when iteration is completed. * * @return * @throws SQLException */ public RepositoryResult<Version> listVersions(KiWiResource r) throws SQLException { return new RepositoryResult<Version>( new ExceptionConvertingIteration<Version, RepositoryException>(listVersionsInternal(r)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException("database error while iterating over result set",e); } } ); }
/** * List all versions in the database; operates directly on the result set, i.e. the iteration is carried out * lazily and needs to be closed when iteration is completed. * * @return * @throws SQLException */ public RepositoryResult<Version> listVersions(final KiWiResource r, final Date from, final Date to) throws SQLException { return new RepositoryResult<Version>( new ExceptionConvertingIteration<Version, RepositoryException>(listVersionsInternal(r, from, to)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException("database error while iterating over result set",e); } } ); }
/** * List all versions in the database; operates directly on the result set, i.e. the iteration is carried out * lazily and needs to be closed when iteration is completed. * * @return * @throws SQLException */ public RepositoryResult<Version> listVersions() throws SQLException { return new RepositoryResult<Version>( new ExceptionConvertingIteration<Version, RepositoryException>(listVersionsInternal()) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException("database error while iterating over result set",e); } } ); }
@Override public RepositoryResult<Resource> getContextIDs() throws RepositoryException { //Gets all resources that are used as content identifiers. //Care should be taken that the returned RepositoryResult //is closed to free any resources that it keeps hold of. List<Resource> contexts = new LinkedList<Resource>(); return new RepositoryResult<Resource>(new CloseableIteratorIteration<Resource, RepositoryException>(contexts.iterator())); }
/** * Return a Sesame RepositoryResult of statements according to the query pattern given in the arguments. Each of * the parameters subject, predicate, object and context may be null, indicating a wildcard query. If the boolean * parameter "inferred" is set to true, the result will also include inferred triples, if it is set to false only * base triples. * <p/> * The RepositoryResult holds a direct connection to the database and needs to be closed properly, or otherwise * the system might run out of resources. The returned RepositoryResult will try its best to clean up when the * iteration has completed or the garbage collector calls the finalize() method, but this can take longer than * necessary. * * * @param subject the subject to query for, or null for a wildcard query * @param predicate the predicate to query for, or null for a wildcard query * @param object the object to query for, or null for a wildcard query * @param context the context to query for, or null for a wildcard query * @param inferred if true, the result will also contain triples inferred by the reasoner, if false not * @return a new RepositoryResult with a direct connection to the database; the result should be properly closed * by the caller */ public RepositoryResult<Statement> listTriplesSnapshot(KiWiResource subject, KiWiUriResource predicate, KiWiNode object, KiWiResource context, boolean inferred, Date snapshotDate) throws SQLException { return new RepositoryResult<Statement>( new ExceptionConvertingIteration<Statement, RepositoryException>(listTriplesInternalSnapshot(subject, predicate, object, context, inferred, snapshotDate)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException("database error while iterating over result set",e); } } ); }
/** * Wraps a CloseableIteration coming from a Sail in a RepositoryResult * object, applying the required conversions */ protected <E> RepositoryResult<E> createRepositoryResult( CloseableIteration<? extends E, SailException> sailIter) { return new RepositoryResult<E>(new SailCloseableIteration<E>(sailIter)); }
public RepositoryResult<Namespace> getNamespaces() throws RepositoryException { return new RepositoryResult<Namespace>(new EmptyIteration<Namespace, RepositoryException>()); }
public RepositoryResult<Namespace> getNamespaces() throws RepositoryException { return new RepositoryResult<Namespace>( new EmptyIteration<Namespace, RepositoryException>()); }
@Override public RepositoryResult<Namespace> getNamespaces() throws RepositoryException { //Gets all declared namespaces as a RepositoryResult of Namespace objects. //Each Namespace object consists of a prefix and a namespace name. Set<Namespace> namespSet = new HashSet<Namespace>(); Map<String, String> namesp = repository.getNamespaces(); Set<String> keys = namesp.keySet(); for (String key : keys) { //convert into namespace objects namespSet.add(new NamespaceImpl(key, namesp.get(key))); } return new RepositoryResult<Namespace>(new CloseableIteratorIteration<Namespace, RepositoryException>( namespSet.iterator())); }
private RepositoryResult<Statement> detach(RepositoryResult<Statement> stmts) throws RepositoryException { try { Iterator<Statement> iter = stmts.asList().iterator(); CloseableIteration<Statement, RepositoryException> itern; itern = new CloseableIteratorIteration<Statement, RepositoryException>( iter); return new RepositoryResult<Statement>(itern); } finally { stmts.close(); } }
return new RepositoryResult<Resource>(new CloseableIteration<Resource, RepositoryException>() {
/** * Return an iterator over the resources contained in this repository. * * @return */ @Override public RepositoryResult<Resource> getResources() throws RepositoryException { try { return new RepositoryResult<>(new ExceptionConvertingIteration<Resource, RepositoryException>(databaseConnection.listResources()) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (SQLException e) { throw new RepositoryException(e); } }
/** * Return an iterator over the resources contained in this repository matching the given prefix. * * @return */ @Override public RepositoryResult<URI> getResources(String prefix) throws RepositoryException { try { return new RepositoryResult<>(new ExceptionConvertingIteration<URI, RepositoryException>(databaseConnection.listResources(prefix)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (SQLException e) { throw new RepositoryException(e); } }
/** * Return an iterator over the resources contained in this repository matching the given prefix. * * @return */ @Override public RepositoryResult<URI> getResources(String prefix) throws RepositoryException { try { return new RepositoryResult<>(new ExceptionConvertingIteration<URI, RepositoryException>(databaseConnection.listResources(prefix)) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (SQLException e) { throw new RepositoryException(e); } }
/** * Return an iterator over the resources contained in this repository. * * @return */ @Override public RepositoryResult<Resource> getResources() throws RepositoryException { try { return new RepositoryResult<>(new ExceptionConvertingIteration<Resource, RepositoryException>(databaseConnection.listResources()) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (SQLException e) { throw new RepositoryException(e); } }
@Override public RepositoryResult<Statement> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException { AugurStatementNode node; node = _factory.createAugurStatementNode(subj, pred, obj, includeInferred, contexts); if (isCacheEnabled(node)) { CachableAugurNode node2 = (CachableAugurNode)node; return getCachableStatements(node2, subj, obj, includeInferred); } CloseableIteration<? extends Statement, RepositoryException> stmts; stmts = super.getStatements(subj, pred, obj, includeInferred, contexts); return new RepositoryResult<Statement>(new AStatementIterator<RepositoryException>(stmts, node)); }
public RepositoryResult<Resource> getContextIDs() throws RepositoryException { try { TupleQuery query = prepareTupleQuery(SPARQL, NAMEDGRAPHS, ""); TupleQueryResult result = query.evaluate(); return new RepositoryResult<Resource>( new ExceptionConvertingIteration<Resource, RepositoryException>( new ConvertingIteration<BindingSet, Resource, QueryEvaluationException>( result) { @Override protected Resource convert(BindingSet bindings) throws QueryEvaluationException { return (Resource) bindings.getValue("_"); } }) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } }
public RepositoryResult<Resource> getContextIDs() throws RepositoryException { try { TupleQuery query = prepareTupleQuery(SPARQL, NAMEDGRAPHS, ""); TupleQueryResult result = query.evaluate(); return new RepositoryResult<Resource>( new ExceptionConvertingIteration<Resource, RepositoryException>( new ConvertingIteration<BindingSet, Resource, QueryEvaluationException>(result) { @Override protected Resource convert(BindingSet bindings) throws QueryEvaluationException { return (Resource)bindings.getValue("_"); } }) { @Override protected RepositoryException convert(Exception e) { return new RepositoryException(e); } }); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } }
private RepositoryResult<Statement> getCachableStatements( CachableAugurNode node, Resource subj, Value obj, boolean includeInferred) throws RepositoryException { CloseableIteration<? extends Statement, QueryEvaluationException> stmts; stmts = node.getStatements(subj, obj); if (stmts == null) { try { ParsedGraphQuery parsedQuery = createGraphQuery(node); String queryString = formatter.formatGraphQuery(parsedQuery); GraphQuery graphQuery = super.prepareGraphQuery(QueryLanguage.SERQO, queryString, null); graphQuery.setIncludeInferred(node.isIncludeInferred()); GraphQueryResult results = graphQuery.evaluate(); Iteration<Statement, QueryEvaluationException> iter = results; AResource carried = (AResource)node.getCarriedOverResource(subj, obj); iter = new ConsumeStatementIterator<QueryEvaluationException>(iter, carried, node, getVersion()); return new RepositoryResult<Statement>(new RepositoryCloseableIteration<Statement>( new AStatementIterator<QueryEvaluationException>(iter, node))); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (QueryEvaluationException e) { throw new RepositoryException(e); } } return new RepositoryResult<Statement>(new RepositoryCloseableIteration<Statement>(new AStatementIterator<QueryEvaluationException>( stmts, node))); }