@Test public void testEmptyOperatorException() throws Exception { MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>(); queryParams.add( "filter", "authors.name=isempty=0" ); assertThrows(ParseException.class, () -> dialect.parseTypedExpression("/book", queryParams)); }
@Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionByType = new HashMap<>(); for (MultivaluedMap.Entry<String, List<String>> entry : filterParams.entrySet()) { String paramName = entry.getKey(); List<String> paramValues = entry.getValue(); Matcher matcher = TYPED_FILTER_PATTERN.matcher(paramName); if (matcher.find()) { String typeName = matcher.group(1); if (paramValues.size() != 1) { throw new ParseException("Exactly one RSQL expression must be defined for type : " + typeName); } Class entityType = dictionary.getEntityClass(typeName); if (entityType == null) { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } String expressionText = paramValues.get(0); FilterExpression filterExpression = parseFilterExpression(expressionText, entityType, true); expressionByType.put(typeName, filterExpression); } else { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } } return expressionByType; }
RSQLFilterDialect implements SubqueryFilterDialect, JoinFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionByType = new HashMap<>(); for (MultivaluedMap.Entry<String, List<String>> entry : filterParams.entrySet()) { String paramName = entry.getKey(); List<String> paramValues = entry.getValue(); Matcher matcher = TYPED_FILTER_PATTERN.matcher(paramName); if (matcher.find()) { String typeName = matcher.group(1); if (paramValues.size() != 1) { throw new ParseException("Exactly one RSQL expression must be defined for type : " + typeName); } Class entityType = dictionary.getEntityClass(typeName); if (entityType == null) { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } String expressionText = paramValues.get(0); FilterExpression filterExpression = parseFilterExpression(expressionText, entityType, true); expressionByType.put(typeName, filterExpression); } else { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } } return expressionByType; } }
RSQLFilterDialect implements SubqueryFilterDialect, JoinFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionByType = new HashMap<>(); for (MultivaluedMap.Entry<String, List<String>> entry : filterParams.entrySet()) { String paramName = entry.getKey(); List<String> paramValues = entry.getValue(); Matcher matcher = TYPED_FILTER_PATTERN.matcher(paramName); if (matcher.find()) { String typeName = matcher.group(1); if (paramValues.size() != 1) { throw new ParseException("Exactly one RSQL expression must be defined for type : " + typeName); } Class entityType = dictionary.getEntityClass(typeName); if (entityType == null) { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } String expressionText = paramValues.get(0); FilterExpression filterExpression = parseFilterExpression(expressionText, entityType, true); expressionByType.put(typeName, filterExpression); } else { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } } return expressionByType; } RSQLFilterDialect(EntityDictionary dictionary);  RSQLFilterDialect(EntityDictionary dictionary, CaseSensitivityStrategy caseSensitivityStrategy); }
RSQLFilterDialect implements SubqueryFilterDialect, JoinFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionByType = new HashMap<>(); for (MultivaluedMap.Entry<String, List<String>> entry : filterParams.entrySet()) { String paramName = entry.getKey(); List<String> paramValues = entry.getValue(); Matcher matcher = TYPED_FILTER_PATTERN.matcher(paramName); if (matcher.find()) { String typeName = matcher.group(1); if (paramValues.size() != 1) { throw new ParseException("Exactly one RSQL expression must be defined for type : " + typeName); } Class entityType = dictionary.getEntityClass(typeName); if (entityType == null) { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } String expressionText = paramValues.get(0); FilterExpression filterExpression = parseFilterExpression(expressionText, entityType, true); expressionByType.put(typeName, filterExpression); } else { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } } return expressionByType; } RSQLFilterDialect(EntityDictionary dictionary);  RSQLFilterDialect(EntityDictionary dictionary, CaseSensitivityStrategy caseSensitivityStrategy); @Override FilterExpression parseGlobalExpression(String path, MultivaluedMap<String, String> filterParams); @Override Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams); FilterExpression parseFilterExpression(String expressionText,
                                                  Class<?> entityType,
                                                  boolean allowNestedToManyAssociations); }
RSQLFilterDialect implements SubqueryFilterDialect, JoinFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionByType = new HashMap<>(); for (MultivaluedMap.Entry<String, List<String>> entry : filterParams.entrySet()) { String paramName = entry.getKey(); List<String> paramValues = entry.getValue(); Matcher matcher = TYPED_FILTER_PATTERN.matcher(paramName); if (matcher.find()) { String typeName = matcher.group(1); if (paramValues.size() != 1) { throw new ParseException("Exactly one RSQL expression must be defined for type : " + typeName); } Class entityType = dictionary.getEntityClass(typeName); if (entityType == null) { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } String expressionText = paramValues.get(0); FilterExpression filterExpression = parseFilterExpression(expressionText, entityType, true); expressionByType.put(typeName, filterExpression); } else { throw new ParseException(INVALID_QUERY_PARAMETER + paramName); } } return expressionByType; } RSQLFilterDialect(EntityDictionary dictionary);  RSQLFilterDialect(EntityDictionary dictionary, CaseSensitivityStrategy caseSensitivityStrategy); @Override FilterExpression parseGlobalExpression(String path, MultivaluedMap<String, String> filterParams); @Override Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams); FilterExpression parseFilterExpression(String expressionText,
                                                  Class<?> entityType,
                                                  boolean allowNestedToManyAssociations);  }