Class QueryFragment
java.lang.Object
org.aksw.jena_sparql_api.data_query.impl.QueryFragment
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
FieldsModifier and TypeFieldDescriptionprotected org.apache.jena.sparql.core.Varstatic org.apache.jena.rdf.model.Propertyprotected org.apache.jena.query.Query -
Constructor Summary
ConstructorsConstructorDescriptionQueryFragment(org.apache.jena.sparql.core.Var conceptVar, org.apache.jena.query.Query query) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaggregate(QueryFragment queryFragment, org.apache.jena.sparql.path.Path path, org.apache.jena.sparql.expr.aggregate.Aggregator agg) static QueryFragmentcreateForFacetCountRemainder(Concept concept, boolean isReverse) static QueryFragmentcreateForPredicate(org.apache.jena.graph.Node p, boolean isReverse) static org.apache.jena.graph.TriplecreateTriple(boolean isReverse, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) static voidextractFacetConstraints(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.VargetOrCreateAlias(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> voidtoElement(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> Fragment2toElement(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) toString()
-
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
-
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
-
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
-