/** * Request that the ObjectStore commits and closes the transaction, delegate to internal * ObjectStoreWriter. * * @throws ObjectStoreException if a transaction is not in progress, or is aborted */ public void commitTransaction() throws ObjectStoreException { osw.commitTransaction(); }
/** * Request that the ObjectStore commits and closes the transaction, delegate to internal * ObjectStoreWriter. * * @throws ObjectStoreException if a transaction is not in progress, or is aborted */ public void commitTransaction() throws ObjectStoreException { osw.commitTransaction(); }
/** * {@inheritDoc} */ public void close() throws ObjectStoreException { if (osw.isInTransaction()) { osw.commitTransaction(); } }
/** * {@inheritDoc} */ public void close() throws ObjectStoreException { if (osw.isInTransaction()) { osw.commitTransaction(); } }
private void incrementTransaction() throws ObjectStoreException { transactionCounter++; if (transactionCounter >= TRANSACTION_BATCH_SIZE) { LOG.info("Committing transaction"); osw.commitTransaction(); osw.beginTransaction(); transactionCounter = 0; } } }
private void incrementTransaction() throws ObjectStoreException { transactionCounter++; if (transactionCounter >= TRANSACTION_BATCH_SIZE) { LOG.info("Committing transaction"); osw.commitTransaction(); osw.beginTransaction(); transactionCounter = 0; } } }
public static void storeData(ObjectStoreWriter dataWriter, Map data) throws Exception { //checkIsEmpty(); System.out.println("Storing data"); long start = new Date().getTime(); try { //Iterator iter = data.entrySet().iterator(); //while (iter.hasNext()) { // InterMineObject o = (InterMineObject) ((Map.Entry) iter.next()) // .getValue(); // o.setId(null); //} dataWriter.beginTransaction(); Iterator iter = data.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); Object o = entry.getValue(); dataWriter.store(o); } dataWriter.commitTransaction(); } catch (Exception e) { dataWriter.abortTransaction(); throw new Exception(e); } System.out.println("Took " + (new Date().getTime() - start) + " ms to set up data"); }
osw.delete((Tag) o); osw.commitTransaction(); } catch (Exception e) { throw new BuildException("Error deleting tags", e);
@AfterClass public static void tearDown() { try { osw = ObjectStoreWriterFactory.getObjectStoreWriter(ALIAS); } catch (ObjectStoreException e) { LOG.error("Could not initialise object-store", e); return; } if (osw != null) { try { osw.beginTransaction(); for (InterMineObject o: madeThings) { osw.delete(o); } osw.commitTransaction(); LOG.info("Deleted " + madeThings.size() + " things"); madeThings.clear(); } catch (ObjectStoreException e) { LOG.error("While unloading fixture", e); } finally { if (osw != null) { try { osw.close(); } catch (ObjectStoreException e) { LOG.error("Closing object store", e); } } } } }
osw.delete((Tag) o); osw.commitTransaction(); } catch (Exception e) { throw new BuildException("Error deleting tags", e);
writer.delete(toDelete); writer.commitTransaction(); } catch (Exception e) { writer.abortTransaction();
osw.store(employee); osw.commitTransaction(); osw.close();
public void tearDown() throws Exception { Query q = new Query(); QueryClass qc = new QueryClass(InterMineObject.class); q.addToSelect(qc); q.addFrom(qc); Collection toDelete = osw.getObjectStore().executeSingleton(q); Iterator iter = toDelete.iterator(); osw.beginTransaction(); while (iter.hasNext()) { InterMineObject obj = (InterMineObject) iter.next(); System.out.println("Deleting " + obj); osw.delete(obj); } osw.commitTransaction(); itemWriter.close(); osw.close(); }
public void tearDown() throws Exception { System.out.println("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); System.out.println("created results"); Iterator resIter = res.iterator(); osw.beginTransaction(); while (resIter.hasNext()) { InterMineObject o = (InterMineObject) resIter.next(); System.out.println("deleting: " + o.getId()); osw.delete(o); } osw.commitTransaction(); System.out.println("committed transaction"); osw.close(); System.out.println("closed objectstore"); }
deleted++; osw.commitTransaction(); } catch (Exception e) { e.printStackTrace(System.err);
q.addToSelect(osb); r = new SingletonResults(q, os, os.getSequence(os.getComponentsForQuery(q))); storeDataWriter.commitTransaction(); try { r.get(0);
private void cleanUserProfile() throws ObjectStoreException { if (userProfileOSW.isInTransaction()) { userProfileOSW.abortTransaction(); } Query q = new Query(); QueryClass qc = new QueryClass(Tag.class); q.addFrom(qc); q.addToSelect(qc); q.setConstraint(new SimpleConstraint(new QueryField(qc, "tagName"), ConstraintOp.MATCHES, new QueryValue("test%"))); SingletonResults res = userProfileOS.executeSingleton(q); Iterator resIter = res.iterator(); userProfileOSW.beginTransaction(); while (resIter.hasNext()) { InterMineObject o = (InterMineObject) resIter.next(); userProfileOSW.delete(o); } removeUserProfile("bob"); removeUserProfile("sally"); userProfileOSW.commitTransaction(); userProfileOSW.close(); }
made++; osw.commitTransaction(); System.out.printf("Made %d employables\n", made); } catch (Exception e) {
uosw.commitTransaction(); } catch (ObjectStoreException e) { if (uosw.isInTransaction()) {
Assert.assertEquals(2, res.size()); writer.commitTransaction(); Assert.assertFalse(writer.isInTransaction()); res = os.execute(q);