Search in sources :

Example 56 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternQueryExpressionTests method test_8.

/**
 * Test 8.
 */
@Test
@Order(8)
void test_8() {
    CharStream input = CharStreams.fromString(":Location@:appearsOn[ rdfs:label \"eastman3d\" ]#[a :Location ]/:lat");
    PathElement element = prepareElement(input);
    // Query.assertEqualsWOSpaces
    assertEquals("Join\r\n" + "   Join\r\n" + "      Join\r\n" + "         Join\r\n" + "            Join\r\n" + "               StatementPattern\r\n" + "                  Variable (name=r1)\r\n" + "                  Variable (name=subject1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "                  Variable (name=n0)\r\n" + "               StatementPattern\r\n" + "                  Variable (name=r1)\r\n" + "                  Variable (name=property1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "                  Variable (name=p_n0_n1, value=http://default/appearsOn)\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1)\r\n" + "               Variable (name=object1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "               Variable (name=n1)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n1)\r\n" + "            Variable (name=p_n1_n1_1, value=http://rdfs/label)\r\n" + "            Variable (name=n1_1, value=\"eastman3d\")\r\n" + "      StatementPattern\r\n" + "         Variable (name=r1)\r\n" + "         Variable (name=p_r1_n0_1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#type)\r\n" + "         Variable (name=n0_1, value=http://default/Location)\r\n" + "   StatementPattern\r\n" + "      Variable (name=r1)\r\n" + "      Variable (name=p_r1_n2, value=http://default/lat)\r\n" + "      Variable (name=n2)\r\n" + "", element.pathPatternQuery().toString());
}
Also used : PathElement(com.inova8.pathql.element.PathElement) CharStream(org.antlr.v4.runtime.CharStream) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 57 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternQueryExpressionTests method test_11.

/**
 * Test 11.
 */
@Test
@Order(11)
void test_11() {
    try {
        String expression = ":Location@:appearsOn[eq id:Calc2Graph2]#";
        CharStream input = CharStreams.fromString(expression);
        PathPatternLexer lexer = new PathPatternLexer(input);
        PathErrorListener errorListener = new PathErrorListener(expression);
        lexer.removeErrorListeners();
        lexer.addErrorListener(errorListener);
        CommonTokenStream tokens = new CommonTokenStream(lexer);
        PathPatternParser parser = new PathPatternParser(tokens);
        parser.removeErrorListeners();
        parser.addErrorListener(errorListener);
        PathPatternContext pathPatternTree = parser.pathPattern();
        PathPatternVisitor pathPatternVisitor = new PathPatternVisitor(repositoryContext);
        PathElement element = pathPatternVisitor.visit(pathPatternTree);
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   Join\r\n" + "      StatementPattern\r\n" + "         Variable (name=rnull)\r\n" + "         Variable (name=subjectnull, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "         Variable (name=nnull)\r\n" + "      StatementPattern\r\n" + "         Variable (name=rnull)\r\n" + "         Variable (name=propertynull, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "         Variable (name=p_nnull_nnull, value=http://default/appearsOn)\r\n" + "   StatementPattern\r\n" + "      Variable (name=rnull)\r\n" + "      Variable (name=objectnull, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "      Variable (name=nnull, value=http://id/Calc2Graph2)\r\n" + "", element.pathPatternQuery().toString());
    } catch (Exception e) {
        Query.assertEqualsWOSpaces("<http://default/Location>@<http://default/appearsOn>[eq <http://id/Calc2Graph2> ;]#", "");
    }
}
Also used : PathPatternVisitor(com.inova8.pathql.processor.PathPatternVisitor) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) PathElement(com.inova8.pathql.element.PathElement) PathPatternParser(com.inova8.pathql.pathPattern.PathPatternParser) PathPatternLexer(com.inova8.pathql.pathPattern.PathPatternLexer) PathErrorListener(com.inova8.pathql.processor.PathErrorListener) PathPatternContext(com.inova8.pathql.pathPattern.PathPatternParser.PathPatternContext) CharStream(org.antlr.v4.runtime.CharStream) RecognitionException(org.antlr.v4.runtime.RecognitionException) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 58 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternQueryExpressionTests method test_9.

/**
 * Test 9.
 */
@Test
@Order(9)
void test_9() {
    CharStream input = CharStreams.fromString(":Location@:appearsOn#[:location.Map  id:Calc2Graph2 ]/:long");
    PathElement element = prepareElement(input);
    // Query.assertEqualsWOSpaces
    assertEquals("Join\r\n" + "   Join\r\n" + "      Join\r\n" + "         Join\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1)\r\n" + "               Variable (name=subject1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=n0)\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1)\r\n" + "               Variable (name=property1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=p_n0_n1, value=http://default/appearsOn)\r\n" + "         StatementPattern\r\n" + "            Variable (name=r1)\r\n" + "            Variable (name=object1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=n1)\r\n" + "      StatementPattern\r\n" + "         Variable (name=r1)\r\n" + "         Variable (name=p_r1_n0_1, value=http://default/location.Map)\r\n" + "         Variable (name=n0_1, value=http://id/Calc2Graph2)\r\n" + "   StatementPattern\r\n" + "      Variable (name=r1)\r\n" + "      Variable (name=p_r1_n2, value=http://default/long)\r\n" + "      Variable (name=n2)\r\n" + "", element.pathPatternQuery().toString());
}
Also used : PathElement(com.inova8.pathql.element.PathElement) CharStream(org.antlr.v4.runtime.CharStream) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 59 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternSPARQLTests method test_9.

/**
 * Test 9.
 *
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
@Test
@Order(9)
void test_9() throws RecognitionException, PathPatternException {
    PathElement element = PathParser.parsePathPattern(repositoryContext, ":Location@:appearsOn#[:location.Map  id:Calc2Graph2 ]/:long");
    assertEquals("?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> ?n0\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://default/appearsOn>\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?n1\r\n" + "?r1 <http://default/location.Map> <http://id/Calc2Graph2> .\r\n" + "?r1 <http://default/long> ?n2 .\r\n" + "", element.toSPARQL());
}
Also used : PathElement(com.inova8.pathql.element.PathElement) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 60 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternSPARQLTests method test_8.

/**
 * Test 8.
 *
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
@Test
@Order(8)
void test_8() throws RecognitionException, PathPatternException {
    PathElement element = PathParser.parsePathPattern(repositoryContext, ":Location@:appearsOn[ rdfs:label \"eastman3d\" ]#[a :Location ]/:lat");
    assertEquals("?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> ?n0\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://default/appearsOn>\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?n1\r\n" + "?n1 <http://rdfs/label> 'eastman3d' .\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://default/Location> .\r\n" + "?r1 <http://default/lat> ?n2 .\r\n" + "", element.toSPARQL());
}
Also used : PathElement(com.inova8.pathql.element.PathElement) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

Order (org.junit.jupiter.api.Order)26 Test (org.junit.jupiter.api.Test)26 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)26 PathElement (com.inova8.pathql.element.PathElement)22 IRI (org.eclipse.rdf4j.model.IRI)15 Thing (com.inova8.intelligentgraph.model.Thing)12 PathTupleExpr (com.inova8.intelligentgraph.path.PathTupleExpr)10 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)10 RecognitionException (org.antlr.v4.runtime.RecognitionException)9 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)8 CharStream (org.antlr.v4.runtime.CharStream)8 Statement (org.eclipse.rdf4j.model.Statement)8 Value (org.eclipse.rdf4j.model.Value)8 EvaluationContext (com.inova8.intelligentgraph.evaluator.EvaluationContext)7 SimpleLiteral (org.eclipse.rdf4j.model.impl.SimpleLiteral)7 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)6 Resource (com.inova8.intelligentgraph.model.Resource)6 Join (org.eclipse.rdf4j.query.algebra.Join)6 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)6 PathPatternException (com.inova8.pathql.processor.PathPatternException)5