public class ItemList extends AnnotatedItem<ItemListData>
Listable
interface.Modifier and Type | Class and Description |
---|---|
static class |
ItemList.SynchronizeOption
Options for synchronizing an existing item list with a current settings
in an
ItemContext . |
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 |
---|
ItemList(ItemListData listData) |
Modifier and Type | Method and Description |
---|---|
int |
add(Iterator<? extends Listable> it)
Add multiple items to this list in one go.
|
boolean |
add(Listable item)
Add an item to this list.
|
int |
addAll(ItemList list)
Add all items from another item list to this
list.
|
int |
addIfPresentIn(int minCount,
int maxCount,
Collection<ItemList> lists)
Add items that are present in the specified number of lists to
this list.
|
int |
addIntersection(Collection<ItemList> lists)
Add items that are present in ALL OF the given lists to
this list.
|
private int |
addMembers(Set<Integer> items)
Add members to this list.
|
int |
addUnion(Collection<ItemList> lists)
Add items that are present in at least ONE OF the given lists to
this list.
|
private void |
checkManualMembersAllowed() |
private void |
checkMemberType(Collection<ItemList> 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 void |
checkSyncFiltersAllowed() |
void |
copySyncFiltersAndMembers(DbControl dc,
ItemList copyFrom)
Copy all sync filters and list members from the given list.
|
private static Set<Integer> |
count(Collection<ItemList> 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 Listable> |
getAllItems()
Get a query that returns all items that can possibly be
members of this list.
|
Set<Annotatable> |
getAnnotatableParents()
Always returns null
|
static ItemList |
getById(DbControl dc,
int id)
Get an
ItemList item when you know the id. |
boolean |
getDisableManualMembers()
If this flag is set manual modification of members is disabled.
|
boolean |
getDisableSyncFilters()
If this flag is set synchronization of members with sync filters is disabled.
|
String |
getExternalId()
Get the external id for this list.
|
ItemSubtype |
getItemSubtype()
Get the subtype of items that can be members in this list.
|
ItemQuery<? extends Listable> |
getMembers()
Get a query that returns all items that are members of this list.
|
Item |
getMemberType()
Get the item type of members on this list.
|
static ItemList |
getNew(DbControl dc,
Item memberType)
Create a new
ItemList item. |
static ItemQuery<ItemList> |
getQuery()
Get a query that returns item lists.
|
RawDataType |
getRawDataType()
Get the raw data type of raw bioassays that can be members in this list.
|
int |
getSize()
Get the number of members in this list.
|
Date |
getSyncDate()
Get the last sync date+time.
|
ItemQuery<SyncFilter> |
getSyncFilters()
Get a query returning all synchronization filters
for this list
|
Item |
getType()
Get the type of item represented by the object.
|
private static Set<Integer> |
intersection(Collection<ItemList> lists)
Create a set with the intersection of the items
in the given lists.
|
SyncFilter |
newSyncFilter(DbControl dc)
Creates a new sync filter for this list.
|
void |
remove(Listable item)
Remove an item from the list.
|
int |
removeAll(ItemList list)
Remove all items from this list that are present
in the other list.
|
int |
removeIfPresentIn(int minCount,
int maxCount,
Collection<ItemList> lists)
Remove items that are present in the specified number of lists from
this list.
|
int |
removeIntersection(Collection<ItemList> lists)
Remove items that are present in ALL OF the given lists from
this list.
|
private int |
removeMembers(Set<Integer> items)
Remove members from this list
|
int |
removeUnion(Collection<ItemList> lists)
Remove items that are present in at least ONE OF the given lists from
this list.
|
int |
resyncFilter(DbControl dc,
ItemList.SynchronizeOption syncOptions,
boolean applySubtypeFilter,
ProgressReporter progress)
Re-sync with the current synchronization filter.
|
int |
retainAll(ItemList list)
Remove all items from this list that are NOT present
in the other list.
|
int |
retainIfPresentIn(int minCount,
int maxCount,
Collection<ItemList> lists)
Retain items that are present in the specified number of lists in
this list.
|
int |
retainIntersection(Collection<ItemList> lists)
Retain items that are present in ALL OF the given lists
in this list.
|
private int |
retainMembers(Set<Integer> items)
Keep only specified members in this list
|
int |
retainUnion(Collection<ItemList> lists)
Retain items that are present in at least ONE OF the given lists
in this list.
|
void |
setDisableManualMembers(boolean disable)
Disable or enable manual modification of members.
|
void |
setDisableSyncFilters(boolean disable)
Disable or enable synchronization of members with sync filters.
|
void |
setExternalId(String externalId)
Set the external id for this list.
|
void |
setItemSubtype(ItemSubtype subtype)
Set the subtype of items that can be members in this list.
|
private void |
setMemberType(Item memberType) |
void |
setRawDataType(RawDataType rawDataType)
Set the raw data type of raw bioassays that can be members in this list.
|
private static Set<Integer> |
union(Collection<ItemList> lists)
Create a set with the union of the items
in the given lists.
|
getAnnotationSet, getProtocol, isAnnotated, removeAnnotations
getDescription, getName, isRemoved, setDescription, setName, setRemoved
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey
getOwner, isOwner, setOwner, takeOwnership
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getVersion
checkPermission, getPermissions, hasPermission
getOwner, isOwner, setOwner, takeOwnership
public static final Item TYPE
Item.ITEMLIST
,
getType()
public static final int MAX_EXTERNAL_ID_LENGTH
setExternalId(String)
method to avoid exceptions.ItemList(ItemListData listData)
public static ItemList getNew(DbControl dc, Item memberType) throws BaseException
ItemList
item.dc
- The DbControl
which will be used for
permission checking and database accessmemberType
- The item type of members in this listItemList
itemBaseException
- If there is an errorpublic static ItemList getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
ItemList
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 loadItemList
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<ItemList> getQuery()
ItemQuery
objectprivate static Set<Integer> intersection(Collection<ItemList> lists)
private static Set<Integer> union(Collection<ItemList> lists)
private static Set<Integer> count(Collection<ItemList> 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 Set<Annotatable> getAnnotatableParents() throws BaseException
BaseException
- If there is an errorpublic Item getType()
Identifiable
Item
enumeration.public String getExternalId()
public void setExternalId(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(Collection<ItemList> lists)
public ItemSubtype getItemSubtype()
public void setItemSubtype(ItemSubtype subtype)
subtype
- A subtype or null if the subtype is not importantpublic RawDataType getRawDataType()
RawDataType
objectpublic void setRawDataType(RawDataType rawDataType)
Item.RAWBIOASSAY
rawDataType
- the RawDataType
to use as default.public boolean getDisableSyncFilters()
resyncFilter(DbControl, SynchronizeOption, boolean, ProgressReporter)
method will throw an exception if this is set.public void setDisableSyncFilters(boolean disable)
private void checkSyncFiltersAllowed()
public boolean getDisableManualMembers()
public void setDisableManualMembers(boolean disable)
private void checkManualMembersAllowed()
public boolean add(Listable item) throws PermissionDeniedException, InvalidDataException
item
- The item to add to the listPermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the item is null or not of the
correct member typepublic int add(Iterator<? extends Listable> it) throws PermissionDeniedException, InvalidDataException
it
- An iterator that returns all items to be added,
null items are ignoredPermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the iterator returns an item
of a different type than getMemberType()
public void remove(Listable item) throws PermissionDeniedException, InvalidDataException
item
- The item to remove.PermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the item is nullpublic ItemQuery<? extends Listable> getMembers() throws BaseException
ItemQuery
objectBaseException
- If the query could not be created and configured.public ItemQuery<? extends Listable> getAllItems() throws BaseException
BioSource.getQuery()
, etc. depending on the
member type of the list.ItemQuery
objectBaseException
- If the query could not be created and configuredItem.getQuery()
private int addMembers(Set<Integer> items)
items
- The items to addprivate int removeMembers(Set<Integer> items)
items
- The items to removeprivate int retainMembers(Set<Integer> items)
items
- The items to keeppublic int addAll(ItemList list)
list
- The list to add items frompublic int addUnion(Collection<ItemList> lists)
lists
- The lists to add items frompublic int addIfPresentIn(int minCount, int maxCount, Collection<ItemList> 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(Collection<ItemList> lists)
lists
- The lists to add items frompublic int removeAll(ItemList list)
list
- The list that contains the items
to removepublic int removeUnion(Collection<ItemList> lists)
lists
- The lists that contains the items to removepublic int removeIfPresentIn(int minCount, int maxCount, Collection<ItemList> 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(Collection<ItemList> lists)
lists
- The lists that contains the items to removepublic int retainAll(ItemList list)
list
- The list that contains the items
to be retainedpublic int retainUnion(Collection<ItemList> lists)
lists
- The lists that contains the items to retainpublic int retainIntersection(Collection<ItemList> lists)
lists
- The lists that contains the items to retainpublic int retainIfPresentIn(int minCount, int maxCount, Collection<ItemList> 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 inpublic Date getSyncDate()
public ItemQuery<SyncFilter> getSyncFilters()
ItemQuery
objectpublic SyncFilter newSyncFilter(DbControl dc)
SyncFilter.SourceItemTransform.NONE
. Use SyncFilter.setSyncContext(ItemContext, SourceItemTransform)
to apply different sync filter and options.public void copySyncFiltersAndMembers(DbControl dc, ItemList copyFrom)
public int resyncFilter(DbControl dc, ItemList.SynchronizeOption syncOptions, boolean applySubtypeFilter, ProgressReporter progress)