Class AGRepositoryConnection
- All Implemented Interfaces:
AutoCloseable
,RepositoryConnection
RepositoryConnection
interface for AllegroGraph.
By default, a connection is in autoCommit
mode. Connections in this mode are said to be
shared. Multiple shared connections may be serviced by the
same server back-end process and they have no associated state,
thus they do not support some functionality such as multi-step
transactions and datatype mappings.
Full functionality is offered by dedicated sessions at the cost of higher server resource requirements.
Note that concurrent access to the same connection object of
either kind is explicitly forbidden. The client must perform its
own synchronization to ensure non-concurrent access. This is
typically achieved by employing connection pooling (see AGConnPool
) and having exactly one thread
that uses each connection.
Dedicated Session Overview
Sessions with AllegroGraph server are used for ACID transactions and also for server code in InitFile and Scripts. See more documentation for Sessions in the AllegroGraph HTTP Protocol and ACID transactions in the AllegroGraph Server documentation.
Operations such as
setAutoCommit
,
addRules
, and
registerSNAGenerator
will spawn a dedicated session (simply session, from now on) in
order to perform their duties. Adds and deletes during a session
must be committed
or rolled
back
.
To conserve resources, the server will drop a session when
its idle lifetime
is exceeded.
To avoid this, the client periodically sends a ping
message to the server. This automated behavior can be controlled
by changing the executor used to schedule maintenance tasks.
This can be done either in the
AGServer.setExecutor(ScheduledExecutorService)
server}
object or when creating a new connection with
AGRepository.getConnection(ScheduledExecutorService)
.
A session should be closed
when finished.
InitFiles
and Scripts
are loaded into the server only for sessions. See
Scripting in HTTP Protocol and
search for "InitFile" in WebView for how to create initFiles.
Starting a session causes http requests to use a new port, which may cause an exception if the client can not access it. See Session Port Setup.
Methods that start a session if not already started:
setAutoCommit(boolean)
addRules(String)
addRules(InputStream)
registerSNAGenerator(String, List, List, List, String)
Methods that affect a session in use:
Methods to configure a session before it is started:
setSessionLifetime(int)
andgetSessionLifetime()
setSessionLoadInitFile(boolean)
addSessionLoadScript(String)
Data-type and Predicate Mapping
For more details, see the HTTP Protocol docs for Type Mappings and the Lisp reference for Data-type and Predicate Mapping.
Methods for type mappings:
- Since:
- v4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Builder class for defining a new attribute definition. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAGRepositoryConnection
(AGRepository repository, AGHttpRepoClient client) AGRepositoryConnection
(AGVirtualRepository repository, AGHttpRepoClient client) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds RDF data from the specified file to a specific contexts in the repository.void
Adds RDF data from the specified file to a specific contexts in the repository.void
add
(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) Adds RDF data from an InputStream to the repository, optionally to one or more named contexts.void
add
(InputStream in, String baseURI, RDFFormat dataFormat, JSONObject attributes, Resource... contexts) Adds RDF data from an InputStream to the repository, optionally to one or more named contexts.void
Adds RDF data from a Reader to the repository, optionally to one or more named contexts.void
add
(Reader reader, String baseURI, RDFFormat dataFormat, JSONObject attributes, Resource... contexts) Adds RDF data from a Reader to the repository, optionally to one or more named contexts.void
void
add
(Iterable<? extends Statement> statements, JSONObject attributes, Resource... contexts) void
Adds the RDF data that can be found at the specified URL to the repository, optionally to one or more named contexts.void
Adds the RDF data that can be found at the specified URL to the repository, optionally to one or more named contexts.void
add
(CloseableIteration<? extends Statement> statementIter, Resource... contexts) void
add
(CloseableIteration<? extends Statement> statementIter, JSONObject attributes, Resource... contexts) void
Adds a statement with the specified subject, predicate and object to this repository, optionally to one or more named contexts.void
void
void
add
(Statement st, JSONObject attributes, Resource... contexts) void
Adds the given index to the list of actively managed indices.void
addRules
(InputStream rulestream) Adds Prolog rules to be used on this connection.void
Adds Prolog rules to be used on this connection.void
addSessionLoadScript
(String scriptName) Adds a 'script' for a dedicated session spawned by this connection.void
begin()
Begins a transaction requiringcommit()
orrollback()
to be called to end the transaction.callStoredProc
(String functionName, String moduleName, Object... args) Deprecated.The stored proc feature and API are experimental, and subject to change in a future release.void
Removes all statement(s) within the specified contexts.void
Deletes all attribute definitions from the repository.void
Deletes all user-defined predicate and datatype mappings for this connection, and reestablishes the automatic mappings for primitive datatypes.void
clearMappings
(boolean includeAutoEncodedPrimitiveTypes) Deletes all predicate and user-defined datatype mappings for this connection.void
void
close()
Closes the session if there is one started.void
commit()
Commit the current transaction.void
commit
(TransactionSettings transactionSettings) Commit the current transaction.void
Finalize a previously prepared two phase commit (2PC).void
createFreetextIndex
(String indexName, AGFreetextIndexConfig config) Creates a freetext index with the given name and configuration.void
createFreetextIndex
(String name, IRI[] predicates) Deprecated.<E> RepositoryResult<E>
createRepositoryResult
(Iterable<? extends E> elements) Creates a RepositoryResult for the supplied element set.defineAttribute
(String name) void
Delete an existing triple attribute definition.void
deleteDatatypeMapping
(IRI datatype) Deletes any datatype mapping associated with the given datatype.void
deleteDuplicates
(String comparisonMode) Deletes all duplicates from the store.void
deleteFreetextIndex
(String indexName) Deletes the freetext index of the specified name.long
Deletes materialized statements from the default graph.long
deleteMaterialized
(AGMaterializer materializer) Deletes materialized statements.long
deleteMaterialized
(Resource inferredGraph) Deletes materialized statements from given graph.void
deletePredicateMapping
(IRI predicate) Deletes any predicate mapping associated with the given predicate.void
deleteSpinFunction
(String uri) void
void
Delete the static attribute filter defined on this repository.void
Disable nD Geospatical Datatype Automation on this repository.void
Disables the spogi triple cache.void
downloadStatements
(File file, String mimeType, String ids) Downloads statements with given ids to a file.void
downloadStatements
(File file, String mimeType, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Downloads statements matching given pattern to a file.void
downloadStatements
(File file, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Downloads statements matching given pattern to a file.void
downloadStatements
(File file, RDFFormat format, String ids) Downloads statements with given ids to a file.void
downloadStatements
(File file, RDFFormat format, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Downloads statements matching given pattern to a file.void
downloadStatements
(String file, String mimeType, String ids) Downloads statements with given ids to a file.void
downloadStatements
(String file, String mimeType, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Downloads statements matching given pattern to a file.void
downloadStatements
(String file, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Downloads statements matching given pattern to a file.void
downloadStatements
(String file, RDFFormat format, String ids) Downloads statements with given ids to a file.void
downloadStatements
(String file, RDFFormat format, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Downloads statements matching given pattern to a file.void
Drops the given index from the list of actively managed indices.void
Enable nD Geospatical Datatype Automation on this repository.void
enableTripleCache
(long size) Enables the spogi cache in this repository.evalInServer
(InputStream stream) Evaluates a Lisp form on the server, and returns the result as a String.evalInServer
(String lispForm) Evaluates a Lisp form on the server, and returns the result as a String.void
exportStatements
(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts) void
exportStatements
(RDFHandler handler, String... ids) int
getAttributeDefinition
(String name) Return the definition of the attribute named by NAME.Return a list of all attributes defined for the current connection.String[]
Gets the datatype mappings defined for this connection.getDuplicateStatements
(String comparisonMode) Returns all duplicates from the store.getFreetextIndexConfig
(String indexName) Gets the configuration of the specified free text index.String[]
Deprecated.String[]
getFreetextPredicates
(String index) Deprecated.getGeoHaversine
(IRI type, IRI predicate, float lat, float lon, float radius, String unit, int limit, boolean infer) String[]
getNamespace
(String prefix) boolean
Fetch the status of nD Geospatical Datatype Automation on this repository.int
String[]
Gets the predicate mappings defined for this connection.Xid[]
getQueryOption
(String name) Gets the value of the query option.Gets a set of all currently set query options.int
Returns the lifetime for a dedicated session spawned by this connection.getSpinFunction
(String uri) getStatements
(String... ids) Returns statements having the specified ids.getStatements
(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) getStatementsInBox
(IRI type, IRI predicate, float xmin, float xmax, float ymin, float ymax, int limit, boolean infer) getStatementsInCircle
(IRI type, IRI predicate, float x, float y, float radius, int limit, boolean infer) getStatementsInPolygon
(IRI type, IRI predicate, IRI polygon, int limit, boolean infer) Fetch the string representation of the static attribute filter defined on this repositorylong
Returns the store IDlong
Returns the size of the spogi cache.int
Gets the commit period used within large add/load operations.boolean
hasStatement
(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) boolean
isActive()
Indicates if a transaction is currently active on the connection.boolean
boolean
Deprecated.since release 2.7.0.boolean
If true, automatically useAGStreamTupleQuery
.boolean
Lists the freetext indices that have been defined for this repository.void
Instructs the server to load data from the specified server-side path.void
load
(String absoluteServerPath, String baseURI, RDFFormat dataFormat, JSONObject attributes, Resource... contexts) Instructs the server to load data from the specified server-side path.void
Instructs the server to fetch and load data from the specified URI.void
Instructs the server to fetch and load data from the specified URI.long
materialize
(AGMaterializer materializer) Materializes inferred statements (generates and adds them to the store).void
optimizeIndices
(Boolean wait) void
optimizeIndices
(Boolean wait, int level) Instruct the server to optimize the indices for this store.void
ping()
Instructs the server to extend the life of this connection's dedicated session, if it is using one.prepareBooleanQuery
(QueryLanguage ql, String queryString) prepareBooleanQuery
(QueryLanguage ql, String queryString, String baseURI) void
prepareCommit
(Xid xid) Asks the server to prepare a commit for later finalization/rollback.prepareGraphQuery
(QueryLanguage ql, String queryString) prepareGraphQuery
(QueryLanguage ql, String queryString, String baseURI) This is the method to call, in this or other classes, if you want to do HTTP interaction with the repository.prepareQuery
(QueryLanguage ql, String queryString, String baseURI) Prepares aAGQuery
for evaluation on this repository.prepareTupleQuery
(QueryLanguage ql, String queryString) prepareTupleQuery
(QueryLanguage ql, String queryString, String baseURI) prepareUpdate
(QueryLanguage ql, String queryString) prepareUpdate
(QueryLanguage ql, String queryString, String baseURI) void
void
registerCartesianType
(float stripWidth, float xmin, float xmax, float ymin, float ymax) Registers a cartesian geospatial subtype.void
registerDatatypeMapping
(IRI datatype, IRI primtype) Registers a datatype mapping from the datatype to a primitive datatype.void
registerEncodableNamespace
(String namespace, String format) Registers an encodable namespace having the specified format.void
registerEncodableNamespaces
(Iterable<? extends AGFormattedNamespace> formattedNamespaces) Registers multiple formatted namespaces in a single request.void
registerPolygon
(IRI polygon, List<Literal> points) Registers a polygon.void
registerPredicateMapping
(IRI predicate, IRI primtype) Registers a predicate mapping from the predicate to a primitive datatype.void
registerSNAGenerator
(String generator, List<IRI> objectOfs, List<IRI> subjectOfs, List<IRI> undirecteds, String query) void
registerSNANeighborMatrix
(String matrix, String generator, List<IRI> group, int depth) registerSphericalType
(float stripWidth, String unit) registerSphericalType
(float stripWidth, String unit, float latmin, float lonmin, float latmax, float lonmax) Registers a spherical geospatial subtype.void
void
remove
(CloseableIteration<? extends Statement> statements, Resource... contexts) void
Removes the statement(s) with the specified subject, predicate and object from the repository, optionally restricted to the specified contexts.void
void
removeNamespace
(String prefix) void
removeQueryOption
(String name) Removes the given query option's value.void
rollback()
Roll back the current transaction (discard all changes made since last commit).void
Aborts a previously prepared commit.void
sendRDFTransaction
(InputStream rdftransaction) Executes an application/x-rdftransaction.void
sendRDFTransaction
(InputStream rdftransaction, JSONObject attributes) send an RDFTransaction, including attributes.void
setAddStatementBufferEnabled
(boolean enabled) Enable or disable the use of the addStatementBuffer.void
setAddStatementBufferMaxSize
(int size) Set the maximum size of the addStatementBuffer.void
setAutoCommit
(boolean autoCommit) Deprecated.As of release 2.7.0, use begin() instead.void
setMasqueradeAsUser
(String user) Sets the AG user for X-Masquerade-As-User requests.void
setNamespace
(String prefix, String name) void
setPool
(AGConnPool pool) Sets the connection pool this object will be returned to on close.void
setQueryOption
(String name, String value) Sets query option given by name to the specified values.void
setSessionLifetime
(int lifetimeInSeconds) Sets the 'lifetime' for a dedicated session spawned by this connection.void
setSessionLoadInitFile
(boolean loadInitFile) Sets the 'loadInitFile' flag for a dedicated session spawned by this connection.void
setStaticAttributeFilter
(String filter) Establish a static attribute filter on the current repository.void
setStreamResults
(boolean streamResults) Set to true to automatically useAGStreamTupleQuery
forprepareTupleQuery(QueryLanguage, String, String)
.void
setTransactionSettings
(TransactionSettings transactionSettings) Configure distributed transaction behavior.void
setUploadCommitPeriod
(int period) Sets the commit period to use within large add/load operations.void
setUserAttributes
(String value) void
setUserAttributes
(JSONObject value) long
streamStatements
(String mimeType, String... ids) Returns statements with given ids as an InputStream.streamStatements
(String mimeType, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Returns statements matching given pattern as an InputStream.streamStatements
(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Returns statements matching given pattern as an InputStream.streamStatements
(RDFFormat format, String... ids) Returns statements with given ids as an InputStream.streamStatements
(RDFFormat format, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Returns statements matching given pattern as an InputStream.toString()
transactionSettingsCtx
(TransactionSettings transactionSettings) A 'context manager' for temporarily changing transaction settings.void
unregisterEncodableNamespace
(String namespace) Unregisters the specified encodable namespace.void
warmup()
Asks the server to read store's internal data structures into memory.void
warmup
(WarmupConfig config) Asks the server to read store's internal data structures into memory.Methods inherited from class org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection
begin, export, getIsolationLevel, getParserConfig, hasStatement, isEmpty, isOpen, prepareQuery, setIsolationLevel, setParserConfig
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.rdf4j.repository.RepositoryConnection
add, add, add, add, add, add, add, begin, begin, export, getIsolationLevel, getParserConfig, getStatements, hasStatement, isEmpty, isOpen, prepare, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareQuery, prepareTupleQuery, prepareUpdate, remove, setIsolationLevel, setParserConfig
-
Field Details
-
PROP_STREAM_RESULTS
- See Also:
-
PROP_USE_ADD_STATEMENT_BUFFER
- See Also:
-
PROP_ADD_STATEMENT_BUFFER_MAX_SIZE
- See Also:
-
DEFAULT_ADD_STATEMENT_BUFFER_SIZE
public static final int DEFAULT_ADD_STATEMENT_BUFFER_SIZE- See Also:
-
-
Constructor Details
-
AGRepositoryConnection
- Parameters:
repository
- a repository nameclient
- the HTTP client through which requests on this connection will be made- See Also:
-
AGRepositoryConnection
-
-
Method Details
-
toString
-
getRepository
- Specified by:
getRepository
in interfaceRepositoryConnection
- Overrides:
getRepository
in classAbstractRepositoryConnection
-
getServer
- Returns:
- the AGServer object associated with this connection
-
prepareHttpRepoClient
This is the method to call, in this or other classes, if you want to do HTTP interaction with the repository. As a side effect (what the "prepare" stands for) any buffered statements are sent over.- Returns:
- the AGHttpRepoclient used by this connection (after the addStatementBuffer is cleared)
-
isAddStatementBufferEnabled
public boolean isAddStatementBufferEnabled()- Returns:
- whether the addStatementBuffer is in principle enabled (by the
PROP_USE_ADD_STATEMENT_BUFFER
property or a call tosetAddStatementBufferEnabled
).
-
setAddStatementBufferEnabled
public void setAddStatementBufferEnabled(boolean enabled) Enable or disable the use of the addStatementBuffer. This can be called within an active transaction and will affect (speed up) the rest of the transaction. When called in autocommit mode, it has no immediate effect, but in a subsequent transaction the buffer functionality will be used.The buffer can also be enabled by setting property
PROP_USE_ADD_STATEMENT_BUFFER
.- Parameters:
enabled
- whether to enable buffering
-
isUseAddStatementBuffer
public boolean isUseAddStatementBuffer()- Returns:
- whether the addStatementBuffer is actually used right now for the connection.
-
getAddStatementBufferMaxSize
public int getAddStatementBufferMaxSize() -
setAddStatementBufferMaxSize
public void setAddStatementBufferMaxSize(int size) Set the maximum size of the addStatementBuffer.This size can also be set by using property
PROP_ADD_STATEMENT_BUFFER_MAX_SIZE
.- Parameters:
size
- new maximum buffer size
-
getNumBufferedAddStatements
public int getNumBufferedAddStatements()- Returns:
- the number of buffered statements to be added
-
getValueFactory
- Specified by:
getValueFactory
in interfaceRepositoryConnection
- Overrides:
getValueFactory
in classAbstractRepositoryConnection
-
add
public void add(Iterable<? extends Statement> statements, Resource... contexts) throws RepositoryException - Specified by:
add
in interfaceRepositoryConnection
- Overrides:
add
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
add
public void add(Iterable<? extends Statement> statements, JSONObject attributes, Resource... contexts) throws RepositoryException - Throws:
RepositoryException
-
add
public void add(CloseableIteration<? extends Statement> statementIter, Resource... contexts) throws RepositoryException - Specified by:
add
in interfaceRepositoryConnection
- Overrides:
add
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
add
public void add(CloseableIteration<? extends Statement> statementIter, JSONObject attributes, Resource... contexts) throws RepositoryException - Throws:
RepositoryException
-
add
public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException Adds RDF data from the specified file to a specific contexts in the repository.- Specified by:
add
in interfaceRepositoryConnection
- Overrides:
add
in classAbstractRepositoryConnection
- Parameters:
file
- a file containing RDF databaseURI
- the base URI against which any relative URIs in the data are resolved. This defaults to the value offile.toURI()
if the value is set tonull
dataFormat
- the serialization format of the datacontexts
- the contexts to add the data to. Note that this parameter is a vararg and as such is optional. If no contexts are specified, the data is added to any context specified in the actual data file, or if the data contains no context, it is added to the default context. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself- Throws:
IOException
- if an I/O error occurred while reading from the fileUnsupportedRDFormatException
- if no parser is available for the specified RDF formatRDFParseException
- if an error occurred while parsing the RDF dataRepositoryException
- if the data could not be added to the repository, for example because the repository is not writable
-
add
public void add(File file, String baseURI, RDFFormat dataFormat, JSONObject attributes, Resource... contexts) throws IOException, RDFParseException, RepositoryException Adds RDF data from the specified file to a specific contexts in the repository.- Parameters:
file
- a file containing RDF databaseURI
- the base URI against which any relative URIs in the data are resolved. This defaults to the value offile.toURI()
if the value is set tonull
dataFormat
- the serialization format of the dataattributes
- a JSONObject of attribute bindings that will be added to each statement imported from `file'. For RDFFormats that support the specification of attributes (like NQX) these attributes will be applied to statements that do not already specify attributescontexts
- the contexts to add the data to. Note that this parameter is a vararg and as such is optional. If no contexts are specified, the data is added to any context specified in the actual data file, or if the data contains no context, it is added to the default context. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself- Throws:
IOException
- if an I/O error occurred while reading from the fileUnsupportedRDFormatException
- if no parser is available for the specified RDF formatRDFParseException
- if an error occurred while parsing the RDF dataRepositoryException
- if the data could not be added to the repository, for example because the repository is not writable
-
add
public void add(URL url, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException Adds the RDF data that can be found at the specified URL to the repository, optionally to one or more named contexts.- Specified by:
add
in interfaceRepositoryConnection
- Overrides:
add
in classAbstractRepositoryConnection
- Parameters:
url
- the URL of the RDF databaseURI
- the base URI against which any relative URIs in the data are resolved. This defaults to the value ofurl.toExternalForm()
if the value is set tonull
dataFormat
- the serialization format of the datacontexts
- the contexts to add the data to. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself- Throws:
IOException
- if an I/O error occurred while reading from the URLUnsupportedRDFormatException
- if no parser is available for the specified RDF formatRDFParseException
- if an error occurred while parsing the RDF dataRepositoryException
- if the data could not be added to the repository, for example because the repository is not writable
-
add
public void add(URL url, String baseURI, RDFFormat dataFormat, JSONObject attributes, Resource... contexts) throws IOException, RDFParseException, RepositoryException Adds the RDF data that can be found at the specified URL to the repository, optionally to one or more named contexts.- Parameters:
url
- the URL of the RDF databaseURI
- the base URI against which any relative URIs in the data are resolved. This defaults to the value ofurl.toExternalForm()
if the value is set tonull
dataFormat
- the serialization format of the dataattributes
- a JSONObject of attribute bindings that will be added to each statement imported from `url'. For RDFFormats that support the specification of attributes (like NQX) these attributes will be applied to statements that do not already specify attributescontexts
- the contexts to add the data to. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself- Throws:
IOException
- if an I/O error occurred while reading from the URLUnsupportedRDFormatException
- if no parser is available for the specified RDF formatRDFParseException
- if an error occurred while parsing the RDF dataRepositoryException
- if the data could not be added to the repository, for example because the repository is not writable
-
add
public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException Adds RDF data from an InputStream to the repository, optionally to one or more named contexts.- Specified by:
add
in interfaceRepositoryConnection
- Overrides:
add
in classAbstractRepositoryConnection
- Parameters:
in
- an InputStream from which RDF data can be readbaseURI
- the base URI against which any relative URIs in the data are resolveddataFormat
- the serialization format of the datacontexts
- the contexts to add the data to. If one or more contexts are supplied the method ignores contextual information in the actual data. If no contexts are supplied the contextual information in the input stream is used, if no context information is available the data is added without any context- Throws:
IOException
- if an I/O error occurred while reading from the input streamUnsupportedRDFormatException
- if no parser is available for the specified RDF formatRDFParseException
- if an error occurred while parsing the RDF dataRepositoryException
- if the data could not be added to the repository, for example because the repository is not writable
-
add
public void add(InputStream in, String baseURI, RDFFormat dataFormat, JSONObject attributes, Resource... contexts) throws IOException, RDFParseException, RepositoryException Adds RDF data from an InputStream to the repository, optionally to one or more named contexts.- Parameters:
in
- an InputStream from which RDF data can be readbaseURI
- the base URI against which any relative URIs in the data are resolveddataFormat
- the serialization format of the dataattributes
- a JSONObject of attribute bindings that will be added to each statement imported from `in'. For RDFFormats that support the specification of attributes (like NQX) these attributes will be applied to statements that do not already specify attributescontexts
- the contexts to add the data to. If one or more contexts are supplied the method ignores contextual information in the actual data. If no contexts are supplied the contextual information in the input stream is used, if no context information is available the data is added without any context- Throws:
IOException
- if an I/O error occurred while reading from the input streamUnsupportedRDFormatException
- if no parser is available for the specified RDF formatRDFParseException
- if an error occurred while parsing the RDF dataRepositoryException
- if the data could not be added to the repository, for example because the repository is not writable
-
add
public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException Adds RDF data from a Reader to the repository, optionally to one or more named contexts. Note: using a Reader to upload byte-based data means that you have to be careful not to destroy the data's character encoding by enforcing a default character encoding upon the bytes. If possible, adding such data using an InputStream is to be preferred.- Specified by:
add
in interfaceRepositoryConnection
- Overrides:
add
in classAbstractRepositoryConnection
- Parameters:
reader
- a Reader from which RDF data can be readbaseURI
- the base URI against which any relative URIs in the data are resolveddataFormat
- the serialization format of the datacontexts
- he contexts to add the data to. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself- Throws:
IOException
- if an I/O error occurred while reading from the readerUnsupportedRDFormatException
- if no parser is available for the specified RDF formatRDFParseException
- if an error occurred while parsing the RDF dataRepositoryException
- if the data could not be added to the repository, for example because the repository is not writable
-
add
public void add(Reader reader, String baseURI, RDFFormat dataFormat, JSONObject attributes, Resource... contexts) throws IOException, RDFParseException, RepositoryException Adds RDF data from a Reader to the repository, optionally to one or more named contexts. Note: using a Reader to upload byte-based data means that you have to be careful not to destroy the data's character encoding by enforcing a default character encoding upon the bytes. If possible, adding such data using an InputStream is to be preferred.- Parameters:
reader
- a Reader from which RDF data can be readbaseURI
- the base URI against which any relative URIs in the data are resolveddataFormat
- the serialization format of the dataattributes
- a JSONObject of attribute bindings that will be added to each statement imported from `reader'. For RDFFormats that support the specification of attributes (like NQX) these attributes will be applied to statements that do not already specify attributescontexts
- the contexts to add the data to. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself- Throws:
IOException
- if an I/O error occurred while reading from the readerUnsupportedRDFormatException
- if no parser is available for the specified RDF formatRDFParseException
- if an error occurred while parsing the RDF dataRepositoryException
- if the data could not be added to the repository, for example because the repository is not writable
-
add
public void add(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException Adds a statement with the specified subject, predicate and object to this repository, optionally to one or more named contexts.- Specified by:
add
in interfaceRepositoryConnection
- Overrides:
add
in classAbstractRepositoryConnection
- Parameters:
subject
- the statement's subjectpredicate
- the statement's predicateobject
- the statement's objectcontexts
- the contexts to add the data to. Note that this parameter is a vararg and as such is optional. If the data contains no context, it is added to the default context. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself- Throws:
RepositoryException
- if the data could not be added to the repository, for example because the repository is not writable
-
add
public void add(Resource subject, IRI predicate, Value object, JSONObject attributes, Resource... contexts) throws RepositoryException - Throws:
RepositoryException
-
remove
public void remove(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException Removes the statement(s) with the specified subject, predicate and object from the repository, optionally restricted to the specified contexts.- Specified by:
remove
in interfaceRepositoryConnection
- Overrides:
remove
in classAbstractRepositoryConnection
- Parameters:
subject
- the statement's subject, ornull
for a wildcardpredicate
- the statement's predicate, ornull
for a wildcardobject
- the statement's object, ornull
for a wildcardcontexts
- the context(s) to remove the data from. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository- Throws:
RepositoryException
- if the statement(s) could not be removed from the repository, for example because the repository is not writable
-
remove
- Specified by:
remove
in interfaceRepositoryConnection
- Overrides:
remove
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
add
- Specified by:
add
in interfaceRepositoryConnection
- Overrides:
add
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
add
public void add(Statement st, JSONObject attributes, Resource... contexts) throws RepositoryException - Throws:
RepositoryException
-
remove
public void remove(Iterable<? extends Statement> statements, Resource... contexts) throws RepositoryException - Specified by:
remove
in interfaceRepositoryConnection
- Overrides:
remove
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
remove
public void remove(CloseableIteration<? extends Statement> statements, Resource... contexts) throws RepositoryException - Specified by:
remove
in interfaceRepositoryConnection
- Overrides:
remove
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
isAutoCommit
Deprecated.since release 2.7.0. Use isActive() instead.- Specified by:
isAutoCommit
in interfaceRepositoryConnection
- Overrides:
isAutoCommit
in classAbstractRepositoryConnection
- Throws:
RepositoryException
- See Also:
-
setAutoCommit
Deprecated.As of release 2.7.0, use begin() instead.Setting autoCommit to false creates a dedicated server session which supports ACID transactions. Setting to true will create a dedicated server session.See session overview and POST session for more details.
Starting a session causes http requests to use a new port, which may cause an exception if the client can not access it. See Session Port Setup.
- Specified by:
setAutoCommit
in interfaceRepositoryConnection
- Overrides:
setAutoCommit
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
getXAResource
- Returns:
- an XAResource suitable for passing to a transaction manager to allow this connection to participate in an XA/2PC distributed transaction.
-
prepareCommit
Asks the server to prepare a commit for later finalization/rollback.- Parameters:
xid
- The transaction id to assign to the prepared commit
-
commit
Commit the current transaction. See session overview and POST commit for more details.- Specified by:
commit
in interfaceRepositoryConnection
- Throws:
RepositoryException
-
commit
Finalize a previously prepared two phase commit (2PC).- Parameters:
xid
- The XID of the prepared transaction to be finalized
-
commit
Commit the current transaction.See session overview and POST commit for more details.
- Parameters:
transactionSettings
- Distributed transaction settings to be used by this commit.- Throws:
RepositoryException
-
rollback
Roll back the current transaction (discard all changes made since last commit). See session overview and POST rollback for more details.- Specified by:
rollback
in interfaceRepositoryConnection
- Throws:
RepositoryException
-
rollback
Aborts a previously prepared commit.- Parameters:
xid
- The transaction id of the prepared commit to abort.
-
getPreparedTransactions
- Returns:
- an array of Xids of commits that have been prepared on the server.
- Throws:
DecoderException
- if the response from the server is invalid.
-
isStreamResults
public boolean isStreamResults()If true, automatically useAGStreamTupleQuery
. Default is false.- Returns:
- boolean the value of the
streamResults
parameter - See Also:
-
setStreamResults
public void setStreamResults(boolean streamResults) Set to true to automatically useAGStreamTupleQuery
forprepareTupleQuery(QueryLanguage, String, String)
.- Parameters:
streamResults
- new setting for the streamResults parameter- See Also:
-
clearNamespaces
- Specified by:
clearNamespaces
in interfaceRepositoryConnection
- Throws:
RepositoryException
-
close
Closes the session if there is one started. See session overview and POST close for more details.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceRepositoryConnection
- Overrides:
close
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
exportStatements
public void exportStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts) throws RDFHandlerException, RepositoryException - Specified by:
exportStatements
in interfaceRepositoryConnection
- Throws:
RDFHandlerException
RepositoryException
-
exportStatements
public void exportStatements(RDFHandler handler, String... ids) throws RDFHandlerException, RepositoryException -
getContextIDs
- Specified by:
getContextIDs
in interfaceRepositoryConnection
- Throws:
RepositoryException
-
createRepositoryResult
Creates a RepositoryResult for the supplied element set.- Type Parameters:
E
- the class of elements in the set- Parameters:
elements
- the set of elements- Returns:
- RepositoryResult the set of elements as a RepositoryResult
-
getNamespace
- Specified by:
getNamespace
in interfaceRepositoryConnection
- Specified by:
getNamespace
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
getNamespaces
- Specified by:
getNamespaces
in interfaceRepositoryConnection
- Throws:
RepositoryException
-
getQueryOption
Gets the value of the query option.- Parameters:
name
- a query option name- Returns:
- the
String
value for the given query option ornull
if query option is not set - Throws:
RepositoryException
- if the query options API is not supported by the server or the query option name is unknown
-
getQueryOptions
Gets a set of all currently set query options.- Returns:
- a
Map<String, String>
from query option names to values - Throws:
RepositoryException
- if the query options API is not supported by the server
-
getStatements
public RepositoryResult<Statement> getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException - Specified by:
getStatements
in interfaceRepositoryConnection
- Throws:
RepositoryException
-
hasStatement
public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException - Specified by:
hasStatement
in interfaceRepositoryConnection
- Overrides:
hasStatement
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
downloadStatements
public void downloadStatements(File file, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException Downloads statements matching given pattern to a file.The output format is determined by the server.
- Parameters:
file
- Output path.subj
- Subject filter.pred
- Predicate filter.obj
- Object filter.includeInferred
- If true, inferred triples will be included in the result.contexts
- Optional list of graphs to export.- Throws:
AGHttpException
- .
-
downloadStatements
public void downloadStatements(String file, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException Downloads statements matching given pattern to a file.The output format is determined by the server.
- Parameters:
file
- Output path.subj
- Subject filter.pred
- Predicate filter.obj
- Object filter.includeInferred
- If true, inferred triples will be included in the result.contexts
- Optional list of graphs to export.- Throws:
AGHttpException
- .
-
downloadStatements
public void downloadStatements(File file, RDFFormat format, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException Downloads statements matching given pattern to a file.- Parameters:
file
- Output path.format
- Format to export the data in.subj
- Subject filter.pred
- Predicate filter.obj
- Object filter.includeInferred
- If true, inferred triples will be included in the result.contexts
- Optional list of graphs to export.- Throws:
AGHttpException
- .
-
downloadStatements
public void downloadStatements(String file, RDFFormat format, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException Downloads statements matching given pattern to a file.- Parameters:
file
- Output path.format
- Format to export the data in.subj
- Subject filter.pred
- Predicate filter.obj
- Object filter.includeInferred
- If true, inferred triples will be included in the result.contexts
- Optional list of graphs to export.- Throws:
AGHttpException
- .
-
downloadStatements
public void downloadStatements(File file, String mimeType, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException Downloads statements matching given pattern to a file.- Parameters:
file
- Output path.mimeType
- MIME type that will be requested from the server (output format).subj
- Subject filter.pred
- Predicate filter.obj
- Object filter.includeInferred
- If true, inferred triples will be included in the result.contexts
- Optional list of graphs to export.- Throws:
AGHttpException
- .
-
downloadStatements
public void downloadStatements(String file, String mimeType, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException Downloads statements matching given pattern to a file.- Parameters:
file
- Output path.mimeType
- MIME type that will be requested from the server (output format).subj
- Subject filter.pred
- Predicate filter.obj
- Object filter.includeInferred
- If true, inferred triples will be included in the result.contexts
- Optional list of graphs to export.- Throws:
AGHttpException
- .
-
streamStatements
public InputStream streamStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException Returns statements matching given pattern as an InputStream.The output format will be chosen by the server.
Note that it is important to close the returned stream, to avoid resource leaks.
- Parameters:
subj
- Subject filter.pred
- Predicate filter.obj
- Object filter.includeInferred
- If true, inferred triples will be included in the result.contexts
- Optional list of graphs to export.- Returns:
- An input stream containing response data. The caller MUST close this stream to release connection resources.
- Throws:
AGHttpException
- .
-
streamStatements
public InputStream streamStatements(String mimeType, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException Returns statements matching given pattern as an InputStream.Note that it is important to close the returned stream, to avoid resource leaks.
- Parameters:
mimeType
- MIME type that will be requested from the server (output format).subj
- Subject filter.pred
- Predicate filter.obj
- Object filter.includeInferred
- If true, inferred triples will be included in the result.contexts
- Optional list of graphs to export.- Returns:
- An input stream containing response data. The caller MUST close this stream to release connection resources.
- Throws:
AGHttpException
- .
-
streamStatements
public InputStream streamStatements(RDFFormat format, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException Returns statements matching given pattern as an InputStream.Note that it is important to close the returned stream, to avoid resource leaks.
- Parameters:
format
- Format to export the data in.subj
- Subject filter.pred
- Predicate filter.obj
- Object filter.includeInferred
- If true, inferred triples will be included in the result.contexts
- Optional list of graphs to export.- Returns:
- An input stream containing response data. The caller MUST close this stream to release connection resources.
- Throws:
AGHttpException
- .
-
getStatements
Returns statements having the specified ids.This api is subject to change. There is currently no natural way to obtain a statement's triple id from the java client; when that is possible, this api may change.
- Parameters:
ids
- Strings representing statement ids- Returns:
- the statements having the specified ids. The result object
is a
RepositoryResult
object, a lazy Iterator-like object containingStatement
s and optionally throwing aRepositoryException
when an error when a problem occurs during retrieval - Throws:
RepositoryException
- if there is an error with this request
-
downloadStatements
Downloads statements with given ids to a file.- Parameters:
file
- Output path.format
- Format to export the data in.ids
- Strings representing statement ids- Throws:
AGHttpException
- .
-
downloadStatements
Downloads statements with given ids to a file.- Parameters:
file
- Output path.format
- Format to export the data in.ids
- Strings representing statement ids- Throws:
AGHttpException
- .
-
downloadStatements
Downloads statements with given ids to a file.- Parameters:
file
- Output path.mimeType
- MIME type to be requested from the server. Use"*/*"
to let the server choose the output format.ids
- Strings representing statement ids- Throws:
AGHttpException
- .
-
downloadStatements
Downloads statements with given ids to a file.- Parameters:
file
- Output path.mimeType
- MIME type to be requested from the server. Use"*/*"
to let the server choose the output format.ids
- Strings representing statement ids- Throws:
AGHttpException
- .
-
streamStatements
Returns statements with given ids as an InputStream.Note that it is important to close the returned stream, to avoid resource leaks.
- Parameters:
format
- Format to export the data in.ids
- Strings representing statement ids- Returns:
- An input stream containing response data. The caller MUST close this stream to release connection resources.
- Throws:
AGHttpException
- .
-
streamStatements
Returns statements with given ids as an InputStream.Note that it is important to close the returned stream, to avoid resource leaks.
- Parameters:
mimeType
- MIME type to be requested from the server. Use"*/*"
to let the server choose the output format.ids
- Strings representing statement ids- Returns:
- An input stream containing response data. The caller MUST close this stream to release connection resources.
- Throws:
AGHttpException
- .
-
prepareQuery
Prepares aAGQuery
for evaluation on this repository. Note that the preferred way of preparing queries is to use the more specificprepareTupleQuery(QueryLanguage, String, String)
,prepareBooleanQuery(QueryLanguage, String, String)
, orprepareGraphQuery(QueryLanguage, String, String)
methods instead.- Specified by:
prepareQuery
in interfaceRepositoryConnection
- Throws:
UnsupportedOperationException
- if the method is not supported for the supplied query languageIllegalArgumentException
- if the query type (Tuple, Graph, Boolean) cannot be determined
-
prepareTupleQuery
- Specified by:
prepareTupleQuery
in interfaceRepositoryConnection
- Overrides:
prepareTupleQuery
in classAbstractRepositoryConnection
-
prepareTupleQuery
- Specified by:
prepareTupleQuery
in interfaceRepositoryConnection
-
prepareGraphQuery
- Specified by:
prepareGraphQuery
in interfaceRepositoryConnection
- Overrides:
prepareGraphQuery
in classAbstractRepositoryConnection
-
prepareGraphQuery
- Specified by:
prepareGraphQuery
in interfaceRepositoryConnection
-
prepareBooleanQuery
- Specified by:
prepareBooleanQuery
in interfaceRepositoryConnection
- Overrides:
prepareBooleanQuery
in classAbstractRepositoryConnection
-
prepareBooleanQuery
- Specified by:
prepareBooleanQuery
in interfaceRepositoryConnection
-
prepareUpdate
- Specified by:
prepareUpdate
in interfaceRepositoryConnection
-
prepareUpdate
- Specified by:
prepareUpdate
in interfaceRepositoryConnection
- Overrides:
prepareUpdate
in classAbstractRepositoryConnection
-
removeNamespace
- Specified by:
removeNamespace
in interfaceRepositoryConnection
- Throws:
RepositoryException
-
setNamespace
- Specified by:
setNamespace
in interfaceRepositoryConnection
- Specified by:
setNamespace
in classAbstractRepositoryConnection
- Throws:
RepositoryException
-
removeQueryOption
Removes the given query option's value. Does not throw an exception if the query option name is unknown.- Parameters:
name
- a query option name- Throws:
RepositoryException
-
setQueryOption
Sets query option given by name to the specified values.- Parameters:
name
- a query option namevalue
- a value for the given query option- Throws:
RepositoryException
- if the given query option name is unknown or the value didn't pass the validation
-
size
- Specified by:
size
in interfaceRepositoryConnection
- Throws:
RepositoryException
-
createFreetextIndex
public void createFreetextIndex(String indexName, AGFreetextIndexConfig config) throws RepositoryException Creates a freetext index with the given name and configuration.See documentation for freetext index parameters.
- Parameters:
indexName
- the index name to createconfig
- the index configuration- Throws:
RepositoryException
- if there is an error with this request- See Also:
-
deleteFreetextIndex
Deletes the freetext index of the specified name.- Parameters:
indexName
- the index to be deleted- Throws:
RepositoryException
- if there is an error with this request- See Also:
-
createFreetextIndex
@Deprecated public void createFreetextIndex(String name, IRI[] predicates) throws RepositoryException Deprecated.Registers a predicate for free text indexing. Once registered, the objects of data added to the repository having this predicate will be text indexed and searchable.- Parameters:
name
- of the index to createpredicates
- the predicates this index will operate on- Throws:
RepositoryException
- if there is an error with this request- See Also:
-
getFreetextPredicates
Deprecated.Gets the predicates that have been registered for text indexing.- Parameters:
index
- name of the index to lookup- Returns:
- String[] the predicates this index operates on
- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
getFreetextIndexConfig
public AGFreetextIndexConfig getFreetextIndexConfig(String indexName) throws RepositoryException, JSONException Gets the configuration of the specified free text index.- Parameters:
indexName
- name of the index- Returns:
AGFreetextIndexConfig
the configuration of the specified index- Throws:
RepositoryException
- if there is an error during the requestJSONException
- if there is a problem parsing the response to JSON
-
getFreetextIndices
Deprecated.Gets freetext indexes that have been created- Returns:
- String[] a list of freetext index names
- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
listFreetextIndices
Lists the freetext indices that have been defined for this repository.- Returns:
- List a list of freetext index names
- Throws:
RepositoryException
- if there is an error during the request
-
registerPredicateMapping
Registers a predicate mapping from the predicate to a primitive datatype. This can be useful in speeding up query performance and enabling range queries over datatypes.Once registered, the objects of any data added via this connection that have this predicate will be mapped to the primitive datatype.
For example, registering that predicate
<http://example.org/age>
is mapped toXSD.INT
and adding the triple:<http://example.org/Fred> <http://example.org/age> "24"
will result in the object being treated as"24"^^xsd:int
.See mapping overview and POST predicate mapping.
- Parameters:
predicate
- the predicate URIprimtype
- the datatype URI- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
deletePredicateMapping
Deletes any predicate mapping associated with the given predicate.See mapping overview and DELETE predicate mapping.
- Parameters:
predicate
- the predicate mapping to delete- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
getPredicateMappings
Gets the predicate mappings defined for this connection.See mapping overview and GET predicate mapping and the Lisp reference for the predicate-mapping function.
- Returns:
- String[] the predicate mappings that have been registered
- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
registerDatatypeMapping
Registers a datatype mapping from the datatype to a primitive datatype. This can be useful in speeding up query performance and enabling range queries over user datatypes.Once registered, the objects of any data added via this connection that have this datatype will be mapped to the primitive datatype.
For example, registering that datatype
<http://example.org/usertype>
is mapped toXSD.INT
and adding the triple:<http://example.org/Fred> <http://example.org/age> "24"^^<http://example.org/usertype>
will result in the object being treated as"24"^^xsd:int
.See mapping overview and POST type mapping.
- Parameters:
datatype
- the name of the datatype mapping to registerprimtype
- the primitive type of the new mapping- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
deleteDatatypeMapping
Deletes any datatype mapping associated with the given datatype.See mapping overview and DELETE type mapping.
- Parameters:
datatype
- the datatype mapping to delete- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
getDatatypeMappings
Gets the datatype mappings defined for this connection.See mapping overview and GET type mapping and the Lisp reference for the datatype-mapping function.
- Returns:
- String[] the datatype mappings that have been registered
- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
clearMappings
Deletes all user-defined predicate and datatype mappings for this connection, and reestablishes the automatic mappings for primitive datatypes.This is equivalent to clearMappings(false).
See mapping overview and DELETE all mapping for more details.
- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
clearMappings
Deletes all predicate and user-defined datatype mappings for this connection.When includeAutoEncodedPrimitiveTypes is true, also deletes the automatic mappings for primitive datatypes; this is rarely what you want to do, as it will cause range queries to perform much less efficiently than when encodings are used; this option can be useful for ensuring literal forms are preserved in the store (there can be precision loss when encoding some literals).
See mapping overview and DELETE all mapping for more details.
- Parameters:
includeAutoEncodedPrimitiveTypes
- true if auto-encoded primitive types should be cleared- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
clearAttributes
Deletes all attribute definitions from the repository.- Throws:
RepositoryException
- if there is an error during the request
-
addRules
Adds Prolog rules to be used on this connection.See Prolog Lisp documentation and Prolog functor registration.
Starts a session if one is not already started. See session overview for more details. Starting a session causes http requests to use a new port, which may cause an exception if the client can not access it. See Session Port Setup.
- Parameters:
rules
- a string of rule text- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
addRules
Adds Prolog rules to be used on this connection.See Prolog Lisp documentation and Prolog functor registration.
Starts a session if one is not already started. See session overview for more details. Starting a session causes http requests to use a new port, which may cause an exception if the client can not access it. See Session Port Setup.
- Parameters:
rulestream
- a stream of rule text- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
evalInServer
Evaluates a Lisp form on the server, and returns the result as a String.See HTTP POST eval.
- Parameters:
lispForm
- the Lisp form to evaluate- Returns:
- String the result of the evaluation
- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
evalInServer
Evaluates a Lisp form on the server, and returns the result as a String.See HTTP POST eval.
- Parameters:
stream
- the Lisp form to evaluate- Returns:
- the result in a String
- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
load
public void load(IRI source, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RepositoryException Instructs the server to fetch and load data from the specified URI.- Parameters:
source
- the URI to fetch and loadbaseURI
- the base URI for the source documentdataFormat
- the RDF data format for the source documentcontexts
- zero or more contexts into which data will be loaded- Throws:
RepositoryException
- if there is an error during the request
-
load
public void load(IRI source, String baseURI, RDFFormat dataFormat, JSONObject attributes, Resource... contexts) throws RepositoryException Instructs the server to fetch and load data from the specified URI.- Parameters:
source
- the URI to fetch and loadbaseURI
- the base URI for the source documentdataFormat
- the RDF data format for the source documentattributes
- a JSONObject of attribute bindings that will be added to each statement imported from `source'. For RDFFormats that support the specification of attributes (like NQX) these attributes will be applied to statements that do not already specify attributescontexts
- zero or more contexts into which data will be loaded- Throws:
RepositoryException
- if there is an error during the request
-
load
public void load(String absoluteServerPath, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RepositoryException Instructs the server to load data from the specified server-side path.- Parameters:
absoluteServerPath
- the path to the server-side source filebaseURI
- the base URI for the source documentdataFormat
- the RDF data format for the source documentcontexts
- zero or more contexts into which data will be loaded- Throws:
RepositoryException
- if there is an error during the request
-
load
public void load(String absoluteServerPath, String baseURI, RDFFormat dataFormat, JSONObject attributes, Resource... contexts) throws RepositoryException Instructs the server to load data from the specified server-side path.- Parameters:
absoluteServerPath
- the path to the server-side source filebaseURI
- the base URI for the source documentdataFormat
- the RDF data format for the source documentattributes
- a JSONObject of attribute bindings that will be added to each statement imported from `absoluteServerPath'. For RDFFormats that support the specification of attributes (like NQX) these attributes will be applied to statements that do not already specify attributescontexts
- zero or more contexts into which data will be loaded- Throws:
RepositoryException
- if there is an error during the request
-
ping
Instructs the server to extend the life of this connection's dedicated session, if it is using one. Sessions that are idle for more than the session lifetime will be terminated by the server.Note that this method is called automatically before the timeout expires.
See session overview and GET ping for more details.
- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
getGeoTypes
- Returns:
- String[] the geospatial types that have been registered
- Throws:
RepositoryException
- if there is an error during the request
-
registerCartesianType
public IRI registerCartesianType(float stripWidth, float xmin, float xmax, float ymin, float ymax) throws RepositoryException Registers a cartesian geospatial subtype.- Parameters:
stripWidth
- the strip width in some unitsxmin
- the minimum x rangeymin
- the minimum y rangexmax
- the maximum x rangeymax
- the maximum y range- Returns:
- URI the datatype encoding of this subtype
- Throws:
RepositoryException
- if there is an error during the request
-
registerSphericalType
public IRI registerSphericalType(float stripWidth, String unit, float latmin, float lonmin, float latmax, float lonmax) throws RepositoryException Registers a spherical geospatial subtype.- Parameters:
stripWidth
- the strip width in some unitsunit
- the distance unitstripWidth
is specified inlatmin
- the minimum latitude rangelonmin
- the minimum longitude rangelatmax
- the maximum latitude rangelonmax
- the maximum longitude range- Returns:
- URI the datatype encoding of this subtype
- Throws:
RepositoryException
- if there is an error during the request
-
registerSphericalType
- Throws:
RepositoryException
-
registerPolygon
Registers a polygon.- Parameters:
polygon
- the name of this polygonpoints
- a List of points describing the polygon- Throws:
RepositoryException
- if there is an error during the request
-
getStatementsInBox
public RepositoryResult<Statement> getStatementsInBox(IRI type, IRI predicate, float xmin, float xmax, float ymin, float ymax, int limit, boolean infer) throws RepositoryException - Throws:
RepositoryException
-
getStatementsInCircle
public RepositoryResult<Statement> getStatementsInCircle(IRI type, IRI predicate, float x, float y, float radius, int limit, boolean infer) throws RepositoryException - Throws:
RepositoryException
-
getGeoHaversine
public RepositoryResult<Statement> getGeoHaversine(IRI type, IRI predicate, float lat, float lon, float radius, String unit, int limit, boolean infer) throws RepositoryException - Throws:
RepositoryException
-
getStatementsInPolygon
public RepositoryResult<Statement> getStatementsInPolygon(IRI type, IRI predicate, IRI polygon, int limit, boolean infer) throws RepositoryException - Throws:
RepositoryException
-
registerSNAGenerator
public void registerSNAGenerator(String generator, List<IRI> objectOfs, List<IRI> subjectOfs, List<IRI> undirecteds, String query) throws RepositoryException See Social network analysis Lisp documentation and SNA generator registration.Starts a session if one is not already started. See session overview for more details. Starting a session causes http requests to use a new port, which may cause an exception if the client can not access it. See Session Port Setup.
- Parameters:
generator
- Generator nameobjectOfs
- a list of predicatessubjectOfs
- a list of predicatesundirecteds
- a list of predicatesquery
- a string representation of a select clause- Throws:
RepositoryException
- if there is an error during the request
-
registerSNANeighborMatrix
public void registerSNANeighborMatrix(String matrix, String generator, List<IRI> group, int depth) throws RepositoryException - Throws:
RepositoryException
-
listIndices
- Returns:
- a list of actively managed indices for this repository
-
listValidIndices
- Returns:
- a list of valid index types
-
addIndex
Adds the given index to the list of actively managed indices. This will take affect on the next commit.- Parameters:
type
- a valid index type- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
dropIndex
Drops the given index from the list of actively managed indices. This will take affect on the next commit.- Parameters:
type
- an actively managed index type- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
sendRDFTransaction
public void sendRDFTransaction(InputStream rdftransaction) throws RepositoryException, RDFParseException, IOException Executes an application/x-rdftransaction.This method is useful for bundling add/remove operations into a single request and minimizing round trips to the server.
Changes are committed iff the connection is in autoCommit mode. For increased throughput when sending multiple rdftransaction requests, consider using autoCommit=false and committing less frequently .
- Parameters:
rdftransaction
- a stream in application/x-rdftransaction format- Throws:
RepositoryException
- if there is an error during the requestRDFParseException
- if malformed data is encounteredIOException
- on errors reading from therdftransaction
stream
-
sendRDFTransaction
public void sendRDFTransaction(InputStream rdftransaction, JSONObject attributes) throws RepositoryException, RDFParseException, IOException send an RDFTransaction, including attributes.- Parameters:
rdftransaction
- a stream in application/x-rdftransaction formatattributes
- a JSONObject of attribute bindings that will be added to each triple imported from `rdftransaction'.- Throws:
RepositoryException
- if there is an error during the requestRDFParseException
- if malformed data is encounteredIOException
- on errors reading from therdftransaction
stream
-
registerEncodableNamespace
Registers an encodable namespace having the specified format.Registering an encodable namespace enables a more efficient encoding of URIs in a namespace, and generation of unique URIs for that namespace, because its URIs are declared to conform to a specified format; the namespace is thereby bounded in size, and encodable.
The namespace is any valid URIref, e.g.:
http://franz.com/ns0
The format is a string using a simplified regular expression syntax supporting character ranges and counts specifying the suffix portion of the URIs in the namespace, e.g:
[a-z][0-9]-[a-f]{3}
Generation of unique URIs
AGValueFactory.generateURI(String)
for the above namespace and format might yield an ID such as:http://franz.com/ns0@@a0-aaa
Note: "@@" is used to concatenate the namespace and id suffix to facilitate efficient recognition/encoding during parsing.
The format can be ambiguous (e.g., "[A-Z]{1,2}[B-C}{0,1}"). We will not check for ambiguity in this first version but can add this checking at a later time.
If the format corresponds to a namespace that is not encodable (it may be malformed, or perhaps it's too large to encode), an exception is thrown.
For more details, see Encoded IDs.
- Parameters:
namespace
- a valid namespace, a URI refformat
- a valid format for an encodable namespace- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
registerEncodableNamespaces
public void registerEncodableNamespaces(Iterable<? extends AGFormattedNamespace> formattedNamespaces) throws RepositoryException Registers multiple formatted namespaces in a single request.- Parameters:
formattedNamespaces
- an iterable collection of formatted namespaces- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
listEncodableNamespaces
- Returns:
- List a list of the registered encodable namespaces
- See Also:
-
unregisterEncodableNamespace
Unregisters the specified encodable namespace.- Parameters:
namespace
- the namespace to unregister- Throws:
RepositoryException
- if there is an error during the request- See Also:
-
callStoredProc
@Deprecated public Object callStoredProc(String functionName, String moduleName, Object... args) throws RepositoryException Deprecated.The stored proc feature and API are experimental, and subject to change in a future release.Invoke a stored procedure on the AllegroGraph server.The input arguments and the return value can be:
String
,Integer
, null, byte[], or Object[] orList
of these (can be nested).See also
prepareHttpRepoClient()
.callStoredProc
(functionName, moduleName, args)
- Parameters:
functionName
- stored proc lisp function, for example "addTwo"moduleName
- lisp FASL file name, for example "example.fasl"args
- arguments to the stored proc- Returns:
- return value of stored proc
- Throws:
AGCustomStoredProcException
- for errors from stored procRepositoryException
- Since:
- v4.2
-
getSessionLifetime
public int getSessionLifetime()Returns the lifetime for a dedicated session spawned by this connection.See also: Session overview.
- Returns:
- the session lifetime, in seconds
- See Also:
-
setSessionLifetime
public void setSessionLifetime(int lifetimeInSeconds) Sets the 'lifetime' for a dedicated session spawned by this connection. Seconds a session can be idle before being collected. If unset, the lifetime defaults to the value of DefaultSessionTimeout. If set, the value must not be larger than MaximumSessionTimeout. See Session directives in Server Configuration and Control for more information.Also see session overview and POST session for more details.
- Parameters:
lifetimeInSeconds
- the session lifetime, in seconds- See Also:
-
setSessionLoadInitFile
public void setSessionLoadInitFile(boolean loadInitFile) Sets the 'loadInitFile' flag for a dedicated session spawned by this connection. This method does not create a session.See also: Session overview.
- Parameters:
loadInitFile
- boolean determining if the init file is loaded into this session- See Also:
-
addSessionLoadScript
Adds a 'script' for a dedicated session spawned by this connection. This method does not create a session. May be called multiple times for different scripts. The script text must already be uploaded to the user.Scripts are server code that may be loaded during a session.
See also: Session overview.
- Parameters:
scriptName
- name of the script to be loaded- See Also:
-
getStoreID
Returns the store ID- Returns:
- The store ID
- Throws:
RepositoryException
- if there is an error during the request
-
enableTripleCache
Enables the spogi cache in this repository.Takes a size argument to set the size of the cache.
- Parameters:
size
- the size of the cache, in triples- Throws:
RepositoryException
- if there is an error during the request
-
getTripleCacheSize
Returns the size of the spogi cache.- Returns:
- the size of the spogi cache, in triples
- Throws:
RepositoryException
- if there is an error during the request
-
disableTripleCache
Disables the spogi triple cache.- Throws:
RepositoryException
- if there is an error during the request
-
getUploadCommitPeriod
Gets the commit period used within large add/load operations.- Returns:
- int the current upload commit period
- Throws:
RepositoryException
- if there is an error with this request- See Also:
-
setUploadCommitPeriod
Sets the commit period to use within large add/load operations.- Parameters:
period
- commit after this many statements- Throws:
RepositoryException
- if there is an error with this request- See Also:
-
optimizeIndices
Instruct the server to optimize the indices for this store.- Parameters:
wait
- a boolean, false for request to return immediatelylevel
- determines the work to be done. See the index documentation for an explanation of the different levels- Throws:
RepositoryException
- if there is an error with this request See the Index documentation for more details.
-
optimizeIndices
- Throws:
RepositoryException
-
getSpinFunction
- Parameters:
uri
- SPIN function identifier- Returns:
- String the SPIN function query text
- Since:
- v4.4
- See Also:
-
listSpinFunctions
- Returns:
- List currently defined SPIN functions
- Since:
- v4.4
- See Also:
-
putSpinFunction
- Parameters:
fn
- the SPIN function to add- Since:
- v4.4
- See Also:
-
deleteSpinFunction
- Parameters:
uri
- SPIN function identifier- Since:
- v4.4
- See Also:
-
getSpinMagicProperty
- Parameters:
uri
- SPIN magic property identifier- Returns:
- String describing the SPIN magic property
- Since:
- v4.4
- See Also:
-
listSpinMagicProperties
- Returns:
- List all defined SPIN magic properties
- Since:
- v4.4
- See Also:
-
deleteSpinMagicProperty
- Parameters:
uri
- SPIN magic property identifier- Since:
- v4.4
- See Also:
-
putSpinMagicProperty
- Parameters:
fn
- the SPIN magic property to add- Since:
- v4.4
- See Also:
-
deleteDuplicates
Deletes all duplicates from the store.The comparisonMode determines what will be deemed a "duplicate".
If comparisonMode is "spog", quad parts (s,p,o,g) will all be compared when looking for duplicates.
If comparisonMode is "spo", only the (s,p,o) parts will be compared; the same triple in different graphs will thus be deemed duplicates.
See also the protocol documentation for deleting duplicates
- Parameters:
comparisonMode
- method to determine what is a duplicate- Throws:
AGHttpException
- if there is an error with this requestRepositoryException
-
getDuplicateStatements
public RepositoryResult<Statement> getDuplicateStatements(String comparisonMode) throws RepositoryException Returns all duplicates from the store.The comparisonMode determines what will be deemed a "duplicate".
If comparisonMode is "spog", quad parts (s,p,o,g) will all be compared when looking for duplicates.
If comparisonMode is "spo", only the (s,p,o) parts will be compared; the same triple in different graphs will thus be deemed duplicates.
See also the protocol documentation for deleting duplicates
- Parameters:
comparisonMode
- method to determine what is a duplicate- Returns:
- RepositoryResult the duplicates that exist in the store
- Throws:
AGHttpException
- if there is an error with this requestRepositoryException
-
materialize
Materializes inferred statements (generates and adds them to the store).The materializer's configuration determines how statements are materialized.
- Parameters:
materializer
- the materializer to use- Returns:
- long the number of statements added
- Throws:
AGHttpException
- if there is an error with this requestRepositoryException
- See Also:
-
deleteMaterialized
Deletes materialized statements from the default graph.- Returns:
- the number of statements deleted
- Throws:
AGHttpException
- if there is an error with this requestRepositoryException
- See Also:
-
deleteMaterialized
Deletes materialized statements.- Parameters:
materializer
- Materializer parameters used to create the triples.- Returns:
- the number of statements deleted
- Throws:
AGHttpException
- if there is an error with this requestRepositoryException
- See Also:
-
deleteMaterialized
Deletes materialized statements from given graph.- Parameters:
inferredGraph
- Graph to delete the statements from. If null the default graph will be used.- Returns:
- the number of statements deleted
- Throws:
AGHttpException
- if there is an error with this requestRepositoryException
- See Also:
-
setMasqueradeAsUser
Sets the AG user for X-Masquerade-As-User requests.For AG superusers only. This allows AG superusers to run requests as another user in a dedicated session.
- Parameters:
user
- the user for X-Masquerade-As-User requests- Throws:
RepositoryException
- if there is an error with this request
-
begin
Begins a transaction requiringcommit()
orrollback()
to be called to end the transaction.- Specified by:
begin
in interfaceRepositoryConnection
- Throws:
RepositoryException
- if there is an error with this request- Since:
- 2.7.0
- See Also:
-
isActive
public boolean isActive()Indicates if a transaction is currently active on the connection. A transaction is active ifbegin()
has been called, and becomes inactive aftercommit()
orrollback()
has been called.- Specified by:
isActive
in interfaceRepositoryConnection
- Returns:
true
iff a transaction is active,false
iff no transaction is active.- Throws:
UnknownTransactionStateException
- if the transaction state can not be determined. This can happen for instance when communication with a repository fails or times out.RepositoryException
- if there is an error with this request- Since:
- 2.7.0
-
clear
Removes all statement(s) within the specified contexts.- Specified by:
clear
in interfaceRepositoryConnection
- Overrides:
clear
in classAbstractRepositoryConnection
- Parameters:
contexts
- the context(s) to remove the data from. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository- Throws:
RepositoryException
- if the statement(s) could not be removed from the repository, for example because the repository is not writable
-
deleteAttributeDefinition
Delete an existing triple attribute definition.- Parameters:
name
- The name of the defined attribute to delete- Throws:
RepositoryException
- if there is an error with this request
-
getAttributeDefinitions
Return a list of all attributes defined for the current connection.- Returns:
- JSONArray of Triple Attribute definitions
- Throws:
RepositoryException
- if there is an error with this requestJSONException
- if there is an error parsing the response to JSON
-
getAttributeDefinition
Return the definition of the attribute named by NAME.- Parameters:
name
- the attribute definition to lookup- Returns:
- JSONArray of all found definitions
- Throws:
RepositoryException
- if there is an error with this requestJSONException
- if there is an error parsing the response to JSON
-
getStaticAttributeFilter
Fetch the string representation of the static attribute filter defined on this repository- Returns:
- String, or null if no static filter is defined
- Throws:
RepositoryException
- if there is an error with this request
-
setStaticAttributeFilter
Establish a static attribute filter on the current repository.- Parameters:
filter
- a String representing a static attribute filter definition- Throws:
RepositoryException
- if there is an error with this request
-
deleteStaticAttributeFilter
Delete the static attribute filter defined on this repository.- Throws:
RepositoryException
- if there is an error with this request
-
getNDGeospatialDatatypeAutomation
Fetch the status of nD Geospatical Datatype Automation on this repository.- Returns:
- boolean, true if enabled, false if disabled
- Throws:
RepositoryException
- if there is an error with this request
-
enableNDGeospatialDatatypeAutomation
Enable nD Geospatical Datatype Automation on this repository.- Throws:
RepositoryException
- if there is an error with this request
-
disableNDGeospatialDatatypeAutomation
Disable nD Geospatical Datatype Automation on this repository.- Throws:
RepositoryException
- if there is an error with this request
-
getUserAttributes
-
setUserAttributes
-
setUserAttributes
-
setTransactionSettings
Configure distributed transaction behavior.- Parameters:
transactionSettings
- Distributed transaction settings.
-
transactionSettingsCtx
A 'context manager' for temporarily changing transaction settings.Use it in a try-with-resources block, like this:
try (Ctx ignored = conn.transactionSettingsCtx(newSettings)) { // Any explicit or implicit commits here will use new settings }
- Parameters:
transactionSettings
- New distributed transaction settings.- Returns:
- A closeable object that can be used in try-with-resources statement. When closed the object will restore old transaction settings.
-
setPool
Sets the connection pool this object will be returned to on close.Set to
null
to make close really shutdown the connection.- Parameters:
pool
- Connection pool.
-
defineAttribute
-
warmup
public void warmup()Asks the server to read store's internal data structures into memory. Usewarmup(WarmupConfig)
to specify which structures should be read. -
warmup
Asks the server to read store's internal data structures into memory.- Parameters:
config
- Config object that can be used to specify which structures should be read into memory. If this parameter isnull
then the choice will be left to the server.
-