public class BioMaterialList extends AnnotatedItem<BioMaterialListData>
Modifier and Type | Field and Description |
---|---|
static int |
MAX_EXTERNAL_ID_LENGTH
The maximum length of the external id variable that can be stored in the
database.
|
static Item |
TYPE
The type of item represented by this class.
|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
Constructor and Description |
---|
BioMaterialList(BioMaterialListData listData) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(BioMaterial bioMaterial)
Add a biomaterial to this list.
|
int |
add(java.util.Iterator<? extends BioMaterial> it)
Add multiple biomaterials to this list in one go.
|
int |
addAll(BioMaterialList list)
Add all items from another biomaterial list to this
list.
|
int |
addIfPresentIn(int minCount,
int maxCount,
java.util.Collection<BioMaterialList> lists)
Add items that are present in the specified number of lists to
this list.
|
int |
addIntersection(java.util.Collection<BioMaterialList> lists)
Add items that are present in ALL OF the given lists to
this list.
|
private int |
addMembers(java.util.Set<BioMaterialData> items)
Add members to this list.
|
int |
addUnion(java.util.Collection<BioMaterialList> lists)
Add items that are present in at least ONE OF the given lists to
this list.
|
private void |
checkMemberType(java.util.Collection<BioMaterialList> lists)
Checks that the lists have the same member type as this list.
|
private void |
checkMemberType(Item otherType)
Checks if the other type is the same type as the member type of
this list.
|
private static java.util.Set<BioMaterialData> |
count(java.util.Collection<BioMaterialList> lists,
int minCount,
int maxCount)
Count the number of times each item is present in the
given lists and return those items that are found in
>=minCount and <=maxCount lists.
|
ItemQuery<? extends BioMaterial> |
getAllBioMaterials()
Get a query that returns all biomaterials that can possibly be
members of this list.
|
java.util.Set<Annotatable> |
getAnnotatableParents()
Always returns null
|
static BioMaterialList |
getById(DbControl dc,
int id)
Get a
BioMaterialList item when you know the id. |
java.lang.String |
getExternalId()
Get the external id for this list.
|
ItemQuery<? extends BioMaterial> |
getMemberBioMaterials()
Get a query that returns all biomaterials that are
members of this list.
|
Item |
getMemberType()
Get the item type of members on this list.
|
static BioMaterialList |
getNew(DbControl dc,
Item memberType)
Create a new
BioMaterialList item. |
static ItemQuery<BioMaterialList> |
getQuery()
Get a query that returns biomaterial lists.
|
int |
getSize()
Get the number of members in this list.
|
Item |
getType()
Get the type of item represented by the object.
|
private static java.util.Set<BioMaterialData> |
intersection(java.util.Collection<BioMaterialList> lists)
Create a set with the intersection of the items
in the given lists.
|
void |
remove(BioMaterial bioMaterial)
Remove a biomaterial from the list.
|
int |
removeAll(BioMaterialList list)
Remove all items from this list that are present
in the other list.
|
int |
removeIfPresentIn(int minCount,
int maxCount,
java.util.Collection<BioMaterialList> lists)
Remove items that are present in the specified number of lists from
this list.
|
int |
removeIntersection(java.util.Collection<BioMaterialList> lists)
Remove items that are present in ALL OF the given lists from
this list.
|
private int |
removeMembers(java.util.Set<BioMaterialData> items)
Remove members from this list
|
int |
removeUnion(java.util.Collection<BioMaterialList> lists)
Remove items that are present in at least ONE OF the given lists from
this list.
|
int |
retainAll(BioMaterialList list)
Remove all items from this list that are NOT present
in the other list.
|
int |
retainIfPresentIn(int minCount,
int maxCount,
java.util.Collection<BioMaterialList> lists)
Retain items that are present in the specified number of lists in
this list.
|
int |
retainIntersection(java.util.Collection<BioMaterialList> lists)
Retain items that are present in ALL OF the given lists
in this list.
|
private int |
retainMembers(java.util.Set<BioMaterialData> items)
Keep only specified members in this list
|
int |
retainUnion(java.util.Collection<BioMaterialList> lists)
Retain items that are present in at least ONE OF the given lists
in this list.
|
void |
setExternalId(java.lang.String externalId)
Set the external id for this list.
|
private void |
setMemberType(Item memberType) |
private static java.util.Set<BioMaterialData> |
union(java.util.Collection<BioMaterialList> lists)
Create a set with the union of the items
in the given lists.
|
getAnnotationSet, getProtocol, isAnnotated, removeAnnotations, toTransferable
getDescription, getName, isRemoved, setDescription, setName, setRemoved, toTransferable
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey, toTransferable
getOwner, isOwner, setOwner, takeOwnership, toTransferable
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getVersion
checkPermission, getPermissions, hasPermission
getOwner, isOwner, setOwner, takeOwnership
public static final Item TYPE
Item.BIOMATERIALLIST
,
getType()
public static final int MAX_EXTERNAL_ID_LENGTH
setExternalId(String)
method to avoid
exceptions.BioMaterialList(BioMaterialListData listData)
public static BioMaterialList getNew(DbControl dc, Item memberType) throws BaseException
BioMaterialList
item.dc
- The DbControl
which will be used for
permission checking and database accessmemberType
- The item type of members in this listBioMaterialList
itemBaseException
- If there is an errorpublic static BioMaterialList getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
BioMaterialList
item when you know the id.dc
- The DbControl
which will be used for
permission checking and database access.id
- The id of the item to loadBioMaterialList
itemItemNotFoundException
- If an item with the specified
id is not foundPermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the itemBaseException
- If there is another errorpublic static ItemQuery<BioMaterialList> getQuery()
ItemQuery
objectprivate static java.util.Set<BioMaterialData> intersection(java.util.Collection<BioMaterialList> lists)
private static java.util.Set<BioMaterialData> union(java.util.Collection<BioMaterialList> lists)
private static java.util.Set<BioMaterialData> count(java.util.Collection<BioMaterialList> lists, int minCount, int maxCount)
NOTE!
union(Collection)
intersection(Collection)
.
lists
- The lists to look inminCount
- The minimum number of list an item
is required to be present inmaxCount
- The maximum number of lists an item
is allowed to the present inpublic java.util.Set<Annotatable> getAnnotatableParents() throws BaseException
BaseException
- If there is an errorpublic Item getType()
Identifiable
Item
enumeration.public java.lang.String getExternalId()
public void setExternalId(java.lang.String externalId) throws PermissionDeniedException, InvalidDataException
MAX_EXTERNAL_ID_LENGTH
constant. The value doesn't have to be unique.externalId
- The new external id for this itemPermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the new value is longer than
MAX_EXTERNAL_ID_LENGTH
public int getSize()
public Item getMemberType()
private void setMemberType(Item memberType)
private void checkMemberType(Item otherType)
private void checkMemberType(java.util.Collection<BioMaterialList> lists)
public boolean add(BioMaterial bioMaterial) throws PermissionDeniedException, InvalidDataException
bioMaterial
- The biomaterial to add to the listPermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the biomaterial is null or not of the
correct member typepublic int add(java.util.Iterator<? extends BioMaterial> it) throws PermissionDeniedException, InvalidDataException
it
- An iterator that returns all biomaterials to be added,
null items are ignoredPermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the iterator returns a biomaterial
of a different type than getMemberType()
public void remove(BioMaterial bioMaterial) throws PermissionDeniedException, InvalidDataException
bioMaterial
- The biomaterial to remove.PermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the biomaterial is nullpublic ItemQuery<? extends BioMaterial> getMemberBioMaterials() throws BaseException
ItemQuery
objectBaseException
- If the query could not be created and configured.public ItemQuery<? extends BioMaterial> getAllBioMaterials() throws BaseException
BioSource.getQuery()
, etc. depending on the
member type of the list.ItemQuery
objectBaseException
- If the query could not be created and configuredListUtil.getQuery(Item)
private int addMembers(java.util.Set<BioMaterialData> items)
items
- The items to addprivate int removeMembers(java.util.Set<BioMaterialData> items)
items
- The items to removeprivate int retainMembers(java.util.Set<BioMaterialData> items)
items
- The items to keeppublic int addAll(BioMaterialList list)
list
- The list to add items frompublic int addUnion(java.util.Collection<BioMaterialList> lists)
lists
- The lists to add items frompublic int addIfPresentIn(int minCount, int maxCount, java.util.Collection<BioMaterialList> lists)
addUnion(Collection)
if
minCount <= 1 && maxCount >= size(lists)
addIntersection(Collection)
if minCount = size(lists) && maxCount >= size(lists)
.
minCount > size(lists) || minCount > maxCount
no
items will be added.
lists
- The lists to add items fromminCount
- The minimum number of lists an item is required to
be present inmaxCount
- The maximum number of lists an item is allowed to
be present inpublic int addIntersection(java.util.Collection<BioMaterialList> lists)
lists
- The lists to add items frompublic int removeAll(BioMaterialList list)
list
- The list that contains the items
to removepublic int removeUnion(java.util.Collection<BioMaterialList> lists)
lists
- The lists that contains the items to removepublic int removeIfPresentIn(int minCount, int maxCount, java.util.Collection<BioMaterialList> lists)
removeUnion(Collection)
if
minCount <= 1 && maxCount >= size(lists)
removeIntersection(Collection)
if minCount = size(lists) && maxCount >= size(lists)
.
minCount > size(lists) || minCount > maxCount
no
items will be removed.
lists
- The lists with the itemsminCount
- The minimum number of lists an item is required to
be present inmaxCount
- The maximum number of lists an item is allowed to
be present inpublic int removeIntersection(java.util.Collection<BioMaterialList> lists)
lists
- The lists that contains the items to removepublic int retainAll(BioMaterialList list)
list
- The list that contains the items
to be retainedpublic int retainUnion(java.util.Collection<BioMaterialList> lists)
lists
- The lists that contains the items to retainpublic int retainIntersection(java.util.Collection<BioMaterialList> lists)
lists
- The lists that contains the items to retainpublic int retainIfPresentIn(int minCount, int maxCount, java.util.Collection<BioMaterialList> lists)
retainUnion(Collection)
if
minCount <= 1 && maxCount >= size(lists)
retainIntersection(Collection)
if minCount = size(lists) && maxCount >= size(lists)
.
minCount > size(lists) || minCount > maxCount
no
items will be removed.
lists
- The lists with the itemsminCount
- The minimum number of lists an item is required to
be present inmaxCount
- The maximum number of lists an item is allowed to
be present in