public class Annotation extends BasicItem
Annotatable
items. They can be very useful in the filtering and analysis
process.
An annotation must have an AnnotationType
,
which controls the type of and how many values that can be attached
to an annotation.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Annotation.QueryRuntimeFilterImpl |
static class |
Annotation.Source
The annotation source.
|
Modifier and Type | Field and Description |
---|---|
private AnnotationSet |
annotationSet |
private boolean |
disableATPermissionCheck |
static Item |
TYPE
The type of item represented by this class.
|
Constructor and Description |
---|
Annotation(AnnotationData annotationData) |
Annotation(AnnotationData annotationData,
AnnotationSet annotationSet) |
Modifier and Type | Method and Description |
---|---|
boolean |
belongsTo(AnnotationSet as)
Check if this annotation belongs to the primaray annotations for a specified annotation set.
|
(package private) void |
disableATPermissionCheck() |
AnnotationSet |
getAnnotationSet()
Get the annotation set this annotation belongs to.
|
AnnotationType |
getAnnotationType()
Get the annotation type of this annotation.
|
static Annotation |
getById(DbControl dc,
int id)
Get an
Annotation item when you know the id. |
(package private) AnnotationData |
getData()
Get the
BasicData object that holds all data for this item. |
Annotation |
getInheritedFrom()
Get the parent annotation if this is an inherited or cloned
annotation.
|
Date |
getLastUpdate()
Get the date and time the values in this annotation was last
updated.
|
(package private) static Annotation |
getNewInherited(DbControl dc,
AnnotationSet annotationSet,
AnnotationData inheritedFrom,
boolean clone)
Create a new inherited or cloned annotation.
|
(package private) static Annotation |
getNewPrimary(DbControl dc,
AnnotationSet annotationSet,
AnnotationTypeData annotationType)
Create a new primary annotation.
|
(package private) PluginPermission |
getPluginPermissions() |
(package private) static ItemQuery<Annotation> |
getQuery()
Get a query configured to retrieve annotations.
|
Annotation.Source |
getSource()
Get the annotation source.
|
Item |
getType()
Get the type of item represented by the object.
|
Unit |
getUnit()
Get the unit used for the values in this annotation.
|
UnitConverter |
getUnitConverter(Unit unit)
Get a converter for converting the values in this annotation to
a specific unit.
|
<T> Formatter<T> |
getUnitFormatter(Formatter<T> parent,
Unit unit)
Wrap a parent formatter with a formatter for units.
|
String |
getUnitSymbol(Unit unit)
Shortcut for
Unit.getDisplaySymbol() , but also
checks the default unit of the annotation type. |
List<?> |
getValues()
Get the values this annotation contains.
|
List<?> |
getValues(Unit unit)
Get the values for this annotation in a specific unit.
|
int |
getValuesVersion()
Get the version number of the item keeping the values.
|
Type |
getValueType()
Get the value type for this annotation type.
|
boolean |
hasUnit()
Checks if the values in this annotation has a unit.
|
(package private) void |
initPermissions(int granted,
int denied)
READ permission is granted if the logged in user has READ permission on
the associated item and annotation type.
|
(package private) void |
onBeforeCommit(Transactional.Action action)
Nullify links to this annotation from cloned annotations when this annotation is deleted
(since the cloned annotation should not be deleted).
|
void |
resyncCloned()
If this is a cloned annotation, resync the cloned values.
|
void |
setValue(Object value) |
void |
setValue(Object value,
Unit unit)
Set the value of the annotation, replacing any previous values.
|
void |
setValues(List<?> values) |
void |
setValues(List<?> values,
Unit unit)
Set the values of the annotation, replacing any previous values.
|
addAnnotatableParents, addUsingItems, addUsingItems, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, validate
public static final Item TYPE
Item.ANNOTATION
,
getType()
private AnnotationSet annotationSet
private boolean disableATPermissionCheck
Annotation(AnnotationData annotationData)
Annotation(AnnotationData annotationData, AnnotationSet annotationSet)
static Annotation getNewPrimary(DbControl dc, AnnotationSet annotationSet, AnnotationTypeData annotationType) throws BaseException
dc
- The DbControl objectannotationType
- The annotation type of the new annotationannotationSet
- The annotation set of the new annotationBaseException
AnnotationSet.getAnnotation(AnnotationType)
static Annotation getNewInherited(DbControl dc, AnnotationSet annotationSet, AnnotationData inheritedFrom, boolean clone) throws BaseException
dc
- The DbControl objectinheritedFrom
- The annotation to inheritannotationSet
- The annotation set of the new annotationclone
- If the annotation values should be cloned or notBaseException
AnnotationSet.getAnnotation(AnnotationType)
public static Annotation getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
Annotation
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 loadAnnotation
itemItemNotFoundException
- If an item with the specified
id is not foundPermissionDeniedException
- If the logged in user doesn't
have read permission to the itemBaseException
- If there is another errorstatic ItemQuery<Annotation> getQuery()
ItemQuery
objectAnnotationData getData()
BasicItem
BasicData
object that holds all data for this item.public Item getType()
Identifiable
Item
enumeration.void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclassBaseException
- If the permissions couldn't be initialisedvoid onBeforeCommit(Transactional.Action action) throws BaseException
onBeforeCommit
in class BasicItem
BaseException
- If there is an errorTransactional
,
Developer documentation: Transactions,
Developer documentation: Coding rules and guidelines for item classesPluginPermission getPluginPermissions()
getPluginPermissions
in class BasicItem
void disableATPermissionCheck()
public AnnotationSet getAnnotationSet() throws PermissionDeniedException, BaseException
AnnotationSet
PermissionDeniedException
- If the logged in user doesn't have
read permission for the annotation set (should never happen)BaseException
- If anything else goes wrong when getting the annotation set.public Date getLastUpdate()
public boolean belongsTo(AnnotationSet as)
as
- The annotation set to checkpublic AnnotationType getAnnotationType() throws PermissionDeniedException, BaseException
AnnotationType
PermissionDeniedException
- If the logged in user doesn't have
read permission for the annotation typeBaseException
- If anything else goes wrong when getting the annotation type.public Annotation.Source getSource()
public Annotation getInheritedFrom()
public boolean hasUnit()
public Unit getUnit()
public UnitConverter getUnitConverter(Unit unit)
unit
- The unit to convert the values to, or null
to convert the values to the unit specified by getUnit()
AnnotationType.getDefaultUnit()
public <T> Formatter<T> getUnitFormatter(Formatter<T> parent, Unit unit)
getValues(Unit)
to be correctly formatted with the
returned formatter.parent
- The parent formatter, which should be of the
correct type for the annotation valuesunit
- The unit to use for formatting, or null to
use the annotation's unitpublic String getUnitSymbol(Unit unit)
Unit.getDisplaySymbol()
, but also
checks the default unit of the annotation type.unit
- The unit to get the symbol for, or null to use
the annotation's unitpublic Type getValueType()
public List<?> getValues() throws BaseException
Type
appropriate for the given annotation type, ie. Integer object
for an integer annotation type. All objects in the list are of the same type.
If this is an annotation with units, the values are returned in the unit
of the annotation type (AnnotationType.getDefaultUnit()
). Use
getValues(Unit)
to get the values in a different unit, including the
specific unit used on this annotation.BaseException
- If there is an errorAnnotationType.getValueType()
public List<?> getValues(Unit unit) throws BaseException
Type
appropriate for the given annotation type, ie. Integer object
for an integer annotation type. All objects in the list are of the same type.unit
- The unit to convert the values to, or null to get the values
in the unit used on this annotationBaseException
- If there is an errorAnnotationType.getValueType()
public int getValuesVersion()
public void setValue(Object value) throws PermissionDeniedException, InvalidDataException, BaseException
public void setValue(Object value, Unit unit) throws PermissionDeniedException, InvalidDataException, BaseException
value
- The new valueunit
- The unit of the value, or null to use the default unit of
the annotation typePermissionDeniedException
- If the logged in user doesn't have
write permission for the annotation or read permission for the annotation
typeInvalidDataException
- If the value isn't a valid value for the
annotation type, see AnnotationType.validateAnnotationValue(Object)
BaseException
- If there is another errorpublic void setValues(List<?> values) throws PermissionDeniedException, InvalidDataException, BaseException
public void setValues(List<?> values, Unit unit) throws PermissionDeniedException, InvalidDataException, BaseException
values
- A list containing the new valuesunit
- The unit of the value, or null to use the default unit of
the annotation typePermissionDeniedException
- If the logged in user doesn't have
write permission for the annotation or read permission for the annotation
typeInvalidDataException
- If the number of values are too many according
to the AnnotationType.getMultiplicity()
setting any of the values
isn't a valid value for the annotation type, see
AnnotationType.validateAnnotationValue(Object)
BaseException
- If there is another errorpublic void resyncCloned()