it.uniroma2.art.owlart.models.impl
Class SPARQLBasedRDFTripleModelImpl

java.lang.Object
  extended by it.uniroma2.art.owlart.models.impl.BaseRDFModelImpl
      extended by it.uniroma2.art.owlart.models.impl.SPARQLBasedRDFTripleModelImpl
All Implemented Interfaces:
ARTNodeFactory, BaseRDFTripleModel, PrefixMapping, TripleQueryModel

public class SPARQLBasedRDFTripleModelImpl
extends BaseRDFModelImpl
implements BaseRDFTripleModel


Nested Class Summary
 class SPARQLBasedRDFTripleModelImpl.StatementAfterTupleBindings
          wraps a TupleBindings object the content of which is composed of a triple by exporting it as an RDF Statement
 class SPARQLBasedRDFTripleModelImpl.StatementIteratorAfterTupleBindingsIterator
          wraps a TupleBindingsIterator the content of which is composed of triples by exporting this content as an RDFIterator over statements
 
Field Summary
 
Fields inherited from class it.uniroma2.art.owlart.models.impl.BaseRDFModelImpl
baseRep
 
Constructor Summary
SPARQLBasedRDFTripleModelImpl(TripleQueryModelHTTPConnection tqModel)
           
 
Method Summary
 void addRDF(java.io.File inputFile, java.lang.String baseURI, RDFFormat rdfFormat, ARTResource... graphs)
          adds RDF data to graphs graphs by loading it from inputfile inputFile.
 void addRDF(java.net.URL url, java.lang.String baseURI, RDFFormat rdfFormat, ARTResource... graphs)
          adds RDF data to graphs graphs by loading it from url url.
 void addStatement(ARTStatement stat, ARTResource... graphs)
          add statement stat to graphs graphs
 void addTriple(ARTResource subject, ARTURIResource predicate, ARTNode object, ARTResource... graphs)
          adds the specified triple to graphs graphs
 void clearRDF(ARTResource... graphs)
          completely clears any RDF statement from the specified graphs
 void close()
          closes the current model, releasing its resources
 ARTBNode createBNode()
          this method just generates a POJO wrapping a blank node for the ontology.
 ARTBNode createBNode(java.lang.String ID)
          this method just generates a POJO wrapping a blank node for the ontology.
 BooleanQuery createBooleanQuery(QueryLanguage ql, java.lang.String query, java.lang.String baseURI)
          creates a boolean query.
 GraphQuery createGraphQuery(QueryLanguage ql, java.lang.String query, java.lang.String baseURI)
          creates a graph query.
 ARTLiteral createLiteral(java.lang.String literalString)
          creates a literal from its string representation
 ARTLiteral createLiteral(java.lang.String literalString, ARTURIResource datatype)
          composes an creates a literal with a given datatype
 ARTLiteral createLiteral(java.lang.String literalString, java.lang.String language)
          composes and creates a literal starting from its base label and the assigned language
 Query createQuery(QueryLanguage ql, java.lang.String query, java.lang.String baseURI)
          creates a generic query.
 TupleQuery createTupleQuery(QueryLanguage ql, java.lang.String query, java.lang.String baseURI)
          creates a tuple query.
 ARTURIResource createURIResource(java.lang.String uri)
          this method just generates a POJO wrapping an URI for the ontology.
 void deleteStatement(ARTStatement statement, ARTResource... graphs)
          deletes the specified statement from graphs graphs
 void deleteTriple(ARTResource subject, ARTURIResource property, ARTNode object, ARTResource... graphs)
          deletes the triple identified by <subject, property, object > from the specified graphs
 java.lang.String expandQName(java.lang.String qname)
          Expand a qname into an uri using the prefix mappings, if a prefix is available The contract for this method requests that also a valid URI is acceptable as the argument, and in case this is returned as it is
 java.lang.String getBaseURI()
          returns the baseuri of the ontology managed by this model
 java.lang.String getDefaultNamespace()
          returns the default namespace of the ontology managed by this model
 java.util.Map<java.lang.String,java.lang.String> getNamespacePrefixMapping()
          Return a copy of the internal mapping from prefixes to namespaces (as strings).
 java.lang.String getNSForPrefix(java.lang.String prefix)
          Gets the URI bound to a specific prefix, null if there isn't one.
 java.lang.String getPrefixForNS(java.lang.String namespace)
          Answer the prefix for the given URI, or null if there isn't one.
 java.lang.String getQName(java.lang.String uri)
          Compress the URI into a qname using the prefix mappings, if a prefix is available.
 boolean hasStatement(ARTStatement stat, boolean inferred, ARTResource... graphs)
          checks that the specified statement is present in this model, inside one of the graphs specified in graphs
 boolean hasTriple(ARTResource subj, ARTURIResource pred, ARTNode obj, boolean inferred, ARTResource... graphs)
          checks that the triple identified by <subj, pred, obj> is present in this model, inside one of the graphs specified in graphs
 ARTResourceIterator listNamedGraphs()
          returns an ARTResourceIterator over the namedgraphs declared in the global RDF graph
 ARTNamespaceIterator listNamespaces()
          list all namespaces used in this model
 ARTStatementIterator listStatements(ARTResource subj, ARTURIResource pred, ARTNode obj, boolean inferred, ARTResource... graphs)
          returns statements which unify with triples containing subj, pred and obj in their respective positions.
 void removeNsPrefixMapping(java.lang.String namespace)
          Removes prefix/namespace mapping
 void setBaseURI(java.lang.String uri)
          sets the baseuri for the ontology managed by this model
 void setDefaultNamespace(java.lang.String namespace)
          sets the default namespace for the ontology managed by this model
 void setNsPrefix(java.lang.String namespace, java.lang.String prefix)
          Specify the prefix name for a URI prefix string.
 void writeRDF(java.io.File outputFile, RDFFormat rdfFormat, ARTResource... graphs)
          writes RDF data from graphs graphs into file outputFile.
 void writeRDF(java.io.OutputStream os, RDFFormat rdfFormat, ARTResource... graphs)
          writes RDF data from graphs graphs to output stream os.
 
Methods inherited from class it.uniroma2.art.owlart.models.impl.BaseRDFModelImpl
listPredicatesOfSubjObjPair, listSubjectsOfPredObjPair, listValuesOfSubjPredPair
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface it.uniroma2.art.owlart.models.BaseRDFTripleModel
listPredicatesOfSubjObjPair, listSubjectsOfPredObjPair, listValuesOfSubjPredPair
 

Constructor Detail

SPARQLBasedRDFTripleModelImpl

public SPARQLBasedRDFTripleModelImpl(TripleQueryModelHTTPConnection tqModel)
Method Detail

createQuery

public Query createQuery(QueryLanguage ql,
                         java.lang.String query,
                         java.lang.String baseURI)
                  throws UnsupportedQueryLanguageException,
                         ModelAccessException,
                         MalformedQueryException
Description copied from interface: TripleQueryModel
creates a generic query. The type of query is established at run-time on the basis of its content ( query)

Specified by:
createQuery in interface TripleQueryModel
Parameters:
ql - the query language
query - the text content of the query
baseURI - the baseuri to be considered for relative resources' names in the given query
Returns:
Throws:
UnsupportedQueryLanguageException
ModelAccessException
MalformedQueryException

createBooleanQuery

public BooleanQuery createBooleanQuery(QueryLanguage ql,
                                       java.lang.String query,
                                       java.lang.String baseURI)
                                throws UnsupportedQueryLanguageException,
                                       ModelAccessException,
                                       MalformedQueryException
Description copied from interface: TripleQueryModel
creates a boolean query.

Specified by:
createBooleanQuery in interface TripleQueryModel
Parameters:
ql - the query language
query - the text content of the query
baseURI - the baseuri to be considered for relative resources' names in the given query
Returns:
Throws:
UnsupportedQueryLanguageException
ModelAccessException
MalformedQueryException

createGraphQuery

public GraphQuery createGraphQuery(QueryLanguage ql,
                                   java.lang.String query,
                                   java.lang.String baseURI)
                            throws UnsupportedQueryLanguageException,
                                   ModelAccessException,
                                   MalformedQueryException
Description copied from interface: TripleQueryModel
creates a graph query.

Specified by:
createGraphQuery in interface TripleQueryModel
Parameters:
ql - the query language
query - the text content of the query
baseURI - the baseuri to be considered for relative resources' names in the given query
Returns:
Throws:
UnsupportedQueryLanguageException
ModelAccessException
MalformedQueryException

createTupleQuery

public TupleQuery createTupleQuery(QueryLanguage ql,
                                   java.lang.String query,
                                   java.lang.String baseURI)
                            throws UnsupportedQueryLanguageException,
                                   ModelAccessException,
                                   MalformedQueryException
Description copied from interface: TripleQueryModel
creates a tuple query.

Specified by:
createTupleQuery in interface TripleQueryModel
Parameters:
ql - the query language
query - the text content of the query
baseURI - the baseuri to be considered for relative resources' names in the given query
Returns:
Throws:
UnsupportedQueryLanguageException
ModelAccessException
MalformedQueryException

addTriple

public void addTriple(ARTResource subject,
                      ARTURIResource predicate,
                      ARTNode object,
                      ARTResource... graphs)
               throws ModelUpdateException
Description copied from interface: BaseRDFTripleModel
adds the specified triple to graphs graphs

Specified by:
addTriple in interface BaseRDFTripleModel
Throws:
ModelUpdateException

addStatement

public void addStatement(ARTStatement stat,
                         ARTResource... graphs)
                  throws ModelUpdateException
Description copied from interface: BaseRDFTripleModel
add statement stat to graphs graphs

Specified by:
addStatement in interface BaseRDFTripleModel
Throws:
ModelUpdateException

deleteTriple

public void deleteTriple(ARTResource subject,
                         ARTURIResource property,
                         ARTNode object,
                         ARTResource... graphs)
                  throws ModelUpdateException
Description copied from interface: BaseRDFTripleModel
deletes the triple identified by <subject, property, object > from the specified graphs

Specified by:
deleteTriple in interface BaseRDFTripleModel
Throws:
ModelUpdateException

deleteStatement

public void deleteStatement(ARTStatement statement,
                            ARTResource... graphs)
                     throws ModelUpdateException
Description copied from interface: BaseRDFTripleModel
deletes the specified statement from graphs graphs

Specified by:
deleteStatement in interface BaseRDFTripleModel
Throws:
ModelUpdateException

clearRDF

public void clearRDF(ARTResource... graphs)
              throws ModelUpdateException
Description copied from interface: BaseRDFTripleModel
completely clears any RDF statement from the specified graphs

Specified by:
clearRDF in interface BaseRDFTripleModel
Throws:
ModelUpdateException

addRDF

public void addRDF(java.io.File inputFile,
                   java.lang.String baseURI,
                   RDFFormat rdfFormat,
                   ARTResource... graphs)
            throws java.io.FileNotFoundException,
                   java.io.IOException,
                   ModelAccessException,
                   ModelUpdateException,
                   UnsupportedRDFFormatException
Description copied from interface: BaseRDFTripleModel
adds RDF data to graphs graphs by loading it from inputfile inputFile. Data in the file must be formatted according to the specified rdfFormat. The specified baseURI is used for those formats where relative resource names are present and the baseuri is not present in the file.

Specified by:
addRDF in interface BaseRDFTripleModel
Throws:
java.io.FileNotFoundException
java.io.IOException
ModelAccessException
ModelUpdateException
UnsupportedRDFFormatException

addRDF

public void addRDF(java.net.URL url,
                   java.lang.String baseURI,
                   RDFFormat rdfFormat,
                   ARTResource... graphs)
            throws java.io.FileNotFoundException,
                   java.io.IOException,
                   ModelAccessException,
                   ModelUpdateException,
                   UnsupportedRDFFormatException
Description copied from interface: BaseRDFTripleModel
adds RDF data to graphs graphs by loading it from url url. Data in the file must be formatted according to the specified rdfFormat. The specified baseURI is used for those formats where relative resource names are present and the baseuri is not present in the file.
Implementation of this method are expected to use content negotiation to negotiate RDF data with the server, asking MIME type for the appropriate rdf serialization format (MIME type can be obtained through RDFFormat.getMIMEType() method.

Specified by:
addRDF in interface BaseRDFTripleModel
Throws:
java.io.FileNotFoundException
java.io.IOException
ModelAccessException
ModelUpdateException
UnsupportedRDFFormatException

writeRDF

public void writeRDF(java.io.File outputFile,
                     RDFFormat rdfFormat,
                     ARTResource... graphs)
              throws java.io.IOException,
                     ModelAccessException,
                     UnsupportedRDFFormatException
Description copied from interface: BaseRDFTripleModel
writes RDF data from graphs graphs into file outputFile. Data in the file will be formatted according to the specified rdfFormat.

Specified by:
writeRDF in interface BaseRDFTripleModel
Throws:
java.io.IOException
ModelAccessException
UnsupportedRDFFormatException

writeRDF

public void writeRDF(java.io.OutputStream os,
                     RDFFormat rdfFormat,
                     ARTResource... graphs)
              throws java.io.IOException,
                     ModelAccessException,
                     UnsupportedRDFFormatException
Description copied from interface: BaseRDFTripleModel
writes RDF data from graphs graphs to output stream os. Data in the file will be formatted according to the specified rdfFormat.

Specified by:
writeRDF in interface BaseRDFTripleModel
Throws:
java.io.IOException
ModelAccessException
UnsupportedRDFFormatException

listNamespaces

public ARTNamespaceIterator listNamespaces()
                                    throws ModelAccessException
Description copied from interface: BaseRDFTripleModel
list all namespaces used in this model

Specified by:
listNamespaces in interface BaseRDFTripleModel
Returns:
Throws:
ModelAccessException

listNamedGraphs

public ARTResourceIterator listNamedGraphs()
                                    throws ModelAccessException
Description copied from interface: BaseRDFTripleModel
returns an ARTResourceIterator over the namedgraphs declared in the global RDF graph

Specified by:
listNamedGraphs in interface BaseRDFTripleModel
Returns:
Throws:
ModelAccessException

hasTriple

public boolean hasTriple(ARTResource subj,
                         ARTURIResource pred,
                         ARTNode obj,
                         boolean inferred,
                         ARTResource... graphs)
                  throws ModelAccessException
Description copied from interface: BaseRDFTripleModel
checks that the triple identified by <subj, pred, obj> is present in this model, inside one of the graphs specified in graphs

Specified by:
hasTriple in interface BaseRDFTripleModel
Parameters:
subj - the subject of the triple
pred - the predicate of the triple
obj - the object of the triple
inferred - tells if the inference engine of the model is to be used for this retrieval operation
graphs - the graphs where to look for the specified triple
Returns:
true or false according to the presence of the triple in the model
Throws:
ModelAccessException

hasStatement

public boolean hasStatement(ARTStatement stat,
                            boolean inferred,
                            ARTResource... graphs)
                     throws ModelAccessException
Description copied from interface: BaseRDFTripleModel
checks that the specified statement is present in this model, inside one of the graphs specified in graphs

Specified by:
hasStatement in interface BaseRDFTripleModel
Parameters:
stat - the statement which is checked inside the model
inferred - tells if the inference engine of the model is to be used for this retrieval operation
graphs - the graphs where to look for the specified statement
Returns:
Throws:
ModelAccessException

listStatements

public ARTStatementIterator listStatements(ARTResource subj,
                                           ARTURIResource pred,
                                           ARTNode obj,
                                           boolean inferred,
                                           ARTResource... graphs)
                                    throws ModelAccessException
Description copied from interface: BaseRDFTripleModel
returns statements which unify with triples containing subj, pred and obj in their respective positions. A NodeFilters.ANY value in one of these positions is equivalent to putting a wildcard in that position.

Specified by:
listStatements in interface BaseRDFTripleModel
Parameters:
subj - the subject of the triple
pred - the predicate of the triple
obj - the object of the triple
Returns:
an STStatementIterator over statements in the loaded set of ontologies
Throws:
ModelAccessException

close

public void close()
           throws ModelUpdateException
Description copied from interface: BaseRDFTripleModel
closes the current model, releasing its resources

Specified by:
close in interface BaseRDFTripleModel
Throws:
ModelUpdateException

setDefaultNamespace

public void setDefaultNamespace(java.lang.String namespace)
                         throws ModelUpdateException
Description copied from interface: BaseRDFTripleModel
sets the default namespace for the ontology managed by this model

Specified by:
setDefaultNamespace in interface BaseRDFTripleModel
Throws:
ModelUpdateException

setBaseURI

public void setBaseURI(java.lang.String uri)
                throws ModelUpdateException
Description copied from interface: BaseRDFTripleModel
sets the baseuri for the ontology managed by this model

Specified by:
setBaseURI in interface BaseRDFTripleModel
Throws:
ModelUpdateException

getDefaultNamespace

public java.lang.String getDefaultNamespace()
Description copied from interface: BaseRDFTripleModel
returns the default namespace of the ontology managed by this model

Specified by:
getDefaultNamespace in interface BaseRDFTripleModel
Returns:

getBaseURI

public java.lang.String getBaseURI()
Description copied from interface: BaseRDFTripleModel
returns the baseuri of the ontology managed by this model

Specified by:
getBaseURI in interface BaseRDFTripleModel
Returns:

createLiteral

public ARTLiteral createLiteral(java.lang.String literalString)
Description copied from interface: ARTNodeFactory
creates a literal from its string representation

Specified by:
createLiteral in interface ARTNodeFactory
Returns:

createLiteral

public ARTLiteral createLiteral(java.lang.String literalString,
                                java.lang.String language)
Description copied from interface: ARTNodeFactory
composes and creates a literal starting from its base label and the assigned language

Specified by:
createLiteral in interface ARTNodeFactory
Returns:

createLiteral

public ARTLiteral createLiteral(java.lang.String literalString,
                                ARTURIResource datatype)
Description copied from interface: ARTNodeFactory
composes an creates a literal with a given datatype

Specified by:
createLiteral in interface ARTNodeFactory
Returns:

createURIResource

public ARTURIResource createURIResource(java.lang.String uri)
Description copied from interface: ARTNodeFactory
this method just generates a POJO wrapping an URI for the ontology. When it is created, it is not added in any way to any of the triple store resources, and is just an object used for querying/comparison purposes. When used in a addTriple method, the URI is then truly added (inside its triple) to the triple store

Specified by:
createURIResource in interface ARTNodeFactory
Returns:

createBNode

public ARTBNode createBNode()
Description copied from interface: ARTNodeFactory
this method just generates a POJO wrapping a blank node for the ontology. When it is created, it is not added in any way to any of the triple store resources, and is just used for querying/comparison purposes. When used in a addTriple method, the blank node is then truly added (inside its triple) to the triple store

Specified by:
createBNode in interface ARTNodeFactory
Returns:

createBNode

public ARTBNode createBNode(java.lang.String ID)
Description copied from interface: ARTNodeFactory
this method just generates a POJO wrapping a blank node for the ontology. When it is created, it is not added in any way to any of the triple store resources, and is just used for querying/comparison purposes. When used in a addTriple method, the blank node is then truly added (inside its triple) to the triple store

Specified by:
createBNode in interface ARTNodeFactory
Parameters:
ID - an internal identifier which can be used to retrieve the blank node, if known
Returns:

expandQName

public java.lang.String expandQName(java.lang.String qname)
                             throws ModelAccessException
Description copied from interface: PrefixMapping
Expand a qname into an uri using the prefix mappings, if a prefix is available The contract for this method requests that also a valid URI is acceptable as the argument, and in case this is returned as it is

Specified by:
expandQName in interface PrefixMapping
Returns:
Throws:
ModelAccessException

getQName

public java.lang.String getQName(java.lang.String uri)
                          throws ModelAccessException
Description copied from interface: PrefixMapping
Compress the URI into a qname using the prefix mappings, if a prefix is available. The contract for this method requests that a valid URI string is passed as the argument

Specified by:
getQName in interface PrefixMapping
Returns:
Throws:
ModelAccessException

getNamespacePrefixMapping

public java.util.Map<java.lang.String,java.lang.String> getNamespacePrefixMapping()
                                                                           throws ModelAccessException
Description copied from interface: PrefixMapping
Return a copy of the internal mapping from prefixes to namespaces (as strings).

Specified by:
getNamespacePrefixMapping in interface PrefixMapping
Returns:
Throws:
ModelAccessException

getNSForPrefix

public java.lang.String getNSForPrefix(java.lang.String prefix)
                                throws ModelAccessException
Description copied from interface: PrefixMapping
Gets the URI bound to a specific prefix, null if there isn't one.

Specified by:
getNSForPrefix in interface PrefixMapping
Returns:
Throws:
ModelAccessException

getPrefixForNS

public java.lang.String getPrefixForNS(java.lang.String namespace)
                                throws ModelAccessException
Description copied from interface: PrefixMapping
Answer the prefix for the given URI, or null if there isn't one.

Specified by:
getPrefixForNS in interface PrefixMapping
Returns:
Throws:
ModelAccessException

setNsPrefix

public void setNsPrefix(java.lang.String namespace,
                        java.lang.String prefix)
                 throws ModelUpdateException
Description copied from interface: PrefixMapping
Specify the prefix name for a URI prefix string.

Specified by:
setNsPrefix in interface PrefixMapping
Throws:
ModelUpdateException

removeNsPrefixMapping

public void removeNsPrefixMapping(java.lang.String namespace)
                           throws ModelUpdateException
Description copied from interface: PrefixMapping
Removes prefix/namespace mapping

Specified by:
removeNsPrefixMapping in interface PrefixMapping
Throws:
ModelUpdateException


Copyright © 2011 ART Group, University of Rome, Tor Vergata. All Rights Reserved.