/** * Constructs the ItemWriter with an ObjectStoreWriter. * * @param osw the ObjectStoreWriter in which to store the Items * @throws ObjectStoreException if the ObjectStore is already in a transaction */ public ObjectStoreItemWriter(ObjectStoreWriter osw) throws ObjectStoreException { this.osw = osw; osw.beginTransaction(); }
/** * Request that the ObjectStore begins a transaction, delegate to internal * ObjectStoreWriter. * * @throws ObjectStoreException if a transaction is in progress, or is aborted */ public void beginTransaction() throws ObjectStoreException { osw.beginTransaction(); }
/** * Constructs the ItemWriter with an ObjectStoreWriter. * * @param osw the ObjectStoreWriter in which to store the Items * @throws ObjectStoreException if the ObjectStore is already in a transaction */ public ObjectStoreItemWriter(ObjectStoreWriter osw) throws ObjectStoreException { this.osw = osw; osw.beginTransaction(); }
/** * Request that the ObjectStore begins a transaction, delegate to internal * ObjectStoreWriter. * * @throws ObjectStoreException if a transaction is in progress, or is aborted */ public void beginTransaction() throws ObjectStoreException { osw.beginTransaction(); }
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.beginTransaction(); for (Object o: res) { osw.delete((Tag) o);
@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); } } } } }
writer.beginTransaction(); Query q = new Query(); QueryClass qc = new QueryClass(InterMineObject.class);
osw.beginTransaction(); for (Object o : res){ Employee employee = (Employee) o;
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"); }
osw.beginTransaction(); PathQuery pq = new PathQuery(osw.getModel()); pq.addView("Employee.id");
coll.add(new Integer(23)); coll.add(new Integer(30)); storeDataWriter.beginTransaction(); storeDataWriter.addAllToBag(osb, coll); Query q = new Query();
@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(); }
evictFromCache(profile); try { uosw.beginTransaction(); UserProfile userProfile = getUserProfile(userId); if (userProfile == null) {
writer.beginTransaction(); Assert.assertTrue(writer.isInTransaction());
Assert.assertEquals(res.toString(), 0, res.size()); writer.beginTransaction(); Assert.assertTrue(writer.isInTransaction());