org.intermine.api.profile
Class InterMineBag

java.lang.Object
  extended by org.intermine.api.profile.InterMineBag
All Implemented Interfaces:
java.lang.Cloneable, WebSearchable

public class InterMineBag
extends java.lang.Object
implements WebSearchable, java.lang.Cloneable

An object that represents a bag of objects in our database for the webapp. It is backed by an ObjectStoreBag object, but contains extra data such as name and description.


Field Summary
protected static org.apache.log4j.Logger LOG
           
protected  java.lang.String type
           
 
Constructor Summary
InterMineBag(ObjectStore os, java.lang.Integer savedBagId, ObjectStoreWriter uosw)
          Loads an InterMineBag from the UserProfile database.
InterMineBag(java.lang.String name, java.lang.String type, java.lang.String description, java.util.Date dateCreated, ObjectStore os, java.lang.Integer profileId, ObjectStoreWriter uosw)
          Constructs a new InterMineIdBag, and saves it in the UserProfile database.
 
Method Summary
 void addIdsToBag(java.util.Collection<java.lang.Integer> ids, java.lang.String type)
          Add the given ids to the bag, this updates the bag contents in the database.
 void addIdToBag(java.lang.Integer id, java.lang.String type)
          Add the given id to the bag, this updates the bag contents in the database. he type can be a qualified or un-qualified class name.
 void addToBagFromQuery(Query query)
          Add elements to the bag from a query, this is able to operate entirely in the database without needing to read objects into memory.
 java.lang.Object clone()
          Create copy of bag.
protected  void delete()
          Delete this bag from the userprofile database, bag should not be used after this method has been called.
 java.util.Set<ClassDescriptor> getClassDescriptors()
          Return the class descriptors for the type of this bag.
 java.util.List<java.lang.Integer> getContentsAsIds()
          Returns a List which contains the contents of this bag as Integer IDs.
 java.util.Date getDateCreated()
          Return the creation date that was passed to the constructor.
 java.lang.String getDescription()
          Return the description of this bag.
 java.lang.String getName()
          Returns the value of name
 ObjectStoreBag getOsb()
          Returns the ObjectStoreBag, so that elements can be added and removed.
 java.lang.String getQualifiedType()
          Get the fully qualified type of this bag
 int getSize()
          Getter for size, just to make jsp happy.
 java.lang.String getTitle()
          The user-friendly title for this object.
 java.lang.String getType()
          Get the type of this bag (a class from InterMine model)
 boolean isOfType(java.lang.String testType)
          Test whether the given type can be added to this bag, type can be a qualified or un-qualified string.
 void removeIdFromBag(java.lang.Integer id)
          Remove the given id from the bag, this updates the bag contents in the database
 void removeIdsFromBag(java.util.Collection<java.lang.Integer> ids)
          Remove the given ids from the bag, this updates the bag contents in the database
 void setDate(java.util.Date date)
          Sets date when bag was created.
 void setDescription(java.lang.String description)
           
 void setName(java.lang.String name)
          Set the value of name
 void setProfileId(java.lang.Integer profileId)
          Sets the profileId - moves this bag from one profile to another.
 int size()
          Returns the size of the bag.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG

type

protected final java.lang.String type
Constructor Detail

InterMineBag

public InterMineBag(java.lang.String name,
                    java.lang.String type,
                    java.lang.String description,
                    java.util.Date dateCreated,
                    ObjectStore os,
                    java.lang.Integer profileId,
                    ObjectStoreWriter uosw)
             throws ObjectStoreException
Constructs a new InterMineIdBag, and saves it in the UserProfile database.

Parameters:
name - the name of the bag
type - the class of objects stored in the bag
description - the description of the bag
dateCreated - the Date when this bag was created
os - the production ObjectStore
profileId - the ID of the user in the userprofile database
uosw - the ObjectStoreWriter of the userprofile database
Throws:
ObjectStoreException - if an error occurs

InterMineBag

public InterMineBag(ObjectStore os,
                    java.lang.Integer savedBagId,
                    ObjectStoreWriter uosw)
             throws ObjectStoreException
Loads an InterMineBag from the UserProfile database.

Parameters:
os - the production ObjectStore
savedBagId - the ID of the bag in the userprofile database
uosw - the ObjectStoreWriter of the userprofile database
Throws:
ObjectStoreException - if something goes wrong
Method Detail

delete

protected void delete()
               throws ObjectStoreException
Delete this bag from the userprofile database, bag should not be used after this method has been called.

Throws:
ObjectStoreException - if problem deleting bag

getContentsAsIds

public java.util.List<java.lang.Integer> getContentsAsIds()
Returns a List which contains the contents of this bag as Integer IDs.

Returns:
a List of Integers

size

public int size()
         throws ObjectStoreException
Returns the size of the bag.

Returns:
the number of elements in the bag
Throws:
ObjectStoreException - if something goes wrong

getSize

public int getSize()
            throws ObjectStoreException
Getter for size, just to make jsp happy.

Returns:
the number of elements in the bag
Throws:
ObjectStoreException - if something goes wrong

getOsb

public ObjectStoreBag getOsb()
Returns the ObjectStoreBag, so that elements can be added and removed.

Returns:
the ObjectStoreBag

setProfileId

public void setProfileId(java.lang.Integer profileId)
                  throws ObjectStoreException
Sets the profileId - moves this bag from one profile to another.

Parameters:
profileId - the ID of the new userprofile
Throws:
ObjectStoreException - if something goes wrong

getName

public java.lang.String getName()
Returns the value of name

Specified by:
getName in interface WebSearchable
Returns:
the name of the bag

setName

public void setName(java.lang.String name)
             throws ObjectStoreException
Set the value of name

Parameters:
name - the bag name
Throws:
ObjectStoreException - if something goes wrong

getDescription

public java.lang.String getDescription()
Return the description of this bag.

Specified by:
getDescription in interface WebSearchable
Returns:
the description

getDateCreated

public java.util.Date getDateCreated()
Return the creation date that was passed to the constructor.

Returns:
the creation date

setDescription

public void setDescription(java.lang.String description)
                    throws ObjectStoreException
Parameters:
description - the description to set
Throws:
ObjectStoreException - if something goes wrong

getType

public java.lang.String getType()
Get the type of this bag (a class from InterMine model)

Returns:
the type of objects in this bag

getQualifiedType

public java.lang.String getQualifiedType()
Get the fully qualified type of this bag

Returns:
the type of objects in this bag

getClassDescriptors

public java.util.Set<ClassDescriptor> getClassDescriptors()
Return the class descriptors for the type of this bag.

Returns:
the set of class descriptors

getTitle

public java.lang.String getTitle()
The user-friendly title for this object.

Specified by:
getTitle in interface WebSearchable
Returns:
the title

clone

public java.lang.Object clone()
Create copy of bag. Bag is saved to objectstore.

Overrides:
clone in class java.lang.Object
Returns:
create bag

setDate

public void setDate(java.util.Date date)
Sets date when bag was created.

Parameters:
date - new date

addIdToBag

public void addIdToBag(java.lang.Integer id,
                       java.lang.String type)
                throws ObjectStoreException
Add the given id to the bag, this updates the bag contents in the database. he type can be a qualified or un-qualified class name.

Parameters:
id - the id to add
type - the type of ids being added
Throws:
ObjectStoreException - if problem storing

addIdsToBag

public void addIdsToBag(java.util.Collection<java.lang.Integer> ids,
                        java.lang.String type)
                 throws ObjectStoreException
Add the given ids to the bag, this updates the bag contents in the database. The type can be a qualified or un-qualified class name.

Parameters:
ids - the ids to add
type - the type of ids being added
Throws:
ObjectStoreException - if problem storing

isOfType

public boolean isOfType(java.lang.String testType)
Test whether the given type can be added to this bag, type can be a qualified or un-qualified string.

Parameters:
testType - type to check
Returns:
true if type can be added to the bag

addToBagFromQuery

public void addToBagFromQuery(Query query)
                       throws ObjectStoreException
Add elements to the bag from a query, this is able to operate entirely in the database without needing to read objects into memory. The query should have a single column on the select list returning an object id.

Parameters:
query - to select object ids
Throws:
ObjectStoreException - if problem storing

removeIdFromBag

public void removeIdFromBag(java.lang.Integer id)
                     throws ObjectStoreException
Remove the given id from the bag, this updates the bag contents in the database

Parameters:
id - the id to remove
Throws:
ObjectStoreException - if problem storing

removeIdsFromBag

public void removeIdsFromBag(java.util.Collection<java.lang.Integer> ids)
                      throws ObjectStoreException
Remove the given ids from the bag, this updates the bag contents in the database

Parameters:
ids - the ids to remove
Throws:
ObjectStoreException - if problem storing