Map<String, String> prefixes = PrefixDeclProcessor.process(qc);
WildcardProjectionProcessor.process(qc);
BlankNodeVarProcessor.process(qc);
TupleExpr tupleExpr = buildQueryModel(qc);
QueryModel query;
ASTQuery queryNode = qc.getQuery();
if (queryNode instanceof ASTSelectQuery) {
query = new TupleQueryModel(tupleExpr);
}
else if (queryNode instanceof ASTConstructQuery) {
query = new GraphQueryModel(tupleExpr, prefixes);
}
else if (queryNode instanceof ASTAskQuery) {
query = new BooleanQueryModel(tupleExpr);
}
else if (queryNode instanceof ASTDescribeQuery) {
query = new GraphQueryModel(tupleExpr, prefixes);
}
else {
throw new RuntimeException("Unexpected query type: " + queryNode.getClass());
}
// Handle dataset declaration
Dataset dataset = DatasetDeclProcessor.process(qc);
if (dataset != null) {
query.setDefaultGraphs(dataset.getDefaultGraphs());
query.setNamedGraphs(dataset.getNamedGraphs());
}
return query;
}
catch (ParseException e) {