use of org.openrdf.query.algebra.SingletonSet in project incubator-rya by apache.
the class ConstructConsequentVisitorTest method testConcreteSP.
@Test
public void testConcreteSP() {
Extension extension = new Extension(new SingletonSet(), new ExtensionElem(new ValueConstant(FOAF.PERSON), "x"), new ExtensionElem(new ValueConstant(RDF.TYPE), "y"), new ExtensionElem(new ValueConstant(OWL.CLASS), "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(FOAF.PERSON), p(RDF.TYPE), o(OWL.CLASS)));
Assert.assertEquals(expected, visitor.getConsequents());
}
use of org.openrdf.query.algebra.SingletonSet in project incubator-rya by apache.
the class ConstructConsequentVisitorTest method testMissingVariables.
@Test
public void testMissingVariables() {
Extension extension = new Extension(new SingletonSet(), new ExtensionElem(new ValueConstant(FOAF.PERSON), "x"), new ExtensionElem(new ValueConstant(RDF.TYPE), "y"));
Projection projection = new Projection(extension, new ProjectionElemList(new ProjectionElem("x", "s"), 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(RDF.TYPE), o(null)));
Assert.assertEquals(expected, visitor.getConsequents());
}
use of org.openrdf.query.algebra.SingletonSet in project incubator-rya by apache.
the class FilterSerializer method serialize.
/**
* Converts a {@link Filter} to a SPARQL query containing only the SPARQL representation
* of the Filter along with a Select clause that return all variables. The argument of the
* Filter is replaced by a {@link SingletonSet} so that the body of the SPARQL query consists of only a
* single Filter clause.
* @param filter - Filter to be serialized
* @return - SPARQL String containing a single Filter clause that represents the serialized Filter
* @throws FilterParseException
*/
public static String serialize(Filter filter) throws FilterParseException {
Filter clone = filter.clone();
clone.setArg(new SingletonSet());
try {
return removeAngularBracketsFromNonUriFunctions(renderer.render(new ParsedTupleQuery(clone)));
} catch (Exception e) {
throw new FilterParseException("Unable to parse Filter.", e);
}
}
use of org.openrdf.query.algebra.SingletonSet in project incubator-rya by apache.
the class ConstructConsequentVisitorTest method testBNode.
@Test
public void testBNode() {
Extension extension = new Extension(new SingletonSet(), new ExtensionElem(new Var("x"), "x"), new ExtensionElem(new BNodeGenerator(), "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), anon(o(null))));
Assert.assertEquals(expected, visitor.getConsequents());
}
use of org.openrdf.query.algebra.SingletonSet 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());
}
Aggregations