public class AGRepositoryConnection extends AbstractRepositoryConnection implements RepositoryConnection, AutoCloseable
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.
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)
and getSessionLifetime()
setSessionLoadInitFile(boolean)
addSessionLoadScript(String)
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:
Modifier and Type | Class and Description |
---|---|
class |
AGRepositoryConnection.AttributeDefinition
Builder class for defining a new attribute definition.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ADD_STATEMENT_BUFFER_SIZE |
static String |
PROP_ADD_STATEMENT_BUFFER_MAX_SIZE |
static String |
PROP_STREAM_RESULTS |
static String |
PROP_USE_ADD_STATEMENT_BUFFER |
Constructor and Description |
---|
AGRepositoryConnection(AGRepository repository,
AGHttpRepoClient client) |
AGRepositoryConnection(AGVirtualRepository repository,
AGHttpRepoClient client) |
Modifier and Type | Method and Description |
---|---|
void |
add(File file,
String baseURI,
RDFFormat dataFormat,
org.json.JSONObject attributes,
Resource... contexts)
Adds RDF data from the specified file to a specific contexts in the
repository.
|
void |
add(File file,
String baseURI,
RDFFormat dataFormat,
Resource... contexts)
Adds RDF data from the specified file to a specific contexts in the
repository.
|
void |
add(InputStream in,
String baseURI,
RDFFormat dataFormat,
org.json.JSONObject attributes,
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,
Resource... contexts)
Adds RDF data from an InputStream to the repository, optionally to one or
more named contexts.
|
void |
add(Iterable<? extends Statement> statements,
org.json.JSONObject attributes,
Resource... contexts) |
void |
add(Iterable<? extends Statement> statements,
Resource... contexts) |
<E extends Exception> |
add(Iteration<? extends Statement,E> statementIter,
org.json.JSONObject attributes,
Resource... contexts) |
<E extends Exception> |
add(Iteration<? extends Statement,E> statementIter,
Resource... contexts) |
void |
add(Reader reader,
String baseURI,
RDFFormat dataFormat,
org.json.JSONObject attributes,
Resource... contexts)
Adds RDF data from a Reader to the repository, optionally to one or more
named contexts.
|
void |
add(Reader reader,
String baseURI,
RDFFormat dataFormat,
Resource... contexts)
Adds RDF data from a Reader to the repository, optionally to one or more
named contexts.
|
void |
add(Resource subject,
IRI predicate,
Value object,
org.json.JSONObject attributes,
Resource... contexts) |
void |
add(Resource subject,
IRI predicate,
Value object,
Resource... contexts)
Adds a statement with the specified subject, predicate and object to this
repository, optionally to one or more named contexts.
|
void |
add(Statement st,
org.json.JSONObject attributes,
Resource... contexts) |
void |
add(Statement st,
Resource... contexts) |
void |
add(URL url,
String baseURI,
RDFFormat dataFormat,
org.json.JSONObject attributes,
Resource... contexts)
Adds the RDF data that can be found at the specified URL to the
repository, optionally to one or more named contexts.
|
void |
add(URL url,
String baseURI,
RDFFormat dataFormat,
Resource... contexts)
Adds the RDF data that can be found at the specified URL to the
repository, optionally to one or more named contexts.
|
void |
addIndex(String type)
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 |
addRules(String rules)
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 requiring
commit() or rollback() to
be called to end the transaction. |
Object |
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 |
clear(Resource... contexts)
Removes all statement(s) within the specified contexts.
|
void |
clearAttributes()
Deletes all attribute definitions from the repository.
|
void |
clearMappings()
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 |
clearNamespaces() |
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 |
commit(Xid xid)
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.
|
void |
deleteAttributeDefinition(String name)
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 |
deleteMaterialized()
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 |
deleteSpinMagicProperty(String uri) |
void |
deleteStaticAttributeFilter()
Delete the static attribute filter defined on this repository.
|
void |
disableNDGeospatialDatatypeAutomation()
Disable nD Geospatical Datatype Automation on this repository.
|
void |
disableTripleCache()
Disables the spogi triple cache.
|
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(File file,
RDFFormat format,
String ids)
Downloads statements with given ids 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,
String mimeType,
Resource subj,
IRI pred,
Value obj,
boolean includeInferred,
Resource... contexts)
Downloads statements matching given pattern to a file.
|
void |
downloadStatements(File file,
String mimeType,
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 |
downloadStatements(String file,
RDFFormat format,
String ids)
Downloads statements with given ids 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,
String mimeType,
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 |
dropIndex(String type)
Drops the given index from the list of actively managed indices.
|
void |
enableNDGeospatialDatatypeAutomation()
Enable nD Geospatical Datatype Automation on this repository.
|
void |
enableTripleCache(long size)
Enables the spogi cache in this repository.
|
String |
evalInServer(InputStream stream)
Evaluates a Lisp form on the server, and returns the result as a String.
|
String |
evalInServer(String lispForm)
Evaluates a Lisp form on the server, and returns the result as a String.
|
void |
exportStatements(RDFHandler handler,
String... ids) |
void |
exportStatements(Resource subj,
IRI pred,
Value obj,
boolean includeInferred,
RDFHandler handler,
Resource... contexts) |
int |
getAddStatementBufferMaxSize() |
org.json.JSONArray |
getAttributeDefinition(String name)
Return the definition of the attribute named by NAME.
|
org.json.JSONArray |
getAttributeDefinitions()
Return a list of all attributes defined for the current connection.
|
RepositoryResult<Resource> |
getContextIDs() |
String[] |
getDatatypeMappings()
Gets the datatype mappings defined for this connection.
|
RepositoryResult<Statement> |
getDuplicateStatements(String comparisonMode)
Returns all duplicates from the store.
|
AGFreetextIndexConfig |
getFreetextIndexConfig(String indexName)
Gets the configuration of the specified free text index.
|
String[] |
getFreetextIndices()
Deprecated.
|
String[] |
getFreetextPredicates(String index)
Deprecated.
|
RepositoryResult<Statement> |
getGeoHaversine(IRI type,
IRI predicate,
float lat,
float lon,
float radius,
String unit,
int limit,
boolean infer) |
String[] |
getGeoTypes() |
String |
getNamespace(String prefix) |
RepositoryResult<Namespace> |
getNamespaces() |
boolean |
getNDGeospatialDatatypeAutomation()
Fetch the status of nD Geospatical Datatype Automation on this repository.
|
int |
getNumBufferedAddStatements() |
String[] |
getPredicateMappings()
Gets the predicate mappings defined for this connection.
|
Xid[] |
getPreparedTransactions() |
String |
getQueryOption(String name)
Gets the value of the query option.
|
Map<String,String> |
getQueryOptions()
Gets a set of all currently set query options.
|
AGAbstractRepository |
getRepository() |
AGServer |
getServer() |
int |
getSessionLifetime()
Returns the lifetime for a dedicated session spawned by this connection.
|
String |
getSpinFunction(String uri) |
String |
getSpinMagicProperty(String uri) |
RepositoryResult<Statement> |
getStatements(Resource subj,
IRI pred,
Value obj,
boolean includeInferred,
Resource... contexts) |
RepositoryResult<Statement> |
getStatements(String... ids)
Returns statements having the specified ids.
|
RepositoryResult<Statement> |
getStatementsInBox(IRI type,
IRI predicate,
float xmin,
float xmax,
float ymin,
float ymax,
int limit,
boolean infer) |
RepositoryResult<Statement> |
getStatementsInCircle(IRI type,
IRI predicate,
float x,
float y,
float radius,
int limit,
boolean infer) |
RepositoryResult<Statement> |
getStatementsInPolygon(IRI type,
IRI predicate,
IRI polygon,
int limit,
boolean infer) |
String |
getStaticAttributeFilter()
Fetch the string representation of the static attribute filter defined on this
repository
|
long |
getStoreID()
Returns the store ID
|
long |
getTripleCacheSize()
Returns the size of the spogi cache.
|
int |
getUploadCommitPeriod()
Gets the commit period used within large add/load operations.
|
String |
getUserAttributes() |
AGValueFactory |
getValueFactory() |
XAResource |
getXAResource() |
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 |
isAddStatementBufferEnabled() |
boolean |
isAutoCommit()
Deprecated.
since release 2.7.0. Use isActive() instead.
|
boolean |
isStreamResults()
If true, automatically use
AGStreamTupleQuery . |
boolean |
isUseAddStatementBuffer() |
List<AGFormattedNamespace> |
listEncodableNamespaces()
Returns a list of the registered encodable namespaces.
|
List<String> |
listFreetextIndices()
Lists the freetext indices that have been defined for this repository.
|
List<String> |
listIndices()
Returns a list of actively managed indices for this repository.
|
List<AGSpinFunction> |
listSpinFunctions() |
List<AGSpinMagicProperty> |
listSpinMagicProperties() |
List<String> |
listValidIndices()
Returns a list of all possible index types for this repository.
|
void |
load(IRI source,
String baseURI,
RDFFormat dataFormat,
org.json.JSONObject attributes,
Resource... contexts)
Instructs the server to fetch and load data from the specified URI.
|
void |
load(IRI source,
String baseURI,
RDFFormat dataFormat,
Resource... contexts)
Instructs the server to fetch and load data from the specified URI.
|
void |
load(String absoluteServerPath,
String baseURI,
RDFFormat dataFormat,
org.json.JSONObject attributes,
Resource... contexts)
Instructs the server to load data from the specified server-side path.
|
void |
load(String absoluteServerPath,
String baseURI,
RDFFormat dataFormat,
Resource... contexts)
Instructs the server to load data from the specified server-side path.
|
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.
|
AGBooleanQuery |
prepareBooleanQuery(QueryLanguage ql,
String queryString) |
AGBooleanQuery |
prepareBooleanQuery(QueryLanguage ql,
String queryString,
String baseURI) |
void |
prepareCommit(Xid xid)
Asks the server to prepare a commit for later finalization/rollback.
|
AGGraphQuery |
prepareGraphQuery(QueryLanguage ql,
String queryString) |
AGGraphQuery |
prepareGraphQuery(QueryLanguage ql,
String queryString,
String baseURI) |
AGHttpRepoClient |
prepareHttpRepoClient()
This is the method to call, in this or other classes, if you want to do HTTP interaction with the repository.
|
AGQuery |
prepareQuery(QueryLanguage ql,
String queryString,
String baseURI)
Prepares a
AGQuery for evaluation on this repository. |
AGTupleQuery |
prepareTupleQuery(QueryLanguage ql,
String queryString) |
AGTupleQuery |
prepareTupleQuery(QueryLanguage ql,
String queryString,
String baseURI) |
AGUpdate |
prepareUpdate(QueryLanguage ql,
String queryString) |
AGUpdate |
prepareUpdate(QueryLanguage ql,
String queryString,
String baseURI) |
void |
putSpinFunction(AGSpinFunction fn) |
void |
putSpinMagicProperty(AGSpinMagicProperty fn) |
IRI |
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) |
IRI |
registerSphericalType(float stripWidth,
String unit) |
IRI |
registerSphericalType(float stripWidth,
String unit,
float latmin,
float lonmin,
float latmax,
float lonmax)
Registers a spherical geospatial subtype.
|
void |
remove(Iterable<? extends Statement> statements,
Resource... contexts) |
<E extends Exception> |
remove(Iteration<? extends Statement,E> statements,
Resource... contexts) |
void |
remove(Resource subject,
IRI predicate,
Value object,
Resource... contexts)
Removes the statement(s) with the specified subject, predicate and object
from the repository, optionally restricted to the specified contexts.
|
void |
remove(Statement st,
Resource... contexts) |
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 |
rollback(Xid xid)
Aborts a previously prepared commit.
|
void |
sendRDFTransaction(InputStream rdftransaction)
Executes an application/x-rdftransaction.
|
void |
sendRDFTransaction(InputStream rdftransaction,
org.json.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 use
AGStreamTupleQuery
for prepareTupleQuery(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(org.json.JSONObject value) |
void |
setUserAttributes(String value) |
long |
size(Resource... contexts) |
InputStream |
streamStatements(RDFFormat format,
Resource subj,
IRI pred,
Value obj,
boolean includeInferred,
Resource... contexts)
Returns statements matching given pattern as an InputStream.
|
InputStream |
streamStatements(RDFFormat format,
String... ids)
Returns statements with given ids as an InputStream.
|
InputStream |
streamStatements(Resource subj,
IRI pred,
Value obj,
boolean includeInferred,
Resource... contexts)
Returns statements matching given pattern as an InputStream.
|
InputStream |
streamStatements(String mimeType,
Resource subj,
IRI pred,
Value obj,
boolean includeInferred,
Resource... contexts)
Returns statements matching given pattern as an InputStream.
|
InputStream |
streamStatements(String mimeType,
String... ids)
Returns statements with given ids as an InputStream.
|
String |
toString() |
Ctx |
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.
|
begin, export, getIsolationLevel, getParserConfig, hasStatement, isEmpty, isOpen, prepareQuery, setIsolationLevel, setParserConfig
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, begin, export, getIsolationLevel, getParserConfig, getStatements, getStatements, hasStatement, hasStatement, isEmpty, isOpen, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareQuery, prepareTupleQuery, prepareUpdate, remove, setIsolationLevel, setParserConfig
public static final String PROP_STREAM_RESULTS
public static final String PROP_USE_ADD_STATEMENT_BUFFER
public static final String PROP_ADD_STATEMENT_BUFFER_MAX_SIZE
public static final int DEFAULT_ADD_STATEMENT_BUFFER_SIZE
public AGRepositoryConnection(AGRepository repository, AGHttpRepoClient client)
repository
- a repository nameclient
- the HTTP client through which requests on this connection will be madeAGRepository.getConnection()
,
AGVirtualRepository.getConnection()
public AGRepositoryConnection(AGVirtualRepository repository, AGHttpRepoClient client)
public AGAbstractRepository getRepository()
getRepository
in interface RepositoryConnection
getRepository
in class AbstractRepositoryConnection
public AGServer getServer()
public AGHttpRepoClient prepareHttpRepoClient()
public boolean isAddStatementBufferEnabled()
PROP_USE_ADD_STATEMENT_BUFFER
property
or a call to setAddStatementBufferEnabled
).public void setAddStatementBufferEnabled(boolean enabled)
The buffer can also be enabled by setting property PROP_USE_ADD_STATEMENT_BUFFER
.
enabled
- whether to enable bufferingpublic boolean isUseAddStatementBuffer()
public int getAddStatementBufferMaxSize()
public void setAddStatementBufferMaxSize(int size)
This size can also be set by using property PROP_ADD_STATEMENT_BUFFER_MAX_SIZE
.
size
- new maximum buffer sizepublic int getNumBufferedAddStatements()
public AGValueFactory getValueFactory()
getValueFactory
in interface RepositoryConnection
getValueFactory
in class AbstractRepositoryConnection
public void add(Iterable<? extends Statement> statements, Resource... contexts) throws RepositoryException
add
in interface RepositoryConnection
add
in class AbstractRepositoryConnection
RepositoryException
public void add(Iterable<? extends Statement> statements, org.json.JSONObject attributes, Resource... contexts) throws RepositoryException
RepositoryException
public <E extends Exception> void add(Iteration<? extends Statement,E> statementIter, Resource... contexts) throws RepositoryException, E extends Exception
add
in interface RepositoryConnection
add
in class AbstractRepositoryConnection
RepositoryException
E extends Exception
public <E extends Exception> void add(Iteration<? extends Statement,E> statementIter, org.json.JSONObject attributes, Resource... contexts) throws RepositoryException, E extends Exception
RepositoryException
E extends Exception
public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException
add
in interface RepositoryConnection
add
in class AbstractRepositoryConnection
file
- a file containing RDF databaseURI
- the base URI against which any relative URIs in the data are
resolved. This defaults to the value of
file.toURI()
if the value is set to
null
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 itselfIOException
- 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 writablepublic void add(File file, String baseURI, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws IOException, RDFParseException, RepositoryException
file
- a file containing RDF databaseURI
- the base URI against which any relative URIs in the data are
resolved. This defaults to the value of
file.toURI()
if the value is set to
null
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 itselfIOException
- 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 writablepublic void add(URL url, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException
add
in interface RepositoryConnection
add
in class AbstractRepositoryConnection
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 of url.toExternalForm()
if the value is
set to null
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 itselfIOException
- 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 writablepublic void add(URL url, String baseURI, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws IOException, RDFParseException, RepositoryException
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 of url.toExternalForm()
if the value is
set to null
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 itselfIOException
- 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 writablepublic void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException
add
in interface RepositoryConnection
add
in class AbstractRepositoryConnection
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 contextIOException
- 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 writablepublic void add(InputStream in, String baseURI, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws IOException, RDFParseException, RepositoryException
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 contextIOException
- 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 writablepublic void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException
add
in interface RepositoryConnection
add
in class AbstractRepositoryConnection
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 itselfIOException
- 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 writablepublic void add(Reader reader, String baseURI, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws IOException, RDFParseException, RepositoryException
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 itselfIOException
- 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 writablepublic void add(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException
add
in interface RepositoryConnection
add
in class AbstractRepositoryConnection
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 itselfRepositoryException
- if the data could not be added to the repository, for example
because the repository is not writablepublic void add(Resource subject, IRI predicate, Value object, org.json.JSONObject attributes, Resource... contexts) throws RepositoryException
RepositoryException
public void remove(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException
remove
in interface RepositoryConnection
remove
in class AbstractRepositoryConnection
subject
- the statement's subject, or null
for a wildcardpredicate
- the statement's predicate, or null
for a wildcardobject
- the statement's object, or null
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 repositoryRepositoryException
- if the statement(s) could not be removed from the repository, for
example because the repository is not writablepublic void remove(Statement st, Resource... contexts) throws RepositoryException
remove
in interface RepositoryConnection
remove
in class AbstractRepositoryConnection
RepositoryException
public void add(Statement st, Resource... contexts) throws RepositoryException
add
in interface RepositoryConnection
add
in class AbstractRepositoryConnection
RepositoryException
public void add(Statement st, org.json.JSONObject attributes, Resource... contexts) throws RepositoryException
RepositoryException
public void remove(Iterable<? extends Statement> statements, Resource... contexts) throws RepositoryException
remove
in interface RepositoryConnection
remove
in class AbstractRepositoryConnection
RepositoryException
public <E extends Exception> void remove(Iteration<? extends Statement,E> statements, Resource... contexts) throws RepositoryException, E extends Exception
remove
in interface RepositoryConnection
remove
in class AbstractRepositoryConnection
RepositoryException
E extends Exception
public boolean isAutoCommit() throws RepositoryException
isAutoCommit
in interface RepositoryConnection
isAutoCommit
in class AbstractRepositoryConnection
RepositoryException
setAutoCommit(boolean)
public void setAutoCommit(boolean autoCommit) throws RepositoryException
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.
setAutoCommit
in interface RepositoryConnection
setAutoCommit
in class AbstractRepositoryConnection
RepositoryException
public XAResource getXAResource()
public void prepareCommit(Xid xid)
xid
- The transaction id to assign to the prepared commitpublic void commit() throws RepositoryException
commit
in interface RepositoryConnection
RepositoryException
public void commit(Xid xid)
xid
- The XID of the prepared transaction to be finalizedpublic void commit(TransactionSettings transactionSettings) throws RepositoryException
See session overview and POST commit for more details.
transactionSettings
- Distributed transaction settings to be used by this commit.RepositoryException
public void rollback() throws RepositoryException
rollback
in interface RepositoryConnection
RepositoryException
public void rollback(Xid xid)
xid
- The transaction id of the prepared commit to abort.public Xid[] getPreparedTransactions() throws org.apache.commons.codec.DecoderException
org.apache.commons.codec.DecoderException
- if the response from the server is invalid.public boolean isStreamResults()
AGStreamTupleQuery
.
Default is false.streamResults
parametersetStreamResults(boolean)
public void setStreamResults(boolean streamResults)
AGStreamTupleQuery
for prepareTupleQuery(QueryLanguage, String, String)
.streamResults
- new setting for the streamResults parameterisStreamResults()
public void clearNamespaces() throws RepositoryException
clearNamespaces
in interface RepositoryConnection
RepositoryException
public void close() throws RepositoryException
close
in interface AutoCloseable
close
in interface RepositoryConnection
close
in class AbstractRepositoryConnection
RepositoryException
public void exportStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts) throws RDFHandlerException, RepositoryException
exportStatements
in interface RepositoryConnection
RDFHandlerException
RepositoryException
public void exportStatements(RDFHandler handler, String... ids) throws RDFHandlerException, RepositoryException
public RepositoryResult<Resource> getContextIDs() throws RepositoryException
getContextIDs
in interface RepositoryConnection
RepositoryException
public <E> RepositoryResult<E> createRepositoryResult(Iterable<? extends E> elements)
E
- the class of elements in the setelements
- the set of elementspublic String getNamespace(String prefix) throws RepositoryException
getNamespace
in interface RepositoryConnection
RepositoryException
public RepositoryResult<Namespace> getNamespaces() throws RepositoryException
getNamespaces
in interface RepositoryConnection
RepositoryException
public String getQueryOption(String name) throws RepositoryException
name
- a query option nameString
value for the given query option or
null
if query option is not setRepositoryException
- if the query options API is not
supported by the server or the
query option name is unknownpublic Map<String,String> getQueryOptions() throws RepositoryException
Map<String, String>
from query option names to valuesRepositoryException
- if the query options API is not
supported by the serverpublic RepositoryResult<Statement> getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException
getStatements
in interface RepositoryConnection
RepositoryException
public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException
hasStatement
in interface RepositoryConnection
hasStatement
in class AbstractRepositoryConnection
RepositoryException
public void downloadStatements(File file, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException
The output format is determined by the server.
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.AGHttpException
- .public void downloadStatements(String file, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException
The output format is determined by the server.
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.AGHttpException
- .public void downloadStatements(File file, RDFFormat format, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException
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.AGHttpException
- .public void downloadStatements(String file, RDFFormat format, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException
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.AGHttpException
- .public void downloadStatements(File file, String mimeType, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException
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.AGHttpException
- .public void downloadStatements(String file, String mimeType, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException
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.AGHttpException
- .public InputStream streamStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException
The output format will be chosen by the server.
Note that it is important to close the returned stream, to avoid resource leaks.
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.AGHttpException
- .public InputStream streamStatements(String mimeType, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException
Note that it is important to close the returned stream, to avoid resource leaks.
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.AGHttpException
- .public InputStream streamStatements(RDFFormat format, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws AGHttpException
Note that it is important to close the returned stream, to avoid resource leaks.
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.AGHttpException
- .public RepositoryResult<Statement> getStatements(String... ids) throws RepositoryException
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.
ids
- Strings representing statement idsRepositoryResult
object, a lazy Iterator-like object
containing Statement
s and optionally throwing a
RepositoryException
when an error when a problem occurs
during retrievalRepositoryException
- if there is an error with this requestpublic void downloadStatements(File file, RDFFormat format, String ids) throws AGHttpException
file
- Output path.format
- Format to export the data in.ids
- Strings representing statement idsAGHttpException
- .public void downloadStatements(String file, RDFFormat format, String ids) throws AGHttpException
file
- Output path.format
- Format to export the data in.ids
- Strings representing statement idsAGHttpException
- .public void downloadStatements(File file, String mimeType, String ids) throws AGHttpException
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 idsAGHttpException
- .public void downloadStatements(String file, String mimeType, String ids) throws AGHttpException
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 idsAGHttpException
- .public InputStream streamStatements(RDFFormat format, String... ids) throws AGHttpException
Note that it is important to close the returned stream, to avoid resource leaks.
format
- Format to export the data in.ids
- Strings representing statement idsAGHttpException
- .public InputStream streamStatements(String mimeType, String... ids) throws AGHttpException
Note that it is important to close the returned stream, to avoid resource leaks.
mimeType
- MIME type to be requested from the server.
Use "*/*"
to let the server choose
the output format.ids
- Strings representing statement idsAGHttpException
- .public AGQuery prepareQuery(QueryLanguage ql, String queryString, String baseURI)
AGQuery
for evaluation on this repository. Note
that the preferred way of preparing queries is to use the more specific
prepareTupleQuery(QueryLanguage, String, String)
,
prepareBooleanQuery(QueryLanguage, String, String)
, or
prepareGraphQuery(QueryLanguage, String, String)
methods instead.prepareQuery
in interface RepositoryConnection
UnsupportedOperationException
- if the method is not supported for the supplied query languageIllegalArgumentException
- if the query type (Tuple, Graph, Boolean) cannot be determinedpublic AGTupleQuery prepareTupleQuery(QueryLanguage ql, String queryString)
prepareTupleQuery
in interface RepositoryConnection
prepareTupleQuery
in class AbstractRepositoryConnection
public AGTupleQuery prepareTupleQuery(QueryLanguage ql, String queryString, String baseURI)
prepareTupleQuery
in interface RepositoryConnection
public AGGraphQuery prepareGraphQuery(QueryLanguage ql, String queryString)
prepareGraphQuery
in interface RepositoryConnection
prepareGraphQuery
in class AbstractRepositoryConnection
public AGGraphQuery prepareGraphQuery(QueryLanguage ql, String queryString, String baseURI)
prepareGraphQuery
in interface RepositoryConnection
public AGBooleanQuery prepareBooleanQuery(QueryLanguage ql, String queryString)
prepareBooleanQuery
in interface RepositoryConnection
prepareBooleanQuery
in class AbstractRepositoryConnection
public AGBooleanQuery prepareBooleanQuery(QueryLanguage ql, String queryString, String baseURI)
prepareBooleanQuery
in interface RepositoryConnection
public AGUpdate prepareUpdate(QueryLanguage ql, String queryString, String baseURI)
prepareUpdate
in interface RepositoryConnection
public AGUpdate prepareUpdate(QueryLanguage ql, String queryString)
prepareUpdate
in interface RepositoryConnection
prepareUpdate
in class AbstractRepositoryConnection
public void removeNamespace(String prefix) throws RepositoryException
removeNamespace
in interface RepositoryConnection
RepositoryException
public void setNamespace(String prefix, String name) throws RepositoryException
setNamespace
in interface RepositoryConnection
RepositoryException
public void removeQueryOption(String name) throws RepositoryException
name
- a query option nameRepositoryException
public void setQueryOption(String name, String value) throws RepositoryException
name
- a query option namevalue
- a value for the given query optionRepositoryException
- if the given query option name is
unknown or the value didn't pass
the validationpublic long size(Resource... contexts) throws RepositoryException
size
in interface RepositoryConnection
RepositoryException
public void createFreetextIndex(String indexName, AGFreetextIndexConfig config) throws RepositoryException
See documentation for freetext index parameters.
indexName
- the index name to createconfig
- the index configurationRepositoryException
- if there is an error with this requestAGFreetextIndexConfig.newInstance()
public void deleteFreetextIndex(String indexName) throws RepositoryException
indexName
- the index to be deletedRepositoryException
- if there is an error with this requestcreateFreetextIndex(String, AGFreetextIndexConfig)
public void createFreetextIndex(String name, IRI[] predicates) throws RepositoryException
name
- of the index to createpredicates
- the predicates this index will operate onRepositoryException
- if there is an error with this requestcreateFreetextIndex(String, AGFreetextIndexConfig)
public String[] getFreetextPredicates(String index) throws RepositoryException
index
- name of the index to lookupRepositoryException
- if there is an error during the requestgetFreetextIndexConfig(String)
public AGFreetextIndexConfig getFreetextIndexConfig(String indexName) throws RepositoryException, org.json.JSONException
indexName
- name of the indexAGFreetextIndexConfig
the configuration of the specified indexRepositoryException
- if there is an error during the requestorg.json.JSONException
- if there is a problem parsing the response to JSONpublic String[] getFreetextIndices() throws RepositoryException
RepositoryException
- if there is an error during the requestlistFreetextIndices()
public List<String> listFreetextIndices() throws RepositoryException
RepositoryException
- if there is an error during the requestpublic void registerPredicateMapping(IRI predicate, IRI primtype) throws RepositoryException
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 to XMLSchema.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.
predicate
- the predicate URIprimtype
- the datatype URIRepositoryException
- if there is an error during the requestgetPredicateMappings()
public void deletePredicateMapping(IRI predicate) throws RepositoryException
See mapping overview and DELETE predicate mapping.
predicate
- the predicate mapping to deleteRepositoryException
- if there is an error during the requestgetPredicateMappings()
public String[] getPredicateMappings() throws RepositoryException
See mapping overview and GET predicate mapping and the Lisp reference for the predicate-mapping function.
RepositoryException
- if there is an error during the requestregisterPredicateMapping(IRI, IRI)
,
deletePredicateMapping(IRI)
,
getDatatypeMappings()
public void registerDatatypeMapping(IRI datatype, IRI primtype) throws RepositoryException
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 to XMLSchema.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.
datatype
- the name of the datatype mapping to registerprimtype
- the primitive type of the new mappingRepositoryException
- if there is an error during the requestgetDatatypeMappings()
public void deleteDatatypeMapping(IRI datatype) throws RepositoryException
See mapping overview and DELETE type mapping.
datatype
- the datatype mapping to deleteRepositoryException
- if there is an error during the requestgetDatatypeMappings()
,
clearMappings()
public String[] getDatatypeMappings() throws RepositoryException
See mapping overview and GET type mapping and the Lisp reference for the datatype-mapping function.
RepositoryException
- if there is an error during the requestdeleteDatatypeMapping(IRI)
,
clearMappings()
,
registerDatatypeMapping(IRI, IRI)
,
getPredicateMappings()
public void clearMappings() throws RepositoryException
This is equivalent to clearMappings(false).
See mapping overview and DELETE all mapping for more details.
RepositoryException
- if there is an error during the requestgetDatatypeMappings()
,
getPredicateMappings()
public void clearMappings(boolean includeAutoEncodedPrimitiveTypes) throws RepositoryException
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.
includeAutoEncodedPrimitiveTypes
- true if auto-encoded primitive types should be clearedRepositoryException
- if there is an error during the requestgetDatatypeMappings()
,
getPredicateMappings()
public void clearAttributes() throws RepositoryException
RepositoryException
- if there is an error during the requestpublic void addRules(String rules) throws RepositoryException
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.
rules
- a string of rule textRepositoryException
- if there is an error during the requestaddRules(InputStream)
public void addRules(InputStream rulestream) throws RepositoryException
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.
rulestream
- a stream of rule textRepositoryException
- if there is an error during the requestaddRules(String)
public String evalInServer(String lispForm) throws RepositoryException
See HTTP POST eval.
lispForm
- the Lisp form to evaluateRepositoryException
- if there is an error during the requestevalInServer(String)
public String evalInServer(InputStream stream) throws RepositoryException
See HTTP POST eval.
stream
- the Lisp form to evaluateRepositoryException
- if there is an error during the requestevalInServer(String)
public void load(IRI source, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RepositoryException
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 loadedRepositoryException
- if there is an error during the requestpublic void load(IRI source, String baseURI, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws RepositoryException
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 loadedRepositoryException
- if there is an error during the requestpublic void load(String absoluteServerPath, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RepositoryException
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 loadedRepositoryException
- if there is an error during the requestpublic void load(String absoluteServerPath, String baseURI, RDFFormat dataFormat, org.json.JSONObject attributes, Resource... contexts) throws RepositoryException
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 loadedRepositoryException
- if there is an error during the requestpublic void ping() throws RepositoryException
Note that this method is called automatically before the timeout expires.
See session overview and GET ping for more details.
RepositoryException
- if there is an error during the requestsetSessionLifetime(int)
public String[] getGeoTypes() throws RepositoryException
RepositoryException
- if there is an error during the requestpublic IRI registerCartesianType(float stripWidth, float xmin, float xmax, float ymin, float ymax) throws RepositoryException
stripWidth
- the strip width in some unitsxmin
- the minimum x rangeymin
- the minimum y rangexmax
- the maximum x rangeymax
- the maximum y rangeRepositoryException
- if there is an error during the requestpublic IRI registerSphericalType(float stripWidth, String unit, float latmin, float lonmin, float latmax, float lonmax) throws RepositoryException
stripWidth
- the strip width in some unitsunit
- the distance unit stripWidth
is specified inlatmin
- the minimum latitude rangelonmin
- the minimum longitude rangelatmax
- the maximum latitude rangelonmax
- the maximum longitude rangeRepositoryException
- if there is an error during the requestpublic IRI registerSphericalType(float stripWidth, String unit) throws RepositoryException
RepositoryException
public void registerPolygon(IRI polygon, List<Literal> points) throws RepositoryException
polygon
- the name of this polygonpoints
- a List of points describing the polygonRepositoryException
- if there is an error during the requestpublic RepositoryResult<Statement> getStatementsInBox(IRI type, IRI predicate, float xmin, float xmax, float ymin, float ymax, int limit, boolean infer) throws RepositoryException
RepositoryException
public RepositoryResult<Statement> getStatementsInCircle(IRI type, IRI predicate, float x, float y, float radius, int limit, boolean infer) throws RepositoryException
RepositoryException
public RepositoryResult<Statement> getGeoHaversine(IRI type, IRI predicate, float lat, float lon, float radius, String unit, int limit, boolean infer) throws RepositoryException
RepositoryException
public RepositoryResult<Statement> getStatementsInPolygon(IRI type, IRI predicate, IRI polygon, int limit, boolean infer) throws RepositoryException
RepositoryException
public void registerSNAGenerator(String generator, List<IRI> objectOfs, List<IRI> subjectOfs, List<IRI> undirecteds, String query) throws RepositoryException
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.
generator
- Generator nameobjectOfs
- a list of predicatessubjectOfs
- a list of predicatesundirecteds
- a list of predicatesquery
- a string representation of a select clauseRepositoryException
- if there is an error during the requestpublic void registerSNANeighborMatrix(String matrix, String generator, List<IRI> group, int depth) throws RepositoryException
RepositoryException
public List<String> listIndices() throws RDF4JException
RDF4JException
- if there is an error during the requestpublic List<String> listValidIndices() throws RDF4JException
RDF4JException
- if there is an error during the requestpublic void addIndex(String type) throws RepositoryException
type
- a valid index typeRepositoryException
- if there is an error during the requestlistValidIndices()
public void dropIndex(String type) throws RepositoryException
type
- an actively managed index typeRepositoryException
- if there is an error during the requestlistValidIndices()
public void sendRDFTransaction(InputStream rdftransaction) throws RepositoryException, RDFParseException, IOException
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 .
rdftransaction
- a stream in application/x-rdftransaction formatRepositoryException
- if there is an error during the requestRDFParseException
- if malformed data is encounteredIOException
- on errors reading from the rdftransaction
streampublic void sendRDFTransaction(InputStream rdftransaction, org.json.JSONObject attributes) throws RepositoryException, RDFParseException, IOException
rdftransaction
- a stream in application/x-rdftransaction formatattributes
- a JSONObject of attribute bindings that will be added
to each triple imported from `rdftransaction'.RepositoryException
- if there is an error during the requestRDFParseException
- if malformed data is encounteredIOException
- on errors reading from the rdftransaction
streampublic void registerEncodableNamespace(String namespace, String format) throws RepositoryException
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.
namespace
- a valid namespace, a URI refformat
- a valid format for an encodable namespaceRepositoryException
- if there is an error during the requestregisterEncodableNamespaces(Iterable)
,
listEncodableNamespaces()
,
unregisterEncodableNamespace(String)
,
AGValueFactory.generateURI(String)
,
AGValueFactory.generateURIs(String, int)
public void registerEncodableNamespaces(Iterable<? extends AGFormattedNamespace> formattedNamespaces) throws RepositoryException
formattedNamespaces
- an iterable collection of formatted namespacesRepositoryException
- if there is an error during the requestregisterEncodableNamespace(String, String)
public List<AGFormattedNamespace> listEncodableNamespaces() throws RDF4JException
RDF4JException
- if there is a problem parsing the requestregisterEncodableNamespace(String, String)
public void unregisterEncodableNamespace(String namespace) throws RepositoryException
namespace
- the namespace to unregisterRepositoryException
- if there is an error during the requestregisterEncodableNamespace(String, String)
public Object callStoredProc(String functionName, String moduleName, Object... args) throws RepositoryException
The input arguments and the return value can be:
String
, Integer
, null, byte[],
or Object[] or List
of these (can be nested).
See also
prepareHttpRepoClient()
.callStoredProc
(functionName, moduleName, args)
functionName
- stored proc lisp function, for example "addTwo"moduleName
- lisp FASL file name, for example "example.fasl"args
- arguments to the stored procAGCustomStoredProcException
- for errors from stored procRepositoryException
public int getSessionLifetime()
See also: Session overview.
setSessionLifetime(int)
,
ping()
public void setSessionLifetime(int lifetimeInSeconds)
Also see session overview and POST session for more details.
lifetimeInSeconds
- the session lifetime, in secondsgetSessionLifetime()
,
ping()
public void setSessionLoadInitFile(boolean loadInitFile)
See also: Session overview.
loadInitFile
- boolean determining if the init file is loaded
into this sessionaddSessionLoadScript(String)
public void addSessionLoadScript(String scriptName)
Scripts are server code that may be loaded during a session.
See also: Session overview.
scriptName
- name of the script to be loadedsetSessionLoadInitFile(boolean)
public long getStoreID() throws RepositoryException
RepositoryException
- if there is an error during the requestpublic void enableTripleCache(long size) throws RepositoryException
Takes a size argument to set the size of the cache.
size
- the size of the cache, in triplesRepositoryException
- if there is an error during the requestpublic long getTripleCacheSize() throws RepositoryException
RepositoryException
- if there is an error during the requestpublic void disableTripleCache() throws RepositoryException
RepositoryException
- if there is an error during the requestpublic int getUploadCommitPeriod() throws RepositoryException
RepositoryException
- if there is an error with this requestAGHttpRepoClient.getUploadCommitPeriod()
public void setUploadCommitPeriod(int period) throws RepositoryException
period
- commit after this many statementsRepositoryException
- if there is an error with this requestAGHttpRepoClient.setUploadCommitPeriod(int)
public void optimizeIndices(Boolean wait, int level) throws RepositoryException
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 levelsRepositoryException
- if there is an error with this request
See the Index documentation
for more details.public void optimizeIndices(Boolean wait) throws RepositoryException
RepositoryException
public String getSpinFunction(String uri) throws RDF4JException
uri
- SPIN function identifierRDF4JException
- if there is an error with this requestputSpinFunction(AGSpinFunction)
,
deleteSpinFunction(String)
,
listSpinFunctions()
,
getSpinMagicProperty(String)
public List<AGSpinFunction> listSpinFunctions() throws RDF4JException
RDF4JException
- if there is an error with this requestgetSpinFunction(String)
,
putSpinFunction(AGSpinFunction)
,
deleteSpinFunction(String)
,
listSpinMagicProperties()
public void putSpinFunction(AGSpinFunction fn) throws RDF4JException
fn
- the SPIN function to addRDF4JException
- if there is an error with this requestgetSpinFunction(String)
,
deleteSpinFunction(String)
,
putSpinMagicProperty(AGSpinMagicProperty)
public void deleteSpinFunction(String uri) throws RDF4JException
uri
- SPIN function identifierRDF4JException
- if there is an error with this requestputSpinFunction(AGSpinFunction)
,
getSpinFunction(String)
public String getSpinMagicProperty(String uri) throws RDF4JException
uri
- SPIN magic property identifierRDF4JException
- if there is an error with this requestputSpinMagicProperty(AGSpinMagicProperty)
,
deleteSpinMagicProperty(String)
public List<AGSpinMagicProperty> listSpinMagicProperties() throws RDF4JException
RDF4JException
- if there is an error with this requestgetSpinMagicProperty(String)
,
putSpinMagicProperty(AGSpinMagicProperty)
,
deleteSpinMagicProperty(String)
,
listSpinFunctions()
public void deleteSpinMagicProperty(String uri) throws RDF4JException
uri
- SPIN magic property identifierRDF4JException
- if there is an error with this requestputSpinMagicProperty(AGSpinMagicProperty)
,
getSpinMagicProperty(String)
public void putSpinMagicProperty(AGSpinMagicProperty fn) throws RDF4JException
fn
- the SPIN magic property to addRDF4JException
- if there is an error with this requestgetSpinMagicProperty(String)
,
deleteSpinMagicProperty(String)
,
putSpinFunction(AGSpinFunction)
public void deleteDuplicates(String comparisonMode) throws RepositoryException
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
comparisonMode
- method to determine what is a duplicateAGHttpException
- if there is an error with this requestRepositoryException
public RepositoryResult<Statement> getDuplicateStatements(String comparisonMode) throws RepositoryException
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
comparisonMode
- method to determine what is a duplicateAGHttpException
- if there is an error with this requestRepositoryException
public long materialize(AGMaterializer materializer) throws RepositoryException
The materializer's configuration determines how statements are materialized.
materializer
- the materializer to useAGHttpException
- if there is an error with this requestRepositoryException
AGMaterializer.newInstance()
public long deleteMaterialized() throws RepositoryException
AGHttpException
- if there is an error with this requestRepositoryException
materialize(AGMaterializer)
public long deleteMaterialized(AGMaterializer materializer) throws RepositoryException
materializer
- Materializer parameters used to create the triples.AGHttpException
- if there is an error with this requestRepositoryException
materialize(AGMaterializer)
public long deleteMaterialized(Resource inferredGraph) throws RepositoryException
inferredGraph
- Graph to delete the statements from.
If null the default graph will be used.AGHttpException
- if there is an error with this requestRepositoryException
materialize(AGMaterializer)
public void setMasqueradeAsUser(String user) throws RepositoryException
For AG superusers only. This allows AG superusers to run requests as another user in a dedicated session.
user
- the user for X-Masquerade-As-User requestsRepositoryException
- if there is an error with this requestpublic void begin() throws RepositoryException
commit()
or rollback()
to
be called to end the transaction.begin
in interface RepositoryConnection
RepositoryException
- if there is an error with this requestisActive()
,
commit()
,
rollback()
public boolean isActive() throws UnknownTransactionStateException, RepositoryException
begin()
has been called, and becomes
inactive after commit()
or rollback()
has been called.isActive
in interface RepositoryConnection
true
iff a transaction is active, false
iff no transaction is active.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 requestpublic void clear(Resource... contexts) throws RepositoryException
clear
in interface RepositoryConnection
clear
in class AbstractRepositoryConnection
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 repositoryRepositoryException
- if the statement(s) could not be removed from the repository, for
example because the repository is not writablepublic void deleteAttributeDefinition(String name) throws RepositoryException
name
- The name of the defined attribute to deleteRepositoryException
- if there is an error with this requestpublic org.json.JSONArray getAttributeDefinitions() throws RepositoryException, org.json.JSONException
RepositoryException
- if there is an error with this requestorg.json.JSONException
- if there is an error parsing the response to JSONpublic org.json.JSONArray getAttributeDefinition(String name) throws RepositoryException, org.json.JSONException
name
- the attribute definition to lookupRepositoryException
- if there is an error with this requestorg.json.JSONException
- if there is an error parsing the response to JSONpublic String getStaticAttributeFilter() throws RepositoryException
RepositoryException
- if there is an error with this requestpublic void setStaticAttributeFilter(String filter) throws RepositoryException
filter
- a String representing a static attribute filter definitionRepositoryException
- if there is an error with this requestpublic void deleteStaticAttributeFilter() throws RepositoryException
RepositoryException
- if there is an error with this requestpublic boolean getNDGeospatialDatatypeAutomation() throws RepositoryException
RepositoryException
- if there is an error with this requestpublic void enableNDGeospatialDatatypeAutomation() throws RepositoryException
RepositoryException
- if there is an error with this requestpublic void disableNDGeospatialDatatypeAutomation() throws RepositoryException
RepositoryException
- if there is an error with this requestpublic String getUserAttributes()
public void setUserAttributes(String value)
public void setUserAttributes(org.json.JSONObject value)
public void setTransactionSettings(TransactionSettings transactionSettings)
transactionSettings
- Distributed transaction settings.public Ctx transactionSettingsCtx(TransactionSettings transactionSettings)
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
}
transactionSettings
- New distributed transaction settings.public void setPool(AGConnPool pool)
Set to null
to make close really shutdown the connection.
pool
- Connection pool.public void warmup()
warmup(WarmupConfig)
to specify which structures should be read.public void warmup(WarmupConfig config)
config
- Config object that can be used to specify which structures
should be read into memory. If this parameter is null
then the choice will be left to the server.Copyright © 2021 Franz Inc.. All rights reserved.