public class ItemList extends AnnotatedItem
Listable
interface.Modifier and Type | Class and Description |
---|---|
(package private) static class |
ItemList.DelayedAdditionManager
Handles items that should be added as members to the list, but
since they were created in the same transaction doesn't have any
ID until later in the commit phase.
|
static class |
ItemList.SynchronizeOption
Options for synchronizing an existing item list with a current settings
in an
ItemContext . |
Modifier and Type | Field and Description |
---|---|
private ItemList.DelayedAdditionManager |
delayed |
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(java.util.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,
java.util.Collection<ItemList> lists)
Add items that are present in the specified number of lists to
this list.
|
int |
addIntersection(java.util.Collection<ItemList> lists)
Add items that are present in ALL OF the given lists to
this list.
|
private int |
addMembers(java.util.Set<java.lang.Integer> items,
ItemList.DelayedAdditionManager other)
Add members to this list.
|
int |
addUnion(java.util.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(java.util.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 java.util.Set<java.lang.Integer> |
count(java.util.Collection<ItemList> lists,
int minCount,
int maxCount,
ItemList.DelayedAdditionManager delayed)
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.
|
private ItemList.DelayedAdditionManager |
createDelayedAdditionManager() |
private boolean |
delayedAdd(Listable item) |
private boolean |
delayedRemove(Listable item) |
ItemQuery<? extends Listable> |
getAllItems()
Get a query that returns all items that can possibly be
members of this list.
|
java.util.Set<Annotatable> |
getAnnotatableParents()
Always returns null
|
static ItemList |
getById(DbControl dc,
int id)
Get an
ItemList item when you know the id. |
(package private) ItemListData |
getData()
Get the
BasicData object that holds all data for this item. |
ItemQuery<ItemList> |
getDependingLists()
Get a query that return all item lists that are used
by synchronization filters in this list.
|
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.
|
java.lang.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.
|
java.util.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.
|
boolean |
hasSyncFilters()
Does this item list define any sync filters?
|
private static java.util.Set<java.lang.Integer> |
intersection(java.util.Collection<ItemList> lists,
ItemList.DelayedAdditionManager delayed)
Create a set with the intersection of the items
in the given lists.
|
boolean |
isInSync(DbControl dc)
Checks if all enabled sync filters appears to be in sync or not.
|
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,
java.util.Collection<ItemList> lists)
Remove items that are present in the specified number of lists from
this list.
|
int |
removeIntersection(java.util.Collection<ItemList> lists)
Remove items that are present in ALL OF the given lists from
this list.
|
private int |
removeMembers(java.util.Set<java.lang.Integer> items,
ItemList.DelayedAdditionManager other)
Remove members from this list
|
int |
removeUnion(java.util.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,
java.util.Collection<ItemList> lists)
Retain items that are present in the specified number of lists in
this list.
|
int |
retainIntersection(java.util.Collection<ItemList> lists)
Retain items that are present in ALL OF the given lists
in this list.
|
private int |
retainMembers(java.util.Set<java.lang.Integer> items,
ItemList.DelayedAdditionManager other)
Keep only specified members in this list
|
int |
retainUnion(java.util.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(java.lang.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 java.util.Set<java.lang.Integer> |
union(java.util.Collection<ItemList> lists,
ItemList.DelayedAdditionManager delayed)
Create a set with the union of the items
in the given lists.
|
getAnnotationSet, getProtocol, isAnnotated, removeAnnotations
getDescription, getName, getRemovedBy, isRemoved, setDescription, setName, setRemoved
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey
getOwner, isOwner, setOwner, takeOwnership
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, 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.private ItemList.DelayedAdditionManager delayed
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 java.util.Set<java.lang.Integer> intersection(java.util.Collection<ItemList> lists, ItemList.DelayedAdditionManager delayed)
private static java.util.Set<java.lang.Integer> union(java.util.Collection<ItemList> lists, ItemList.DelayedAdditionManager delayed)
delayed
- A temporary delayed additions manager to be used for collecting the
union of delayed additionsprivate static java.util.Set<java.lang.Integer> count(java.util.Collection<ItemList> lists, int minCount, int maxCount, ItemList.DelayedAdditionManager delayed)
NOTE!
union(Collection, DelayedAdditionManager)
intersection(Collection, DelayedAdditionManager)
.
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 indelayed
- A temporary delayed additions manager to be used for collecting the
union of delayed additionsItemListData getData()
BasicItem
BasicData
object that holds all data for this item.getData
in class AnnotatedItem
public 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<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()
private ItemList.DelayedAdditionManager createDelayedAdditionManager()
private boolean delayedAdd(Listable item)
private boolean delayedRemove(Listable item)
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(java.util.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(java.util.Set<java.lang.Integer> items, ItemList.DelayedAdditionManager other)
items
- The items to addother
- Delayed items to addprivate int removeMembers(java.util.Set<java.lang.Integer> items, ItemList.DelayedAdditionManager other)
items
- The items to removeprivate int retainMembers(java.util.Set<java.lang.Integer> items, ItemList.DelayedAdditionManager other)
items
- The items to keeppublic int addAll(ItemList list)
list
- The list to add items frompublic int addUnion(java.util.Collection<ItemList> lists)
lists
- The lists to add items frompublic int addIfPresentIn(int minCount, int maxCount, java.util.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(java.util.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(java.util.Collection<ItemList> lists)
lists
- The lists that contains the items to removepublic int removeIfPresentIn(int minCount, int maxCount, java.util.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(java.util.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(java.util.Collection<ItemList> lists)
lists
- The lists that contains the items to retainpublic int retainIntersection(java.util.Collection<ItemList> lists)
lists
- The lists that contains the items to retainpublic int retainIfPresentIn(int minCount, int maxCount, java.util.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 java.util.Date getSyncDate()
public boolean hasSyncFilters()
public ItemQuery<SyncFilter> getSyncFilters()
ItemQuery
objectpublic boolean isInSync(DbControl dc)
public 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 ItemQuery<ItemList> getDependingLists()
public int resyncFilter(DbControl dc, ItemList.SynchronizeOption syncOptions, boolean applySubtypeFilter, ProgressReporter progress)