private void addItems(NotItem notItem, List<Object> children) { for (Object child : children) { TypeCheck.ensureInstanceOf(child, Item.class); notItem.addItem((Item) child); } }
/** * Adds a negative item. Like addItem but skips the first position * (position 0) if it is not already set. */ public void addNegativeItem(Item negative) { if (getItemCount() == 0) { insertNullFirstItem(); } addItem(negative); }
/** * Sets the positive item (the first item) * * @return the old positive item, or null if there was no items */ public Item setPositiveItem(Item item) { Validator.ensureNotNull("Positive item of " + this, item); if (getItemCount() == 0) { addItem(item); return null; } else { return setItem(0, item); } }
public Result search(Query query, Execution execution) { // Get tensor and read items from user profile Object userIdProperty = query.properties().get("user_id"); if (userIdProperty != null) { Hit userProfile = retrieveUserProfile(userIdProperty.toString(), execution); if (userProfile != null) { addUserProfileTensorToQuery(query, userProfile); NotItem notItem = new NotItem(); notItem.addItem(new IntItem(1, "has_user_item_cf")); for (String item : getReadItems(userProfile.getField("has_read_items"))){ notItem.addItem(new WordItem(item, "post_id")); } QueryTreeUtil.andQueryItemWithRoot(query, notItem); } } // Restrict to search in blog_posts query.getModel().setRestrict("blog_post"); // Rank blog posts using tensor rank profile if(query.properties().get("ranking") == null) { query.properties().set(new CompoundName("ranking"), "tensor"); } return execution.search(query); }