private void createListAndSubtract(PathQuery pq) { ListCreationInfo info = services.getListService().new ListCreationInfo(pq); ItemList removalList = null; try { removalList = services.getListService().createList(info); ItemList res = subtract(removalList); update(res); delete(); res.rename(getName()); } finally { try { removalList.delete(); } catch (Exception e) { // Ignore } } }
/** * Add items to this list by using a query. * * @param items The items to add to the list. */ private void appendItems(Iterable<Item> items) { PathQuery pq = new PathQuery(services.getModel()); pq.addViews(getType() + ".id"); Set<String> values = new HashSet<String>(); for (Item i : items) { values.add(Integer.toString(i.getId())); } pq.addConstraint(Constraints.oneOfValues(getType() + ".id", values)); update(services.getListService().append(this, pq)); }
@SuppressWarnings("unchecked") @Override public boolean containsAll(@SuppressWarnings("rawtypes") Collection c) { if (c == null) { return false; } Item[] candidates; try { candidates = (Item[]) c.toArray(new Item[c.size()]); } catch (ArrayStoreException e) { return false; } return services.getListService().contains(this, candidates); }
/** * Rename this list on the server. * * <p>This method will update the name of the list stored on the server, and also change of the * name returned by this object. * * @param newName The new name to give this list. */ public void rename(String newName) { ItemList updated = services.getListService().rename(this, newName); this.name = updated.getName(); }
/** * Remove the items in the given lists from this list. * * <p>This call performs the operation of asymmetric difference on the current list and returns * the result. For operations that alter the current list see {@link #removeAll(Collection)} * * @param lists The lists to subtract from this list. * @param info The options describing the new list. * @return A new list */ public ItemList subtract(ListOperationInfo info, Collection<ItemList> lists) { return services.getListService().subtract(info, Collections.singleton(this), lists); }
/** * Remove the items in the given lists from this list. * * <p>This call performs the operation of asymmetric difference on the current list and returns * the result. For operations that alter the current list see {@link #removeAll(Collection)} * * @param lists The lists to subtract from this list. * @return A new list */ public ItemList subtract(Collection<ItemList> lists) { return services.getListService().subtract(Collections.singleton(this), lists); }
/** * Remove the items in the given lists from this list. * * <p>This call performs the operation of asymmetric difference on the current list and returns * the result. For operations that alter the current list see {@link #removeAll(Collection)} * * @param lists The lists to subtract from this list. * @param info The options describing the new list. * @return A new list */ public ItemList subtract(ListOperationInfo info, ItemList... lists) { return services .getListService() .subtract(info, Collections.singleton(this), Arrays.asList(lists)); }
/** * Remove the items in the given lists from this list. * * <p>This call performs the operation of asymmetric difference on the current list and returns * the result. For operations that alter the current list see {@link #removeAll(Collection)} * * @param lists The lists to subtract from this list. * @return A new list */ public ItemList subtract(ItemList... lists) { return services.getListService().subtract(Collections.singleton(this), Arrays.asList(lists)); }
/** * Call for this list to be deleted on the server. As soon as the call returns, this list should * no longer be used for any operation. */ public void delete() { services.getListService().deleteList(this); }
/** * Add new items to the list by resolving the identifiers of objects. * * <p>This method will update the size of the list, and clear the items cache. * * @param pq The query to run to find objects with. */ public void append(PathQuery pq) { update(services.getListService().append(this, pq)); }
/** * Add new items to the list by resolving the identifiers of objects. * * <p>This method will update the size of the list, and clear the items cache. * * @param ids The identifiers to use to find objects to add. */ public void append(Collection<? extends String> ids) { update(services.getListService().append(this, ids.toArray(new String[ids.size()]))); }
/** * Add new items to the list by resolving the identifiers of objects. * * <p>This method will update the size of the list, and clear the items cache. * * @param ids The identifiers to use to find objects to add. */ public void append(String... ids) { update(services.getListService().append(this, ids)); }
/** * Remove some tags from this list. After removing, the list will have an updated set of tags, and * the tags will be synchronised with those on the server. * * @param removeThese The tags to remove. */ public void removeTags(String... removeThese) { tags = services.getListService().removeTags(this, removeThese); }
/** * Add some new tags to this list. After adding, list will have an updated set of tags, and the * tags will be stored on the server. * * @param newTags The tags to add. */ public void addTags(String... newTags) { tags = services.getListService().addTags(this, newTags); }
/** Make sure that the tags on this object are up-to-date with those stored on the server. */ public void updateTags() { tags = services.getListService().getTags(this); }