Search in sources :

Example 1 with LinkedListAtomSet

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);
    }
}
Also used : Neo4jStore(fr.lirmm.graphik.graal.store.gdb.Neo4jStore) RDF4jStore(fr.lirmm.graphik.graal.store.triplestore.rdf4j.RDF4jStore) SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) SQLException(java.sql.SQLException) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) AtomSet(fr.lirmm.graphik.graal.api.core.AtomSet) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) IOError(java.io.IOError) NaturalRDBMSStore(fr.lirmm.graphik.graal.store.rdbms.natural.NaturalRDBMSStore) AdHocRdbmsStore(fr.lirmm.graphik.graal.store.rdbms.adhoc.AdHocRdbmsStore) MemoryStore(org.eclipse.rdf4j.sail.memory.MemoryStore) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) HSQLDBDriver(fr.lirmm.graphik.graal.store.rdbms.driver.HSQLDBDriver) DefaultInMemoryGraphStore(fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore)

Example 2 with LinkedListAtomSet

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));
}
Also used : RuleSet(fr.lirmm.graphik.graal.api.core.RuleSet) LinkedListRuleSet(fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet) IDCompilation(fr.lirmm.graphik.graal.core.compilation.IDCompilation) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) LinkedListRuleSet(fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet) RulesCompilation(fr.lirmm.graphik.graal.api.core.RulesCompilation) Theory(org.junit.experimental.theories.Theory)

Example 3 with LinkedListAtomSet

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;
}
Also used : DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) Term(fr.lirmm.graphik.graal.api.core.Term) LinkedList(java.util.LinkedList) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) Atom(fr.lirmm.graphik.graal.api.core.Atom) OWLIndividual(org.semanticweb.owlapi.model.OWLIndividual)

Example 4 with LinkedListAtomSet

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>();
    }
}
Also used : LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) Term(fr.lirmm.graphik.graal.api.core.Term)

Example 5 with LinkedListAtomSet

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;
    }
}
Also used : DefaultNegativeConstraint(fr.lirmm.graphik.graal.core.DefaultNegativeConstraint) Variable(fr.lirmm.graphik.graal.api.core.Variable) LinkedListAtomSet(fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet) ParseError(fr.lirmm.graphik.graal.api.io.ParseError) Term(fr.lirmm.graphik.graal.api.core.Term)

Aggregations

LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)52 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)35 Atom (fr.lirmm.graphik.graal.api.core.Atom)28 LinkedList (java.util.LinkedList)19 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)18 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)17 Term (fr.lirmm.graphik.graal.api.core.Term)17 DefaultInMemoryGraphStore (fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore)11 Theory (org.junit.experimental.theories.Theory)11 DefaultConjunctiveQuery (fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery)9 Test (org.junit.Test)9 Variable (fr.lirmm.graphik.graal.api.core.Variable)8 DefaultConjunctiveQueryWithNegatedParts (fr.lirmm.graphik.graal.core.DefaultConjunctiveQueryWithNegatedParts)8 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)7 Rule (fr.lirmm.graphik.graal.api.core.Rule)6 AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)5 SubstitutionIterator2AtomIterator (fr.lirmm.graphik.graal.core.stream.SubstitutionIterator2AtomIterator)5 SqlHomomorphism (fr.lirmm.graphik.graal.store.rdbms.homomorphism.SqlHomomorphism)5 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)4 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)4