/** * {@inheritDoc} */ public InterMineObject getObjectById(Integer id) throws ObjectStoreException { return os.getObjectById(id); }
/** * {@inheritDoc} */ public InterMineObject getObjectById(Integer id, Class<? extends InterMineObject> clazz) throws ObjectStoreException { return os.getObjectById(id, clazz); }
/** * {@inheritDoc} */ public InterMineObject getObjectById(Integer id) throws ObjectStoreException { return os.getObjectById(id); }
/** * {@inheritDoc} */ public InterMineObject getObjectById(Integer id, Class<? extends InterMineObject> clazz) throws ObjectStoreException { return os.getObjectById(id, clazz); }
/** * Gets the real object from the database. * * @return a InterMineObject */ public InterMineObject getObject() { try { InterMineObject retval = os.getObjectById(id, clazz); if (retval == null) { if (os instanceof ObjectStoreTranslatingImpl) { Translator trans = ((ObjectStoreTranslatingImpl) os).getTranslator(); Object identifier = trans.translateIdToIdentifier(id); throw new NullPointerException("Error retrieving object from Items database" + " with identifier " + identifier); } throw new NullPointerException("Error retrieving object from proxy with ID " + id + " for class " + clazz.getName() + " from ObjectStore " + os); } return retval; } catch (ObjectStoreException e) { throw new RuntimeException("ObjectStoreException while materialising proxy with ID " + id + " for class " + clazz.getName() + " from ObjectStore " + os + ": " + e.getMessage(), e); } }
/** * Gets the real object from the database. * * @return a InterMineObject */ public InterMineObject getObject() { try { InterMineObject retval = os.getObjectById(id, clazz); if (retval == null) { if (os instanceof ObjectStoreTranslatingImpl) { Translator trans = ((ObjectStoreTranslatingImpl) os).getTranslator(); Object identifier = trans.translateIdToIdentifier(id); throw new NullPointerException("Error retrieving object from Items database" + " with identifier " + identifier); } throw new NullPointerException("Error retrieving object from proxy with ID " + id + " for class " + clazz.getName() + " from ObjectStore " + os); } return retval; } catch (ObjectStoreException e) { throw new RuntimeException("ObjectStoreException while materialising proxy with ID " + id + " for class " + clazz.getName() + " from ObjectStore " + os + ": " + e.getMessage(), e); } }
/** * Set the superuser flag and store it in userprofile database * @param isSuperUser if true the profile is set as superuser * @throws ObjectStoreException if an error occurs during storage of the object */ public void setSuperuser(boolean isSuperUser) throws ObjectStoreException { ObjectStoreWriter uosw = manager.getProfileObjectStoreWriter(); UserProfile p = (UserProfile) uosw.getObjectStore().getObjectById(userId, UserProfile.class); p.setSuperuser(isSuperUser); uosw.store(p); this.isSuperUser = isSuperUser; }
/** * Set the superuser flag and store it in userprofile database * @param isSuperUser if true the profile is set as superuser * @throws ObjectStoreException if an error occurs during storage of the object */ public void setSuperuser(boolean isSuperUser) throws ObjectStoreException { ObjectStoreWriter uosw = manager.getProfileObjectStoreWriter(); UserProfile p = (UserProfile) uosw.getObjectStore().getObjectById(userId, UserProfile.class); p.setSuperuser(isSuperUser); uosw.store(p); this.isSuperUser = isSuperUser; }
/** * Delete this bag from the userprofile database, bag should not be used after this method has * been called. Delete the ids from the production database too. * @throws ObjectStoreException if problem deleting bag */ @Override public void delete() throws ObjectStoreException { super.delete(); if (!deleted) { SavedBag savedBag = (SavedBag) uosw.getObjectStore().getObjectById(savedBagId, SavedBag.class); uosw.delete(savedBag); deleteAllBagValues(); } this.deleted = true; }
@Test public void testGetObjectById() throws Exception { Integer id = ((Employee) data.get("EmployeeA1")).getId(); Employee e = (Employee) osForOsTests.getObjectById(id, Employee.class); Assert.assertEquals(data.get("EmployeeA1"), e); Assert.assertTrue(e == osForOsTests.getObjectById(id, Employee.class)); }
/** * Delete this bag from the userprofile database, bag should not be used after this method has * been called. Delete the ids from the production database too. * @throws ObjectStoreException if problem deleting bag */ @Override public void delete() throws ObjectStoreException { super.delete(); if (!deleted) { SavedBag savedBag = (SavedBag) uosw.getObjectStore().getObjectById(savedBagId, SavedBag.class); uosw.delete(savedBag); deleteAllBagValues(); } this.deleted = true; }
private static SharingInvite restoreFromRow( ProfileManager pm, BagManager bm, IntermediateRepresentation rep) throws ObjectStoreException { ObjectStore os = pm.getProfileObjectStoreWriter(); Profile inviter = pm.getProfile(rep.inviterId); SavedBag savedBag = (SavedBag) os.getObjectById(rep.bagId, SavedBag.class); InterMineBag bag = bm.getBag(inviter, savedBag.getName()); return new SharingInvite(bag, rep.invitee, rep.token, rep.createdAt, rep.acceptedAt, rep.accepted); }
private static SharingInvite restoreFromRow( ProfileManager pm, BagManager bm, IntermediateRepresentation rep) throws ObjectStoreException { ObjectStore os = pm.getProfileObjectStoreWriter(); Profile inviter = pm.getProfile(rep.inviterId); SavedBag savedBag = (SavedBag) os.getObjectById(rep.bagId, SavedBag.class); InterMineBag bag = bm.getBag(inviter, savedBag.getName()); return new SharingInvite(bag, rep.invitee, rep.token, rep.createdAt, rep.acceptedAt, rep.accepted); }
@Test public void testGetObjectByNullId() throws Exception { try { osForOsTests.getObjectById(null); Assert.fail("Expected NullPointerException"); } catch (NullPointerException e) { } }
private void deleteAddress() throws ObjectStoreException { ObjectStoreWriter osw = os.getNewWriter(); osw.delete(os.getObjectById(ADDRESS_ID)); osw.close(); } }
/** * Delete this bag from the userprofile database, bag should not be used after this method has * been called. Delete the ids from the production database too. * @throws ObjectStoreException if problem deleting bag */ @Override public void delete() throws ObjectStoreException { super.delete(); if (profileId != null) { SavedBag savedBag = (SavedBag) uosw.getObjectStore().getObjectById(savedBagId, SavedBag.class); uosw.delete(savedBag); removeIdsFromBag(getContentsAsIds(), false); deleteAllBagValues(); this.profileId = null; this.savedBagId = null; } }
/** * Delete this bag from the userprofile database, bag should not be used after this method has * been called. Delete the ids from the production database too. * @throws ObjectStoreException if problem deleting bag */ @Override public void delete() throws ObjectStoreException { super.delete(); if (profileId != null) { SavedBag savedBag = (SavedBag) uosw.getObjectStore().getObjectById(savedBagId, SavedBag.class); uosw.delete(savedBag); removeIdsFromBag(getContentsAsIds(), false); deleteAllBagValues(); this.profileId = null; this.savedBagId = null; } }
@Test public void testGetObjectMultipleTimes() throws Exception { Query q = IqlQueryParser.parse(new IqlQuery("select Secretary from Secretary where Secretary.name = 'Secretary1'", "org.intermine.model.testmodel")); Secretary a = (Secretary) ((List) osForOsTests.execute(q).get(0)).get(0); Secretary b = (Secretary) osForOsTests.getObjectById(a.getId(), Secretary.class); Secretary c = (Secretary) osForOsTests.getObjectById(a.getId(), Secretary.class); Assert.assertEquals(b, c); Assert.assertTrue(b == c); Assert.assertEquals(a, b); Assert.assertTrue(a == b); }
/** * Loads an InterMineBag from the UserProfile database. * * @param os the production ObjectStore * @param savedBagId the ID of the bag in the userprofile database * @param uosw the ObjectStoreWriter of the userprofile database * @param classDescriptor if true the classDescriptor will be set * @throws UnknownBagTypeException if the type bag is unknown * @throws ObjectStoreException if something goes wrong */ public InterMineBag(ObjectStore os, Integer savedBagId, ObjectStoreWriter uosw, boolean classDescriptor) throws UnknownBagTypeException, ObjectStoreException { this.os = os; this.uosw = uosw; this.savedBagId = savedBagId; ObjectStore uos = uosw.getObjectStore(); SavedBag savedBag = (SavedBag) uos.getObjectById(savedBagId, SavedBag.class); checkAndSetName(savedBag.getName()); this.type = TypeUtil.unqualifiedName(savedBag.getType()); this.description = savedBag.getDescription(); this.dateCreated = savedBag.getDateCreated(); this.profileId = savedBag.proxGetUserProfile().getId(); setState(savedBag.getState()); this.osb = new ObjectStoreBag(savedBag.getOsbId()); if (classDescriptor) { setClassDescriptors(); } }
/** * Loads an InterMineBag from the UserProfile database. * * @param os the production ObjectStore * @param savedBagId the ID of the bag in the userprofile database * @param uosw the ObjectStoreWriter of the userprofile database * @param classDescriptor if true the classDescriptor will be set * @throws UnknownBagTypeException if the type bag is unknown * @throws ObjectStoreException if something goes wrong */ public InterMineBag(ObjectStore os, Integer savedBagId, ObjectStoreWriter uosw, boolean classDescriptor) throws UnknownBagTypeException, ObjectStoreException { this.os = os; this.uosw = uosw; this.savedBagId = savedBagId; ObjectStore uos = uosw.getObjectStore(); SavedBag savedBag = (SavedBag) uos.getObjectById(savedBagId, SavedBag.class); checkAndSetName(savedBag.getName()); this.type = TypeUtil.unqualifiedName(savedBag.getType()); this.description = savedBag.getDescription(); this.dateCreated = savedBag.getDateCreated(); this.profileId = savedBag.proxGetUserProfile().getId(); setState(savedBag.getState()); this.osb = new ObjectStoreBag(savedBag.getOsbId()); if (classDescriptor) { setClassDescriptors(); } }