Class InvalidBag

  • All Implemented Interfaces:
    Taggable, WebSearchable

    public class InvalidBag
    extends StorableBag
    A class representing a bag that is invalid because it does not conform to the current model.
    Author:
    Alex Kalderimis.
    • Field Detail

      • LOG

        protected static final org.apache.log4j.Logger LOG
    • Constructor Detail

      • InvalidBag

        public InvalidBag​(java.lang.String name,
                          java.lang.String type,
                          java.lang.String desc,
                          java.util.Date createdAt,
                          ObjectStore os,
                          java.lang.Integer savedBagId,
                          java.lang.Integer profileId,
                          ObjectStoreBag osb,
                          ObjectStoreWriter userprofileObjectStore)
                   throws ObjectStoreException
        Constructor.
        Parameters:
        name - The name of this bag.
        type - The type it is meant to have.
        desc - A free text description of the bag.
        createdAt - When this list was first created.
        os - The production object store.
        profileId - The internal DB id of the profile of the user this list belongs to.
        savedBagId - The internal DB id of the saved bag this list represents.
        osb - The bag that represents the production DB level stored set of object ids.
        userprofileObjectStore - The user-profile object store writer.
        Throws:
        ObjectStoreException - If a ObjectStoreBag needs to be created and there is a problem doing so.
      • InvalidBag

        public InvalidBag​(java.lang.String name,
                          java.lang.String type,
                          java.lang.String description,
                          java.util.Date createdAt,
                          ObjectStore os,
                          ObjectStoreWriter uosw)
                   throws ObjectStoreException
        Minimal constructor. This constructor only requires the minimal set of values.
        Parameters:
        name - The name of the list.
        type - The erstwhile type of the list.
        description - A free text description of the list.
        createdAt - When the list was first created.
        os - A connection to the production object store.
        uosw - The writer to the user-profile object store.
        Throws:
        ObjectStoreException - If there is a problem creating an ObjectStoreBag
      • InvalidBag

        protected InvalidBag​(SavedBag savedBag,
                             java.lang.Integer profileId,
                             ObjectStore os,
                             ObjectStoreWriter userprofileObjectStore)
                      throws ObjectStoreException
        Constructor callable by the ProfileManager.
        Parameters:
        savedBag - The saved bag retrieved from the DB.
        profileId - The id of the user profile.
        os - The production object store.
        userprofileObjectStore - The userprofile object store.
        Throws:
        ObjectStoreException - If there is a problem creating an ObjectStoreBag.
    • Method Detail

      • rename

        protected InvalidBag rename​(java.lang.String newName)
                             throws ObjectStoreException
        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.
        Parameters:
        newName - The new name
        Returns:
        A new invalid bag with the given 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.
      • getName

        public java.lang.String getName()
        Description copied from interface: Taggable
        The name (or identifier) used as the primary key for storing this object.
        Specified by:
        getName in interface Taggable
        Specified by:
        getName in class StorableBag
        Returns:
        the bags's name
      • getTitle

        public java.lang.String getTitle()
        Description copied from interface: WebSearchable
        The user-friendly title for this object.
        Returns:
        the bag's name
      • getSize

        public int getSize()
        Description copied from class: StorableBag
        Returns the size of the bag.
        Specified by:
        getSize in class StorableBag
        Returns:
        the number of items in this bag.
      • getType

        public java.lang.String getType()
        Description copied from class: StorableBag
        Get the unqualified name of class that the objects in this bag represent.
        Specified by:
        getType in class StorableBag
        Returns:
        the bag's (now defunct) type
      • getDateCreated

        public java.util.Date getDateCreated()
        Description copied from class: StorableBag
        Get the date that this bag was created at.
        Specified by:
        getDateCreated in class StorableBag
        Returns:
        the bags's DOB
      • getOsb

        public ObjectStoreBag getOsb()
        Description copied from class: StorableBag
        Return a reference to the object store bag contained in the production database.
        Specified by:
        getOsb in class StorableBag
        Returns:
        the production DB level collection of object ids.
      • getState

        public java.lang.String getState()
        Description copied from class: StorableBag
        Return a string representing the state of this bag (eg. CURRENT).
        Specified by:
        getState in class StorableBag
        Returns:
        The state of this bag. Always returns "NOT CURRENT"
      • getUserProfileWriter

        public ObjectStoreWriter getUserProfileWriter()
        Description copied from class: StorableBag
        Get a reference to a connection to the database where user data is persisted.
        Specified by:
        getUserProfileWriter in class StorableBag
        Returns:
        The connection to the user-profile DB
      • delete

        public void delete()
                    throws ObjectStoreException
        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.
        Overrides:
        delete in class StorableBag
        Throws:
        ObjectStoreException - if problem deleting bag
      • amendTo

        public InterMineBag amendTo​(java.lang.String newType)
                             throws UnknownBagTypeException,
                                    ObjectStoreException
        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.
        Parameters:
        newType - The new type of this list. This must be a valid type in the current model.
        Returns:
        A valid InterMineBag.
        Throws:
        UnknownBagTypeException - If the new type is not in the current model.
        ObjectStoreException - If there is a problem saving state to the DB.