Search in sources :

Example 1 with SQLRuleApplier

use of fr.lirmm.graphik.graal.store.rdbms.rule_applier.SQLRuleApplier in project graal by graphik-team.

the class RdbmsStoreTest method SQLRuleApplierTest.

// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
@Theory
public void SQLRuleApplierTest(RdbmsStore store) throws AtomSetException, IteratorException, ParseException {
    RuleSet ruleSet = new LinkedListRuleSet();
    ruleSet.add(DlgpParser.parseRule("<Q>(X,Y) :- <P>(X)."));
    ruleSet.add(DlgpParser.parseRule("<R>(Y) :- <Q>(X,Y)."));
    Atom a = DlgpParser.parseAtom("<P>(a).");
    store.add(a);
    Chase chase = new BasicChase<RdbmsStore>(ruleSet, store, new SQLRuleApplier(SqlHomomorphism.instance()));
    try {
        chase.execute();
    } catch (ChaseException e) {
        Assert.fail(e.getMessage());
    }
    CloseableIterator<Atom> it = store.iterator();
    int count = Iterators.count(it);
    Assert.assertEquals(3, count);
}
Also used : RuleSet(fr.lirmm.graphik.graal.api.core.RuleSet) LinkedListRuleSet(fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet) BasicChase(fr.lirmm.graphik.graal.forward_chaining.BasicChase) SQLRuleApplier(fr.lirmm.graphik.graal.store.rdbms.rule_applier.SQLRuleApplier) LinkedListRuleSet(fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet) ChaseException(fr.lirmm.graphik.graal.api.forward_chaining.ChaseException) Atom(fr.lirmm.graphik.graal.api.core.Atom) Chase(fr.lirmm.graphik.graal.api.forward_chaining.Chase) BasicChase(fr.lirmm.graphik.graal.forward_chaining.BasicChase) Theory(org.junit.experimental.theories.Theory)

Aggregations

Atom (fr.lirmm.graphik.graal.api.core.Atom)1 RuleSet (fr.lirmm.graphik.graal.api.core.RuleSet)1 Chase (fr.lirmm.graphik.graal.api.forward_chaining.Chase)1 ChaseException (fr.lirmm.graphik.graal.api.forward_chaining.ChaseException)1 LinkedListRuleSet (fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet)1 BasicChase (fr.lirmm.graphik.graal.forward_chaining.BasicChase)1 SQLRuleApplier (fr.lirmm.graphik.graal.store.rdbms.rule_applier.SQLRuleApplier)1 Theory (org.junit.experimental.theories.Theory)1