public class SparqlUtil extends Object
| Constructor and Description |
|---|
SparqlUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
addTriplesToGraphQuery(String namedGraphUrl,
org.apache.jena.rdf.model.Model jenaModel)
Gets an rdf model and a named graph as arguments and returns a sparql
query for adding the statements of the rdf model to the named graph
|
static String |
addTriplesToGraphQuery(String namedGraphUrl,
String triples)
Gets a set of statements and a named graph as arguments and returns a
sparql query for adding the statements to the named graph
|
static String |
addTriplesToGraphQuery(URI namedGraphUrl,
org.apache.jena.rdf.model.Model jenaModel) |
static void |
addTriplesToNamedGraph(org.apache.jena.rdf.model.Model jenaModel,
String namedGraphUrl,
String serviceUrl)
create a spaql update adding the triples in the given rdf model to the
graph with the given name and send it to the specified sparql update
endpoint
|
static String |
appendSparqldQuery(String appending,
String appended)
append a sparql update to another
|
static void |
createGraph(String namedGraphUrl,
String serviceUrl)
create a graph creation of the graph with the specified name sparql
update and post it to the given service url
|
static String |
createGraphQuery(String namedGraphUrl)
returns the sparql query for the creation of the named graph with the
given name as a String
|
static String |
createGraphQuery(URI namedGraphUrl) |
static void |
dropGraph(String namedGraphUrl,
String serviceUrl)
create a graph creation of the graph with the specified name sparql
update and post it to the given service url
|
static String |
dropGraphQuery(String namedGraphUrl)
returns the query deleting siltently the graph with the given name
|
static org.eclipse.rdf4j.query.TupleQueryResult |
evalQuery(org.eclipse.rdf4j.repository.RepositoryConnection conn,
String sparqlQuery)
evaluate the given sparql query using the sesame repository connection
object
|
static org.eclipse.rdf4j.query.TupleQueryResult |
evalQuery(String queryEndpoint,
String user,
String pwd,
String query)
evaluate the given sparql query against the given sparql query endpoint
|
static void |
evalUpdate(org.eclipse.rdf4j.repository.RepositoryConnection conn,
String sparqlQuery)
evaluate the given sparql update using the sesame repository connection
object
|
static String |
getChangeEventQuery(ChangeEvent changeEvent,
org.apache.jena.rdf.model.Model model)
For a change event return a sparql update relfecting the change event.
|
static String |
getCreationEventQuery(ChangeEvent changeEvent,
org.apache.jena.rdf.model.Model model)
* For a creation event return a sparql update reflecting the change
event.
|
static String |
getDeletionEventQuery(ChangeEvent changeEvent)
For a deletion event return a sparql update relfecting the change event.
|
static String |
getModificationEventQuery(ChangeEvent changeEvent,
org.apache.jena.rdf.model.Model model)
For a modification event return a sparql update relfecting the change
event.
|
static String |
getModificationEventQuery(ChangeEvent changeEvent,
String triples)
For a modification event return a sparql update relfecting the change
event.
|
static String |
getModificationEventQuery(String changeEventTarget,
String triples)
For a modification event target return a sparql update relfecting the
change event.
|
static org.eclipse.rdf4j.repository.RepositoryConnection |
getRepoConnection(String queryEndpoint,
String user,
String pwd)
return the repo connection object in order to be able to use the sesame
client libraries
|
static org.eclipse.rdf4j.repository.RepositoryConnection |
getRepoConnection(String queryEndpoint,
String updateEndPoint,
String user,
String pwd)
return the repo connection object in order to be able to use the sesame
client libraries
|
static String |
linkTriple(String src,
String dst,
String linkType)
Create a triple with the link type as a predicate the src as subject and
destination as object.
|
static void |
processChangeEvent(ChangeEvent changeEvent,
org.apache.jena.rdf.model.Model model,
String serviceUrl)
create a spaql update reflecting the given change event and send it to
the sparql update endpoint
|
static void |
processQuery_sesame(String query,
org.eclipse.rdf4j.repository.RepositoryConnection conn)
Send the given sparql update to the sparql update service using the
sesame libraries
|
static void |
processQuery_sesame(String query,
String serviceUrl,
String user,
String pwd)
Send the given sparql update to the sparql update service using the
sesame libraries
|
static void |
processQuery(String query,
String serviceUrl)
Send the given sparql update to the sparql update service using the jena
arq libraries
|
void |
processTripleAdditionQuery(org.eclipse.rdf4j.repository.RepositoryConnection conn,
String triples,
String graphName)
Create a sparql update ading the triples to the named graph with the
specified name and send it to the sparql update endpoint specified using
the given repo connection object.
|
static String |
removeAllTriplesInGraphQuery(String namedGraphUrl)
returns the sparql query removing all the triples in the requested graph
as a string
|
static void |
removeAllTriplesInNamedGraph(String namedGraphUrl,
String serviceUrl)
create a spaql update removing all triples from the graph with the given
name and send it to the specified sparql update endpoint
|
public static String createGraphQuery(String namedGraphUrl)
namedGraphUrl - name of the named graph to be createdpublic static String dropGraphQuery(String namedGraphUrl)
namedGraphUrl - the name of the graph to be deletedpublic static String removeAllTriplesInGraphQuery(String namedGraphUrl)
namedGraphUrl - graph to be emptiedpublic static String addTriplesToGraphQuery(String namedGraphUrl, org.apache.jena.rdf.model.Model jenaModel)
namedGraphUrl - named graph to which the statements shall be addedjenaModel - the rdf model of which statements are to be added to the named
graphpublic static String addTriplesToGraphQuery(URI namedGraphUrl, org.apache.jena.rdf.model.Model jenaModel)
public static String addTriplesToGraphQuery(String namedGraphUrl, String triples)
namedGraphUrl - named graph to which the statements shall be addedtriples - statements to be added to the named graphpublic static String getChangeEventQuery(ChangeEvent changeEvent, org.apache.jena.rdf.model.Model model)
changeEvent - the change event for which the sparql update is createdmodel - the rdf model corresponding to the updated representation of
the changed resource if applicable ( no rdf model is needed
for a deletion event)public static String getModificationEventQuery(ChangeEvent changeEvent, org.apache.jena.rdf.model.Model model)
changeEvent - the change event for which the sparql update is createdmodel - the rdf model corresponding to the updated representation of
the changed resourcepublic static String getModificationEventQuery(ChangeEvent changeEvent, String triples)
changeEvent - the change event for which the sparql update is createdtriples - the rdf model in n triples corresponding to the updated
representation of the changed resourcepublic static String getModificationEventQuery(String changeEventTarget, String triples)
changeEventTarget - the change resource for which the sparql update is createdtriples - the rdf model in n triples corresponding to the updated
representation of the changed resourcepublic static String getCreationEventQuery(ChangeEvent changeEvent, org.apache.jena.rdf.model.Model model)
changeEvent - change event for which update will be createdmodel - updated rdf representation of the changed resourcepublic static String getDeletionEventQuery(ChangeEvent changeEvent)
changeEvent - the deletion change event for which the sparql update is
createdpublic static void createGraph(String namedGraphUrl, String serviceUrl)
namedGraphUrl - name of the graph to be createdserviceUrl - sparql update endpoint urlpublic static void dropGraph(String namedGraphUrl, String serviceUrl)
namedGraphUrl - name of the graph to be deletedserviceUrl - sparql update endpoint urlpublic static void addTriplesToNamedGraph(org.apache.jena.rdf.model.Model jenaModel,
String namedGraphUrl,
String serviceUrl)
jenaModel - the triples to be added to the named graphnamedGraphUrl - the named graph to which the triples shall be addedserviceUrl - the sparql update endpointpublic static void removeAllTriplesInNamedGraph(String namedGraphUrl, String serviceUrl)
namedGraphUrl - the named graph that shall be emptiedserviceUrl - the sparql update endpointpublic static void processChangeEvent(ChangeEvent changeEvent, org.apache.jena.rdf.model.Model model, String serviceUrl)
changeEvent - the change event to be processedmodel - the updated representation of the changed resource if
applicableserviceUrl - the sparql update endpointpublic static void processQuery(String query, String serviceUrl)
query - sparql update to be processedaserviceUrl - sparql update endpoint for processing the sparql updatepublic static void processQuery_sesame(String query, String serviceUrl, String user, String pwd)
query - sparql update to be processedaserviceUrl - sparql update endpoint for processing the sparql updateuser - username for authentication if applicablepwd - password for authentication if applicablepublic static void processQuery_sesame(String query, org.eclipse.rdf4j.repository.RepositoryConnection conn)
query - sparql update to be processedaconn - the repository connection object holding credentials and the
sparql update endpointpublic static org.eclipse.rdf4j.repository.RepositoryConnection getRepoConnection(String queryEndpoint, String user, String pwd)
queryEndpoint - the sparl query endpointuser - username for authentication if applicablepwd - password for authentication if applicablepublic static org.eclipse.rdf4j.repository.RepositoryConnection getRepoConnection(String queryEndpoint, String updateEndPoint, String user, String pwd)
queryEndpoint - the sparl query endpointuser - username for authentication if applicablepwd - password for authentication if applicablepublic static org.eclipse.rdf4j.query.TupleQueryResult evalQuery(String queryEndpoint, String user, String pwd, String query)
queryEndpoint - sparql query endpointuser - username for authentication if applicablepwd - password for authentication if applicablequery - sparql querypublic static void evalUpdate(org.eclipse.rdf4j.repository.RepositoryConnection conn,
String sparqlQuery)
conn - repo connection sesame objectsparqlQuery - sparql update to evaluatepublic static org.eclipse.rdf4j.query.TupleQueryResult evalQuery(org.eclipse.rdf4j.repository.RepositoryConnection conn,
String sparqlQuery)
conn - repo connection sesame objectsparqlQuery - sparql query to evaluatepublic static String appendSparqldQuery(String appending, String appended)
appending - the original sparql updateappended - the sparql update to be appendedpublic void processTripleAdditionQuery(org.eclipse.rdf4j.repository.RepositoryConnection conn,
String triples,
String graphName)
conn - sesame repo connection objecttriples - triples to be added to the named graphgraphName - named graph to which the triples shall be addedpublic static String linkTriple(String src, String dst, String linkType)
src - source of the linkdst - destination of the linklinkType - type of the linkCopyright © 2021. All rights reserved.