Class ReporterList

    • Field Detail

      • MAX_EXTERNAL_ID_LENGTH

        public static final int MAX_EXTERNAL_ID_LENGTH
        The maximum length of the external id variable that can be stored in the database. Check the length against this value before calling the setExternalId(String) method to avoid exceptions.
        See Also:
        Constant Field Values
    • Method Detail

      • getNew

        public static ReporterList getNew​(DbControl dc)
                                   throws BaseException
        Create a new ReporterList item.
        Parameters:
        dc - The DbControl which will be used for permission checking and database access
        Returns:
        The new Role item
        Throws:
        BaseException - If there is an error
      • intersection

        private static Set<Integer> intersection​(Collection<ReporterList> lists)
        Create a set with the intersection of the reporter ID:s in the given lists.
        Returns:
        A set with reporter ID:s. The set is always a new set, modifications to it will not affect anything else
        Since:
        2.8
      • union

        private static Set<Integer> union​(Collection<ReporterList> lists)
        Create a set with the union of the reporter ID:s in the given lists.
        Returns:
        A set with reporter ID:s. The set is always a new set, modifications to it will not affect anything else
        Since:
        2.8
      • count

        private static Set<Integer> count​(Collection<ReporterList> lists,
                                          int minCount,
                                          int maxCount)
        Count the number of times each reporter is present in the given lists and return those reporters that are found in >=minCount and <=maxCount lists.

        NOTE!

        Parameters:
        lists - The reporter lists to look in
        minCount - The minimum number of list a reporter is required to be present in
        maxCount - The maximum number of lists a reporter is allowed to the present in
        Returns:
        A set with reporter ID:s. It is always a new set, modifications to it will not affect anything else
        Since:
        2.8
      • 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.
        Specified by:
        getType in interface Identifiable
        Returns:
        A value indicating the type of item
      • getEntryDate

        public Date getEntryDate()
        Description copied from interface: Registered
        Get the date that the item was registered in the database.
        Specified by:
        getEntryDate in interface Registered
        Returns:
        A date or null if this is not known
      • setEntryDate

        public void setEntryDate​(Date entryDate)
        Description copied from interface: Registered
        Set the date the entry was registered in the database. Implementations should only allow this property to be set before the item is first stored in the database. The intention of this method is to facilitate export/import of data between server.
        Specified by:
        setEntryDate in interface Registered
        Parameters:
        entryDate - A date or null to use today's date
      • getExternalId

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

        public int getSize()
        Get the number of reporter in this reporter list.
        Since:
        2.8
      • addAll

        public int addAll​(ReporterList list)
        Add all reporters from another reporter list to this list. The new list is the union of the existing list and the added list. Scores on existing reporters are kept. Scores from new reporters are not transfered.
        Parameters:
        list - The reporter list to add reporters from
        Returns:
        The number of reporters added (not including reporters that already was in this list)
        Since:
        2.8
      • addUnion

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

        public int addIfPresentIn​(int minCount,
                                  int maxCount,
                                  Collection<ReporterList> lists)
        Add reporters 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 reporters will be added.
        Parameters:
        lists - The lists to add reporters from
        minCount - The minimum number of lists a reporter is required to be present in
        maxCount - The maximum number of lists a reporter is allowed to be present in
        Returns:
        The number of reporters added (not including reporters that already was in this list)
        Since:
        2.8
      • addIntersection

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

        private int addReporters​(Set<Integer> reporters)
        Since:
        2.8
      • removeAll

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

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

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

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

        private int removeReporters​(Set<Integer> reporters)
        Since:
        2.8
      • retainAll

        public int retainAll​(ReporterList list)
        Remove all reporters 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.
        Parameters:
        list - The reporter list that contains the reporters to be retained
        Returns:
        The number of reporters removed from this list
        Since:
        2.8
      • retainUnion

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

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

        public int retainIfPresentIn​(int minCount,
                                     int maxCount,
                                     Collection<ReporterList> lists)
        Retain reporters that are present in the specified number of lists in this list.
        Parameters:
        lists - The lists with the reporter
        minCount - The minimum number of lists a reporter is required to be present in
        maxCount - The maximum number of lists a reporter is allowed to be present in
        Returns:
        The number of reporters removed
        Since:
        2.8
      • retainReporters

        private int retainReporters​(Set<Integer> reporters)
        Since:
        2.8
      • getScore

        public Float getScore​(ReporterData reporter)
        Get the score for the specified reporter.
        Parameters:
        reporter - The reporter
        Returns:
        The score as a float value, or null if the reporter isn't found or hasn't been assigned a score