Search in sources :

Example 1 with Service

use of org.eclipse.rdf4j.query.algebra.Service in project rdf4j by eclipse.

the class TupleExprBuilder method visit.

@Override
public Object visit(ASTServiceGraphPattern node, Object data) throws VisitorException {
    GraphPattern parentGP = graphPattern;
    ValueExpr serviceRef = (ValueExpr) node.jjtGetChild(0).jjtAccept(this, null);
    graphPattern = new GraphPattern(parentGP);
    node.jjtGetChild(1).jjtAccept(this, null);
    TupleExpr serviceExpr = graphPattern.buildTupleExpr();
    if (serviceExpr instanceof SingletonSet)
        // do not add an empty service block
        return null;
    String serviceExpressionString = node.getPatternString();
    parentGP.addRequiredTE(new Service(mapValueExprToVar(serviceRef), serviceExpr, serviceExpressionString, node.getPrefixDeclarations(), node.getBaseURI(), node.isSilent()));
    graphPattern = parentGP;
    return null;
}
Also used : ValueExpr(org.eclipse.rdf4j.query.algebra.ValueExpr) SingletonSet(org.eclipse.rdf4j.query.algebra.SingletonSet) Service(org.eclipse.rdf4j.query.algebra.Service) TupleExpr(org.eclipse.rdf4j.query.algebra.TupleExpr)

Example 2 with Service

use of org.eclipse.rdf4j.query.algebra.Service in project rdf4j by eclipse.

the class TupleExprBuilderTest method testServiceGraphPatternChopping.

@Test
public void testServiceGraphPatternChopping() throws Exception {
    // just for construction
    Service service = new Service(null, new SingletonSet(), "", null, null, false);
    service.setExpressionString("SERVICE <a> { ?s ?p ?o }");
    assertEquals("?s ?p ?o", service.getServiceExpressionString());
    service.setExpressionString("SERVICE <a> {?s ?p ?o}");
    assertEquals("?s ?p ?o", service.getServiceExpressionString());
}
Also used : SingletonSet(org.eclipse.rdf4j.query.algebra.SingletonSet) Service(org.eclipse.rdf4j.query.algebra.Service) Test(org.junit.Test)

Aggregations

Service (org.eclipse.rdf4j.query.algebra.Service)2 SingletonSet (org.eclipse.rdf4j.query.algebra.SingletonSet)2 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)1 ValueExpr (org.eclipse.rdf4j.query.algebra.ValueExpr)1 Test (org.junit.Test)1