title: jirutka/rsql-parser and QueryDSL
body: <p>I have Spring framework created REST services back-end and now I need to find a way to process complex filters in some requests from the front-end.</p>
  
  <p>I'm using QueryDsl (v3.4.2) framework to do queries construction throughout the back-end. </p>
  
  <p>I think using a FIQL or RSQL parser is the best approach, so I'm trying to integrate <a href="https://github.com/jirutka/rsql-parser" rel="nofollow">jirutka/rsql-parser</a> to my back-end project.</p>
  
  <p>I'm very new to it and also to QueryDsl. </p>
  
  <p>Now I'm confused so here is my request for help:<br>
  <b>Has anybody integrated <i>jirutka/rsql-parser</i> and <i>QueryDsl</i> in a rest spring project before?</b> and <b>How?</b></p>
  
  <p>Jirutka/rsql-parser documentation only says:</p>
  
  <blockquote>
    <p>Nodes are visitable, so to traverse the parsed AST (and convert it to
    SQL query maybe), you can implement the provided RSQLVisitor interface
    or simplified NoArgRSQLVisitorAdapter.</p>
  </blockquote>
  
  <p>And has the following example on how to do it:</p>
  
  <pre><code>Node rootNode = new RSQLParser().parse("name==RSQL;version=ge=2.0");
  rootNode.accept(yourShinyVisitor);
  </code></pre>
  
  <p>Seems pretty easy, right?</p>
  
  <p>So I crated my visitor like this:</p>
  
  <pre><code>public class RsqlParserVisitor extends NoArgRSQLVisitorAdapter&lt;BooleanExpression&gt; {
  </code></pre>
  
  <p>Implemented all the methods the interfaces required me to. </p>
  
  <p>Here I add two examples:</p>
  
  <pre><code>@Override
  public BooleanExpression visit(AndNode arg0) {
      // TODO Auto-generated method stub
  
      String methodNameTmp = "AndNode";
      logger.debug(methodNameTmp + ". arg0: " + arg0);
      logger.debug("operator: " + arg0.getOperator().name());
      for (Node node : arg0) {
          logger.debug(methodNameTmpp + ". node: " + node);
      }
  
      return null; //DO SOMETHING TO CREATE A BooleanExpression;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Override
  public BooleanExpression visit(EqualNode arg0) {
      // TODO Auto-generated method stub
      String methodNameTmp = "EqualNode";
      logger.debug(methodNameTmp + ". arg0: " + arg0);
  
      logger.debug("operator: " + arg0.getOperator());
      for (String arg: arg0.getArguments()) {
          logger.debug(methodNameTmp + ". arg: " + arg);
      }
  
      return null; //DO SOMETHING TO CREATE A BooleanExpression;
  }
  </code></pre>
  
  <p>Now I'm stuck:</p>
  
  <p>a) In order to create a QueryDsl BooleanExpression, I need to know the class I'm processing for example:</p>
  
  <pre><code>    QUser qUser = QUser.user;
      BooleanExpression filter = qUser.firstName.eq("Bob");
  </code></pre>
  
  <p>or</p>
  
  <pre><code>    PathBuilder&lt;User&gt; user = new PathBuilder&lt;User&gt;(User.class, "user");
      BooleanExpression filter = user.getString("firstName").eq("Bob");
  </code></pre>
  
  <p>b) When I test my code, it only executes the <code>public BooleanExpression visit(OrNode arg0)</code> method, then nothing. It stops right there.</p>
  
  <p>At that moment I can't do much. Can't create a BooleanExpression yet, since I need to go through some ComparisonNode methods first and then join them with an "or" or "and" boolean expression. Right?</p>
  
  <p>If at least I could go through all the nodes, then I could manage to find a way to pass the class, I'm not worried about it. But don't understand how to traverse all the nodes, and haven't been able to do it.</p>
  
  <p>Any pointers to fix this, will be really appreciated.</p>