@Test public void testTypedExpressionParsing() throws Exception { MultivaluedMap<String, String> queryParams = new MultivaluedHashMap<>(); queryParams.add( "filter[book.title][in]", "foo,bar,baz" ); queryParams.add( "filter[book.genre]", "scifi" ); queryParams.add( "filter[author.name][infix]", "Hemingway" ); queryParams.add( "filter[author.books.title][in]", "foo,bar,baz" ); Map<String, FilterExpression> expressionMap = dialect.parseTypedExpression("/author", queryParams); assertEquals(2, expressionMap.size()); assertEquals("(book.title IN [foo, bar, baz] AND book.genre IN [scifi])", expressionMap.get("book").toString()); assertEquals("(author.books.title IN [foo, bar, baz] AND author.name INFIX [Hemingway])", expressionMap.get("author").toString()); }
@Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionMap = new HashMap<>(); List<FilterPredicate> filterPredicates = extractPredicates(filterParams); for (FilterPredicate filterPredicate : filterPredicates) { validateFilterPredicate(filterPredicate); String entityType = dictionary.getJsonAliasFor(filterPredicate.getEntityType()); FilterExpression filterExpression = expressionMap.get(entityType); if (filterExpression != null) { expressionMap.put(entityType, new AndFilterExpression(filterExpression, filterPredicate)); } else { expressionMap.put(entityType, filterPredicate); } } return expressionMap; }
DefaultFilterDialect implements JoinFilterDialect, SubqueryFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionMap = new HashMap<>(); List<FilterPredicate> filterPredicates = extractPredicates(filterParams); for (FilterPredicate filterPredicate : filterPredicates) { validateFilterPredicate(filterPredicate); String entityType = dictionary.getJsonAliasFor(filterPredicate.getEntityType()); FilterExpression filterExpression = expressionMap.get(entityType); if (filterExpression != null) { expressionMap.put(entityType, new AndFilterExpression(filterExpression, filterPredicate)); } else { expressionMap.put(entityType, filterPredicate); } } return expressionMap; } }
DefaultFilterDialect implements JoinFilterDialect, SubqueryFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionMap = new HashMap<>(); List<FilterPredicate> filterPredicates = extractPredicates(filterParams); for (FilterPredicate filterPredicate : filterPredicates) { validateFilterPredicate(filterPredicate); String entityType = dictionary.getJsonAliasFor(filterPredicate.getEntityType()); FilterExpression filterExpression = expressionMap.get(entityType); if (filterExpression != null) { expressionMap.put(entityType, new AndFilterExpression(filterExpression, filterPredicate)); } else { expressionMap.put(entityType, filterPredicate); } } return expressionMap; } DefaultFilterDialect(EntityDictionary dictionary); }
DefaultFilterDialect implements JoinFilterDialect, SubqueryFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionMap = new HashMap<>(); List<FilterPredicate> filterPredicates = extractPredicates(filterParams); for (FilterPredicate filterPredicate : filterPredicates) { validateFilterPredicate(filterPredicate); String entityType = dictionary.getJsonAliasFor(filterPredicate.getEntityType()); FilterExpression filterExpression = expressionMap.get(entityType); if (filterExpression != null) { expressionMap.put(entityType, new AndFilterExpression(filterExpression, filterPredicate)); } else { expressionMap.put(entityType, filterPredicate); } } return expressionMap; } DefaultFilterDialect(EntityDictionary dictionary); @Override FilterExpression parseGlobalExpression(String path, MultivaluedMap<String, String> filterParams); @Override Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams); }
DefaultFilterDialect implements JoinFilterDialect, SubqueryFilterDialect { @Override public Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { Map<String, FilterExpression> expressionMap = new HashMap<>(); List<FilterPredicate> filterPredicates = extractPredicates(filterParams); for (FilterPredicate filterPredicate : filterPredicates) { validateFilterPredicate(filterPredicate); String entityType = dictionary.getJsonAliasFor(filterPredicate.getEntityType()); FilterExpression filterExpression = expressionMap.get(entityType); if (filterExpression != null) { expressionMap.put(entityType, new AndFilterExpression(filterExpression, filterPredicate)); } else { expressionMap.put(entityType, filterPredicate); } } return expressionMap; } DefaultFilterDialect(EntityDictionary dictionary); @Override FilterExpression parseGlobalExpression(String path, MultivaluedMap<String, String> filterParams); @Override Map<String, FilterExpression> parseTypedExpression(String path, MultivaluedMap<String, String> filterParams);  }