org.intermine.api.bag
Class BagOperations

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

public final class BagOperations
extends java.lang.Object

Perform logical operations on bags - combine bags to create new InterMineBags


Field Summary
static java.lang.String INTERSECT
          Constant representing logical intersection.
static java.lang.String SUBTRACT
          Constant representing logical substraction.
static java.lang.String UNION
          Constant representing logical union.
 
Method Summary
static java.lang.String getCommonBagType(java.util.Collection<InterMineBag> bags)
          If all of the bags provided are of the same type return the type, otherwise return null.
static int intersect(java.util.Collection<InterMineBag> bags, java.lang.String newBagName, Profile profile)
          Create a bag that is the INTERSECTION of all the bags provided, if the intersection is the empty set then don't create the new bag.
static int subtract(java.util.Collection<InterMineBag> bags, java.lang.String newBagName, Profile profile)
          Create a bag that contains the union of the bags provided minus the intersection of those bags.
static int union(java.util.Collection<InterMineBag> bags, java.lang.String newBagName, Profile profile)
          Create a bag that is the UNION of all the bags provided, if the union is the empty set then don't create the new bag - if bags are of incompatible types or are all empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNION

public static final java.lang.String UNION
Constant representing logical union.

See Also:
Constant Field Values

INTERSECT

public static final java.lang.String INTERSECT
Constant representing logical intersection.

See Also:
Constant Field Values

SUBTRACT

public static final java.lang.String SUBTRACT
Constant representing logical substraction.

See Also:
Constant Field Values
Method Detail

union

public static int union(java.util.Collection<InterMineBag> bags,
                        java.lang.String newBagName,
                        Profile profile)
                 throws ObjectStoreException
Create a bag that is the UNION of all the bags provided, if the union is the empty set then don't create the new bag - if bags are of incompatible types or are all empty.

Parameters:
bags - the bags to operate on
newBagName - name of the new bag to create
profile - the user that will own the new bag
Returns:
the size of the new bag or 0 if no bag created
Throws:
ObjectStoreException - if problems storing bag

intersect

public static int intersect(java.util.Collection<InterMineBag> bags,
                            java.lang.String newBagName,
                            Profile profile)
                     throws ObjectStoreException
Create a bag that is the INTERSECTION of all the bags provided, if the intersection is the empty set then don't create the new bag.

Parameters:
bags - the bags to operate on
newBagName - name of the new bag to create
profile - the user that will own the new bag
Returns:
the size of the new bag or 0 if no bag created
Throws:
ObjectStoreException - if problems storing bag

subtract

public static int subtract(java.util.Collection<InterMineBag> bags,
                           java.lang.String newBagName,
                           Profile profile)
                    throws ObjectStoreException
Create a bag that contains the union of the bags provided minus the intersection of those bags.

Parameters:
bags - the bags to operate on
newBagName - name of the new bag to create
profile - the user that will own the new bag
Returns:
the size of the new bag or 0 if no bag created
Throws:
ObjectStoreException - if problems storing bag

getCommonBagType

public static java.lang.String getCommonBagType(java.util.Collection<InterMineBag> bags)
If all of the bags provided are of the same type return the type, otherwise return null. This method does not take into account inheritance.

Parameters:
bags - the bags to check
Returns:
the common type or null if the bags are not all the same type