org.intermine.api.bag
Class BagManager

java.lang.Object
  extended by org.intermine.api.bag.BagManager

public class BagManager
extends java.lang.Object

A BagManager provides access to all global and/or user bags and methods to fetch them by type, etc.


Constructor Summary
BagManager(Profile superProfile, Model model)
          The BagManager references the super user profile to fetch global bags.
 
Method Summary
protected  java.util.Map<java.lang.String,InterMineBag> getBagsWithTag(Profile profile, java.lang.String tag)
          Fetch bags from given protocol with a particular tag assigned to them.
 InterMineBag getGlobalBag(java.lang.String bagName)
          Fetch a global bag by name.
 java.util.Map<java.lang.String,InterMineBag> getGlobalBags()
          Fetch globally available bags - superuser public bags that are available to everyone.
 java.util.Collection<InterMineBag> getGlobalBagsContainingId(java.lang.Integer id)
          Fetch global bags that contain the given id.
 java.util.Map<java.lang.String,InterMineBag> getUserAndGlobalBags(Profile profile)
          Fetch all global bags and user bags combined in the same map.
 InterMineBag getUserBag(Profile profile, java.lang.String bagName)
          Fetch a user bag by name.
 java.util.Map<java.lang.String,InterMineBag> getUserBags(Profile profile)
          Fetch bags for the given profile.
 java.util.Collection<InterMineBag> getUserBagsContainingId(Profile profile, java.lang.Integer id)
          Fetch user bags that contain the given id.
 InterMineBag getUserOrGlobalBag(Profile profile, java.lang.String bagName)
          Fetch a global or user bag by name.
 java.util.Collection<InterMineBag> getUserOrGlobalBagsContainingId(Profile profile, java.lang.Integer id)
          Fetch user or global bags that contain the given id.
 java.util.Map<java.lang.String,InterMineBag> getUserOrGlobalBagsOfType(Profile profile, java.lang.String type)
          Fetch global and user bags of the specified type or a subclass of the specified type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BagManager

public BagManager(Profile superProfile,
                  Model model)
The BagManager references the super user profile to fetch global bags.

Parameters:
superProfile - the super user profile
model - the object model
Method Detail

getGlobalBags

public java.util.Map<java.lang.String,InterMineBag> getGlobalBags()
Fetch globally available bags - superuser public bags that are available to everyone.

Returns:
a map from bag name to bag

getBagsWithTag

protected java.util.Map<java.lang.String,InterMineBag> getBagsWithTag(Profile profile,
                                                                      java.lang.String tag)
Fetch bags from given protocol with a particular tag assigned to them.

Parameters:
profile - the user to fetch bags from
tag - the tag to filter
Returns:
a map from bag name to bag

getUserBags

public java.util.Map<java.lang.String,InterMineBag> getUserBags(Profile profile)
Fetch bags for the given profile.

Parameters:
profile - the user to fetch bags for
Returns:
a map from bag name to bag

getUserAndGlobalBags

public java.util.Map<java.lang.String,InterMineBag> getUserAndGlobalBags(Profile profile)
Fetch all global bags and user bags combined in the same map. If user has a bag with the same name as a global bag the user's bag takes precedence.

Parameters:
profile - the user to fetch bags for
Returns:
a map from bag name to bag

getGlobalBag

public InterMineBag getGlobalBag(java.lang.String bagName)
Fetch a global bag by name.

Parameters:
bagName - the name of bag to fetch
Returns:
the bag or null if not found

getUserBag

public InterMineBag getUserBag(Profile profile,
                               java.lang.String bagName)
Fetch a user bag by name.

Parameters:
profile - the user to fetch bags for
bagName - the name of bag to fetch
Returns:
the bag or null if not found

getUserOrGlobalBag

public InterMineBag getUserOrGlobalBag(Profile profile,
                                       java.lang.String bagName)
Fetch a global or user bag by name. If user has a bag with the same name as a global bag the user's bag takes precedence.

Parameters:
profile - the user to fetch bags for
bagName - the name of bag to fetch
Returns:
the bag or null if not found

getUserOrGlobalBagsOfType

public java.util.Map<java.lang.String,InterMineBag> getUserOrGlobalBagsOfType(Profile profile,
                                                                              java.lang.String type)
Fetch global and user bags of the specified type or a subclass of the specified type.

Parameters:
profile - the user to fetch bags for
type - an unqualified class name
Returns:
a map from bag name to bag

getGlobalBagsContainingId

public java.util.Collection<InterMineBag> getGlobalBagsContainingId(java.lang.Integer id)
Fetch global bags that contain the given id.

Parameters:
id - the id to search bags for
Returns:
bags containing the given id

getUserBagsContainingId

public java.util.Collection<InterMineBag> getUserBagsContainingId(Profile profile,
                                                                  java.lang.Integer id)
Fetch user bags that contain the given id.

Parameters:
id - the id to search bags for
profile - the user to fetch bags from
Returns:
bags containing the given id

getUserOrGlobalBagsContainingId

public java.util.Collection<InterMineBag> getUserOrGlobalBagsContainingId(Profile profile,
                                                                          java.lang.Integer id)
Fetch user or global bags that contain the given id. If user has a bag with the same name as a global bag the user's bag takes precedence.

Parameters:
id - the id to search bags for
profile - the user to fetch bags from
Returns:
bags containing the given id