use of org.eclipse.rdf4j.query.parser.sparql.ast.ASTDescribe in project rdf4j by eclipse.
the class WildcardProjectionProcessor method process.
public static void process(ASTOperationContainer container) throws MalformedQueryException {
ASTOperation operation = container.getOperation();
// scan for nested SELECT clauses in the operation's WHERE clause
if (operation != null) {
ASTWhereClause whereClause = operation.getWhereClause();
// DESCRIBE queries and certain update operations can be without a WHERE clause
if (whereClause != null) {
SelectClauseCollector collector = new SelectClauseCollector();
try {
whereClause.jjtAccept(collector, null);
Set<ASTSelect> selectClauses = collector.getSelectClauses();
for (ASTSelect selectClause : selectClauses) {
if (selectClause.isWildcard()) {
ASTSelectQuery q = (ASTSelectQuery) selectClause.jjtGetParent();
addQueryVars(q.getWhereClause(), selectClause);
selectClause.setWildcard(false);
}
}
} catch (VisitorException e) {
throw new MalformedQueryException(e);
}
}
}
if (operation instanceof ASTSelectQuery) {
// check for wildcard in upper SELECT query
ASTSelectQuery selectQuery = (ASTSelectQuery) operation;
ASTSelect selectClause = selectQuery.getSelect();
if (selectClause.isWildcard()) {
addQueryVars(selectQuery.getWhereClause(), selectClause);
selectClause.setWildcard(false);
}
} else if (operation instanceof ASTDescribeQuery) {
// check for possible wildcard in DESCRIBE query
ASTDescribeQuery describeQuery = (ASTDescribeQuery) operation;
ASTDescribe describeClause = describeQuery.getDescribe();
if (describeClause.isWildcard()) {
addQueryVars(describeQuery.getWhereClause(), describeClause);
describeClause.setWildcard(false);
}
}
}
Aggregations