use of org.eclipse.rdf4j.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class GeoTemporalTestUtils method getSps.
public static List<StatementPattern> getSps(final String query) throws Exception {
final StatementPatternCollector collector = new StatementPatternCollector();
new SPARQLParser().parseQuery(query, null).getTupleExpr().visit(collector);
return collector.getStatementPatterns();
}
use of org.eclipse.rdf4j.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class GeoTemporalTestUtils method getNodes.
private static List<QueryModelNode> getNodes(final String sparql) throws Exception {
final NodeCollector collector = new NodeCollector();
new SPARQLParser().parseQuery(sparql, null).getTupleExpr().visit(collector);
return collector.getTupleExpr();
}
use of org.eclipse.rdf4j.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class GeoTemporalTestUtils method getFilters.
public static List<FunctionCall> getFilters(final String query) throws Exception {
final FunctionCallCollector collector = new FunctionCallCollector();
new SPARQLParser().parseQuery(query, null).getTupleExpr().visit(collector);
return collector.getTupleExpr();
}
use of org.eclipse.rdf4j.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class ListFluoQueries method getPrettyPrintSparql.
private static String getPrettyPrintSparql(String sparql, int indent) throws Exception {
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq = parser.parseQuery(sparql, null);
SPARQLQueryRenderer render = new SPARQLQueryRenderer();
String renderedQuery = render.render(pq);
// remove extra quotes generated by query renderer
String[] splitRender = renderedQuery.split("\"\"\"");
StringBuilder builder = new StringBuilder();
for (String s : splitRender) {
builder.append(s).append("\"");
}
builder.replace(builder.length() - 1, builder.length(), "");
// add indent to all lines following newline char
String[] newLineRender = builder.toString().split("\n");
builder = new StringBuilder();
String prefix = getVariableIndent(indent);
for (int i = 0; i < newLineRender.length; i++) {
if (i != 0) {
builder.append(prefix);
}
builder.append(newLineRender[i]).append("\n");
}
return builder.toString();
}
use of org.eclipse.rdf4j.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class QueryReportRenderer method prettyFormatSparql.
private String[] prettyFormatSparql(final String sparql) throws Exception {
final SPARQLParser parser = new SPARQLParser();
final SPARQLQueryRenderer renderer = new SPARQLQueryRenderer();
final ParsedQuery pq = parser.parseQuery(sparql, null);
final String prettySparql = renderer.render(pq);
final String[] sparqlLines = StringUtils.split(prettySparql, '\n');
return sparqlLines;
}
Aggregations