0

Hi I want to accept sparql from my exposed rest services for adhoc queries the user wants to issue .My current framework is based on spring data rest and jpa which does most of the heavy lifting for exposes HAL based endpoints but I need to provide this extra hook for the user to do custom queries .Is there any efficient sparql parser around (some mentioned here SPARQL parser for Java Code ) which I can use in to then read and transform the sparql vocab into JPA based criteria query to be executed on my db backend .

I am trying to use apache jina arq but has anyone got an example of using those for parsing sparql and then trying it to convert into sql.

using apache jena I am doing

    String queryString = "PREFIX books:  <http://example.org/book/> PREFIX dc:  <http://purl.org/dc/elements/1.1/>"
        + " SELECT ?book ?title WHERE { ?book dc:title ?title}";
    Query query = QueryFactory.create(queryString);
    Op op = Algebra.compile(query);

Now I want to iterate through that Op with a visitor to use the same to transform it into Sql .I have tried OpWalker.walk(op, new EventSparqlVisitor()); but it doesnt iterate through all for me to generate the query .. any help

Community
  • 1
  • 1
Gaurav Rawat
  • 1,294
  • 1
  • 25
  • 52
  • Something like Jena's [Query QueryFactory#create(String queryString)](https://jena.apache.org/documentation/javadoc/arq/com/hp/hpl/jena/query/QueryFactory.html)? – Joshua Taylor Jun 16 '15 at 20:05
  • Possible duplicate of http://stackoverflow.com/questions/14500599/sparql-parser-for-java-code – Jeen Broekstra Jun 16 '15 at 22:27
  • Ya I have mentioned that thread here trying to use jena but not able to use visitor to iterate so I can transform it into jpa criteria any examples ? – Gaurav Rawat Jun 17 '15 at 03:03
  • @GauravRawat unfortunately that is not how StackOverflow works. This site is intended for specific programming problems. If you have code where you can demonstrate what the problem is we can help you, but this is not a code-writing service or a recommendation site for outside resources such as tutorials. – Jeen Broekstra Jun 17 '15 at 23:08
  • ok let me write some code on the issue and I was not asking for a tutorial but wanted to know if someone can belo me with a parser like apache jena which I can use to read soql grammer and transform it into SQL. – Gaurav Rawat Jun 18 '15 at 06:05

0 Answers0