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;
}
Aggregations