Class StorableBag

  • All Implemented Interfaces:
    Taggable, WebSearchable
    Direct Known Subclasses:
    InterMineBag, InvalidBag

    public abstract class StorableBag
    extends java.lang.Object
    implements WebSearchable
    Base class for representations of user's collections of objects stored in a database.
    Author:
    Alex Kalderimis
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Integer profileId  
      protected java.lang.Integer savedBagId  
    • Constructor Summary

      Constructors 
      Constructor Description
      StorableBag()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addBagValues​(java.util.Collection<BagValue> bagValues)
      Save the values given in input into bagvalues table
      void addObserver​(WebSearchWatcher wsw)
      Add this observer to the list of interested parties.
      void delete()
      Delete this bag.
      void deleteAllBagValues()
      Remove all the values from the bag-value table.
      protected void deleteSomeBagValues​(java.util.List<java.lang.String> values)
      Delete a given set of bag values from the bag value table.
      void fireEvent​(OriginatingEvent e)
      Notify all your observers of this event which originates at this web searchable.
      java.util.List<BagValue> getContents()
      Returns a List of BagValue (key field value and extra value) of the objects contained by this bag.
      java.util.List<BagValue> getContentsOrderByExtraValue()  
      abstract java.util.Date getDateCreated()
      Get the date that this bag was created at.
      abstract java.lang.String getDescription()
      Return the description of this object.
      abstract java.lang.String getName()
      The name (or identifier) used as the primary key for storing this object.
      protected abstract ObjectStoreBag getOsb()
      Return a reference to the object store bag contained in the production database.
      java.lang.Integer getProfileId()  
      java.lang.Integer getSavedBagId()  
      abstract int getSize()
      Returns the size of the bag.
      abstract java.lang.String getState()
      Return a string representing the state of this bag (eg.
      java.lang.String getTagType()
      Poly-Morphic Constant.
      abstract java.lang.String getType()
      Get the unqualified name of class that the objects in this bag represent.
      protected abstract ObjectStoreWriter getUserProfileWriter()
      Get a reference to a connection to the database where user data is persisted.
      void removeObserver​(WebSearchWatcher wsw)
      Remove this observer from the list of interested parties.
      void saveWithBagValues​(java.lang.Integer profile, java.util.Collection<BagValue> bagValues)
      Save the bag into the userprofile database, along with information about what kinds of values this bag contains.
      int size()
      Returns the number of elements in the bag.
      protected SavedBag storeSavedBag()
      Perform the actual insertion of data into the userprofile database.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • profileId

        protected java.lang.Integer profileId
      • savedBagId

        protected java.lang.Integer savedBagId
    • Constructor Detail

      • StorableBag

        public StorableBag()
    • Method Detail

      • getName

        public abstract 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
        Returns:
        the name
      • getDescription

        public abstract java.lang.String getDescription()
        Description copied from interface: WebSearchable
        Return the description of this object.
        Specified by:
        getDescription in interface WebSearchable
        Returns:
        the description
      • getDateCreated

        public abstract java.util.Date getDateCreated()
        Get the date that this bag was created at.
        Returns:
        A date.
      • getType

        public abstract java.lang.String getType()
        Get the unqualified name of class that the objects in this bag represent.
        Returns:
        A name of a class.
      • getProfileId

        public java.lang.Integer getProfileId()
        Returns:
        the id of the profile belonging to the user this list belongs to
      • getSavedBagId

        public java.lang.Integer getSavedBagId()
        Returns:
        the id of the saved bag this list represents
      • getOsb

        protected abstract ObjectStoreBag getOsb()
        Return a reference to the object store bag contained in the production database.
        Returns:
        A reference to the backing store of objects.
      • getState

        public abstract java.lang.String getState()
        Return a string representing the state of this bag (eg. CURRENT).
        Returns:
        A valid representation of a BagState
      • getUserProfileWriter

        protected abstract ObjectStoreWriter getUserProfileWriter()
        Get a reference to a connection to the database where user data is persisted.
        Returns:
        An object capable of storing information in the user data store.
      • delete

        public void delete()
                    throws ObjectStoreException
        Delete this bag. Contrary to appearances, implementations MUST override this method in order to actually delete the bag. They MUST ALSO call this method (as super.delete()). This is to ensure that bag deletion events are registered correctly.
        Throws:
        ObjectStoreException - if can't remove list from database
      • saveWithBagValues

        public void saveWithBagValues​(java.lang.Integer profile,
                                      java.util.Collection<BagValue> bagValues)
                               throws ObjectStoreException
        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.
        Parameters:
        profile - the ID of the userprofile
        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.
      • storeSavedBag

        protected SavedBag storeSavedBag()
                                  throws ObjectStoreException
        Perform the actual insertion of data into the userprofile database.
        Returns:
        The object that represents the database record for this bag.
        Throws:
        ObjectStoreException - If we cannot store the bag.
      • deleteAllBagValues

        public void deleteAllBagValues()
        Remove all the values from the bag-value table.
      • deleteSomeBagValues

        protected void deleteSomeBagValues​(java.util.List<java.lang.String> values)
        Delete a given set of bag values from the bag value table. If an empty list is passed in, no values will be deleted. If null is passed in all values will be deleted.
        Parameters:
        values - The values to delete. null is understood as ALL VALUES..
      • getContents

        public java.util.List<BagValue> getContents()
        Returns a List of BagValue (key field value and extra value) of the objects contained by this bag.
        Returns:
        the values of the bag.
      • getContentsOrderByExtraValue

        public java.util.List<BagValue> getContentsOrderByExtraValue()
        Returns:
        the contents of this list, ordered by their extra-value.
      • addBagValues

        protected void addBagValues​(java.util.Collection<BagValue> bagValues)
        Save the values given in input into bagvalues table
        Parameters:
        bagValues - the values to save
      • addObserver

        public void addObserver​(WebSearchWatcher wsw)
        Description copied from interface: WebSearchable
        Add this observer to the list of interested parties. The observer should be notified of every change event this web searchable object has cause to issue.
        Specified by:
        addObserver in interface WebSearchable
        Parameters:
        wsw - The observer.
      • removeObserver

        public void removeObserver​(WebSearchWatcher wsw)
        Description copied from interface: WebSearchable
        Remove this observer from the list of interested parties. The observer should not be notified of any subsequent events this web searchable object has cause to generate.
        Specified by:
        removeObserver in interface WebSearchable
        Parameters:
        wsw - The observer.
      • getTagType

        public java.lang.String getTagType()
        Description copied from interface: Taggable
        Poly-Morphic Constant.
        Specified by:
        getTagType in interface Taggable
        Returns:
        The appropriate tag-type for this kind of object.
      • fireEvent

        public void fireEvent​(OriginatingEvent e)
        Description copied from interface: WebSearchable
        Notify all your observers of this event which originates at this web searchable.
        Specified by:
        fireEvent in interface WebSearchable
        Parameters:
        e - The event that has just occurred.