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"); }
/** {@inheritDoc} */ public synchronized void setNoExplain() { noExplain = true; if (collectionRef != null) { Collection<E> collection = collectionRef.get(); if ((collection != null) && (collection instanceof SingletonResults)) { ((SingletonResults) collection).setNoExplain(); } } }
/** * 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()); } }
/** {@inheritDoc} */ @Override public SingletonResults executeSingleton( Query q, int batchSize, boolean optimise, boolean explain, boolean prefetch) { SingletonResults retval = new SingletonResults(q, this, getSequence(getComponentsForQuery(q))); if (batchSize != 0) { retval.setBatchSize(batchSize); } if (!optimise) { retval.setNoOptimise(); } if (!explain) { retval.setNoExplain(); } if (!prefetch) { retval.setNoPrefetch(); } retval.setImmutable(); return retval; }