I have built a simple webpage as the frontend user interface for users to enter the sparql query. I am using Jena ARQ as the backend (I am using Grails) sparql query engine. Currently, users can only enter a "Select" query and I use:
ResultSet results = qexec.execSelect();
to execute the query and return the result. But now, I also want users to send Describe and Construct query from the same page to the backend. As has been discussed in this thread: Jena Sparql and construct, we need to use
Model results = qexec.execConstruct()
at the backend. So my question is, at the backend, how can I know if the query string is a Select query, a Describe Query or a Construct query, so that I can select from execSelect(), execDescribe() or execConstruct()? Is there anything I need to change for the frontend?
The Query class has methods for finding out the type of the query:
if (qexec.getQuery().isSelectType()) {
ResultSet results = qexec.execSelect();
// ...
} else {
Model results = qexec.execConstruct();
// ...
}
To be complete, you should probably handle DESCRIBE
and ASK
as well.