use of fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet in project graal by graphik-team.
the class TestUtil method getAtomSet.
public static AtomSet[] getAtomSet() {
if (neo4jStore != null) {
neo4jStore.close();
}
try {
if (defaultRDBMSStore != null) {
defaultRDBMSStore.close();
}
if (plainTableRDBMSStore != null) {
plainTableRDBMSStore.close();
}
defaultRDBMSStore = new AdHocRdbmsStore(new HSQLDBDriver(DEFAULT_RDBMS_TEST, null));
plainTableRDBMSStore = new NaturalRDBMSStore(new HSQLDBDriver(PLAIN_TABLE_RDBMS_TEST, null));
defaultRDBMSStore.clear();
plainTableRDBMSStore.clear();
rm(NEO4J_TEST);
neo4jStore = new Neo4jStore(NEO4J_TEST);
if (sailStore != null) {
sailStore.close();
}
try {
sailStore = new RDF4jStore(new SailRepository(new MemoryStore()));
} catch (AtomSetException e) {
Assert.assertTrue("Error while creating SailStore", false);
}
return new AtomSet[] { new DefaultInMemoryGraphStore(), new LinkedListAtomSet(), defaultRDBMSStore, plainTableRDBMSStore, neo4jStore, sailStore };
} catch (SQLException e) {
throw new Error(e);
} catch (AtomSetException e) {
throw new Error(e);
}
}
use of fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet in project graal by graphik-team.
the class PureHomomorphismTest method issue34.
@Theory
public void issue34(ExistentialHomomorphismWithCompilation<InMemoryAtomSet, AtomSet> h) throws HomomorphismException, IteratorException, ParseException {
InMemoryAtomSet query1 = new LinkedListAtomSet();
query1.add(DlgpParser.parseAtom("p(a,Y)."));
InMemoryAtomSet facts = new LinkedListAtomSet();
facts.add(DlgpParser.parseAtom("q(a,b)."));
RuleSet rules = new LinkedListRuleSet();
rules.add(DlgpParser.parseRule("p(X,Y) :- q(Y,X)."));
RulesCompilation comp = new IDCompilation();
comp.compile(rules.iterator());
Assert.assertFalse(h.exist(query1, facts, comp));
}
use of fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet in project graal by graphik-team.
the class OWLAxiomParser method visit.
@Override
public Iterable<? extends Object> visit(OWLDifferentIndividualsAxiom arg) {
Collection<Object> c = GraalUtils.<Object>createCollection();
LinkedList<OWLIndividual> list = new LinkedList<OWLIndividual>(arg.getIndividualsAsList());
Iterator<OWLIndividual> it1, it2;
it1 = list.iterator();
while (it1.hasNext()) {
OWLIndividual individu1 = it1.next();
it1.remove();
Term t1 = GraalUtils.createTerm(individu1);
it2 = list.iterator();
while (it2.hasNext()) {
OWLIndividual individu2 = it2.next();
Term t2 = GraalUtils.createTerm(individu2);
Atom a = new DefaultAtom(equalityPredicate, t1, t2);
c.add(new DefaultNegativeConstraint(new LinkedListAtomSet(a)));
}
}
return c;
}
use of fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet in project graal by graphik-team.
the class AbstractDlgpListener method startsObject.
@Override
public void startsObject(OBJECT_TYPE objectType, String name) {
this.label = (name == null) ? "" : name;
atomSet = new LinkedListAtomSet();
atomSet2 = null;
if (OBJECT_TYPE.QUERY.equals(objectType)) {
this.answerVars = new LinkedList<Term>();
}
}
use of fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet in project graal by graphik-team.
the class AbstractDlgpListener method endsConjunction.
@Override
public void endsConjunction(OBJECT_TYPE objectType) {
switch(objectType) {
case QUERY:
Set<Variable> bodyVars = this.atomSet.getVariables();
for (Term t : this.answerVars) {
if (t.isVariable() && !bodyVars.contains(t)) {
throw new ParseError("The variable [" + t + "] of the answer list does not appear in the query body.");
}
}
this.createQuery(DefaultConjunctiveQueryFactory.instance().create(this.label, this.atomSet, this.answerVars));
break;
case NEG_CONSTRAINT:
this.createNegConstraint(new DefaultNegativeConstraint(this.label, this.atomSet));
break;
case RULE:
if (this.atomSet2 == null) {
this.atomSet2 = this.atomSet;
this.atomSet = new LinkedListAtomSet();
} else {
this.createRule(DefaultRuleFactory.instance().create(this.label, this.atomSet, this.atomSet2));
}
break;
case FACT:
this.createAtomSet(this.atomSet);
break;
default:
break;
}
}
Aggregations