Search in sources :

Example 11 with Extension

use of org.openrdf.query.algebra.Extension in project incubator-rya by apache.

the class ConstructConsequentVisitorTest method testGenericSP.

@Test
public void testGenericSP() {
    Extension extension = new Extension(new SingletonSet(), new ExtensionElem(new Var("z"), "z"));
    Projection projection = new Projection(extension, new ProjectionElemList(new ProjectionElem("x", "subject"), new ProjectionElem("y", "predicate"), new ProjectionElem("z", "object")));
    ConstructConsequentVisitor visitor = new ConstructConsequentVisitor();
    projection.visit(visitor);
    Set<StatementPattern> expected = Sets.newHashSet(new StatementPattern(s(null), p(null), o(null)));
    Assert.assertEquals(expected, visitor.getConsequents());
}
Also used : Extension(org.openrdf.query.algebra.Extension) ProjectionElemList(org.openrdf.query.algebra.ProjectionElemList) StatementPattern(org.openrdf.query.algebra.StatementPattern) SingletonSet(org.openrdf.query.algebra.SingletonSet) Var(org.openrdf.query.algebra.Var) ExtensionElem(org.openrdf.query.algebra.ExtensionElem) MultiProjection(org.openrdf.query.algebra.MultiProjection) Projection(org.openrdf.query.algebra.Projection) ProjectionElem(org.openrdf.query.algebra.ProjectionElem) Test(org.junit.Test)

Example 12 with Extension

use of org.openrdf.query.algebra.Extension in project incubator-rya by apache.

the class ConstructConsequentVisitorTest method testMultiProjection.

@Test
public void testMultiProjection() {
    Extension extension = new Extension(new SingletonSet(), new ExtensionElem(new ValueConstant(RDF.TYPE), "rdftype"), new ExtensionElem(new ValueConstant(OWL.OBJECTPROPERTY), "owlprop"), new ExtensionElem(new ValueConstant(OWL.EQUIVALENTCLASS), "owleqcls"), new ExtensionElem(new ValueConstant(OWL.CLASS), "owlclass"));
    MultiProjection projection = new MultiProjection(extension, Arrays.asList(new ProjectionElemList(new ProjectionElem("cls", "subject"), new ProjectionElem("rdftype", "predicate"), new ProjectionElem("owlclass", "object")), new ProjectionElemList(new ProjectionElem("prop", "subject"), new ProjectionElem("rdftype", "predicate"), new ProjectionElem("owlprop", "object")), new ProjectionElemList(new ProjectionElem("owleqcls", "predicate"), new ProjectionElem("cls", "object"))));
    ConstructConsequentVisitor visitor = new ConstructConsequentVisitor();
    projection.visit(visitor);
    Set<StatementPattern> expected = Sets.newHashSet(new StatementPattern(s(null), p(RDF.TYPE), o(OWL.CLASS)), new StatementPattern(s(null), p(RDF.TYPE), o(OWL.OBJECTPROPERTY)), new StatementPattern(s(null), p(OWL.EQUIVALENTCLASS), o(null)));
    Assert.assertEquals(expected, visitor.getConsequents());
}
Also used : Extension(org.openrdf.query.algebra.Extension) ProjectionElemList(org.openrdf.query.algebra.ProjectionElemList) StatementPattern(org.openrdf.query.algebra.StatementPattern) SingletonSet(org.openrdf.query.algebra.SingletonSet) ValueConstant(org.openrdf.query.algebra.ValueConstant) ExtensionElem(org.openrdf.query.algebra.ExtensionElem) MultiProjection(org.openrdf.query.algebra.MultiProjection) ProjectionElem(org.openrdf.query.algebra.ProjectionElem) Test(org.junit.Test)

Aggregations

Extension (org.openrdf.query.algebra.Extension)12 ExtensionElem (org.openrdf.query.algebra.ExtensionElem)11 StatementPattern (org.openrdf.query.algebra.StatementPattern)10 Test (org.junit.Test)9 ProjectionElemList (org.openrdf.query.algebra.ProjectionElemList)9 ProjectionElem (org.openrdf.query.algebra.ProjectionElem)7 Var (org.openrdf.query.algebra.Var)7 Projection (org.openrdf.query.algebra.Projection)6 MultiProjection (org.openrdf.query.algebra.MultiProjection)5 SingletonSet (org.openrdf.query.algebra.SingletonSet)5 ValueConstant (org.openrdf.query.algebra.ValueConstant)5 HashSet (java.util.HashSet)3 Resource (org.openrdf.model.Resource)3 TupleExpr (org.openrdf.query.algebra.TupleExpr)3 BNodeGenerator (org.openrdf.query.algebra.BNodeGenerator)2 QueryRoot (org.openrdf.query.algebra.QueryRoot)2 Union (org.openrdf.query.algebra.Union)2 URI (org.openrdf.model.URI)1 Not (org.openrdf.query.algebra.Not)1