use of com.hp.hpl.jena.sparql.syntax.Template in project graal by graphik-team.
the class SparqlRuleParser method execute.
// /////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS
// /////////////////////////////////////////////////////////////////////////
private void execute(String sparqlQuery) {
Query sparql = QueryFactory.create(sparqlQuery);
this.prefixes = new LinkedList<Prefix>();
for (Map.Entry<String, String> e : sparql.getPrefixMapping().getNsPrefixMap().entrySet()) {
this.prefixes.add(new Prefix(e.getKey(), e.getValue()));
}
Rule rule = new DefaultRule();
if (sparql.isConstructType()) {
Template template = sparql.getConstructTemplate();
for (Triple triple : template.getTriples()) {
rule.getHead().add(SparqlUtils.triple2Atom(triple));
}
}
ElementVisitorImpl visitor = new ElementVisitorImpl(rule.getBody());
sparql.getQueryPattern().visit(visitor);
this.rule = rule;
}