Search in sources :

Example 6 with ServiceNode

use of com.bigdata.rdf.sparql.ast.service.ServiceNode in project wikidata-query-rdf by wikimedia.

the class GeoService method getPatternNode.

/**
 * Extract pattern node from parameters.
 *
 * Pattern node looks like:
 *  ?place wdt:P625 ?location .
 * Both variables would be bound by the service.
 */
protected StatementPatternNode getPatternNode(ServiceCallCreateParams params) {
    ServiceNode serviceNode = params.getServiceNode();
    if (serviceNode == null)
        throw new IllegalArgumentException();
    List<StatementPatternNode> patterns = getStatementPatterns(serviceNode);
    if (patterns.isEmpty()) {
        throw new IllegalArgumentException("This service requires arguments");
    }
    StatementPatternNode pattern = patterns.get(0);
    if (pattern == null) {
        throw new IllegalArgumentException();
    }
    if (!pattern.s().isVariable()) {
        throw new IllegalArgumentException("Search pattern subject must be a variable");
    }
    if (!pattern.p().isConstant()) {
        // FIXME: may be not necessary?
        throw new IllegalArgumentException("Search pattern predicate must be a constant");
    }
    if (!pattern.o().isVariable()) {
        throw new IllegalArgumentException("Search pattern object must be a variable");
    }
    return pattern;
}
Also used : ServiceNode(com.bigdata.rdf.sparql.ast.service.ServiceNode) StatementPatternNode(com.bigdata.rdf.sparql.ast.StatementPatternNode)

Aggregations

ServiceNode (com.bigdata.rdf.sparql.ast.service.ServiceNode)6 StatementPatternNode (com.bigdata.rdf.sparql.ast.StatementPatternNode)4 JoinGroupNode (com.bigdata.rdf.sparql.ast.JoinGroupNode)3 IVariable (com.bigdata.bop.IVariable)2 VarNode (com.bigdata.rdf.sparql.ast.VarNode)2 BigdataServiceCall (com.bigdata.rdf.sparql.ast.service.BigdataServiceCall)2 MalformedURLException (java.net.MalformedURLException)2 Test (org.junit.Test)2 URI (org.openrdf.model.URI)2 IVariableOrConstant (com.bigdata.bop.IVariableOrConstant)1 BigdataValueFactory (com.bigdata.rdf.model.BigdataValueFactory)1 DummyConstantNode (com.bigdata.rdf.sparql.ast.DummyConstantNode)1 GraphPatternGroup (com.bigdata.rdf.sparql.ast.GraphPatternGroup)1 IGroupMemberNode (com.bigdata.rdf.sparql.ast.IGroupMemberNode)1 TermNode (com.bigdata.rdf.sparql.ast.TermNode)1 AbstractServiceFactory (com.bigdata.rdf.sparql.ast.eval.AbstractServiceFactory)1 ServiceParams (com.bigdata.rdf.sparql.ast.eval.ServiceParams)1 BigdataNativeServiceOptions (com.bigdata.rdf.sparql.ast.service.BigdataNativeServiceOptions)1 IServiceOptions (com.bigdata.rdf.sparql.ast.service.IServiceOptions)1 ServiceCallCreateParams (com.bigdata.rdf.sparql.ast.service.ServiceCallCreateParams)1