Class QueryBuilder
java.lang.Object
it.uniroma2.art.semanticturkey.services.support.QueryBuilder
A
QueryBuilder
supports the composition and evaluation of the SPARQL query underpinning an Semantic
Turkey service, by taking care of cross-cutting concerns such as rendering and role retrieval.- Author:
- Manuel Fiorelli
-
Field Summary
-
Constructor Summary
ConstructorDescriptionQueryBuilder
(STServiceContext serviceContext, String resourceQuery) Constructs aQueryBuilder
for a service backed by a given (tuple) query. -
Method Summary
Modifier and TypeMethodDescriptionvoid
process
(QueryBuilderProcessor processor, String bindingVariable, String outputVariable) Attaches a given processor.void
Attaches the nature retrieval of the retrieved resources.void
Attaches the qname retrieval of the retrieved (IRI) resources.void
Attaches the rendering of the retrieved resources.void
processRendering
(RenderingEngine renderingEngine) Attaches the rendering of the retrieved resources.void
Attaches the role retrieval of the retrieved resources.void
Attaches recurring processors computing qname, nature and rendering.Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>>
runQuery()
Evaluates the (possibly enriched) query and returns the retrieved resources.<T> T
runQuery
(QueryResultsProcessor<T> resultsProcessor) Evaluates the (possibly enriched) query and returns the processed results.Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>>
runQuery
(org.eclipse.rdf4j.repository.RepositoryConnection conn) Evaluates the (possibly enriched) query on the given repository connection and returns the retrieved resources.<T> T
runQuery
(org.eclipse.rdf4j.repository.RepositoryConnection conn, QueryResultsProcessor<T> resultsProcessor) Evaluates the (possibly enriched) query on the given repository connection and returns the processed results.void
setBinding
(String name, org.eclipse.rdf4j.model.Value value) Binds a variable to a given value.void
setIncludeInferred
(boolean includeInferred) Sets whether inferred statements should be considered during query evaluation.void
setResourceVariable
(String variableName) Sets that name of the variable that holds the resource
-
Field Details
-
DEFAULT_RESOURCE_VARIABLE
- See Also:
-
-
Constructor Details
-
QueryBuilder
Constructs aQueryBuilder
for a service backed by a given (tuple) query.- Parameters:
serviceContext
-resourceQuery
-
-
-
Method Details
-
setResourceVariable
Sets that name of the variable that holds the resource- Parameters:
variableName
-- Throws:
QueryBuilderException
-
processRendering
Attaches the rendering of the retrieved resources.- Throws:
QueryBuilderException
-
processRendering
Attaches the rendering of the retrieved resources.- Parameters:
renderingEngine
-- Throws:
QueryBuilderException
-
processRole
Attaches the role retrieval of the retrieved resources.- Throws:
QueryBuilderException
-
processNature
Attaches the nature retrieval of the retrieved resources.- Throws:
QueryBuilderException
-
processQName
Attaches the qname retrieval of the retrieved (IRI) resources.- Throws:
QueryBuilderException
-
processStandardAttributes
Attaches recurring processors computing qname, nature and rendering.- Throws:
QueryBuilderException
-
process
Attaches a given processor.- Parameters:
processor
-bindingVariable
-outputVariable
-
-
setBinding
public void setBinding(String name, org.eclipse.rdf4j.model.Value value) throws QueryBuilderException Binds a variable to a given value.- Parameters:
name
-value
-- Throws:
QueryBuilderException
-
runQuery
public Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>> runQuery() throws QueryBuilderException, org.eclipse.rdf4j.query.QueryEvaluationExceptionEvaluates the (possibly enriched) query and returns the retrieved resources.- Returns:
- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
QueryBuilderException
-
runQuery
public <T> T runQuery(QueryResultsProcessor<T> resultsProcessor) throws QueryBuilderException, org.eclipse.rdf4j.query.QueryEvaluationException Evaluates the (possibly enriched) query and returns the processed results.- Returns:
- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
QueryBuilderException
-
runQuery
public Collection<AnnotatedValue<org.eclipse.rdf4j.model.Resource>> runQuery(org.eclipse.rdf4j.repository.RepositoryConnection conn) Evaluates the (possibly enriched) query on the given repository connection and returns the retrieved resources.- Returns:
- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
-
runQuery
public <T> T runQuery(org.eclipse.rdf4j.repository.RepositoryConnection conn, QueryResultsProcessor<T> resultsProcessor) Evaluates the (possibly enriched) query on the given repository connection and returns the processed results.- Parameters:
conn
- aRepositoryConnection
to evaluate the queryresultsProcessor
- aQueryResultsProcessor
used to generate the final results- Returns:
- Throws:
org.eclipse.rdf4j.query.QueryEvaluationException
-
setIncludeInferred
public void setIncludeInferred(boolean includeInferred) Sets whether inferred statements should be considered during query evaluation. By default, this property isfalse
.- Parameters:
includeInferred
-
-