Esempio n. 1
0
 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
     }
   }
 }
Esempio n. 2
0
 /**
  * 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));
 }
Esempio n. 3
0
 @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);
 }
Esempio n. 4
0
 /**
  * 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();
 }
Esempio n. 5
0
 /**
  * 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);
 }
Esempio n. 6
0
 /**
  * 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);
 }
Esempio n. 7
0
 /**
  * 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));
 }
Esempio n. 8
0
 /**
  * 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));
 }
Esempio n. 9
0
 /**
  * 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);
 }
Esempio n. 10
0
 /**
  * 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));
 }
Esempio n. 11
0
 /**
  * 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()])));
 }
Esempio n. 12
0
 /**
  * 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));
 }
Esempio n. 13
0
 /**
  * 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);
 }
Esempio n. 14
0
 /**
  * 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);
 }
Esempio n. 15
0
 /** 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);
 }