Package net.sf.basedb.core
Class ReporterList
- java.lang.Object
-
- net.sf.basedb.core.BasicItem
-
- net.sf.basedb.core.OwnedItem
-
- net.sf.basedb.core.SharedItem
-
- net.sf.basedb.core.CommonItem
-
- net.sf.basedb.core.ReporterList
-
- All Implemented Interfaces:
AccessControlled
,Identifiable
,Nameable
,Ownable
,Registered
,Removable
,Shareable
public class ReporterList extends CommonItem implements Registered
- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2018-11-07 09:07:03 +0100 (on, 07 nov 2018) $
-
-
Field Summary
Fields Modifier and Type Field 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.-
Fields inherited from interface net.sf.basedb.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
-
-
Constructor Summary
Constructors Constructor Description ReporterList(ReporterListData data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addAll(ReporterList list)
Add all reporters from another reporter list to this list.int
addIfPresentIn(int minCount, int maxCount, Collection<ReporterList> lists)
Add reporters that are present in the specified number of lists to this list.int
addIntersection(Collection<ReporterList> lists)
Add reporters that are present in ALL OF the given lists to this list.boolean
addReporter(ReporterData reporter, Float score)
Add or update the score for a reporter.private int
addReporters(Set<Integer> reporters)
int
addUnion(Collection<ReporterList> lists)
Add reporters that are present in at least ONE OF the given lists to this list.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.static ReporterList
getById(DbControl dc, int id)
Get aReporterList
item when you know the ID.(package private) ReporterListData
getData()
Get theBasicData
object that holds all data for this item.Date
getEntryDate()
Get the date that the item was registered in the database.Experiment
getExperiment()
Get the experiment this reporter list belongs to.String
getExternalId()
Get the external id for thisReporterList
item.static ReporterList
getNew(DbControl dc)
Create a newReporterList
item.static ItemQuery<ReporterList>
getQuery()
Get a new query object for this class.ReporterScoreQuery
getReporterScores()
Get a query returningReporterScore
objects.Float
getScore(ReporterData reporter)
Get the score for the specified reporter.int
getSize()
Get the number of reporter in this reporter list.Item
getType()
Get the type of item represented by the object.private static Set<Integer>
intersection(Collection<ReporterList> lists)
Create a set with the intersection of the reporter ID:s in the given lists.int
removeAll(ReporterList list)
Remove all reporters from this list that are present in the other list.int
removeIfPresentIn(int minCount, int maxCount, Collection<ReporterList> lists)
Remove reporters that are present in the specified number of lists from this list.int
removeIntersection(Collection<ReporterList> lists)
Remove reporters that are present in ALL OF the given lists from this list.void
removeReporter(ReporterData reporter)
Remove a reporter from the reporter list.private int
removeReporters(Set<Integer> reporters)
int
removeUnion(Collection<ReporterList> lists)
Remove reporters that are present in at least ONE OF the given lists from this list.int
retainAll(ReporterList list)
Remove all reporters from this list that are NOT present in the other list.int
retainIfPresentIn(int minCount, int maxCount, Collection<ReporterList> lists)
Retain reporters that are present in the specified number of lists in this list.int
retainIntersection(Collection<ReporterList> lists)
Retain reporters that are present in ALL OF the given lists in this list.private int
retainReporters(Set<Integer> reporters)
int
retainUnion(Collection<ReporterList> lists)
Retain reporters that are present in at least ONE OF the given lists in this list.void
setEntryDate(Date entryDate)
Set the date the entry was registered in the database.void
setExperiment(Experiment experiment)
Set the experiment.void
setExternalId(String externalId)
Set the external id for thisReporterList
item.private static Set<Integer>
union(Collection<ReporterList> lists)
Create a set with the union of the reporter ID:s in the given lists.-
Methods inherited from class net.sf.basedb.core.CommonItem
getDescription, getName, getRemovedBy, isRemoved, setDescription, setName, setRemoved
-
Methods inherited from class net.sf.basedb.core.SharedItem
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey
-
Methods inherited from class net.sf.basedb.core.OwnedItem
getOwner, isOwner, setOwner, takeOwnership
-
Methods inherited from class net.sf.basedb.core.BasicItem
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
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.basedb.core.AccessControlled
checkPermission, getPermissions, hasPermission
-
Methods inherited from interface net.sf.basedb.core.Identifiable
getId, getVersion
-
Methods inherited from interface net.sf.basedb.core.Ownable
getOwner, isOwner, setOwner, takeOwnership
-
-
-
-
Field Detail
-
TYPE
public static final Item TYPE
The type of item represented by this class.- See Also:
Item.REPORTERLIST
,getType()
-
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 thesetExternalId(String)
method to avoid exceptions.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ReporterList
ReporterList(ReporterListData data)
-
-
Method Detail
-
getNew
public static ReporterList getNew(DbControl dc) throws BaseException
Create a newReporterList
item.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access- Returns:
- The new
Role
item - Throws:
BaseException
- If there is an error
-
getById
public static ReporterList getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
Get aReporterList
item when you know the ID.- Parameters:
dc
- TheDbControl
which will be used for permission checking and database access.id
- The ID of the item to load- Returns:
- The
ReporterList
item - Throws:
ItemNotFoundException
- If an item with the specified ID is not foundPermissionDeniedException
- If the logged in user doesn't havePermission.READ
permission to the itemBaseException
- If there is another error
-
getQuery
public static ItemQuery<ReporterList> getQuery()
Get a new query object for this class.- Returns:
- An
ItemQuery
object
-
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!
- 'minCount=1' and 'maxCount=number of lists' is the same
as
union(Collection)
- 'minCount=maxCount=number of lists' is the same
as
intersection(Collection)
.
- Parameters:
lists
- The reporter lists to look inminCount
- The minimum number of list a reporter is required to be present inmaxCount
- 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
- 'minCount=1' and 'maxCount=number of lists' is the same
as
-
getData
ReporterListData getData()
Description copied from class:BasicItem
Get theBasicData
object that holds all data for this item.- Overrides:
getData
in classCommonItem
-
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 theItem
enumeration.- Specified by:
getType
in interfaceIdentifiable
- 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 interfaceRegistered
- 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 interfaceRegistered
- Parameters:
entryDate
- A date or null to use today's date
-
getExternalId
public String getExternalId()
Get the external id for thisReporterList
item.- Returns:
- A string with the external id of this item
-
setExternalId
public void setExternalId(String externalId) throws PermissionDeniedException, InvalidDataException
Set the external id for thisReporterList
item. Null is allowed, but the value must not be longer than the value specified by theMAX_EXTERNAL_ID_LENGTH
constant. The value doesn't have to be unique.- Parameters:
externalId
- The new external id for this item- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the new value is longer thanMAX_EXTERNAL_ID_LENGTH
-
getExperiment
public Experiment getExperiment() throws PermissionDeniedException, BaseException
Get the experiment this reporter list belongs to.- Returns:
- An
Experiment
object - Throws:
PermissionDeniedException
- If the logged in user doesn't have read permission to the experimentBaseException
- If there is another error
-
setExperiment
public void setExperiment(Experiment experiment) throws PermissionDeniedException, InvalidDataException
Set the experiment.- Parameters:
experiment
- Experiment to set. Null is not allowed.- Throws:
PermissionDeniedException
- If logged in user doesn't have write permission on the reporter list.InvalidDataException
- If experiment is null.
-
getSize
public int getSize()
Get the number of reporter in this reporter list.- Since:
- 2.8
-
addReporter
public boolean addReporter(ReporterData reporter, Float score) throws PermissionDeniedException, InvalidDataException
Add or update the score for a reporter.- Parameters:
reporter
- The reporter to add to the listscore
- The score for the reporter, or null- Returns:
- TRUE if the reporter was added, FALSE if it already existed
- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the reporter is null
-
removeReporter
public void removeReporter(ReporterData reporter) throws PermissionDeniedException, InvalidDataException
Remove a reporter from the reporter list.- Parameters:
reporter
- The reporter to remove.- Throws:
PermissionDeniedException
- If the logged in user doesn't have write permissionInvalidDataException
- If the reporter is null
-
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)
ifminCount <= 1 && maxCount >= size(lists)
- Delegate to
addIntersection(Collection)
ifminCount = size(lists) && maxCount >= size(lists)
. - If
minCount > size(lists) || minCount > maxCount
no reporters will be added.
- Parameters:
lists
- The lists to add reporters fromminCount
- The minimum number of lists a reporter is required to be present inmaxCount
- 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
- Delegate to
-
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
-
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.- Delegate to
removeUnion(Collection)
ifminCount <= 1 && maxCount >= size(lists)
- Delegate to
removeIntersection(Collection)
ifminCount = size(lists) && maxCount >= size(lists)
. - If
minCount > size(lists) || minCount > maxCount
no reporters will be removed.
- Parameters:
lists
- The lists with the reportersminCount
- The minimum number of lists a reporter is required to be present inmaxCount
- The maximum number of lists a reporter is allowed to be present in- Returns:
- The number of reporters removed
- Since:
- 2.8
- Delegate to
-
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
-
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.- Delegate to
retainUnion(Collection)
ifminCount <= 1 && maxCount >= size(lists)
- Delegate to
retainIntersection(Collection)
ifminCount = size(lists) && maxCount >= size(lists)
. - If
minCount > size(lists) || minCount > maxCount
no reporters will be removed.
- Parameters:
lists
- The lists with the reporterminCount
- The minimum number of lists a reporter is required to be present inmaxCount
- The maximum number of lists a reporter is allowed to be present in- Returns:
- The number of reporters removed
- Since:
- 2.8
- Delegate to
-
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
-
getReporterScores
public ReporterScoreQuery getReporterScores()
Get a query returningReporterScore
objects.
-
-