/** * Store an object in this ObjectStore, delegates to internal ObjectStoreWriter. * * @param o the object to store * @throws ObjectStoreException if an error occurs during storage of the object */ public void store(Object o) throws ObjectStoreException { osw.store(o); }
/** * Store an object in this ObjectStore, delegates to internal ObjectStoreWriter. * * @param o the object to store * @throws ObjectStoreException if an error occurs during storage of the object */ public void store(Object o) throws ObjectStoreException { osw.store(o); }
private static long storeEmployees(ObjectStoreWriter osw, int numberToCreate) throws ObjectStoreException { long startTime = System.currentTimeMillis(); List<Employee> employees = createEmployees(numberToCreate); for (Employee e: employees) { osw.store(e); } long totalTime = System.currentTimeMillis() - startTime; System.out.println("Stored " + numberToCreate + " employee objects, took: " + totalTime + "ms"); return totalTime; }
/** * {@inheritDoc} */ public void store(Attribute att, Integer itemId) throws ObjectStoreException { ProxyReference proxy = new ProxyReference(osw.getObjectStore(), itemId, Item.class); att.proxyItem(proxy); osw.store(att); incrementTransaction(); }
/** * {@inheritDoc} */ public void store(ReferenceList refList, Integer itemId) throws ObjectStoreException { ProxyReference proxy = new ProxyReference(osw.getObjectStore(), itemId, Item.class); refList.proxyItem(proxy); osw.store(refList); incrementTransaction(); }
/** * {@inheritDoc} */ public void store(Attribute att, Integer itemId) throws ObjectStoreException { ProxyReference proxy = new ProxyReference(osw.getObjectStore(), itemId, Item.class); att.proxyItem(proxy); osw.store(att); incrementTransaction(); }
/** * {@inheritDoc} */ public void store(Reference ref, Integer itemId) throws ObjectStoreException { ProxyReference proxy = new ProxyReference(osw.getObjectStore(), itemId, Item.class); ref.proxyItem(proxy); osw.store(ref); incrementTransaction(); }
/** * {@inheritDoc} */ public void store(Reference ref, Integer itemId) throws ObjectStoreException { ProxyReference proxy = new ProxyReference(osw.getObjectStore(), itemId, Item.class); ref.proxyItem(proxy); osw.store(ref); incrementTransaction(); }
/** * {@inheritDoc} */ public void store(ReferenceList refList, Integer itemId) throws ObjectStoreException { ProxyReference proxy = new ProxyReference(osw.getObjectStore(), itemId, Item.class); refList.proxyItem(proxy); osw.store(refList); incrementTransaction(); }
@Test public void testWriteInterMineObject() throws Exception { InterMineObject o = (InterMineObject) DynamicUtil.createObject(Collections.singleton(InterMineObject.class)); try { writer.store(o); } finally { writer.delete(o); } }
@Test public void testWriteDynamicObject() throws Exception { InterMineObject o = (InterMineObject) DynamicUtil.createObject(new HashSet(Arrays.asList(new Class[] {Company.class, Employee.class}))); try { writer.store(o); Assert.fail("Expected: error"); } catch (ObjectStoreException e) { Assert.assertEquals("Non-flat model heirarchy used in flat mode. Cannot store object with classes = [interface org.intermine.model.testmodel.Company, class org.intermine.model.testmodel.Employee]", e.getMessage()); } finally { writer.delete(o); } }
@org.junit.Test public void testFailFast2() throws Exception { Query q = new Query(); QueryClass qc = new QueryClass(Employee.class); q.addFrom(qc); q.addToSelect(qc); Results r = os.execute(q); storeDataWriter.store(data.get("CompanyA")); r.iterator().hasNext(); } }
private void storeAddress() throws ObjectStoreException { ObjectStoreWriter osw = os.getNewWriter(); Address address1 = DynamicUtil.createObject(Address.class); address1.setId(ADDRESS_ID); osw.store(address1); osw.close(); }
@org.junit.Test public void testFailFast2() throws Exception { Query q = new Query(); QueryClass qc = new QueryClass(Employee.class); q.addFrom(qc); q.addToSelect(qc); Results r = os.execute(q); storeDataWriter.store((Company) data.get("CompanyA")); r.iterator().hasNext(); } }
@Test public void testWriteInterMineObject() throws Exception { InterMineObject o = (InterMineObject) DynamicUtil.createObject(Collections.singleton(InterMineObject.class)); try { writer.store(o); Assert.fail("Expected: error"); } catch (ObjectStoreException e) { Assert.assertEquals("Object [interface org.intermine.model.InterMineObject] does not map onto any database table.", e.getMessage()); } finally { writer.delete(o); } }
@Test public void testDeleteNonInterMineObjectByQueryClass() throws Exception { // SimpleObject is just a FastPathObject, not an InterMineObject SimpleObject itemA = new SimpleObject(); itemA.setName("simpleobject A"); writer.store(itemA); QueryClass qc = new QueryClass(SimpleObject.class); writer.delete(qc, null); }
@Test public void testExceptionOutOfTransaction() throws Exception { Assert.assertFalse(writer.isInTransaction()); // First, cause an exception outside a transaction try { writer.store(new RuntimeExceptionEmployee()); } catch (Exception e) {} Assert.assertFalse(writer.isInTransaction()); // Now try and do something normal. writer.getObjectById(new Integer(2)); } }
@Test public void testExceptionOutOfTransaction() throws Exception { Assert.assertFalse(writer.isInTransaction()); // First, cause an exception outside a transaction try { writer.store(new RuntimeExceptionEmployee()); } catch (Exception e) {} Assert.assertFalse(writer.isInTransaction()); // Now try and do something normal. writer.getObjectById(new Integer(2)); } }
@Test public void testExceptionOutOfTransaction() throws Exception { Assert.assertFalse(writer.isInTransaction()); // First, cause an exception outside a transaction try { writer.store(new RuntimeExceptionEmployee()); } catch (Exception e) {} Assert.assertFalse(writer.isInTransaction()); // Now try and do something normal. writer.getObjectById(new Integer(2)); } }
@Test public void testWriteCleaner() throws Exception { InterMineObject o = new Cleaner(); try { writer.store(o); Assert.fail("Expected: error"); } catch (ObjectStoreException e) { Assert.assertEquals("Cannot store object [class org.intermine.model.testmodel.Cleaner] - no column for field evenings in table Employee", e.getMessage()); } finally { writer.delete(o); } }