/** * Not a simple getter: recursively scans the search condition tree. * * @return the AnyType key or {@code NULL} if no type condition was found */ public String hasAnyTypeCond() { String anyTypeName = null; if (type == null) { return anyTypeName; } switch (type) { case LEAF: case NOT_LEAF: if (anyTypeCond != null) { anyTypeName = anyTypeCond.getAnyTypeKey(); } break; case AND: case OR: if (leftSearchCond != null) { anyTypeName = leftSearchCond.hasAnyTypeCond(); } if (anyTypeName == null && rightSearchCond != null) { anyTypeName = rightSearchCond.hasAnyTypeCond(); } break; default: } return anyTypeName; }
@Transactional(readOnly = true) @Override public Pair<Integer, List<AnyObjectTO>> search( final SearchCond searchCond, final int page, final int size, final List<OrderByClause> orderBy, final String realm, final boolean details) { if (searchCond.hasAnyTypeCond() == null) { throw new UnsupportedOperationException("Need to specify " + AnyType.class.getSimpleName()); } Set<String> effectiveRealms = RealmUtils.getEffective( AuthContextUtils.getAuthorizations().get(AnyEntitlement.SEARCH.getFor(searchCond.hasAnyTypeCond())), realm); int count = searchDAO.count(effectiveRealms, searchCond, AnyTypeKind.ANY_OBJECT); List<AnyObject> matching = searchDAO.search( effectiveRealms, searchCond, page, size, orderBy, AnyTypeKind.ANY_OBJECT); List<AnyObjectTO> result = matching.stream(). map(anyObject -> binder.getAnyObjectTO(anyObject, details)).collect(Collectors.toList()); return Pair.of(count, result); }