use of fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException 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.homomorphism.HomomorphismException 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.homomorphism.HomomorphismException in project graal by graphik-team.
the class FullyInstantiatedQueryHomomorphism method execute.
// /////////////////////////////////////////////////////////////////////////
// HOMOMORPHISM METHODS
// /////////////////////////////////////////////////////////////////////////
public <U2 extends AtomSet> CloseableIterator<Substitution> execute(InMemoryAtomSet q, U2 a) throws HomomorphismException {
try {
CloseableIteratorWithoutException<Atom> it = q.iterator();
boolean contains = true;
while (contains && it.hasNext()) {
contains = a.contains(it.next());
}
if (contains) {
return Iterators.singletonIterator(Substitutions.emptySubstitution());
} else {
return Iterators.emptyIterator();
}
} catch (AtomSetException e) {
throw new HomomorphismException(e);
}
}
use of fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException in project graal by graphik-team.
the class PreparedBacktrackHomomorphism method exist.
// /////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public boolean exist(Substitution s) throws HomomorphismException {
CloseableIterator<Substitution> results = this.execute(s);
boolean val;
try {
val = results.hasNext();
} catch (IteratorException e) {
throw new HomomorphismException(e);
}
results.close();
return val;
}
use of fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException in project graal by graphik-team.
the class DefaultUCQHomomorphismWithCompilation method exist.
@Override
public boolean exist(UnionOfConjunctiveQueries q, AtomSet a, RulesCompilation compilation) throws HomomorphismException {
try {
CloseableIterator<Substitution> execute = this.execute(q, a, compilation);
boolean res = execute.hasNext();
execute.close();
return res;
} catch (IteratorException e) {
throw new HomomorphismException(e);
}
}
Aggregations