java.lang.Object
it.uniroma2.art.semanticturkey.services.support.QueryBuilder

public class QueryBuilder extends Object
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 Details

  • Constructor Details

    • QueryBuilder

      public QueryBuilder(STServiceContext serviceContext, String resourceQuery)
      Constructs a QueryBuilder for a service backed by a given (tuple) query.
      Parameters:
      serviceContext -
      resourceQuery -
  • Method Details

    • setResourceVariable

      public void setResourceVariable(String variableName) throws QueryBuilderException
      Sets that name of the variable that holds the resource
      Parameters:
      variableName -
      Throws:
      QueryBuilderException
    • processRendering

      public void processRendering() throws QueryBuilderException
      Attaches the rendering of the retrieved resources.
      Throws:
      QueryBuilderException
    • processRendering

      public void processRendering(RenderingEngine renderingEngine) throws QueryBuilderException
      Attaches the rendering of the retrieved resources.
      Parameters:
      renderingEngine -
      Throws:
      QueryBuilderException
    • processRole

      public void processRole() throws QueryBuilderException
      Attaches the role retrieval of the retrieved resources.
      Throws:
      QueryBuilderException
    • processNature

      public void processNature() throws QueryBuilderException
      Attaches the nature retrieval of the retrieved resources.
      Throws:
      QueryBuilderException
    • processQName

      public void processQName() throws QueryBuilderException
      Attaches the qname retrieval of the retrieved (IRI) resources.
      Throws:
      QueryBuilderException
    • processStandardAttributes

      public void processStandardAttributes() throws QueryBuilderException
      Attaches recurring processors computing qname, nature and rendering.
      Throws:
      QueryBuilderException
    • process

      public void process(QueryBuilderProcessor processor, String bindingVariable, String outputVariable)
      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.QueryEvaluationException
      Evaluates 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 - a RepositoryConnection to evaluate the query
      resultsProcessor - a QueryResultsProcessor 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 is false.
      Parameters:
      includeInferred -