public class ReporterList extends CommonItem<ReporterListData> implements Registered
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 |
---|
ReporterList(ReporterListData data) |
Modifier and Type | Method and 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 a
ReporterList item when you know the ID. |
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 this
ReporterList item. |
static ReporterList |
getNew(DbControl dc)
Create a new
ReporterList item. |
static ItemQuery<ReporterList> |
getQuery()
Get a new query object for this class.
|
ReporterScoreQuery |
getReporterScores()
Get a query returning
ReporterScore 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 |
setExperiment(Experiment experiment)
Set the experiment.
|
void |
setExternalId(String externalId)
Set the external id for this
ReporterList item. |
private static Set<Integer> |
union(Collection<ReporterList> lists)
Create a set with the union of the reporter ID:s
in the given lists.
|
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.REPORTERLIST
,
getType()
public static final int MAX_EXTERNAL_ID_LENGTH
setExternalId(String)
method to avoid
exceptions.ReporterList(ReporterListData data)
public static ReporterList getNew(DbControl dc) throws BaseException
ReporterList
item.dc
- The DbControl
which will be used for
permission checking and database accessRole
itemBaseException
- If there is an errorpublic static ReporterList getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
ReporterList
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 loadReporterList
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<ReporterList> getQuery()
ItemQuery
objectprivate static Set<Integer> intersection(Collection<ReporterList> lists)
private static Set<Integer> union(Collection<ReporterList> lists)
private static Set<Integer> count(Collection<ReporterList> lists, int minCount, int maxCount)
NOTE!
union(Collection)
intersection(Collection)
.
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 inpublic Item getType()
Identifiable
Item
enumeration.getType
in interface Identifiable
public Date getEntryDate()
Registered
getEntryDate
in interface Registered
public String getExternalId()
ReporterList
item.public void setExternalId(String externalId) throws PermissionDeniedException, InvalidDataException
ReporterList
item. Null is allowed, but
the value must not be longer than the value specified by
the 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 Experiment getExperiment() throws PermissionDeniedException, BaseException
Experiment
objectPermissionDeniedException
- If the logged in user doesn't have
read permission to the experimentBaseException
- If there is another errorpublic void setExperiment(Experiment experiment) throws PermissionDeniedException, InvalidDataException
experiment
- Experiment to set. Null is not allowed.PermissionDeniedException
- If logged in user doesn't have write permission on the reporter list.InvalidDataException
- If experiment is null.public int getSize()
public boolean addReporter(ReporterData reporter, Float score) throws PermissionDeniedException, InvalidDataException
reporter
- The reporter to add to the listscore
- The score for the reporter, or nullPermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the reporter is nullpublic void removeReporter(ReporterData reporter) throws PermissionDeniedException, InvalidDataException
reporter
- The reporter to remove.PermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the reporter is nullpublic int addAll(ReporterList list)
list
- The reporter list to add reporters frompublic int addUnion(Collection<ReporterList> lists)
lists
- The lists to add reporters frompublic int addIfPresentIn(int minCount, int maxCount, Collection<ReporterList> lists)
addUnion(Collection)
if
minCount <= 1 && maxCount >= size(lists)
addIntersection(Collection)
if minCount = size(lists) && maxCount >= size(lists)
.
minCount > size(lists) || minCount > maxCount
no
reporters will be added.
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 inpublic int addIntersection(Collection<ReporterList> lists)
lists
- The lists to add reporters frompublic int removeAll(ReporterList list)
list
- The reporter list that contains the reporters
to removepublic int removeUnion(Collection<ReporterList> lists)
lists
- The lists that contains the reporters to removepublic int removeIfPresentIn(int minCount, int maxCount, Collection<ReporterList> lists)
removeUnion(Collection)
if
minCount <= 1 && maxCount >= size(lists)
removeIntersection(Collection)
if minCount = size(lists) && maxCount >= size(lists)
.
minCount > size(lists) || minCount > maxCount
no
reporters will be removed.
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 inpublic int removeIntersection(Collection<ReporterList> lists)
lists
- The lists that contains the reporters to removepublic int retainAll(ReporterList list)
list
- The reporter list that contains the reporters
to be retainedpublic int retainUnion(Collection<ReporterList> lists)
lists
- The lists that contains the reporters to retainpublic int retainIntersection(Collection<ReporterList> lists)
lists
- The lists that contains the reporters to retainpublic int retainIfPresentIn(int minCount, int maxCount, Collection<ReporterList> lists)
retainUnion(Collection)
if
minCount <= 1 && maxCount >= size(lists)
retainIntersection(Collection)
if minCount = size(lists) && maxCount >= size(lists)
.
minCount > size(lists) || minCount > maxCount
no
reporters will be removed.
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 inpublic Float getScore(ReporterData reporter)
reporter
- The reporterInvalidDataException
public ReporterScoreQuery getReporterScores()
ReporterScore
objects.