@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) { if (FilterPredicate.toManyInPath(dictionary, filterPredicate.getPath())) { throw new ParseException("Invalid toMany join: " + 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; }
@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) { if (FilterPredicate.toManyInPath(dictionary, filterPredicate.getPath())) { throw new ParseException("Invalid toMany join: " + 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; }
@Override public FilterExpression parseGlobalExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { List<FilterPredicate> filterPredicates; filterPredicates = extractPredicates(filterParams); /* Extract the first collection in the URL */ String normalizedPath = JsonApiParser.normalizePath(path); String[] pathComponents = normalizedPath.split("/"); String firstPathComponent = ""; if (pathComponents.length > 0) { firstPathComponent = pathComponents[0]; } /* Comma separated filter parameters are joined with logical AND. */ FilterExpression joinedExpression = null; for (FilterPredicate filterPredicate : filterPredicates) { Class firstClass = filterPredicate.getPath().getPathElements().get(0).getType(); /* The first type in the predicate must match the first collection in the URL */ if (!dictionary.getJsonAliasFor(firstClass).equals(firstPathComponent)) { throw new ParseException(String.format("Invalid predicate: %s", filterPredicate)); } if (joinedExpression == null) { joinedExpression = filterPredicate; } else { joinedExpression = new AndFilterExpression(joinedExpression, filterPredicate); } } return joinedExpression; }
@Override public FilterExpression parseGlobalExpression(String path, MultivaluedMap<String, String> filterParams) throws ParseException { List<FilterPredicate> filterPredicates; filterPredicates = extractPredicates(filterParams); /* Extract the first collection in the URL */ String normalizedPath = JsonApiParser.normalizePath(path); String[] pathComponents = normalizedPath.split("/"); String firstPathComponent = ""; if (pathComponents.length > 0) { firstPathComponent = pathComponents[0]; } /* Comma separated filter parameters are joined with logical AND. */ FilterExpression joinedExpression = null; for (FilterPredicate filterPredicate : filterPredicates) { Class firstClass = filterPredicate.getPath().getPathElements().get(0).getType(); /* The first type in the predicate must match the first collection in the URL */ if (!dictionary.getJsonAliasFor(firstClass).equals(firstPathComponent)) { throw new ParseException(String.format("Invalid predicate: %s", filterPredicate)); } if (joinedExpression == null) { joinedExpression = filterPredicate; } else { joinedExpression = new AndFilterExpression(joinedExpression, filterPredicate); } } return joinedExpression; }