@Override public boolean equals(Object o) { return (o instanceof SavedBag && id != null) ? id.equals(((SavedBag)o).getId()) : this == o; } @Override public int hashCode() { return (id != null) ? id.hashCode() : super.hashCode(); }
@Override public boolean equals(Object o) { return (o instanceof SavedBag && id != null) ? id.equals(((SavedBag)o).getId()) : this == o; } @Override public int hashCode() { return (id != null) ? id.hashCode() : super.hashCode(); }
@Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, bag.getId()); stm.setInt(2, sharedWith.getId()); return stm.executeUpdate(); } });
@Override public Integer run(PreparedStatement stm) throws SQLException { stm.setInt(1, bag.getId()); stm.setInt(2, sharedWith.getId()); return stm.executeUpdate(); } });
private InterMineBag cloneShallowIntermineBag() { // doesn't clone class descriptions and object store because they shouldn't change // -> cloned instance shares it with the original instance InterMineBag copy; try { copy = (InterMineBag) super.clone(); copy.savedBagId = null; SavedBag savedBag = copy.storeSavedBag(); copy.savedBagId = savedBag.getId(); copy.keyFieldNames = keyFieldNames; } catch (ObjectStoreException ex) { throw new RuntimeException("Clone failed.", ex); } catch (CloneNotSupportedException ex) { throw new RuntimeException("Clone failed.", ex); } return copy; }
private InterMineBag cloneShallowIntermineBag() { // doesn't clone class descriptions and object store because they shouldn't change // -> cloned instance shares it with the original instance InterMineBag copy; try { copy = (InterMineBag) super.clone(); copy.savedBagId = null; SavedBag savedBag = copy.storeSavedBag(); copy.savedBagId = savedBag.getId(); copy.keyFieldNames = keyFieldNames; } catch (ObjectStoreException ex) { throw new RuntimeException("Clone failed.", ex); } catch (CloneNotSupportedException ex) { throw new RuntimeException("Clone failed.", ex); } return copy; }
/** * Sets the profileId - moves this bag from one profile to another. * * @param profileId the ID of the new userprofile * @throws ObjectStoreException if something goes wrong */ public void setProfileId(Integer profileId) throws ObjectStoreException { this.profileId = profileId; SavedBag savedBag = storeSavedBag(); this.savedBagId = savedBag.getId(); addBagValues(); }
/** * Sets the profileId - moves this bag from one profile to another. * * @param profileId the ID of the new userprofile * @throws ObjectStoreException if something goes wrong */ public void setProfileId(Integer profileId) throws ObjectStoreException { this.profileId = profileId; SavedBag savedBag = storeSavedBag(); this.savedBagId = savedBag.getId(); addBagValues(); }
/** * Constructor with the actual objects we are trying to link. * @param bag The SavedBag we are trying to share * @param up The UserProfile we are trying to share this with. */ public UserAlreadyShareBagException(SavedBag bag, UserProfile up) { super(String.format("This bag (%s:%d) is already shared with this user (%s:%d)", bag.getName(), bag.getId(), up.getUsername(), up.getId())); } }
/** * Save the bag into the userprofile database, along with information about what kinds of values * this bag contains. These bag values can then be used later to reconstruct the contents of the * bag if when the bag is used with a different production database. * * @param profile the ID of the userprofile * @param bagValues the list of the key field values of the objects contained by the bag * @throws ObjectStoreException if something goes wrong when inserting data into the database. */ public void saveWithBagValues(Integer profile, Collection<BagValue> bagValues) throws ObjectStoreException { if (profile == null) { throw new NullPointerException("profileId may not be null"); } this.profileId = profile; SavedBag savedBag = storeSavedBag(); this.savedBagId = savedBag.getId(); addBagValues(bagValues); }
/** * Save the bag into the userprofile database, along with information about what kinds of values * this bag contains. These bag values can then be used later to reconstruct the contents of the * bag if when the bag is used with a different production database. * * @param profile the ID of the userprofile * @param bagValues the list of the key field values of the objects contained by the bag * @throws ObjectStoreException if something goes wrong when inserting data into the database. */ public void saveWithBagValues(Integer profile, Collection<BagValue> bagValues) throws ObjectStoreException { if (profile == null) { throw new NullPointerException("profileId may not be null"); } this.profileId = profile; SavedBag savedBag = storeSavedBag(); this.savedBagId = savedBag.getId(); addBagValues(bagValues); }
/** * Constructor with the actual objects we are trying to link. * @param bag The SavedBag we are trying to share * @param up The UserProfile we are trying to share this with. */ public UserAlreadyShareBagException(SavedBag bag, UserProfile up) { super(String.format("This bag (%s:%d) is already shared with this user (%s:%d)", bag.getName(), bag.getId(), up.getUsername(), up.getId())); } }
/** * Returns a new Invalid Bag identical to this one, but with the given name. The * underlying user-profile saved bag will be renamed at the same time, and this * object marked as deleted. * * @param newName The new name * @throws ObjectStoreException if there is a problem renaming the underlying bag. * If that happens, this bag will not be marked as deleted, and a new bag * will not be created. * @return A new invalid bag with the given name. */ protected InvalidBag rename(String newName) throws ObjectStoreException { InvalidBag renamed = new InvalidBag(newName, type, description, dateCreated, os, savedBagId, profileId, osb, uosw); SavedBag sb = renamed.storeSavedBag(); renamed.savedBagId = sb.getId(); deleted = true; return renamed; }
/** * Returns a new Invalid Bag identical to this one, but with the given name. The * underlying user-profile saved bag will be renamed at the same time, and this * object marked as deleted. * * @param newName The new name * @throws ObjectStoreException if there is a problem renaming the underlying bag. * If that happens, this bag will not be marked as deleted, and a new bag * will not be created. * @return A new invalid bag with the given name. */ protected InvalidBag rename(String newName) throws ObjectStoreException { InvalidBag renamed = new InvalidBag(newName, type, description, dateCreated, os, savedBagId, profileId, osb, uosw); SavedBag sb = renamed.storeSavedBag(); renamed.savedBagId = sb.getId(); deleted = true; return renamed; }
private void init(String listName, String descr, Date created, BagState bagState, ObjectStore objectStore, Integer profile, ObjectStoreWriter osw) throws UnknownBagTypeException, ObjectStoreException { checkAndSetName(listName); this.description = descr; this.dateCreated = created; this.state = bagState; this.os = objectStore; this.profileId = profile; this.osb = objectStore.createObjectStoreBag(); this.uosw = osw; this.savedBagId = null; SavedBag savedBag = storeSavedBag(); this.savedBagId = savedBag.getId(); setClassDescriptors(); }
private void init(String listName, String descr, Date created, BagState bagState, ObjectStore objectStore, Integer profile, ObjectStoreWriter osw) throws UnknownBagTypeException, ObjectStoreException { checkAndSetName(listName); this.description = descr; this.dateCreated = created; this.state = bagState; this.os = objectStore; this.profileId = profile; this.osb = objectStore.createObjectStoreBag(); this.uosw = osw; this.savedBagId = null; SavedBag savedBag = storeSavedBag(); this.savedBagId = savedBag.getId(); setClassDescriptors(); }
/** * Constructor callable by the ProfileManager. * @param savedBag The saved bag retrieved from the DB. * @param profileId The id of the user profile. * @param os The production object store. * @param userprofileObjectStore The userprofile object store. * @throws ObjectStoreException If there is a problem creating an ObjectStoreBag. */ protected InvalidBag(SavedBag savedBag, Integer profileId, ObjectStore os, ObjectStoreWriter userprofileObjectStore) throws ObjectStoreException { this.type = TypeUtil.unqualifiedName(savedBag.getType()); this.name = savedBag.getName(); this.description = savedBag.getDescription(); this.dateCreated = savedBag.getDateCreated(); checkArguments(os, userprofileObjectStore); this.os = os; this.osb = os.createObjectStoreBag(); this.uosw = userprofileObjectStore; this.profileId = profileId; this.savedBagId = savedBag.getId(); }
/** * Constructor callable by the ProfileManager. * @param savedBag The saved bag retrieved from the DB. * @param profileId The id of the user profile. * @param os The production object store. * @param userprofileObjectStore The userprofile object store. * @throws ObjectStoreException If there is a problem creating an ObjectStoreBag. */ protected InvalidBag(SavedBag savedBag, Integer profileId, ObjectStore os, ObjectStoreWriter userprofileObjectStore) throws ObjectStoreException { this.type = TypeUtil.unqualifiedName(savedBag.getType()); this.name = savedBag.getName(); this.description = savedBag.getDescription(); this.dateCreated = savedBag.getDateCreated(); checkArguments(os, userprofileObjectStore); this.os = os; this.osb = os.createObjectStoreBag(); this.uosw = userprofileObjectStore; this.profileId = profileId; this.savedBagId = savedBag.getId(); }
/** * Fix this bag by changing its type. If fixed, the DB will be corrected to store the new state, * and this bag will be marked as deleted. * @param newType The new type of this list. This must be a valid type in the current model. * @return A valid InterMineBag. * @throws UnknownBagTypeException If the new type is not in the current model. * @throws ObjectStoreException If there is a problem saving state to the DB. */ public InterMineBag amendTo(String newType) throws UnknownBagTypeException, ObjectStoreException { if (os.getModel().getClassDescriptorByName(newType) == null) { throw new UnknownBagTypeException(newType + " is not a valid class name"); } fireEvent(new DeletionEvent(this)); InvalidBag amended = new InvalidBag(name, newType, description, dateCreated, os, savedBagId, profileId, osb, uosw); SavedBag sb = amended.storeSavedBag(); deleted = true; return new InterMineBag(os, sb.getId(), uosw); }
/** * Fix this bag by changing its type. If fixed, the DB will be corrected to store the new state, * and this bag will be marked as deleted. * @param newType The new type of this list. This must be a valid type in the current model. * @return A valid InterMineBag. * @throws UnknownBagTypeException If the new type is not in the current model. * @throws ObjectStoreException If there is a problem saving state to the DB. */ public InterMineBag amendTo(String newType) throws UnknownBagTypeException, ObjectStoreException { if (os.getModel().getClassDescriptorByName(newType) == null) { throw new UnknownBagTypeException(newType + " is not a valid class name"); } fireEvent(new DeletionEvent(this)); InvalidBag amended = new InvalidBag(name, newType, description, dateCreated, os, savedBagId, profileId, osb, uosw); SavedBag sb = amended.storeSavedBag(); deleted = true; return new InterMineBag(os, sb.getId(), uosw); }