use of org.apache.jena.sparql.syntax.ElementMinus in project jena by apache.
the class WhereClauseTest method testAddMinus.
@ContractTest
public void testAddMinus() {
SelectBuilder sb = new SelectBuilder();
sb.addPrefix("pfx", "uri").addVar("?x").addWhere("<one>", "<two>", "three");
WhereClause<?> whereClause = getProducer().newInstance();
AbstractQueryBuilder<?> builder = whereClause.addMinus(sb);
Query query = builder.build();
ElementPathBlock epb = new ElementPathBlock();
ElementMinus minus = new ElementMinus(epb);
epb.addTriplePath(new TriplePath(new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createLiteral("three"))));
WhereValidator visitor = new WhereValidator(minus);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.sparql.syntax.ElementMinus in project jena by apache.
the class WhereQuadHolder method addMinus.
/**
* Add a minus operation to the where clause. The prefixes will be updated with
* the prefixes from the abstract query builder.
*
* @param qb the abstract builder that defines the data to subtract.
*/
public void addMinus(AbstractQueryBuilder<?> qb) {
prefixHandler.addPrefixes(qb.getPrologHandler().getPrefixes());
ElementGroup clause = getClause();
ElementMinus minus = new ElementMinus(qb.getWhereHandler().getClause());
clause.addElement(minus);
}
use of org.apache.jena.sparql.syntax.ElementMinus in project jena by apache.
the class WhereHandlerTest method testAddMinus.
@Test
public void testAddMinus() {
SelectBuilder sb = new SelectBuilder();
sb.addPrefix("pfx", "uri").addWhere("<one>", "<two>", "three");
handler.addMinus(sb);
handler.build();
ElementPathBlock epb = new ElementPathBlock();
ElementMinus minus = new ElementMinus(epb);
epb.addTriplePath(new TriplePath(new Triple(NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createLiteral("three"))));
WhereValidator visitor = new WhereValidator(minus);
query.getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.sparql.syntax.ElementMinus in project jena by apache.
the class WhereHandler method addMinus.
/**
* Add a minus operation to the where clause. The prolog will be updated with
* the prefixes from the abstract query builder.
*
* @param qb the abstract builder that defines the data to subtract.
*/
public void addMinus(AbstractQueryBuilder<?> qb) {
PrologHandler ph = new PrologHandler(query);
ph.addPrefixes(qb.getPrologHandler().getPrefixes());
ElementGroup clause = getClause();
ElementMinus minus = new ElementMinus(qb.getWhereHandler().getClause());
clause.addElement(minus);
}
use of org.apache.jena.sparql.syntax.ElementMinus in project jena by apache.
the class ElementRewriter method visit.
@Override
public void visit(ElementMinus el) {
el.getMinusElement().visit(this);
push(new ElementMinus(getResult()));
}
Aggregations