Search in sources :

Example 1 with RSQLParser

use of cz.jirutka.rsql.parser.RSQLParser in project molgenis by molgenis.

the class RestConfig method rsqlParser.

@Bean
public RSQLParser rsqlParser() {
    Set<ComparisonOperator> operators = RSQLOperators.defaultOperators();
    operators.add(new ComparisonOperator("=q=", false));
    operators.add(new ComparisonOperator("=notlike=", false));
    operators.add(new ComparisonOperator("=rng=", true));
    operators.add(new ComparisonOperator("=like=", false));
    return new RSQLParser(operators);
}
Also used : ComparisonOperator(cz.jirutka.rsql.parser.ast.ComparisonOperator) RSQLParser(cz.jirutka.rsql.parser.RSQLParser) Bean(org.springframework.context.annotation.Bean)

Example 2 with RSQLParser

use of cz.jirutka.rsql.parser.RSQLParser in project tutorials by eugenp.

the class UserController method findAllByRsql.

@RequestMapping(method = RequestMethod.GET, value = "/users/rsql")
@ResponseBody
public List<User> findAllByRsql(@RequestParam(value = "search") String search) {
    Node rootNode = new RSQLParser().parse(search);
    Specification<User> spec = rootNode.accept(new CustomRsqlVisitor<User>());
    return dao.findAll(spec);
}
Also used : User(org.baeldung.persistence.model.User) MyUser(org.baeldung.persistence.model.MyUser) RSQLParser(cz.jirutka.rsql.parser.RSQLParser) Node(cz.jirutka.rsql.parser.ast.Node) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with RSQLParser

use of cz.jirutka.rsql.parser.RSQLParser in project tutorials by eugenp.

the class RsqlIntegrationTest method givenFirstNameInverse_whenGettingListOfUsers_thenCorrect.

@Test
public void givenFirstNameInverse_whenGettingListOfUsers_thenCorrect() {
    final Node rootNode = new RSQLParser().parse("firstName!=john");
    final Specification<User> spec = rootNode.accept(new CustomRsqlVisitor<User>());
    final List<User> results = repository.findAll(spec);
    assertThat(userTom, isIn(results));
    assertThat(userJohn, not(isIn(results)));
}
Also used : User(org.baeldung.persistence.model.User) RSQLParser(cz.jirutka.rsql.parser.RSQLParser) Node(cz.jirutka.rsql.parser.ast.Node) Test(org.junit.Test)

Example 4 with RSQLParser

use of cz.jirutka.rsql.parser.RSQLParser in project tutorials by eugenp.

the class RsqlIntegrationTest method givenListOfFirstName_whenGettingListOfUsers_thenCorrect.

@Test
public void givenListOfFirstName_whenGettingListOfUsers_thenCorrect() {
    final Node rootNode = new RSQLParser().parse("firstName=in=(john,jack)");
    final Specification<User> spec = rootNode.accept(new CustomRsqlVisitor<User>());
    final List<User> results = repository.findAll(spec);
    assertThat(userJohn, isIn(results));
    assertThat(userTom, not(isIn(results)));
}
Also used : User(org.baeldung.persistence.model.User) RSQLParser(cz.jirutka.rsql.parser.RSQLParser) Node(cz.jirutka.rsql.parser.ast.Node) Test(org.junit.Test)

Example 5 with RSQLParser

use of cz.jirutka.rsql.parser.RSQLParser in project tutorials by eugenp.

the class RsqlIntegrationTest method givenMinAge_whenGettingListOfUsers_thenCorrect.

@Test
public void givenMinAge_whenGettingListOfUsers_thenCorrect() {
    final Node rootNode = new RSQLParser().parse("age>25");
    final Specification<User> spec = rootNode.accept(new CustomRsqlVisitor<User>());
    final List<User> results = repository.findAll(spec);
    assertThat(userTom, isIn(results));
    assertThat(userJohn, not(isIn(results)));
}
Also used : User(org.baeldung.persistence.model.User) RSQLParser(cz.jirutka.rsql.parser.RSQLParser) Node(cz.jirutka.rsql.parser.ast.Node) Test(org.junit.Test)

Aggregations

RSQLParser (cz.jirutka.rsql.parser.RSQLParser)8 Node (cz.jirutka.rsql.parser.ast.Node)6 User (org.baeldung.persistence.model.User)6 Test (org.junit.Test)5 ComparisonOperator (cz.jirutka.rsql.parser.ast.ComparisonOperator)1 MyUser (org.baeldung.persistence.model.MyUser)1 Attribute (org.molgenis.data.meta.model.Attribute)1 Bean (org.springframework.context.annotation.Bean)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 BeforeMethod (org.testng.annotations.BeforeMethod)1