Search in sources :

Example 1 with Query

use of fr.lirmm.graphik.graal.api.core.Query in project graal by graphik-team.

the class DefaultUnionOfConjunctiveQueries method appendTo.

@Override
public void appendTo(StringBuilder sb) {
    for (Query q : this.queries) {
        sb.append(q);
        sb.append("\n| ");
    }
}
Also used : ConjunctiveQuery(fr.lirmm.graphik.graal.api.core.ConjunctiveQuery) Query(fr.lirmm.graphik.graal.api.core.Query)

Example 2 with Query

use of fr.lirmm.graphik.graal.api.core.Query in project graal by graphik-team.

the class DefaultKnowledgeBaseTest method testAddTwoQueryWithSameNames.

/**
 * Test method for
 * {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#addQuery(fr.lirmm.graphik.graal.api.core.Query)}.
 * @throws ParseException
 */
@Test
public void testAddTwoQueryWithSameNames() throws ParseException {
    Query q1 = DlgpParser.parseQuery("[Q] ? :- q1(X).");
    Query q2 = DlgpParser.parseQuery("[Q] ? :- q2(X).");
    KnowledgeBase kb = new KBBuilder().build();
    kb.addQuery(q1);
    kb.addQuery(q2);
    Assert.assertTrue(kb.getQueryNames().contains("Q"));
    Assert.assertEquals(q1, kb.getQuery("Q"));
    Assert.assertEquals(2, kb.getQueryNames().size());
    kb.close();
}
Also used : Query(fr.lirmm.graphik.graal.api.core.Query) KnowledgeBase(fr.lirmm.graphik.graal.api.kb.KnowledgeBase) Test(org.junit.Test)

Example 3 with Query

use of fr.lirmm.graphik.graal.api.core.Query in project graal by graphik-team.

the class DefaultKnowledgeBaseTest method testAddSameQueryTwice.

/**
 * Test method for
 * {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#addQuery(fr.lirmm.graphik.graal.api.core.Query)}.
 * @throws ParseException
 */
@Test
public void testAddSameQueryTwice() throws ParseException {
    Query q1 = DlgpParser.parseQuery("[Q1] ? :- p(X).");
    KnowledgeBase kb = new KBBuilder().build();
    kb.addQuery(q1);
    kb.addQuery(q1);
    Assert.assertTrue(kb.getQueryNames().contains("Q1"));
    Assert.assertEquals(q1, kb.getQuery("Q1"));
    Assert.assertEquals(1, kb.getQueryNames().size());
    kb.close();
}
Also used : Query(fr.lirmm.graphik.graal.api.core.Query) KnowledgeBase(fr.lirmm.graphik.graal.api.kb.KnowledgeBase) Test(org.junit.Test)

Example 4 with Query

use of fr.lirmm.graphik.graal.api.core.Query in project graal by graphik-team.

the class DefaultKnowledgeBaseTest method testAddQuery.

/**
 * Test method for
 * {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#addQuery(fr.lirmm.graphik.graal.api.core.Query)}.
 * @throws ParseException
 */
@Test
public void testAddQuery() throws ParseException {
    Query q1 = DlgpParser.parseQuery("[Q1] ? :- p(X).");
    KnowledgeBase kb = new KBBuilder().build();
    kb.addQuery(q1);
    Assert.assertTrue(kb.getQueryNames().contains("Q1"));
    Assert.assertEquals(q1, kb.getQuery("Q1"));
    kb.close();
}
Also used : Query(fr.lirmm.graphik.graal.api.core.Query) KnowledgeBase(fr.lirmm.graphik.graal.api.kb.KnowledgeBase) Test(org.junit.Test)

Aggregations

Query (fr.lirmm.graphik.graal.api.core.Query)4 KnowledgeBase (fr.lirmm.graphik.graal.api.kb.KnowledgeBase)3 Test (org.junit.Test)3 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)1