Search in sources :

Example 6 with DefaultRule

use of fr.lirmm.graphik.graal.core.DefaultRule in project graal by graphik-team.

the class DefaultRuleFactory method create.

@Override
public Rule create(Atom[] body, Atom[] head) {
    InMemoryAtomSet bodySet = DefaultAtomSetFactory.instance().create(body);
    InMemoryAtomSet headSet = DefaultAtomSetFactory.instance().create(head);
    return new DefaultRule(bodySet, headSet);
}
Also used : DefaultRule(fr.lirmm.graphik.graal.core.DefaultRule) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)

Example 7 with DefaultRule

use of fr.lirmm.graphik.graal.core.DefaultRule in project graal by graphik-team.

the class DefaultRuleFactory method create.

@Override
public Rule create(Atom body, Atom head) {
    InMemoryAtomSet bodySet = DefaultAtomSetFactory.instance().create(body);
    InMemoryAtomSet headSet = DefaultAtomSetFactory.instance().create(head);
    return new DefaultRule(bodySet, headSet);
}
Also used : DefaultRule(fr.lirmm.graphik.graal.core.DefaultRule) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)

Example 8 with DefaultRule

use of fr.lirmm.graphik.graal.core.DefaultRule 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;
}
Also used : DefaultRule(fr.lirmm.graphik.graal.core.DefaultRule) Triple(com.hp.hpl.jena.graph.Triple) Query(com.hp.hpl.jena.query.Query) Prefix(fr.lirmm.graphik.util.Prefix) Rule(fr.lirmm.graphik.graal.api.core.Rule) DefaultRule(fr.lirmm.graphik.graal.core.DefaultRule) Map(java.util.Map) Template(com.hp.hpl.jena.sparql.syntax.Template)

Aggregations

DefaultRule (fr.lirmm.graphik.graal.core.DefaultRule)8 Rule (fr.lirmm.graphik.graal.api.core.Rule)5 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)4 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)3 Atom (fr.lirmm.graphik.graal.api.core.Atom)2 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)2 RuleSet (fr.lirmm.graphik.graal.api.core.RuleSet)2 Term (fr.lirmm.graphik.graal.api.core.Term)2 LinkedListRuleSet (fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet)2 AnalyserRuleSet (fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet)2 LinkedList (java.util.LinkedList)2 Triple (com.hp.hpl.jena.graph.Triple)1 Query (com.hp.hpl.jena.query.Query)1 Template (com.hp.hpl.jena.sparql.syntax.Template)1 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)1 TreeMapSubstitution (fr.lirmm.graphik.graal.core.TreeMapSubstitution)1 Prefix (fr.lirmm.graphik.util.Prefix)1 Map (java.util.Map)1