ObjectStoreWriterFactory.getObjectStoreWriter(userProfileAlias); ProfileManager pm = new ProfileManager(os, userProfileOS); osw = os.getNewWriter();
ObjectStoreWriterFactory.getObjectStoreWriter(userProfileAlias); ProfileManager pm = new ProfileManager(os, userProfileOS); osw = os.getNewWriter();
private void cloneInternalObjectStoreBag(InterMineBag bag) { ObjectStoreWriter osw = null; try { osw = os.getNewWriter(); ObjectStoreBag newBag = osw.createObjectStoreBag(); Query q = new Query(); q.addToSelect(this.osb); osw.addToBagFromQuery(newBag, q); bag.osb = newBag; } catch (ObjectStoreException e) { LOG.error("Clone failed.", e); throw new RuntimeException("Clone failed.", e); } finally { try { if (osw != null) { osw.close(); } } catch (ObjectStoreException e) { LOG.error("Closing object store failed.", e); } } }
private void cloneInternalObjectStoreBag(InterMineBag bag) { ObjectStoreWriter osw = null; try { osw = os.getNewWriter(); ObjectStoreBag newBag = osw.createObjectStoreBag(); Query q = new Query(); q.addToSelect(this.osb); osw.addToBagFromQuery(newBag, q); bag.osb = newBag; } catch (ObjectStoreException e) { LOG.error("Clone failed.", e); throw new RuntimeException("Clone failed.", e); } finally { try { if (osw != null) { osw.close(); } } catch (ObjectStoreException e) { LOG.error("Closing object store failed.", e); } } }
/** * Remove the given ids from the bag, this updates the bag contents in the database * @param ids the ids to remove * @param updateBagValues whether or not to update the values * @throws ObjectStoreException if problem storing */ public void removeIdsFromBag(Collection<Integer> ids, boolean updateBagValues) throws ObjectStoreException { ObjectStoreWriter oswProduction = null; try { oswProduction = os.getNewWriter(); oswProduction.removeAllFromBag(osb, ids); } finally { if (oswProduction != null) { oswProduction.close(); } } if (profileId != null && updateBagValues) { updateBagValues(); } }
/** * Add elements to the bag from a query, this is able to operate entirely in the database * without needing to read objects into memory. The query should have a single column on the * select list returning an object id. * @param query to select object ids * @throws ObjectStoreException if problem storing */ public void addToBagFromQuery(Query query) throws ObjectStoreException { // query is checked in ObjectStoreWriter method ObjectStoreWriter oswProduction = null; try { oswProduction = os.getNewWriter(); oswProduction.addToBagFromQuery(osb, query); } finally { if (oswProduction != null) { oswProduction.close(); } } if (profileId != null) { updateBagValues(); } }
/** * Remove the given ids from the bag, this updates the bag contents in the database * @param ids the ids to remove * @param updateBagValues whether or not to update the values * @throws ObjectStoreException if problem storing */ public void removeIdsFromBag(Collection<Integer> ids, boolean updateBagValues) throws ObjectStoreException { ObjectStoreWriter oswProduction = null; try { oswProduction = os.getNewWriter(); oswProduction.removeAllFromBag(osb, ids); } finally { if (oswProduction != null) { oswProduction.close(); } } if (profileId != null && updateBagValues) { updateBagValues(); } }
/** * Add elements to the bag from a query, this is able to operate entirely in the database * without needing to read objects into memory. The query should have a single column on the * select list returning an object id. * @param query to select object ids * @throws ObjectStoreException if problem storing */ public void addToBagFromQuery(Query query) throws ObjectStoreException { // query is checked in ObjectStoreWriter method ObjectStoreWriter oswProduction = null; try { oswProduction = os.getNewWriter(); oswProduction.addToBagFromQuery(osb, query); } finally { if (oswProduction != null) { oswProduction.close(); } } if (profileId != null) { updateBagValues(); } }
oswProduction = os.getNewWriter(); oswProduction.addAllToBag(osb, ids); } finally {
oswProduction = os.getNewWriter(); oswProduction.addAllToBag(osb, ids); } finally {
private void deleteAddress() throws ObjectStoreException { ObjectStoreWriter osw = os.getNewWriter(); osw.delete(os.getObjectById(ADDRESS_ID)); osw.close(); } }
private void storeAddress() throws ObjectStoreException { ObjectStoreWriter osw = os.getNewWriter(); Address address1 = DynamicUtil.createObject(Address.class); address1.setId(ADDRESS_ID); osw.store(address1); osw.close(); }
ObjectStoreWriter osw = null; try { osw = userProfileOS.getNewWriter(); } catch (ObjectStoreException ose) { throw new BuildException("Problems retrieving the new writer", ose);
ObjectStoreWriter osw = null; try { osw = userProfileOS.getNewWriter(); } catch (ObjectStoreException ose) { throw new BuildException("Problems retrieving the new writer", ose);
q.addToSelect(qcEmployee); ObjectStore os = ObjectStoreFactory.getObjectStore("os.unittest"); ObjectStoreWriter osw = os.getNewWriter();
private void clearDatabase() throws Exception { Query q = new Query(); QueryClass qc = new QueryClass(InterMineObject.class); q.addToSelect(qc); q.addFrom(qc); SingletonResults res = os.executeSingleton(q, 20000, false, false, true); ObjectStoreWriter osw = os.getNewWriter(); Iterator<?> resIter = res.iterator(); while (resIter.hasNext()) { InterMineObject o = (InterMineObject) resIter.next(); osw.delete(o); } osw.close(); }
@Override public void setUp() throws Exception { super.setUp(); Long start = System.currentTimeMillis(); hasAddresses = testUser.createBag("has-addresses", "HasAddress", "Has-Addresses", im.getClassKeys()); Company c = DynamicUtil.simpleCreateObject(Company.class); ObjectStoreWriter osw = os.getNewWriter(); osw.store(c); osw.close(); hasAddresses.addIdToBag(c.getId(), "Company"); hasAddresses.addIdsToBag(managers, "Manager"); }
/** * Upgrades the ObjectStoreBag with a new ObjectStoreBag containing the collection of elements * given in input * @param values the collection of elements to add * @param updateBagValues id true if we upgrade the bagvalues table * @throws ObjectStoreException if an error occurs fetching a new ID */ public void upgradeOsb(Collection<Integer> values, boolean updateBagValues) throws ObjectStoreException { ObjectStoreWriter oswProduction = null; SavedBag savedBag = (SavedBag) uosw.getObjectById(savedBagId, SavedBag.class); try { oswProduction = os.getNewWriter(); osb = oswProduction.createObjectStoreBag(); oswProduction.addAllToBag(osb, values); savedBag.setOsbId(osb.getBagId()); savedBag.setState(BagState.CURRENT.toString()); state = BagState.CURRENT; uosw.store(savedBag); if (updateBagValues) { updateBagValues(); } } finally { if (oswProduction != null) { oswProduction.close(); } } }
/** * Upgrades the ObjectStoreBag with a new ObjectStoreBag containing the collection of elements * given in input * @param values the collection of elements to add * @param updateBagValues id true if we upgrade the bagvalues table * @throws ObjectStoreException if an error occurs fetching a new ID */ public void upgradeOsb(Collection<Integer> values, boolean updateBagValues) throws ObjectStoreException { ObjectStoreWriter oswProduction = null; SavedBag savedBag = (SavedBag) uosw.getObjectById(savedBagId, SavedBag.class); try { oswProduction = os.getNewWriter(); osb = oswProduction.createObjectStoreBag(); oswProduction.addAllToBag(osb, values); savedBag.setOsbId(osb.getBagId()); savedBag.setState(BagState.CURRENT.toString()); state = BagState.CURRENT; uosw.store(savedBag); if (updateBagValues) { updateBagValues(); } } finally { if (oswProduction != null) { oswProduction.close(); } } }
public void testQueryForTypesInCollection() throws ObjectStoreException { String field = "employees"; Department d1 = (Department) DynamicUtil.createObject(Department.class); d1.setId(1); Employee e1 = (Employee) DynamicUtil.createObject(Employee.class); e1.setId(2); e1.setDepartment(d1); Manager m1 = DynamicUtil.createObject(Manager.class); m1.setId(3); m1.setDepartment(d1); ObjectStoreWriter osw = os.getNewWriter(); osw.store(e1); osw.store(m1); osw.store(d1); List<Class<?>> classes = PathQueryResultHelper.queryForTypesInCollection(d1, field, os); List<Class<? extends Employee>> expectedClasses = Arrays.asList(Employee.class, Manager.class); assertEquals(expectedClasses, classes); osw.delete(d1); osw.delete(e1); osw.delete(m1); } }