/** * Request that the ObjectStore aborts and closes the transaction, delegate to internal * ObjectStoreWriter. * * @throws ObjectStoreException if a transaction is not in progress */ public void abortTransaction() throws ObjectStoreException { osw.abortTransaction(); }
/** * Request that the ObjectStore aborts and closes the transaction, delegate to internal * ObjectStoreWriter. * * @throws ObjectStoreException if a transaction is not in progress */ public void abortTransaction() throws ObjectStoreException { osw.abortTransaction(); }
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"); }
try { if (osw.isInTransaction()) { osw.abortTransaction();
try { if (osw.isInTransaction()) { osw.abortTransaction();
} catch (ObjectStoreException e) { if (osw.isInTransaction()) { osw.abortTransaction(); } catch (IOException e) { if (osw.isInTransaction()) { osw.abortTransaction(); } catch (RuntimeException e) { if (osw.isInTransaction()) { osw.abortTransaction();
} catch (ObjectStoreException e) { if (osw.isInTransaction()) { osw.abortTransaction(); } catch (IOException e) { if (osw.isInTransaction()) { osw.abortTransaction(); } catch (RuntimeException e) { if (osw.isInTransaction()) { osw.abortTransaction();
writer.abortTransaction(); throw e;
if (osw != null) { if (osw.isInTransaction()) { osw.abortTransaction();
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"); }
if (osw != null) { try { osw.abortTransaction(); } catch (ObjectStoreException e1) { LOG.error("While aborting transaction", e1);
} catch (ObjectStoreException e) { if (uosw.isInTransaction()) { uosw.abortTransaction(); uosw.abortTransaction();
} catch (ObjectStoreException e) { if (uosw.isInTransaction()) { uosw.abortTransaction(); uosw.abortTransaction();
@Test public void testWriteBatchingAndGetObject() throws Exception { Address address1 = new Address(); address1.setAddress("Address 1"); writer.flushObjectById(); os.flushObjectById(); try { writer.beginTransaction(); writer.store(address1); Assert.assertNotNull(writer.getObjectById(address1.getId(), Address.class)); } finally { if (writer.isInTransaction()) { writer.abortTransaction(); } } }
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(); }
if (osw != null) { if (osw.isInTransaction()) { osw.abortTransaction();
if (osw != null) { if (osw.isInTransaction()) { osw.abortTransaction();
if (osw != null) { if (osw.isInTransaction()) { osw.abortTransaction();
Assert.assertEquals(res.toString(), 0, res.size()); writer.abortTransaction(); Assert.assertFalse(writer.isInTransaction());
Assert.assertEquals("Address 2", ((Address) os.getObjectById(id, Address.class)).getAddress()); writer.abortTransaction(); Assert.assertNotNull(writer.getObjectById(id, Address.class)); Assert.assertEquals("Address 2", ((Address) writer.getObjectById(id, Address.class)).getAddress());