Class ItemList

    • Method Detail

      • getNew

        public static ItemList getNew​(DbControl dc,
                                      Item memberType)
                               throws BaseException
        Create a new ItemList item.
        Parameters:
        dc - The DbControl which will be used for permission checking and database access
        memberType - The item type of members in this list
        Returns:
        The new ItemList item
        Throws:
        BaseException - If there is an error
      • intersection

        private static Set<Integer> intersection​(Collection<ItemList> lists,
                                                 ItemList.DelayedAdditionManager delayed)
        Create a set with the intersection of the items in the given lists.
        Returns:
        A set with IDs of member items. The set is always a new set, modifications to it will not affect anything else
      • union

        private static Set<Integer> union​(Collection<ItemList> lists,
                                          ItemList.DelayedAdditionManager delayed)
        Create a set with the union of the items in the given lists.
        Parameters:
        delayed - A temporary delayed additions manager to be used for collecting the union of delayed additions
        Returns:
        A set with IDs of member items. The set is always a new set, modifications to it will not affect anything else
      • count

        private static Set<Integer> count​(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.

        NOTE!

        Parameters:
        lists - The lists to look in
        minCount - The minimum number of list an item is required to be present in
        maxCount - The maximum number of lists an item is allowed to the present in
        delayed - A temporary delayed additions manager to be used for collecting the union of delayed additions
        Returns:
        A set with IDs of member items. It is always a new set, modifications to it will not affect anything else
      • getAnnotatableParents

        public Set<Annotatable> getAnnotatableParents()
                                               throws BaseException
        Always returns null
        Returns:
        A set containing annotatable items, or null
        Throws:
        BaseException - If there is an error
      • getType

        public Item getType()
        Description copied from interface: Identifiable
        Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.
        Returns:
        A value indicating the type of item
      • getExternalId

        public String getExternalId()
        Get the external id for this list.
        Returns:
        A string with the external id of this item, or null
      • getSize

        public int getSize()
        Get the number of members in this list.
      • getMemberType

        public Item getMemberType()
        Get the item type of members on this list.
        Returns:
        An Item object
      • setMemberType

        private void setMemberType​(Item memberType)
      • checkMemberType

        private void checkMemberType​(Item otherType)
        Checks if the other type is the same type as the member type of this list.
      • checkMemberType

        private void checkMemberType​(Collection<ItemList> lists)
        Checks that the lists have the same member type as this list.
      • getItemSubtype

        public ItemSubtype getItemSubtype()
        Get the subtype of items that can be members in this list. This is a recommendation only and is not enforced.
        Returns:
        A subtype or null if not important
      • setItemSubtype

        public void setItemSubtype​(ItemSubtype subtype)
        Set the subtype of items that can be members in this list. The subtype must have the same member type as this list.
        Parameters:
        subtype - A subtype or null if the subtype is not important
      • getRawDataType

        public RawDataType getRawDataType()
        Get the raw data type of raw bioassays that can be members in this list. This is a recommendation only and is not enforced.
        Returns:
        A RawDataType object
      • setRawDataType

        public void setRawDataType​(RawDataType rawDataType)
        Set the raw data type of raw bioassays that can be members in this list. This is a recommendation only and is not enforced. The member type must be set to Item.RAWBIOASSAY
        Parameters:
        rawDataType - the RawDataType to use as default.
      • setDisableSyncFilters

        public void setDisableSyncFilters​(boolean disable)
        Disable or enable synchronization of members with sync filters.
      • checkSyncFiltersAllowed

        private void checkSyncFiltersAllowed()
      • getDisableManualMembers

        public boolean getDisableManualMembers()
        If this flag is set manual modification of members is disabled.
      • setDisableManualMembers

        public void setDisableManualMembers​(boolean disable)
        Disable or enable manual modification of members.
      • checkManualMembersAllowed

        private void checkManualMembersAllowed()
      • delayedAdd

        private boolean delayedAdd​(Listable item)
      • delayedRemove

        private boolean delayedRemove​(Listable item)
      • isMember

        public boolean isMember​(Listable item)
        Check if the given item is a member of this list.
        Since:
        3.15
      • addMembers

        private int addMembers​(Set<Integer> items,
                               ItemList.DelayedAdditionManager other)
        Add members to this list.
        Parameters:
        items - The items to add
        other - Delayed items to add
        Returns:
        The number of new items
      • removeMembers

        private int removeMembers​(Set<Integer> items,
                                  ItemList.DelayedAdditionManager other)
        Remove members from this list
        Parameters:
        items - The items to remove
        Returns:
        The number of removed items
      • retainMembers

        private int retainMembers​(Set<Integer> items,
                                  ItemList.DelayedAdditionManager other)
        Keep only specified members in this list
        Parameters:
        items - The items to keep
        Returns:
        The number of removed items
      • addAll

        public int addAll​(ItemList list)
        Add all items from another item list to this list. The new list is the union of the existing list and the added list. The other list must have the same member type as this list.
        Parameters:
        list - The list to add items from
        Returns:
        The number of items added (not including items that already was in this list)
      • addUnion

        public int addUnion​(Collection<ItemList> lists)
        Add items that are present in at least ONE OF the given lists to this list. Eg. the added items is the union from the given lists.
        Parameters:
        lists - The lists to add items from
        Returns:
        The number of items added (not including items that already was in this list)
      • addIfPresentIn

        public int addIfPresentIn​(int minCount,
                                  int maxCount,
                                  Collection<ItemList> lists)
        Add items that are present in the specified number of lists to this list.
        • Delegate to addUnion(Collection) if minCount <= 1 && maxCount >= size(lists)
        • Delegate to addIntersection(Collection) if minCount = size(lists) && maxCount >= size(lists).
        • If minCount > size(lists) || minCount > maxCount no items will be added.
        Parameters:
        lists - The lists to add items from
        minCount - The minimum number of lists an item is required to be present in
        maxCount - The maximum number of lists an item is allowed to be present in
        Returns:
        The number of items added (not including items that already was in this list)
      • addIntersection

        public int addIntersection​(Collection<ItemList> lists)
        Add items that are present in ALL OF the given lists to this list. Eg. the added items is the intersection from the given lists.
        Parameters:
        lists - The lists to add items from
        Returns:
        The number of items added (not including items that already was in this list)
      • removeAll

        public int removeAll​(ItemList list)
        Remove all items from this list that are present in the other list.
        Parameters:
        list - The list that contains the items to remove
        Returns:
        The number of items removed from this list
      • removeUnion

        public int removeUnion​(Collection<ItemList> lists)
        Remove items that are present in at least ONE OF the given lists from this list. Eg. the removed items is the union from the given lists.
        Parameters:
        lists - The lists that contains the items to remove
        Returns:
        The number of items removed from this list
      • removeIfPresentIn

        public int removeIfPresentIn​(int minCount,
                                     int maxCount,
                                     Collection<ItemList> lists)
        Remove items that are present in the specified number of lists from this list.
        Parameters:
        lists - The lists with the items
        minCount - The minimum number of lists an item is required to be present in
        maxCount - The maximum number of lists an item is allowed to be present in
        Returns:
        The number of items removed
      • removeIntersection

        public int removeIntersection​(Collection<ItemList> lists)
        Remove items that are present in ALL OF the given lists from this list. Eg. the removed items is the intersection from the given lists.
        Parameters:
        lists - The lists that contains the items to remove
        Returns:
        The number of items removed from this list
      • retainAll

        public int retainAll​(ItemList list)
        Remove all items from this list that are NOT present in the other list. The new list is the intersection of the existing list and the other list. NOTE! If the other list is null or empty, all items will be removed from this list.
        Parameters:
        list - The list that contains the items to be retained
        Returns:
        The number of items removed from this list
      • retainUnion

        public int retainUnion​(Collection<ItemList> lists)
        Retain items that are present in at least ONE OF the given lists in this list. Eg. items that are not found in any of the given lists are removed from this list.
        Parameters:
        lists - The lists that contains the items to retain
        Returns:
        The number of items removed from this list
      • retainIntersection

        public int retainIntersection​(Collection<ItemList> lists)
        Retain items that are present in ALL OF the given lists in this list. Eg. items that are not found in all lists of the given lists are removed from this list.
        Parameters:
        lists - The lists that contains the items to retain
        Returns:
        The number of items removed from this list
      • retainIfPresentIn

        public int retainIfPresentIn​(int minCount,
                                     int maxCount,
                                     Collection<ItemList> lists)
        Retain items that are present in the specified number of lists in this list.
        Parameters:
        lists - The lists with the items
        minCount - The minimum number of lists an item is required to be present in
        maxCount - The maximum number of lists an item is allowed to be present in
        Returns:
        The number of items removed
      • getSyncDate

        public Date getSyncDate()
        Get the last sync date+time. Note that manual changes may have been made to the list after this date.
      • hasSyncFilters

        public boolean hasSyncFilters()
        Does this item list define any sync filters?
        Since:
        3.6
      • getSyncFilters

        public ItemQuery<SyncFilter> getSyncFilters()
        Get a query returning all synchronization filters for this list
        Returns:
        An ItemQuery object
      • isInSync

        public boolean isInSync​(DbControl dc)
        Checks if all enabled sync filters appears to be in sync or not. Note that disabled filters are not checked.
        Since:
        3.6
      • copySyncFiltersAndMembers

        public void copySyncFiltersAndMembers​(DbControl dc,
                                              ItemList copyFrom)
        Copy all sync filters and list members from the given list. This is only allowed if the list to copy from is having the same member type as the current list. Existing members and sync filters in this list are removed.
      • getDependingLists

        public ItemQuery<ItemList> getDependingLists()
        Get a query that return all item lists that are used by synchronization filters in this list. Synchronization filters that are currently not enabled are ignored.
        Since:
        3.6
      • resyncFilter

        public int resyncFilter​(DbControl dc,
                                ItemList.SynchronizeOption syncOptions,
                                boolean applySubtypeFilter,
                                ProgressReporter progress)
        Re-sync with the current synchronization filter. If this list doesn't use a synchronization filter, no change is made.
        Returns:
        The number of members in the list after applying the filter