Пример #1
0
 @SuppressWarnings("unchecked")
 @Override
 public boolean removeAll(@SuppressWarnings("rawtypes") Collection c) {
   int priorSize = getSize();
   if (c instanceof ItemList) {
     ItemList res = subtract(((ItemList) c));
     update(res);
     delete();
     res.rename(getName());
   } else if (!c.isEmpty()) {
     try {
       Item[] is = (Item[]) c.toArray(new Item[0]);
       String path = is[0].getType() + ".id";
       PathQuery pq = new PathQuery(services.getModel());
       pq.addView(path);
       pq.addConstraint(
           Constraints.oneOfValues(
               path,
               collect(
                   collect(Arrays.asList(is), invokerTransformer("getId")),
                   stringValueTransformer())));
       createListAndSubtract(pq);
     } catch (ArrayStoreException e) {
       // Do nothing - we didn't get a collection of items.
     }
   }
   return priorSize != getSize();
 }
Пример #2
0
 /**
  * Return an API query fetching all Comments for Genes, ordered by type
  *
  * @author radek
  * @param proteinID
  * @param query
  * @return
  */
 private PathQuery proteinCommentsQuery(String proteinID, PathQuery query) {
   query.addViews(
       "Protein.comments.description", "Protein.comments.type", "Protein.primaryIdentifier");
   query.addOrderBy("Protein.comments.type", OrderDirection.ASC);
   query.addConstraint(Constraints.eq("Protein.id", proteinID));
   query.addConstraint(
       Constraints.oneOfValues("Protein.comments.type", Arrays.asList(allowedCommentTypes)));
   return query;
 }
Пример #3
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));
 }