use of fr.lirmm.graphik.graal.api.forward_chaining.RuleApplicationException in project graal by graphik-team.
the class AbstractRuleApplier method apply.
@Override
public boolean apply(Rule rule, T atomSet) throws RuleApplicationException {
boolean isChanged = false;
ConjunctiveQuery query = this.generateQuery(rule);
try {
CloseableIterator<Substitution> subIt = this.executeQuery(query, atomSet);
while (subIt.hasNext()) {
Substitution substitution = subIt.next();
CloseableIterator<Atom> it = this.getHaltingCondition().apply(rule, substitution, atomSet);
if (it.hasNext()) {
atomSet.addAll(it);
isChanged = true;
}
}
subIt.close();
} catch (HomomorphismFactoryException e) {
throw new RuleApplicationException("Error during rule application", e);
} catch (HomomorphismException e) {
throw new RuleApplicationException("Error during rule application", e);
} catch (AtomSetException e) {
throw new RuleApplicationException("Error during rule application", e);
} catch (IteratorException e) {
throw new RuleApplicationException("Error during rule application", e);
}
return isChanged;
}
use of fr.lirmm.graphik.graal.api.forward_chaining.RuleApplicationException in project graal by graphik-team.
the class AbstractRuleApplier method delegatedApply.
@Override
public CloseableIterator<Atom> delegatedApply(Rule rule, T atomSetOnWichQuerying, T atomSetOnWichCheck) throws RuleApplicationException {
ConjunctiveQuery query = this.generateQuery(rule);
CloseableIterator<Substitution> subIt;
try {
subIt = this.executeQuery(query, atomSetOnWichQuerying);
} catch (HomomorphismFactoryException e) {
throw new RuleApplicationException("Error during rule application", e);
} catch (HomomorphismException e) {
throw new RuleApplicationException("Error during rule application", e);
}
return new RuleApplierIterator(subIt, rule, atomSetOnWichCheck, haltingCondition);
}
use of fr.lirmm.graphik.graal.api.forward_chaining.RuleApplicationException in project graal by graphik-team.
the class StoreTest method bugConcurrentModificationException.
@Theory
public void bugConcurrentModificationException(InMemoryAtomSet store) throws IteratorException, RuleApplicationException, AtomSetException {
Assume.assumeTrue(store instanceof Store);
Rule r = DlgpParser.parseRule("<T>(Z,W), <P>(Y,W) :- <P>(X,Y).");
store.addAll(DlgpParser.parseAtomSet("<P>(a,a)."));
try {
DefaultRuleApplier<InMemoryAtomSet> applier = new DefaultRuleApplier<InMemoryAtomSet>();
applier.apply(r, store);
applier.apply(r, store);
} catch (Exception e) {
Assert.fail();
}
}
Aggregations