use of com.querydsl.core.types.ExpressionUtils in project querydsl by querydsl.
the class AbstractMongodbQuery method createJoinFilter.
@SuppressWarnings("unchecked")
@Nullable
protected Predicate createJoinFilter(QueryMetadata metadata) {
Map<Expression<?>, Predicate> predicates = new HashMap<>();
List<JoinExpression> joins = metadata.getJoins();
for (int i = joins.size() - 1; i >= 0; i--) {
JoinExpression join = joins.get(i);
Path<?> source = (Path) ((Operation<?>) join.getTarget()).getArg(0);
Path<?> target = (Path) ((Operation<?>) join.getTarget()).getArg(1);
final Predicate extraFilters = predicates.get(target.getRoot());
Predicate filter = ExpressionUtils.allOf(join.getCondition(), extraFilters);
List<? extends Object> ids = getIds(target.getType(), filter);
if (ids.isEmpty()) {
throw new NoResults();
}
Path<?> path = ExpressionUtils.path(String.class, source, "$id");
predicates.merge(source.getRoot(), ExpressionUtils.in((Path<Object>) path, ids), ExpressionUtils::and);
}
Path<?> source = (Path) ((Operation) joins.get(0).getTarget()).getArg(0);
return predicates.get(source.getRoot());
}
Aggregations