Пример #1
0
  public void tearDown() throws Exception {
    LOG.info("in tear down");
    ObjectStoreWriter osw = ObjectStoreWriterFactory.getObjectStoreWriter("osw.unittest");

    if (osw.isInTransaction()) {
      osw.abortTransaction();
    }
    Query q = new Query();
    QueryClass qc = new QueryClass(InterMineObject.class);
    q.addFrom(qc);
    q.addToSelect(qc);
    SingletonResults res = osw.getObjectStore().executeSingleton(q);
    LOG.info("created results");
    Iterator resIter = res.iterator();
    osw.beginTransaction();
    while (resIter.hasNext()) {
      InterMineObject o = (InterMineObject) resIter.next();
      LOG.info("deleting: " + o.getId());
      osw.delete(o);
    }
    osw.commitTransaction();
    LOG.info("committed transaction");
    osw.close();
    LOG.info("closed objectstore");
  }
Пример #2
0
  /**
   * Tell the requester about all the reference sequences that have data (are of non-zero length)
   * and are in the correct domain.
   */
  private void serveRefSeqs() {
    Model m = im.getModel();
    ClassDescriptor ref = m.getClassDescriptorByName(refType);
    if (ref == null) {
      throw new ResourceNotFoundException("No class called " + ref);
    }
    PathQuery pq = new PathQuery(m);
    pq.addView(refType + ".id");
    pq.addConstraint(Constraints.greaterThan(refType + "." + lengthPath, "0"));
    pq.addConstraint(Constraints.eq(refType + "." + domainPath, domain));

    Query q = pathQueryToOSQ(pq);
    SingletonResults res = im.getObjectStore().executeSingleton(q);
    if (res.size() == 0) {
      throw new ResourceNotFoundException("No " + refType + "s on " + domain);
    }
    Iterator<Object> it = res.iterator();

    while (it.hasNext()) {
      FastPathObject o = (FastPathObject) it.next();
      Map<String, Object> refseq = makeRefSeq(o);
      addResultItem(refseq, it.hasNext());
    }
  }