Search in sources :

Example 6 with PathTupleExpr

use of com.inova8.intelligentgraph.path.PathTupleExpr in project com.inova8.intelligentgraph by peterjohnlawrence.

the class MultiPathPatternQueryExpressionTests method test_9.

/**
 * Test 9.
 */
@Test
@Order(9)
void test_9() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, "(^:hasProductBatteryLimit/*){1, 2}/:massThroughput");
        PathTupleExpr pathTupleExpr = element.pathPatternQuery(1, null);
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   Join\r\n" + "      Join\r\n" + "         StatementPattern\r\n" + "            Variable (name=n0_in1)\r\n" + "            Variable (name=p_n0_n0_in1, value=http://default/hasProductBatteryLimit)\r\n" + "            Variable (name=n0)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n0_in1)\r\n" + "            Variable (name=p_n0_in1_n0_i1)\r\n" + "            Variable (name=n0_i1)\r\n" + "      Join\r\n" + "         StatementPattern\r\n" + "            Variable (name=n0_in2)\r\n" + "            Variable (name=p_n0_i1_n0_in2, value=http://default/hasProductBatteryLimit)\r\n" + "            Variable (name=n0_i1)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n0_in2)\r\n" + "            Variable (name=p_n0_in2_n2)\r\n" + "            Variable (name=n2)\r\n" + "   StatementPattern\r\n" + "      Variable (name=n2)\r\n" + "      Variable (name=p_n2_n3, value=http://default/massThroughput)\r\n" + "      Variable (name=n3)\r\n" + "", pathTupleExpr.toString());
        assertEquals("[n0,http://default/hasProductBatteryLimit,n0_in1,INVERSE]\r\n" + "[n0_in1,p_n0_in1_n0_i1,n0_i1,DIRECT]\r\n" + "[n0_i1,http://default/hasProductBatteryLimit,n0_in2,INVERSE]\r\n" + "[n0_in2,p_n0_in2_n2,n2,DIRECT]\r\n" + "[n2,http://default/massThroughput,n3,DIRECT]\r\n" + "", pathTupleExpr.pathToString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : PathElement(com.inova8.pathql.element.PathElement) PathTupleExpr(com.inova8.intelligentgraph.path.PathTupleExpr) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 7 with PathTupleExpr

use of com.inova8.intelligentgraph.path.PathTupleExpr in project com.inova8.intelligentgraph by peterjohnlawrence.

the class MultiPathPatternQueryExpressionTests method test_2.

/**
 * Test 2.
 */
@Test
@Order(2)
void test_2() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, ":hasProductBatteryLimit{1, 8}");
        Iterations iterations = Iterations.create(element);
        assertEquals("{0=1, 1=2, 2=3, 3=4, 4=5, 5=6, 6=7, 7=8}", iterations.toString());
        @SuppressWarnings("unused") Iterations sortedIterations = iterations.sortByPathLength();
        PathTupleExpr pathTupleExpr = element.pathPatternQuery(2, null);
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   Join\r\n" + "      StatementPattern\r\n" + "         Variable (name=n0)\r\n" + "         Variable (name=p_n0_n1, value=http://default/hasProductBatteryLimit)\r\n" + "         Variable (name=n1_i1)\r\n" + "      StatementPattern\r\n" + "         Variable (name=n1_i1)\r\n" + "         Variable (name=p_n0_n1, value=http://default/hasProductBatteryLimit)\r\n" + "         Variable (name=n1_i2)\r\n" + "   StatementPattern\r\n" + "      Variable (name=n1_i2)\r\n" + "      Variable (name=p_n0_n1, value=http://default/hasProductBatteryLimit)\r\n" + "      Variable (name=n1)\r\n" + "", pathTupleExpr.toString());
        assertEquals("[n0,http://default/hasProductBatteryLimit,n1_i1,DIRECT]\r\n" + "[n1_i1,http://default/hasProductBatteryLimit,n1_i2,DIRECT]\r\n" + "[n1_i2,http://default/hasProductBatteryLimit,n1,DIRECT]\r\n" + "", // element.getPathBindings().get(2).toString());
        pathTupleExpr.pathToString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : PathElement(com.inova8.pathql.element.PathElement) PathTupleExpr(com.inova8.intelligentgraph.path.PathTupleExpr) Iterations(com.inova8.pathql.element.Iterations) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 8 with PathTupleExpr

use of com.inova8.intelligentgraph.path.PathTupleExpr in project com.inova8.intelligentgraph by peterjohnlawrence.

the class MultiPathPatternQueryExpressionTests method test_6.

/**
 * Test 6.
 */
@Test
@Order(6)
void test_6() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, "(^:hasProductBatteryLimit/:massThroughput){1,2}");
        PathTupleExpr pathTupleExpr = element.pathPatternQuery(1, null);
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   Join\r\n" + "      StatementPattern\r\n" + "         Variable (name=n0_in1)\r\n" + "         Variable (name=p_n0_n0_in1, value=http://default/hasProductBatteryLimit)\r\n" + "         Variable (name=n0)\r\n" + "      StatementPattern\r\n" + "         Variable (name=n0_in1)\r\n" + "         Variable (name=p_n0_in1_n0_i1, value=http://default/massThroughput)\r\n" + "         Variable (name=n0_i1)\r\n" + "   Join\r\n" + "      StatementPattern\r\n" + "         Variable (name=n0_in2)\r\n" + "         Variable (name=p_n0_i1_n0_in2, value=http://default/hasProductBatteryLimit)\r\n" + "         Variable (name=n0_i1)\r\n" + "      StatementPattern\r\n" + "         Variable (name=n0_in2)\r\n" + "         Variable (name=p_n0_in2_n2, value=http://default/massThroughput)\r\n" + "         Variable (name=n2)\r\n" + "", pathTupleExpr.toString());
        assertEquals("[n0,http://default/hasProductBatteryLimit,n0_in1,INVERSE]\r\n" + "[n0_in1,http://default/massThroughput,n0_i1,DIRECT]\r\n" + "[n0_i1,http://default/hasProductBatteryLimit,n0_in2,INVERSE]\r\n" + "[n0_in2,http://default/massThroughput,n2,DIRECT]\r\n" + "", // element.getPathBindings().get(1).toString());//
        pathTupleExpr.pathToString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : PathElement(com.inova8.pathql.element.PathElement) PathTupleExpr(com.inova8.intelligentgraph.path.PathTupleExpr) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 9 with PathTupleExpr

use of com.inova8.intelligentgraph.path.PathTupleExpr in project com.inova8.intelligentgraph by peterjohnlawrence.

the class MultiPathPatternQueryExpressionTests method test_4.

/**
 * Test 4.
 */
@Test
@Order(4)
void test_4() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, ":Attribute@:density{1, 42}");
        PathTupleExpr pathTupleExpr = element.pathPatternQuery(1, null);
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   Join\r\n" + "      Join\r\n" + "         Union\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1_i1)\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=n0)\r\n" + "               Variable (name=isSubjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=r1_i1)\r\n" + "         Union\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1_i1)\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/density)\r\n" + "            StatementPattern\r\n" + "               Variable (name=p_n0_n1, value=http://default/density)\r\n" + "               Variable (name=isPropertyOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=r1_i1)\r\n" + "      Union\r\n" + "         StatementPattern\r\n" + "            Variable (name=r1_i1)\r\n" + "            Variable (name=object1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=n1_i1)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n1_i1)\r\n" + "            Variable (name=isObjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=r1_i1)\r\n" + "   Join\r\n" + "      Join\r\n" + "         Union\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=n1_i1)\r\n" + "            StatementPattern\r\n" + "               Variable (name=n1_i1)\r\n" + "               Variable (name=isSubjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=r1)\r\n" + "         Union\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/density)\r\n" + "            StatementPattern\r\n" + "               Variable (name=p_n0_n1, value=http://default/density)\r\n" + "               Variable (name=isPropertyOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=r1)\r\n" + "      Union\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=isObjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=r1)\r\n" + "", pathTupleExpr.toString());
        assertEquals("[n0,r1_i1:<http://default/Attribute>@http://default/density,n1_i1,DIRECT,false]\r\n" + "[n1_i1,r1:<http://default/Attribute>@http://default/density,n1,DIRECT,false]\r\n" + "", pathTupleExpr.pathToString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : PathElement(com.inova8.pathql.element.PathElement) PathTupleExpr(com.inova8.intelligentgraph.path.PathTupleExpr) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 10 with PathTupleExpr

use of com.inova8.intelligentgraph.path.PathTupleExpr in project com.inova8.intelligentgraph by peterjohnlawrence.

the class MultiPathPatternQueryExpressionTests method test_1.

/**
 * Test 1.
 */
@Test
@Order(1)
void test_1() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, "^:hasProductBatteryLimit{1, 5}/:massThroughput");
        PathTupleExpr pathTupleExpr = element.pathPatternQuery();
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   StatementPattern\r\n" + "      Variable (name=n1)\r\n" + "      Variable (name=p_n0_n1, value=http://default/hasProductBatteryLimit)\r\n" + "      Variable (name=n0)\r\n" + "   StatementPattern\r\n" + "      Variable (name=n1)\r\n" + "      Variable (name=p_n1_n2, value=http://default/massThroughput)\r\n" + "      Variable (name=n2)\r\n" + "", pathTupleExpr.toString());
        assertEquals("[n0,http://default/hasProductBatteryLimit,n1,INVERSE]\r\n" + "[n1,http://default/massThroughput,n2,DIRECT]\r\n" + "", // element.getPathBindings().get(0).toString());
        pathTupleExpr.pathToString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : PathElement(com.inova8.pathql.element.PathElement) PathTupleExpr(com.inova8.intelligentgraph.path.PathTupleExpr) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

PathTupleExpr (com.inova8.intelligentgraph.path.PathTupleExpr)19 PathElement (com.inova8.pathql.element.PathElement)10 Order (org.junit.jupiter.api.Order)10 Test (org.junit.jupiter.api.Test)10 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)10 Join (org.eclipse.rdf4j.query.algebra.Join)6 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)6 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)3 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)2 StatementBinding (com.inova8.intelligentgraph.path.StatementBinding)2 Filter (org.eclipse.rdf4j.query.algebra.Filter)2 StatementPattern (org.eclipse.rdf4j.query.algebra.StatementPattern)2 Union (org.eclipse.rdf4j.query.algebra.Union)2 QueryException (com.inova8.intelligentgraph.exceptions.QueryException)1 UnionBinding (com.inova8.intelligentgraph.path.UnionBinding)1 Iterations (com.inova8.pathql.element.Iterations)1 ArrayList (java.util.ArrayList)1 IRI (org.eclipse.rdf4j.model.IRI)1 BindingSet (org.eclipse.rdf4j.query.BindingSet)1 And (org.eclipse.rdf4j.query.algebra.And)1