cz.jirutka.rsql.parser.RSQLParser Java Examples
The following examples show how to use
cz.jirutka.rsql.parser.RSQLParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityRefTypeFilterVisitor.java From gemini with Apache License 2.0 | 6 votes |
private QueryWithParams handleMultipleLogicalKeyEntities(EntityField field, ComparisonNode node, String sqlOperator, FilterVisitorContext filterVisitorContext) { List<String> arguments = node.getArguments(); if (arguments.size() == 1) { Entity entityRef = field.getEntityRef(); String entityName = wrapDoubleQuotes(entityRef.getName().toLowerCase()); String idName = wrapDoubleQuotes(entityRef.getIdEntityField().getName().toLowerCase()); String argument = arguments.get(0); // we need to parse again the argument if we dont' have a UUID.. since it contains other conditions on keys Node rootNode = new RSQLParser().parse(argument); QueryWithParams innerQuery = rootNode.accept(this.parentFilterVisitor, FilterVisitorContext.of(entityRef, filterVisitorContext.counterByParameter)); return new QueryWithParams(String.format("SELECT %1$s.%2$s" + " FROM %1$s WHERE ", entityName, idName) + innerQuery.getSql(), innerQuery.getParams()); } throw new GeminiRuntimeException(String.format("EntityRefTypeFilterVisitor unsupported operator %s withRecord for that one argument", node.getOperator().getSymbol())); }
Example #2
Source File: RestControllerTest.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
@Bean RestController restController() { return new RestController( authenticationSettings(), dataService(), tokenService(), authenticationManager(), permissionService(), userAccountService(), new MolgenisRSQL(new RSQLParser()), new RestService( dataService(), idGenerator(), fileStore(), fileMetaFactory(), entityManager(), servletUriComponentsBuilderFactory())); }
Example #3
Source File: PermissionsControllerTest.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
@BeforeEach private void beforeMethod() { RSQLParser rsqlParser = new RSQLParser(); PermissionsController controller = new PermissionsController( permissionsService, rsqlParser, objectIdentityService, userRoleTools, entityHelper); mockMvc = MockMvcBuilders.standaloneSetup(controller) .setMessageConverters(new FormHttpMessageConverter(), gsonHttpMessageConverter) .build(); user1 = new PrincipalSid("user1"); user2 = new PrincipalSid("user2"); role1 = new GrantedAuthoritySid("ROLE_role1"); role2 = new GrantedAuthoritySid("ROLE_role2"); objectIdentity = new ObjectIdentityImpl("typeId", "identifier"); }
Example #4
Source File: RsqlIntegrationTest.java From tutorials with MIT License | 5 votes |
@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))); }
Example #5
Source File: PersistenceEntityManagerImpl.java From gemini with Apache License 2.0 | 5 votes |
private void addFilter(QueryWithParams query, FilterContext filterContext, Entity entity) { FilterContext.FilterType filterType = filterContext.getFilterType(); if (filterType == FilterContext.FilterType.GEMINI && !filterContext.getSearchString().isEmpty()) { Node rootNode = new RSQLParser(filterVisitor.getOperators()).parse(filterContext.getSearchString()); QueryWithParams queryWithParams = rootNode.accept(filterVisitor, FilterVisitor.FilterVisitorContext.of(entity)); query.addToSql(" WHERE " + queryWithParams.getSql()); query.addParams(queryWithParams.getParams()); } if (filterType == FilterContext.FilterType.PERSISTENCE) { query.addToSql(" WHERE " + filterContext.getSearchString()); query.addParams(filterContext.getParams()); } }
Example #6
Source File: RsqlIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void givenFirstNamePrefix_whenGettingListOfUsers_thenCorrect() { final Node rootNode = new RSQLParser().parse("firstName==jo*"); 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))); }
Example #7
Source File: RsqlIntegrationTest.java From tutorials with MIT License | 5 votes |
@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))); }
Example #8
Source File: RsqlIntegrationTest.java From tutorials with MIT License | 5 votes |
@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))); }
Example #9
Source File: RsqlIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void givenFirstAndLastName_whenGettingListOfUsers_thenCorrect() { final Node rootNode = new RSQLParser().parse("firstName==john;lastName==doe"); 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))); }
Example #10
Source File: UserController.java From tutorials with MIT License | 5 votes |
@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); }
Example #11
Source File: RsqlConfig.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Bean public RSQLParser rsqlParser() { Set<ComparisonOperator> operators = RSQLOperators.defaultOperators(); operators.add(new ComparisonOperator("=q=", false)); operators.add(new ComparisonOperator("=sq=", false)); operators.add(new ComparisonOperator("=notlike=", false)); operators.add(new ComparisonOperator("=rng=", true)); operators.add(new ComparisonOperator("=like=", false)); return new RSQLParser(operators); }
Example #12
Source File: PermissionsController.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
public PermissionsController( PermissionService permissionService, RSQLParser rsqlParser, ObjectIdentityService objectIdentityService, UserRoleTools userRoleTools, EntityHelper entityHelper) { super(PERMISSION_API_IDENTIFIER, 1); this.permissionService = requireNonNull(permissionService); this.rsqlParser = requireNonNull(rsqlParser); this.objectIdentityService = requireNonNull(objectIdentityService); this.userRoleTools = requireNonNull(userRoleTools); this.entityHelper = requireNonNull(entityHelper); }
Example #13
Source File: ApiConfig.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
private RSQLParser rsqlParser() { Set<ComparisonOperator> operators = new HashSet<>(RSQLOperators.defaultOperators()); operators.add(new ComparisonOperator("=q=", false)); operators.add(new ComparisonOperator("=sq=", false)); operators.add(new ComparisonOperator("=like=", false)); operators.add(new ComparisonOperator("=notlike=", false)); return new RSQLParser(operators); }
Example #14
Source File: RSQLProducerImpl.java From pnc with Apache License 2.0 | 5 votes |
public RSQLProducerImpl() { Set<ComparisonOperator> predicateOperators = RSQLOperators.defaultOperators(); predicateOperators.add(LIKE); predicateOperators.add(NOT_LIKE); predicateOperators.add(IS_NULL); predicateParser = new RSQLParser(predicateOperators); Set<ComparisonOperator> sortOperators = new HashSet<>(); sortOperators.add(ASC); sortOperators.add(DESC); sortParser = new RSQLParser(sortOperators); }
Example #15
Source File: SearchFilterToQueryConverter.java From dremio-oss with Apache License 2.0 | 5 votes |
public static SearchQuery toQuery(String filterStr, FilterIndexMapping mapping){ if(Strings.isNullOrEmpty(filterStr)){ return SearchQueryUtils.newMatchAllQuery(); } final Node root = new RSQLParser(RSQL_OPERATORS).parse(filterStr); return root.accept(new SearchFilterToQueryConverter(mapping).visitor); }
Example #16
Source File: RSQLJPASupport.java From rsql-jpa-specification with MIT License | 5 votes |
public static <T> Specification<T> toSpecification(final String rsqlQuery, final boolean distinct, final Map<String, String> propertyPathMapper) { log.debug("toSpecification({},distinct:{},propertyPathMapper:{})", rsqlQuery, distinct, propertyPathMapper); return new Specification<T>() { public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { query.distinct(distinct); if (StringUtils.hasText(rsqlQuery)) { Node rsql = new RSQLParser(RSQLOperators.supportedOperators()).parse(rsqlQuery); return rsql.accept(new RSQLJPAPredicateConverter(cb, propertyPathMapper), root); } else return null; } }; }
Example #17
Source File: RSQLQueryDslSupport.java From rsql-jpa-specification with MIT License | 5 votes |
public static BooleanExpression toPredicate(final String rsqlQuery, final Path qClazz, final Map<String, String> propertyPathMapper) { log.debug("toPredicate({},qClazz:{},propertyPathMapper:{})", rsqlQuery, qClazz); if (StringUtils.hasText(rsqlQuery)) { return new RSQLParser(RSQLOperators.supportedOperators()) .parse(rsqlQuery) .accept(new RSQLQueryDslPredicateConverter(propertyPathMapper), qClazz); } else { return null; } }
Example #18
Source File: RSQLCommonSupport.java From rsql-jpa-specification with MIT License | 5 votes |
public static Map<String, MultiValueMap<String, String>> toComplexMultiValueMap(final String rsqlQuery) { log.debug("toComplexMultiValueMap(rsqlQuery:{})", rsqlQuery); Map<String, MultiValueMap<String, String>> map = new HashMap<>(); if (StringUtils.hasText(rsqlQuery)) { new RSQLParser(RSQLOperators.supportedOperators()).parse(rsqlQuery).accept(new RSQLComplexConverter(), map); } return map; }
Example #19
Source File: RSQLCommonSupport.java From rsql-jpa-specification with MIT License | 5 votes |
public static MultiValueMap<String, String> toMultiValueMap(final String rsqlQuery) { log.debug("toMultiValueMap(rsqlQuery:{})", rsqlQuery); MultiValueMap<String, String> map = CollectionUtils.toMultiValueMap(new HashMap<>()); if (StringUtils.hasText(rsqlQuery)) { new RSQLParser(RSQLOperators.supportedOperators()).parse(rsqlQuery).accept(new RSQLSimpleConverter(), map); } return map; }
Example #20
Source File: QueryConverterTest.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
@BeforeEach void setUpBeforeMethod() { // RSQLParser is final, can't be mocked queryConverter = new QueryConverter(new RSQLParser(), rsqlVisitor); }
Example #21
Source File: RestConfig.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
RestConfig(RSQLParser rsqlParser) { this.rsqlParser = requireNonNull(rsqlParser); }
Example #22
Source File: QueryConverter.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
public QueryConverter(RSQLParser rsqlParser, QueryRsqlVisitor rsqlVisitor) { this.rsqlParser = requireNonNull(rsqlParser); this.rsqlVisitor = requireNonNull(rsqlVisitor); }
Example #23
Source File: MolgenisRSQL.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
public MolgenisRSQL(RSQLParser rsqlParser) { this.rsqlParser = requireNonNull(rsqlParser); }
Example #24
Source File: AggregateQueryRsqlConverter.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
public AggregateQueryRsqlConverter(RSQLParser rsqlParser) { this.rsqlParser = checkNotNull(rsqlParser); }
Example #25
Source File: QueryRsqlConverter.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
public QueryRsqlConverter(RSQLParser rsqlParser) { this.rsqlParser = rsqlParser; }
Example #26
Source File: MolgenisRSQLTest.java From molgenis with GNU Lesser General Public License v3.0 | 4 votes |
@BeforeEach void beforeMethod() { molgenisRSQL = new MolgenisRSQL(new RSQLParser()); when(repository.getEntityType()).thenReturn(entityType); }