/** * Generates a {@link Query} for the items contained within this {@link SearchResultSelection}. * The returned Query is {@code .fromAll()} and includes visibility-restricted items. * * @return a {@link Query} for the items contained within this {@link SearchResultSelection}. */ public Query<Object> createItemsQuery() { Set<UUID> itemIds = new HashSet<>(); for (SearchResultSelectionItem item : Query.from(SearchResultSelectionItem.class).where("selectionId = ?", getId()).selectAll()) { itemIds.add(item.getItemId()); } return Query.fromAll().where("_id = ?", itemIds); }
/** * Removes the Object with itemId from this SearchResultSelection. * * @param itemId the id of the Object to be removed. Cannot be {@code null}. */ public boolean removeItem(UUID itemId) { if (itemId == null) { throw new IllegalArgumentException("itemId cannot be null!"); } SearchResultSelectionItem item = Query.from(SearchResultSelectionItem.class) .where("selectionId = ?", getId()) .and("itemId = ?", itemId) .first(); if (item == null) { return false; } item.delete(); return true; }