Package org.intermine.api.profile
Class InvalidBag
- java.lang.Object
-
- org.intermine.api.profile.StorableBag
-
- org.intermine.api.profile.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 Summary
Fields Modifier and Type Field Description protected static org.apache.log4j.Logger
LOG
-
Fields inherited from class org.intermine.api.profile.StorableBag
profileId, savedBagId
-
-
Constructor Summary
Constructors Modifier Constructor Description 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)
Constructor.InvalidBag(java.lang.String name, java.lang.String type, java.lang.String description, java.util.Date createdAt, ObjectStore os, ObjectStoreWriter uosw)
Minimal constructor.protected
InvalidBag(SavedBag savedBag, java.lang.Integer profileId, ObjectStore os, ObjectStoreWriter userprofileObjectStore)
Constructor callable by the ProfileManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InterMineBag
amendTo(java.lang.String newType)
Fix this bag by changing its type.void
delete()
Delete this bag from the userprofile database, bag should not be used after this method has been called.java.util.Date
getDateCreated()
Get the date that this bag was created at.java.lang.String
getDescription()
Return the description of this object.java.lang.String
getName()
The name (or identifier) used as the primary key for storing this object.ObjectStoreBag
getOsb()
Return a reference to the object store bag contained in the production database.int
getSize()
Returns the size of the bag.java.lang.String
getState()
Return a string representing the state of this bag (eg.java.lang.String
getTitle()
The user-friendly title for this object.java.lang.String
getType()
Get the unqualified name of class that the objects in this bag represent.ObjectStoreWriter
getUserProfileWriter()
Get a reference to a connection to the database where user data is persisted.protected InvalidBag
rename(java.lang.String newName)
Returns a new Invalid Bag identical to this one, but with the given name.-
Methods inherited from class org.intermine.api.profile.StorableBag
addBagValues, addObserver, deleteAllBagValues, deleteSomeBagValues, fireEvent, getContents, getContentsOrderByExtraValue, getProfileId, getSavedBagId, getTagType, removeObserver, saveWithBagValues, size, storeSavedBag
-
-
-
-
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 interfaceTaggable
- Specified by:
getName
in classStorableBag
- 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 classStorableBag
- 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 classStorableBag
- 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 classStorableBag
- Returns:
- the bags's DOB
-
getDescription
public java.lang.String getDescription()
Description copied from interface:WebSearchable
Return the description of this object.- Specified by:
getDescription
in interfaceWebSearchable
- Specified by:
getDescription
in classStorableBag
- Returns:
- an optional string describing the bag. Never null.
-
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 classStorableBag
- 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 classStorableBag
- 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 classStorableBag
- 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 classStorableBag
- 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.
-
-