public class RepositoryModel extends AbstractLockingModel implements Model
update(DiffReader)
, addAll(Iterator)
or
removeAll(Iterator)
, then the current connection will be used in
non-autocommit mode and commited, including a rollback when it fails.Modifier and Type | Field and Description |
---|---|
protected org.openrdf.repository.RepositoryConnection |
connection |
protected URI |
context |
static String |
DEFAULT_CONTEXT |
static org.openrdf.model.URI |
DEFAULT_OPENRDF_CONTEXT |
protected org.openrdf.repository.Repository |
repository |
protected org.openrdf.model.ValueFactory |
valueFactory |
model
Constructor and Description |
---|
RepositoryModel(org.openrdf.repository.Repository repository) |
RepositoryModel(URI context,
org.openrdf.repository.Repository repository) |
Modifier and Type | Method and Description |
---|---|
void |
addAll(Iterator<? extends Statement> iterator)
Add all statements contained in 'other' to this model = 'union'
|
void |
addStatement(Resource subject,
URI predicate,
Node object)
adds a (subject, property ,object)-statement to this model
|
protected void |
assertModel()
This method checks if the model is properly initialized and i.e.
|
void |
close()
Closes the Connection to the wrapper Repository.
|
void |
commit()
Deprecated.
|
BlankNode |
createBlankNode()
Create (but do not add) a new blank node
|
BlankNode |
createBlankNode(String internalID)
Create a new blank node with the given internal ID.
|
void |
dump()
Dumps the whole content of the model via System.out
|
void |
finalize()
Makes sure that the Connection to the wrapped Repository has been closed.
|
ClosableIterator<Statement> |
findStatements(ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
get all statements in the model with this subject, predicate and object.
|
URI |
getContextURI() |
String |
getNamespace(String prefix) |
Map<String,String> |
getNamespaces()
Get all namespaces as a map of prefix to namespace.
|
org.openrdf.model.URI |
getOpenRDFContextURI()
Returns the context as a OpenRDF URI.
|
static org.openrdf.rio.RDFFormat |
getRDFFormat(Syntax syntax)
Resolves an RDF2Go
Syntax to an OpenRDF RDFFormat . |
Object |
getUnderlyingModelImplementation() |
boolean |
isIsomorphicWith(Model other)
Two models can be equal even if they do not contain the same statements.
|
boolean |
isLocked() |
boolean |
isOpen() |
boolean |
isValidURI(String uriString)
CHecks URI for syntax errors.
|
ClosableIterator<Statement> |
iterator()
Returns an iterator over a set of elements of type T.
|
void |
lock()
Locking a RepositoryModel disables auto-commit mode and starts a new
transaction, which is left open until this RepositoryModel is unlocked.
|
Model |
open()
Open connection to defined, unterlying implementation.
|
ClosableIterable<Statement> |
queryConstruct(String query,
String querylanguage)
Throws an exception if the syntax is not SPARQL
|
QueryResultTable |
querySelect(String query,
String querylanguage)
Throws an exception if the syntax is not SPARQL
|
void |
readFrom(InputStream stream)
Read from InputStream assuming to read an RDF/XML stream.
|
void |
readFrom(InputStream stream,
org.openrdf.rio.RDFFormat format,
String baseURI) |
void |
readFrom(InputStream stream,
Syntax syntax)
Throws an exception if the syntax is not RDF/XML.
|
void |
readFrom(InputStream stream,
Syntax syntax,
String baseURI)
Note: Subclasses are encouraged to overwrite this.
Throws an exception if the syntax is not RDF/XML.
|
void |
readFrom(Reader reader)
Read from Reader assuming in UTF8 encoding.
|
void |
readFrom(Reader reader,
org.openrdf.rio.RDFFormat format,
String baseURL) |
void |
readFrom(Reader reader,
Syntax syntax)
Reads assuming the given syntax.
|
void |
readFrom(Reader reader,
Syntax syntax,
String baseURI)
Note: Subclasses are encouraged to overwrite this.
Throws an exception if the syntax is not RDF/XML.
|
void |
removeAll()
Removes all statements from this model.
|
void |
removeAll(Iterator<? extends Statement> iterator)
Removes all statements contained in 'other' from this model =
'difference'
|
void |
removeNamespace(String prefix)
Throws no exception if the prefix was not present.
|
void |
removeStatement(Resource subject,
URI predicate,
Node object)
remove a (subject, property ,object)-statement from the model
|
void |
rollback() |
void |
setAutocommit(boolean autocommit)
Deprecated.
|
void |
setNamespace(String prefix,
String namespaceURI) |
void |
setUnderlyingModelImplementation(Object object) |
long |
size()
This is a really slow implementation, please override.
|
boolean |
sparqlAsk(String query)
SPARQL ask queries
|
ClosableIterable<Statement> |
sparqlConstruct(String query) |
ClosableIterable<Statement> |
sparqlDescribe(String query)
Iterator must be auto-close, i.e.
|
QueryResultTable |
sparqlSelect(String queryString)
returns results for SPARQL Select queries, as supported by underlying
implementation.
|
void |
unlock()
Ends the locking status, committing all changed that have been made since
this RepositoryModel was locked and switching back to auto-commit mode.
|
void |
update(DiffReader diff)
Using lock() and unlock()
|
void |
writeTo(OutputStream stream)
Writing an RDF/XML stream in UTF8 encoding
|
void |
writeTo(OutputStream stream,
Syntax syntax)
Throws an exception if the syntax is not known
|
void |
writeTo(org.openrdf.rio.RDFWriter writer) |
void |
writeTo(Writer writer)
Writing an RDF/XML stream in UTF8 encoding
|
void |
writeTo(Writer writer,
Syntax syntax)
Write the model to the passed writer, using the passed syntax.
|
addModel, addReificationOf, addReificationOf, addStatement, addStatement, addStatement, addStatement, addStatement, addStatement, addStatement, contains, contains, contains, countStatements, createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, createTriplePattern, createURI, deleteReification, findStatements, getAllReificationsOf, getDiff, getProperty, hasReifications, isEmpty, newRandomUniqueURI, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatements, removeStatements, serialize, setProperty
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addModel, getProperty, isEmpty, setProperty
createDatatypeLiteral, createLanguageTagLiteral, createPlainLiteral, createStatement, createURI, newRandomUniqueURI
removeStatements, removeStatements
getDiff, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement, removeStatement
forEach, spliterator
addStatement, addStatement, addStatement, addStatement, addStatement, addStatement, addStatement
contains, contains, contains, countStatements, createTriplePattern, findStatements
addReificationOf, addReificationOf, deleteReification, getAllReificationsOf, hasReifications
public static final String DEFAULT_CONTEXT
public static final org.openrdf.model.URI DEFAULT_OPENRDF_CONTEXT
protected org.openrdf.repository.Repository repository
protected org.openrdf.repository.RepositoryConnection connection
protected org.openrdf.model.ValueFactory valueFactory
protected URI context
public RepositoryModel(org.openrdf.repository.Repository repository) throws ModelRuntimeException
ModelRuntimeException
public RepositoryModel(URI context, org.openrdf.repository.Repository repository) throws ModelRuntimeException
ModelRuntimeException
public org.openrdf.model.URI getOpenRDFContextURI()
public Model open()
AbstractModel
open
in interface Model
open
in class AbstractModel
public boolean isOpen() throws ModelRuntimeException
isOpen
in interface Model
isOpen
in class AbstractModel
ModelRuntimeException
public void close()
close
in interface Model
close
in class AbstractModel
public BlankNode createBlankNode()
ModelValueFactory
createBlankNode
in interface ModelValueFactory
public BlankNode createBlankNode(String internalID)
ModelValueFactory
createBlankNode
in interface ModelValueFactory
public boolean isValidURI(String uriString)
ModelValueFactory
isValidURI
in interface ModelValueFactory
public void addStatement(Resource subject, URI predicate, Node object) throws ModelRuntimeException
ModelWriter
addStatement
in interface ModelWriter
addStatement
in class AbstractModelAddRemove
subject
- of the statementpredicate
- of the statementobject
- of the statementModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void removeAll(Iterator<? extends Statement> iterator) throws ModelRuntimeException
ModelAddRemove
removeAll
in interface ModelAddRemove
removeAll
in class AbstractModel
ModelRuntimeException
public void removeAll() throws ModelRuntimeException
ModelAddRemove
removeAll
in interface ModelAddRemove
removeAll
in class AbstractModel
ModelRuntimeException
public void addAll(Iterator<? extends Statement> iterator) throws ModelRuntimeException
ModelWriter
addAll
in interface ModelWriter
addAll
in class AbstractModel
iterator
- another RDF2GO modelModelRuntimeException
- if there is either an error with the
underlying model or an IOException
public void removeStatement(Resource subject, URI predicate, Node object) throws ModelRuntimeException
ModelAddRemove
removeStatement
in interface ModelAddRemove
removeStatement
in class AbstractModelAddRemove
subject
- URI or Object (= blankNode)object
- URI or String (=plainLiteral) or BlankNode (=blankNode) or
TypedLiteral or LanguageTagLiteralModelRuntimeException
public ClosableIterator<Statement> findStatements(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) throws ModelRuntimeException
FindableModel
findStatements
in interface FindableModel
subject
- URI or Object (= blankNode) or Variablepredicate
- URI or Variableobject
- URI or String (=plainLiteral) or BlankNode (=blankNode) or
TypedLiteral or LanguageTagLiteral or VariableModelRuntimeException
- most often caused by underlying
IOException
, if anypublic boolean sparqlAsk(String query) throws ModelRuntimeException
Sparqlable
sparqlAsk
in interface Sparqlable
sparqlAsk
in class AbstractModel
query
- a SPARQL AKS queryModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid SPARQL ASK
querypublic ClosableIterable<Statement> sparqlDescribe(String query) throws ModelRuntimeException
Sparqlable
sparqlDescribe
in interface Sparqlable
ModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid SPARQL
DESCRIBE querypublic ClosableIterable<Statement> sparqlConstruct(String query) throws ModelRuntimeException
sparqlConstruct
in interface Sparqlable
ModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid SPARQL
CONSTRUCT querypublic QueryResultTable querySelect(String query, String querylanguage) throws QueryLanguageNotSupportedException, ModelRuntimeException
AbstractModel
querySelect
in interface Sparqlable
querySelect
in class AbstractModel
QueryLanguageNotSupportedException
- if the given query langauge is
not supportedModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid query in the
given query languagepublic ClosableIterable<Statement> queryConstruct(String query, String querylanguage) throws QueryLanguageNotSupportedException, ModelRuntimeException
AbstractModel
queryConstruct
in interface Sparqlable
queryConstruct
in class AbstractModel
QueryLanguageNotSupportedException
- if the adapter can't
understand the given query languageModelRuntimeException
- if the execution throws an exceptionMalformedQueryException
- if the query is not a valid construct
query in the given query languagepublic QueryResultTable sparqlSelect(String queryString) throws ModelRuntimeException
Sparqlable
sparqlSelect
in interface Sparqlable
queryString
- The SPARQL select query stringModelRuntimeException
- if an error happens when executing the
queryMalformedQueryException
- if the query is not a valid SPARQL SELECT
querypublic ClosableIterator<Statement> iterator()
ClosableIterable
public Object getUnderlyingModelImplementation()
getUnderlyingModelImplementation
in interface Model
getUnderlyingModelImplementation
in class AbstractModel
public void setUnderlyingModelImplementation(Object object)
public long size() throws ModelRuntimeException
AbstractModel
size
in interface Model
size
in class AbstractModel
ModelRuntimeException
public URI getContextURI()
getContextURI
in interface Model
public boolean isLocked()
public void lock() throws LockException
lock
in interface Lockable
LockException
- if already lockedpublic void unlock()
public void rollback()
public void dump()
Model
public void readFrom(InputStream stream) throws IOException, ModelRuntimeException
ModelIO
readFrom
in interface ModelIO
stream
- the input to readIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void readFrom(InputStream stream, Syntax syntax) throws IOException, ModelRuntimeException
AbstractModel
readFrom
in interface ModelIO
readFrom
in class AbstractModel
syntax
- syntax to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void readFrom(InputStream stream, Syntax syntax, String baseURI) throws IOException, ModelRuntimeException
AbstractModel
readFrom
in interface ModelIO
readFrom
in class AbstractModel
IOException
ModelRuntimeException
public void readFrom(Reader reader, Syntax syntax, String baseURI) throws ModelRuntimeException, IOException
AbstractModel
readFrom
in interface ModelIO
readFrom
in class AbstractModel
ModelRuntimeException
- from modelIOException
- from readerpublic void readFrom(InputStream stream, org.openrdf.rio.RDFFormat format, String baseURI) throws IOException, ModelRuntimeException
IOException
ModelRuntimeException
public void readFrom(Reader reader) throws IOException, ModelRuntimeException
ModelIO
readFrom
in interface ModelIO
reader
- the input to readIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void readFrom(Reader reader, Syntax syntax) throws IOException, ModelRuntimeException
ModelIO
readFrom
in interface ModelIO
reader
- the input to readsyntax
- syntax to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void readFrom(Reader reader, org.openrdf.rio.RDFFormat format, String baseURL) throws IOException, ModelRuntimeException
IOException
ModelRuntimeException
public void writeTo(OutputStream stream) throws IOException, ModelRuntimeException
ModelIO
writeTo
in interface ModelIO
stream
- the output to write toIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(OutputStream stream, Syntax syntax) throws IOException, ModelRuntimeException
AbstractModel
writeTo
in interface ModelIO
writeTo
in class AbstractModel
stream
- the output to write tosyntax
- syntax to useIOException
- on IOErrorsModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(Writer writer) throws ModelRuntimeException
ModelIO
writeTo
in interface ModelIO
writer
- the output to write toModelRuntimeException
- on RDF serialization errors or model errorspublic void writeTo(Writer writer, Syntax syntax) throws ModelRuntimeException
ModelIO
writeTo
in interface ModelIO
writer
- the output to write tosyntax
- syntax to useModelRuntimeException
- on RDF serialization errors or model errorspublic static org.openrdf.rio.RDFFormat getRDFFormat(Syntax syntax) throws SyntaxNotSupportedException
Syntax
to an OpenRDF RDFFormat
.syntax
- The RDF2Go Syntax to resolve.SyntaxNotSupportedException
- When the Syntax could not be resolved to a
RDFFormat.public void writeTo(org.openrdf.rio.RDFWriter writer) throws ModelRuntimeException
ModelRuntimeException
@Deprecated public void commit()
AbstractModel
commit
in interface Commitable
commit
in class AbstractModel
@Deprecated public void setAutocommit(boolean autocommit)
AbstractModel
setAutocommit
in interface Commitable
setAutocommit
in class AbstractModel
autocommit
- If true, all changes are immediately written to the
underlying persistence layer, if any is used.public void finalize() throws Throwable
protected void assertModel()
AbstractModel
assertModel
in class AbstractModel
public boolean isIsomorphicWith(Model other)
Model
isIsomorphicWith
in interface Model
public void update(DiffReader diff) throws ModelRuntimeException
AbstractLockingModel
update
in interface ModelAddRemove
update
in class AbstractLockingModel
ModelRuntimeException
public String getNamespace(String prefix)
getNamespace
in interface NamespaceSupport
public Map<String,String> getNamespaces()
NamespaceSupport
getNamespaces
in interface NamespaceSupport
public void removeNamespace(String prefix)
NamespaceSupport
removeNamespace
in interface NamespaceSupport
public void setNamespace(String prefix, String namespaceURI) throws IllegalArgumentException
setNamespace
in interface NamespaceSupport
IllegalArgumentException
- if the given namespaceURI is not a valid URI in this
environment.Copyright © 2005–2016 IT-Consulting Dr. Max V?lkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.