/** * 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; }
/** * 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); }