Class QueryFragment

java.lang.Object
org.aksw.jena_sparql_api.data_query.impl.QueryFragment

public class QueryFragment extends Object
A query fragment is construct query with a designated variable. TODO Clarify whether there needs to be a join() function that injects a given element Component to retrieve additional attributes for a given concept In contrast to the BinaryRelation class, which uses designated source and target variables, this class allows mapping property paths to variables vie the template
Author:
Claus Stadler, May 27, 2018
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.jena.sparql.core.Var
     
    static org.apache.jena.rdf.model.Property
     
    protected org.apache.jena.query.Query
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    QueryFragment(org.apache.jena.sparql.core.Var conceptVar, org.apache.jena.query.Query query)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    aggregate(QueryFragment queryFragment, org.apache.jena.sparql.path.Path path, org.apache.jena.sparql.expr.aggregate.Aggregator agg)
     
    createForFacetCountRemainder(Concept concept, boolean isReverse)
     
    createForPredicate(org.apache.jena.graph.Node p, boolean isReverse)
     
    static org.apache.jena.graph.Triple
    createTriple(boolean isReverse, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o)
     
    static void
    extractFacetConstraints(org.apache.jena.query.Query query)
    - BGPs: BGPs are converted to Map<Path, Var> - TODO What to do with - forks in the path ?x foo [ bar ?y, baz ?z ] - multiple endpoints (a special case of a fork) - - Optional blocks are ignored as they are considered to correspond to the attribute part - i.e.
    static <P> org.apache.jena.sparql.core.Var
    getOrCreateAlias(P path, PathAccessorRdf<P> accessor, Map<P,Fragment2> pathToNode, Set<org.apache.jena.sparql.core.Var> forbiddenVars, org.aksw.commons.collections.generator.Generator<org.apache.jena.sparql.core.Var> varGen)
     
    static <P> void
    toElement(Iterable<P> paths, PathAccessorRdf<P> accessor, Set<org.apache.jena.sparql.syntax.Element> elements, Map<P,Fragment2> pathToNode, Set<org.apache.jena.sparql.core.Var> forbiddenVars, org.aksw.commons.collections.generator.Generator<org.apache.jena.sparql.core.Var> varGen)
    Create a query fragment that counts the number of distinct values for all properties.
    static <P> Fragment2
    toElement(P path, PathAccessorRdf<P> accessor, Map<P,Fragment2> pathToNode, Set<org.apache.jena.sparql.core.Var> forbiddenVars, org.aksw.commons.collections.generator.Generator<org.apache.jena.sparql.core.Var> varGen)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • conceptVar

      protected org.apache.jena.sparql.core.Var conceptVar
    • query

      protected org.apache.jena.query.Query query
    • facetCount

      public static org.apache.jena.rdf.model.Property facetCount
  • Constructor Details

    • QueryFragment

      public QueryFragment(org.apache.jena.sparql.core.Var conceptVar, org.apache.jena.query.Query query)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createTriple

      public static org.apache.jena.graph.Triple createTriple(boolean isReverse, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o)
    • createForPredicate

      public static QueryFragment createForPredicate(org.apache.jena.graph.Node p, boolean isReverse)
    • extractFacetConstraints

      public static void extractFacetConstraints(org.apache.jena.query.Query query)
      - BGPs: BGPs are converted to Map<Path, Var> - TODO What to do with - forks in the path ?x foo [ bar ?y, baz ?z ] - multiple endpoints (a special case of a fork) - - Optional blocks are ignored as they are considered to correspond to the attribute part - i.e. they do not constrain the concept
      Parameters:
      query -
    • toElement

      public static <P> void toElement(Iterable<P> paths, PathAccessorRdf<P> accessor, Set<org.apache.jena.sparql.syntax.Element> elements, Map<P,Fragment2> pathToNode, Set<org.apache.jena.sparql.core.Var> forbiddenVars, org.aksw.commons.collections.generator.Generator<org.apache.jena.sparql.core.Var> varGen)
      Create a query fragment that counts the number of distinct values for all properties. The result is a map from each constrained property to its corresponding query fragment. The 'null' fragment is for all other properties.
      
       # For each $constrainedProperty$:
      
       CONSTRUCT {
         ?p :facetCount ?c
       } WHERE {
         { SELECT ?p (COUNT(DISTINCT ?o) AS ?c {
         	$concept(?s)$
            $constraintElementWithout($constrainedProperty$)$
            ?s ?p ?o . # may be reversed
         	FILTER(?p = $constrainedProperty$)
         } GROUP BY ?p }
       }
       
    • getOrCreateAlias

      public static <P> org.apache.jena.sparql.core.Var getOrCreateAlias(P path, PathAccessorRdf<P> accessor, Map<P,Fragment2> pathToNode, Set<org.apache.jena.sparql.core.Var> forbiddenVars, org.aksw.commons.collections.generator.Generator<org.apache.jena.sparql.core.Var> varGen)
    • toElement

      public static <P> Fragment2 toElement(P path, PathAccessorRdf<P> accessor, Map<P,Fragment2> pathToNode, Set<org.apache.jena.sparql.core.Var> forbiddenVars, org.aksw.commons.collections.generator.Generator<org.apache.jena.sparql.core.Var> varGen)
    • aggregate

      public static void aggregate(QueryFragment queryFragment, org.apache.jena.sparql.path.Path path, org.apache.jena.sparql.expr.aggregate.Aggregator agg)
    • createForFacetCountRemainder

      public static QueryFragment createForFacetCountRemainder(Concept concept, boolean isReverse)