Class FedXRepositoryConnection
java.lang.Object
org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection
org.eclipse.rdf4j.repository.sail.SailRepositoryConnection
org.eclipse.rdf4j.federated.repository.FedXRepositoryConnection
- All Implemented Interfaces:
AutoCloseable, HttpClientDependent, SessionManagerDependent, FederatedServiceResolverClient, RepositoryConnection, RepositoryResolverClient
A special
SailRepositoryConnection which adds the original query string as binding to the returned query. The
binding name is defined by BINDING_ORIGINAL_QUERY and is added to all query instances returned by the
available prepare methods.- Author:
- Andreas Schwarte
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final StringWe add a binding to each parsed query mapping the original query in order to send the original query to the endpoint if there is only a single federation member is relevant for this query.static final StringThe number of bindings in the external binding set that are added by FedX.Fields inherited from class AbstractRepositoryConnection
logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFedXRepositoryConnection(FedXRepository repository, SailConnection sailConnection) -
Method Summary
Modifier and TypeMethodDescriptionprepareBooleanQuery(QueryLanguage ql, String queryString, String baseURI) Prepares queries that return true or false.prepareGraphQuery(QueryLanguage ql, String queryString, String baseURI) Prepares queries that produce RDF graphs.prepareQuery(QueryLanguage ql, String queryString, String baseURI) Prepares a query for evaluation on this repository (optional operation).prepareTupleQuery(QueryLanguage ql, String queryString, String baseURI) Prepares a query that produces sets of value tuples.prepareUpdate(QueryLanguage ql, String updateString, String baseURI) Prepares an Update operation.Methods inherited from class SailRepositoryConnection
addWithoutCommit, begin, begin, begin, clear, clearNamespaces, close, commit, createRepositoryResult, exportStatements, getContextIDs, getFederatedServiceResolver, getHttpClient, getHttpClientSessionManager, getNamespace, getNamespaces, getSailConnection, getStatements, hasStatement, isActive, isEmpty, isOpen, prepare, removeNamespace, removeWithoutCommit, rollback, setFederatedServiceResolver, setHttpClient, setHttpClientSessionManager, setNamespace, setRepositoryResolver, size, toStringModifier and TypeMethodDescriptionprotected voidaddWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) voidbegin()Begins a new transaction, requiringRepositoryConnection.commit()orRepositoryConnection.rollback()to be called to end the transaction.voidbegin(IsolationLevel level) Begins a new transaction with the suppliedIsolationLevel, requiringRepositoryConnection.commit()orRepositoryConnection.rollback()to be called to end the transaction.voidbegin(TransactionSetting... settings) Begins a new transaction with the suppliedTransactionSetting, requiringRepositoryConnection.commit()orRepositoryConnection.rollback()to be called to end the transaction.voidRemoves all statements from a specific contexts in the repository.voidRemoves all namespace declarations from the repository.voidclose()Closes the connection, freeing resources.voidcommit()Commits the active transaction.protected <E> RepositoryResult<E> createRepositoryResult(CloseableIteration<? extends E> sailIter) Wraps a CloseableIteration coming from a Sail in a RepositoryResult object, applying the required conversionsvoidexportStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts) Exports all statements with a specific subject, predicate and/or object from the repository, optionally from the specified contexts.Gets all resources that are used as context identifiers.Gets theFederatedServiceResolverused by this client.RDF4JHttpClientthat has been assigned or has been used by this object.HttpClientSessionManagerthat has been assigned or has been used by this object.getNamespace(String prefix) Gets the namespace that is associated with the specified prefix, if any.Gets all declared namespaces as a RepositoryResult ofNamespaceobjects.Returns the underlying SailConnection.getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Gets all statements with a specific subject, predicate and/or object from the repository.booleanhasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Checks whether the repository contains statements with a specific subject, predicate and/or object, optionally in the specified contexts.booleanisActive()Indicates if a transaction is currently active on the connection.booleanisEmpty()Returns true if this repository does not contain any (explicit) statements.booleanisOpen()Checks whether this connection is open.voidprepare()Checks for an error state in the active transaction that would force the transaction to be rolled back.voidremoveNamespace(String prefix) Removes a namespace declaration by removing the association between a prefix and a namespace name.protected voidremoveWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) voidrollback()Rolls back all updates in the active transaction.voidSets theFederatedServiceResolverto use for this client.voidsetHttpClient(RDF4JHttpClient client) Assign anRDF4JHttpClientthat this object should use.voidAssign anHttpClientSessionManagerthat this object should use.voidsetNamespace(String prefix, String name) Sets the prefix for a namespace.voidsetRepositoryResolver(RepositoryResolver resolver) longReturns the number of (explicit) statements that are in the specified contexts in this repository.toString()Methods inherited from class AbstractRepositoryConnection
add, add, add, add, add, add, add, add, addWithoutCommit, conditionalCommit, conditionalRollback, export, getIsolationLevel, getParserConfig, getRepository, getValueFactory, hasStatement, isAutoCommit, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareTupleQuery, prepareUpdate, remove, remove, remove, remove, removeWithoutCommit, setAutoCommit, setIsolationLevel, setParserConfig, startLocalTransactionModifier and TypeMethodDescriptionvoidAdds RDF data from the specified file to a specific contexts in the repository.voidadd(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) Adds RDF data from an InputStream to the repository, optionally to one or more named contexts.voidAdds RDF data from a Reader to the repository, optionally to one or more named contexts.voidAdds the supplied statements to this repository, optionally to one or more named contexts.voidAdds the RDF data that can be found at the specified URL to the repository, optionally to one or more named contexts.voidadd(CloseableIteration<? extends Statement> statements, Resource... contexts) Adds the supplied statements to this repository, optionally to one or more named contexts.voidAdds a statement with the specified subject, predicate and object to this repository, optionally to one or more named contexts.voidAdds the supplied statement to this repository, optionally to one or more named contexts.protected voidaddWithoutCommit(Statement st, Resource... contexts) protected final voidconditionalCommit(boolean condition) InvokesRepositoryConnection.commit()if supplied boolean condition istrue.protected final voidconditionalRollback(boolean condition) InvokesRepositoryConnection.rollback()if supplied boolean condition istrue.voidexport(RDFHandler handler, Resource... contexts) Exports all explicit statements in the specified contexts to the supplied RDFHandler.Retrieves the currenttransaction isolation levelof the connection.Returns the parser configuration this connection uses for Rio-based operations.Returns the Repository object to which this connection belongs.Gets a ValueFactory for this RepositoryConnection.booleanhasStatement(Statement st, boolean includeInferred, Resource... contexts) Checks whether the repository contains the specified statement, optionally in the specified contexts.booleanDeprecated.prepareBooleanQuery(QueryLanguage ql, String query) Prepares queries that return true or false.prepareGraphQuery(QueryLanguage ql, String query) Prepares queries that produce RDF graphs.prepareQuery(QueryLanguage ql, String query) Prepares a query for evaluation on this repository (optional operation).prepareTupleQuery(QueryLanguage ql, String query) Prepares a query that produces sets of value tuples.prepareUpdate(QueryLanguage ql, String update) Prepares an Update operation.voidRemoves the supplied statements from the specified contexts in this repository.voidremove(CloseableIteration<? extends Statement> statements, Resource... contexts) Removes the supplied statements from a specific context in this repository, ignoring any context information carried by the statements themselves.voidRemoves the statement(s) with the specified subject, predicate and object from the repository, optionally restricted to the specified contexts.voidRemoves the supplied statement from the specified contexts in the repository.protected voidremoveWithoutCommit(Statement st, Resource... contexts) voidsetAutoCommit(boolean autoCommit) Deprecated.UseRepositoryConnection.begin()instead.voidsetIsolationLevel(IsolationLevel level) Sets the transaction isolation level for the next transaction(s) on this connection.voidsetParserConfig(ParserConfig parserConfig) Set the parser configuration this connection should use for RDFParser-based operations.protected final booleanStarts a new transaction if one is not already active.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface RepositoryConnection
add, add, add, add, add, add, add, getStatements, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareTupleQuery, prepareUpdate, removeModifier and TypeMethodDescriptiondefault voidAdds RDF data from the specified file to a specific contexts in the repository.default voidAdds RDF data from the specified file to a specific contexts in the repository.default voidadd(InputStream in, RDFFormat dataFormat, Resource... contexts) Adds RDF data from an InputStream to the repository, optionally to one or more named contexts.default voidAdds RDF data from a Reader to the repository, optionally to one or more named contexts.default voidAdds the RDF data that can be found at the specified URL to the repository, optionally to one or more named contexts.default voidAdds the RDF data that can be found at the specified URL to the repository, optionally to one or more named contexts.default voidadd(RepositoryResult<Statement> statements, Resource... contexts) Adds the supplied statements to this repository, optionally to one or more named contexts.default RepositoryResult<Statement> getStatements(Resource subj, IRI pred, Value obj, Resource... contexts) Gets all statements with a specific subject, predicate and/or object from the repository.default BooleanQueryprepareBooleanQuery(String query) Prepares SPARQL queries that return true or false, that is, SPARQL ASK queries.default GraphQueryprepareGraphQuery(String query) Prepares SPARQL queries that produce RDF graphs, that is, SPARQL CONSTRUCT or DESCRIBE queries.default QueryprepareQuery(String query) Prepares a SPARQL query for evaluation on this repository (optional operation).default TupleQueryprepareTupleQuery(String query) Prepares a SPARQL query that produces sets of value tuples, that is a SPARQL SELECT query.default UpdateprepareUpdate(String update) Prepares a SPARQL Update operation.default voidremove(RepositoryResult<Statement> statements, Resource... contexts) Removes the supplied statements from a specific context in this repository, ignoring any context information carried by the statements themselves.
-
Field Details
-
BINDING_ORIGINAL_QUERY
We add a binding to each parsed query mapping the original query in order to send the original query to the endpoint if there is only a single federation member is relevant for this query.- See Also:
-
BINDING_ORIGINAL_BASE_URI
- See Also:
-
BINDING_ORIGINAL_QUERY_TYPE
- See Also:
-
BINDING_ORIGINAL_MAX_EXECUTION_TIME
- See Also:
-
FEDX_BINDINGS
-
-
Constructor Details
-
FedXRepositoryConnection
-
-
Method Details
-
prepareQuery
public SailQuery prepareQuery(QueryLanguage ql, String queryString, String baseURI) throws MalformedQueryException Description copied from interface:RepositoryConnectionPrepares a query for evaluation on this repository (optional operation).If you already know the type of query, using the more specific
RepositoryConnection.prepareTupleQuery(String),RepositoryConnection.prepareGraphQuery(String)orRepositoryConnection.prepareBooleanQuery(String)is likely to be more efficient.- Specified by:
prepareQueryin interfaceRepositoryConnection- Overrides:
prepareQueryin classSailRepositoryConnection- Parameters:
ql- Thequery languagein which the query is formulated.queryString- The query string.baseURI- The base URI to resolve any relative URIs that are in the query against, can be null if the query does not contain any relative URIs.- Returns:
- A query ready to be evaluated on this repository.
- Throws:
MalformedQueryException- If the supplied query is malformed.
-
prepareTupleQuery
public FedXTupleQuery prepareTupleQuery(QueryLanguage ql, String queryString, String baseURI) throws MalformedQueryException Description copied from interface:RepositoryConnectionPrepares a query that produces sets of value tuples.- Specified by:
prepareTupleQueryin interfaceRepositoryConnection- Overrides:
prepareTupleQueryin classSailRepositoryConnection- Parameters:
ql- Thequery languagein which the query is formulated.queryString- The query string.baseURI- The base URI to resolve any relative URIs that are in the query against, can be null if the query does not contain any relative URIs.- Returns:
- a
TupleQueryready to be evaluated on thisRepositoryConnection. - Throws:
MalformedQueryException- If the supplied query is malformed.
-
prepareGraphQuery
public FedXGraphQuery prepareGraphQuery(QueryLanguage ql, String queryString, String baseURI) throws MalformedQueryException Description copied from interface:RepositoryConnectionPrepares queries that produce RDF graphs.- Specified by:
prepareGraphQueryin interfaceRepositoryConnection- Overrides:
prepareGraphQueryin classSailRepositoryConnection- Parameters:
ql- Thequery languagein which the query is formulated.queryString- The query string.baseURI- The base URI to resolve any relative URIs that are in the query against, can be null if the query does not contain any relative URIs.- Returns:
- a
GraphQueryready to be evaluated on thisRepositoryConnection. - Throws:
MalformedQueryException- If the supplied query is malformed.
-
prepareBooleanQuery
public SailBooleanQuery prepareBooleanQuery(QueryLanguage ql, String queryString, String baseURI) throws MalformedQueryException Description copied from interface:RepositoryConnectionPrepares queries that return true or false.- Specified by:
prepareBooleanQueryin interfaceRepositoryConnection- Overrides:
prepareBooleanQueryin classSailRepositoryConnection- Parameters:
ql- Thequery languagein which the query is formulated.queryString- The query string.baseURI- The base URI to resolve any relative URIs that are in the query against, can be null if the query does not contain any relative URIs.- Returns:
- a
BooleanQueryready to be evaluated on thisRepositoryConnection. - Throws:
MalformedQueryException- If the supplied query is malformed.
-
prepareUpdate
public Update prepareUpdate(QueryLanguage ql, String updateString, String baseURI) throws RepositoryException, MalformedQueryException Description copied from interface:RepositoryConnectionPrepares an Update operation.- Specified by:
prepareUpdatein interfaceRepositoryConnection- Overrides:
prepareUpdatein classSailRepositoryConnection- Parameters:
ql- Thequery languagein which the update operation is formulated.updateString- The update operation string.baseURI- The base URI to resolve any relative URIs that are in the update against, can be null if the update does not contain any relative URIs.- Returns:
- a
Updateready to be executed on thisRepositoryConnection. - Throws:
MalformedQueryException- If the supplied update operation string is malformed.RepositoryException
-
RepositoryConnection.isActive()instead.