public class AnnotationType extends CommonItem implements Registered
Type
,
ie. a string, integer, etc. Limitations on the values can be specified, ie.
min and max values, max string length, etc. It is also possible
to use a predefined list of allowed values, ie an enumeration.
An annotation type also specifies which types of items it can be used on.
Annotatable
,
Annotation
Modifier and Type | Class and Description |
---|---|
(package private) static class |
AnnotationType.RemoveInheritedAnnotationsAction |
Modifier and Type | Field and Description |
---|---|
static int |
MAX_DEFAULT_VALUE_LENGTH
The maximum length of the default value.
|
static int |
MAX_EXTERNAL_ID_LENGTH
The maximum length of the external id that can be stored in the database.
|
static int |
MAX_OPTION_LENGTH
The maximum length of an option.
|
static Item |
TYPE
The type of item represented by this class.
|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
Constructor and Description |
---|
AnnotationType(AnnotationTypeData annotationTypeData) |
Modifier and Type | Method and Description |
---|---|
void |
addCategory(AnnotationTypeCategory category)
Add a category to this annotation type.
|
void |
addUsableUnit(Unit unit)
Add a unit to be used with this annotation type.
|
void |
clearUsableUnits()
Clear all units.
|
long |
countProjectSpecificAnnotations()
Count the number of project-specific annotations that exists for
this annotation type.
|
void |
disableForItem(Item itemType)
Disable this annotation type to be used for items of the specified type.
|
void |
enableForItem(Item itemType)
Enable this annotation type to be used for items of the specified type.
|
String |
findValue(String value,
boolean ignoreCase,
boolean trim)
This method should be used on enumerated string annotation types to find a
matching predefined string value, optionally ignoring case and white-space.
|
static Set<Integer> |
getAllAnnotationTypesWithInheritanceDisabled(DbControl dc)
Load the IDs of all annotation types with the disable inheritance flag set.
|
(package private) boolean |
getBooleanOption(String name,
boolean defaultValue)
Get an option and convert the value to a boolean.
|
static AnnotationType |
getById(DbControl dc,
int id)
Get an
AnnotationType item when you know the id. |
ItemQuery<AnnotationTypeCategory> |
getCategories()
Get a query that returns the categories an
annotation type belongs to.
|
(package private) AnnotationTypeData |
getData()
Get the
BasicData object that holds all data for this item. |
Unit |
getDefaultUnit()
Get the default unit for this annotation type.
|
String |
getDefaultValue()
Get the recommended default value for new annotations of this annotation type.
|
boolean |
getDisableInheritance()
If this flag is set, annotations of this type can't be inherited
to child items.
|
boolean |
getDisableLogOfValues()
If this flag is set, the change history logging will not include
actual annotation values.
|
boolean |
getDisplayAsList()
Check if the enumeration values should be displayed as a selection list
or as radio buttons/checkboxes by the client application.
|
(package private) Double |
getDoubleOption(String name,
Double defaultValue)
Get an option and convert the value to a double.
|
Set<Item> |
getEnabledItems()
Get the
Item types this annotation type is enabled for. |
Date |
getEntryDate()
Get the date that the item was registered in the database.
|
String |
getExternalId()
Get the external id of the annotation type.
|
(package private) Float |
getFloatOption(String name,
Float defaultValue)
Get an option and convert the value to a float.
|
int |
getHeight()
Get the recommended height in characters a client application should use
to render an input field for annotations of this annotation type.
|
(package private) Integer |
getIntOption(String name,
Integer defaultValue)
Get an option and convert the value to an integer.
|
(package private) Long |
getLongOption(String name,
Long defaultValue)
Get an option and convert the value to a long.
|
Integer |
getMaxLength()
Get the maximum allowed string length for a
Type.STRING annotation. |
Double |
getMaxValueDouble()
Get the maximum allowed value for a
Type.FLOAT or Type.DOUBLE annotation. |
Long |
getMaxValueLong()
|
Double |
getMinValueDouble()
Get the minumum allowed value for a
Type.FLOAT or Type.DOUBLE
annotation. |
Long |
getMinValueLong()
|
int |
getMultiplicity()
Get the multiplicity.
|
static AnnotationType |
getNew(DbControl dc,
Type valueType)
Create a new
AnnotationType item. |
String |
getOption(String name)
Get an option.
|
boolean |
getProjectAnnotations()
If this flag is set, annotation values can be set per project.
|
Quantity |
getQuantity()
Get the quantity for this annotation type.
|
static ItemQuery<AnnotationType> |
getQuery(Item itemType)
Get a
ItemQuery that returns annotation types. |
Item |
getType()
Get the type of item represented by the object.
|
ItemQuery<Unit> |
getUsableUnits()
Get a query for returning the units that are considered
"usable" for this annotation type.
|
Set<ItemProxy> |
getUsingItems()
Get all:
Annotations of this type
Experiments that are using this annotation type as an experimental factor
Protocols that are using this annotation type as a protocol parameter
|
List<?> |
getValues()
Get the list of allowed values if this annotation type is an enumeration.
|
Type |
getValueType()
Get the value type for this annotation type.
|
int |
getWidth()
Get the recommended width in characters a client application should use
to render an input field for annotations of this annotation type.
|
boolean |
isEnabledForItem(Item itemType)
Check if this annotation type can be used to annotate item of the specified type.
|
boolean |
isEnumeration()
Check if this annotation type provides a list of predefined allowed values.
|
boolean |
isMember(AnnotationTypeCategory category)
Checks if the annotation type is a member of a category.
|
boolean |
isProtocolParameter()
If this annotation type is intended to be used as a protocol parameter
or as a regular annotations.
|
boolean |
isProtocolParameter(Protocol protocol)
Check if this annotation type is a parameter to the specified protocol.
|
boolean |
isRequiredForMiame()
Check an annotation of this annotation type required for an item to
be compliant with the MIAME recommendation.
|
boolean |
isUsableUnit(Unit unit)
Checks if the given unit is a unit that has been specified as
a "usable" unit for this annotation type.
|
boolean |
isUsed()
Checks if:
Annotations of this type exists
Experiments are using this annotation type as an experimental factor
Protocols are using this annotation type as a protocol parameter
|
void |
removeCategory(AnnotationTypeCategory category)
Remove a category from this annotation type.
|
void |
removeUsableUnit(Unit unit)
Remove a unit from this annotation type.
|
void |
setDefaultUnit(Unit defaultUnit)
Set the default unit to use for this annotation type.
|
void |
setDefaultValue(String defaultValue)
Set the recommended default value for new annotation of this annotation type.
|
void |
setDisableInheritance(boolean disableInheritance)
If this flag is set, annotations of this type can't be inherited
to child items.
|
void |
setDisableLogOfValues(boolean disableLogOfValues)
If this flag is set, the change history logging will not include
actual annotation values.
|
void |
setDisplayAsList(boolean displayAsList)
Set if the enumeration values should be displayed as a selection list
or as radio buttons/checkboxes by the client application.
|
void |
setEnumeration(boolean isEnumeration)
Set if this annotation type should provide a list of predefined allowed values.
|
void |
setExternalId(String externalId)
Set the external id of the annotation type.
|
void |
setHeight(int height)
Set the recommended height in characters a client application should use
to render an input field for annotations of this annotation type.
|
void |
setItemTypes(Collection<Item> items)
Enable the annotation type for all of the specified item
and disable it for all other.
|
void |
setMaxLength(Integer maxLength)
Set the maximum allowed string length for a
Type.STRING annotation. |
void |
setMaxValueDouble(Double maxValue)
Set the maximum allowed value for a
Type.FLOAT or Type.DOUBLE annotation. |
void |
setMaxValueLong(Long maxValue)
|
void |
setMinValueDouble(Double minValue)
Set the minimum allowed value for a
Type.FLOAT or Type.DOUBLE annotation. |
void |
setMinValueLong(Long minValue)
|
void |
setMultiplicity(int multiplicity)
Set the multiplicity.
|
(package private) void |
setOption(String name,
String value)
Set an option.
|
void |
setProjectAnnotations(boolean projectAnnotations)
If this flag is set, annotation values can be set per project.
|
void |
setProtocolParameter(boolean isProtocolParameter)
Specify if this annotation type should be used as a protocol parameter
or as a regular annotation type
|
void |
setRequiredForMiame(boolean required)
Set if an annotation of this annotation type is required for an item to
be compliant with the MIAME recommendation.
|
void |
setValues(List<?> values)
Set the list of allowed values for an enumerated annotation type.
|
void |
setWidth(int width)
Set the recommended width in characters a client application should use
to render an input field for annotations of this annotation type.
|
boolean |
supportUnits()
Checks if this annotation types support units.
|
void |
validateAnnotationValue(Object value)
Validate an annotation value assuming that the value
is in the default unit.
|
Object |
validateAnnotationValue(Object value,
Unit unit)
Validate an annotation value that can be in a different unit than
the default unit.
|
getDescription, getName, getRemovedBy, isRemoved, setDescription, setName, setRemoved
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey
getOwner, isOwner, setOwner, takeOwnership
addAnnotatableParents, addUsingItems, addUsingItems, breakCircularReferences, checkBatchAnnotatableUsage, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, 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.ANNOTATIONTYPE
,
getType()
public static final int MAX_EXTERNAL_ID_LENGTH
setExternalId(String)
,
Constant Field Valuespublic static final int MAX_DEFAULT_VALUE_LENGTH
public static final int MAX_OPTION_LENGTH
AnnotationType(AnnotationTypeData annotationTypeData)
public static AnnotationType getNew(DbControl dc, Type valueType) throws BaseException
AnnotationType
item.dc
- The DbControl
which will be used for
permission checking and database accessvalueType
- The type of values to useAnnotationType
itemBaseException
- If there is an errorpublic static AnnotationType getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
AnnotationType
item when you know the id.dc
- The DbControl
which will be used for
permission checking and database accessid
- The id of the item to loadAnnotationType
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<AnnotationType> getQuery(Item itemType)
ItemQuery
that returns annotation types. If the itemType
parameter is null, annotation types for all item types will be returneditemType
- Optional, limit the annotation types to those
that are enabled for the specified itemItemQuery
objectpublic static Set<Integer> getAllAnnotationTypesWithInheritanceDisabled(DbControl dc)
AnnotationTypeData getData()
BasicItem
BasicData
object that holds all data for this item.getData
in class CommonItem
public Item getType()
Identifiable
Item
enumeration.getType
in interface Identifiable
public Date getEntryDate()
Registered
getEntryDate
in interface Registered
public boolean isUsed() throws BaseException
isUsed
in class BasicItem
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems()
getUsingItems
in class BasicItem
BasicItem.addUsingItems(Set, Item, org.hibernate.Query)
public boolean supportUnits()
public Quantity getQuantity()
setDefaultUnit(Unit)
method. Once a unit has been configured, it is not possible to change
the Quantity
.public Unit getDefaultUnit()
public void setDefaultUnit(Unit defaultUnit)
Quantity
as the existing unit.
Note! Changing units will result in a conversion of existing annotation values to the new unit. This may result in loss of precision due to rounding or truncation errors.
defaultUnit
- The new default unitpublic ItemQuery<Unit> getUsableUnits()
public boolean isUsableUnit(Unit unit)
unit
- The unit to checkpublic void addUsableUnit(Unit unit)
Quantity
) from being
used. This is just a recommendation to allow client applications
to limit the list of choices in the graphical interface.unit
- The unit to addPermissionDeniedException
- If the logged in user
doesn't have write permission for the annotation type or
use permission for the unitInvalidDataException
- If the unit is nullpublic void removeUsableUnit(Unit unit)
unit
- The unit to remove from the set of usable unitsPermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for the annotation typeInvalidDataException
- If the unit is nullpublic void clearUsableUnits()
public String getExternalId()
public void setExternalId(String externalId) throws PermissionDeniedException, InvalidDataException
MAX_EXTERNAL_ID_LENGTH
constant.externalId
- The new value for the external idPermissionDeniedException
- If the logged in user doesn't have
write permissionInvalidDataException
- If the string is too longpublic void addCategory(AnnotationTypeCategory category) throws PermissionDeniedException, InvalidDataException
category
- The category to addPermissionDeniedException
- If the logged in user doesn't have write
permission for the annotation type and use permission for the categoryInvalidDataException
- If the category is nullpublic void removeCategory(AnnotationTypeCategory category) throws PermissionDeniedException, InvalidDataException
category
- The category to removePermissionDeniedException
- If the logged in user doesn't have write permission
for the annotation typeInvalidDataException
- If the category is nullpublic boolean isMember(AnnotationTypeCategory category)
category
- The category to checkpublic ItemQuery<AnnotationTypeCategory> getCategories()
ItemQuery
objectpublic Type getValueType()
Type
constantpublic int getMultiplicity()
public void setMultiplicity(int multiplicity) throws PermissionDeniedException, InvalidDataException
multiplicity
- Multiplicity to set.PermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the multiplicity is lower than zeropublic boolean isRequiredForMiame()
public void setRequiredForMiame(boolean required) throws PermissionDeniedException
required
- Should be TRUE if required or FALSE if it is not.PermissionDeniedException
- If the logged in user doesn't
have write permissionpublic boolean isEnumeration()
public void setEnumeration(boolean isEnumeration) throws PermissionDeniedException, InvalidDataException
isEnumeration
- TRUE if this should be provided, FALSE otherwisePermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the value type doesn't support enumerations,
see Type.canEnumerate
public boolean getDisplayAsList()
public void setDisplayAsList(boolean displayAsList) throws PermissionDeniedException, InvalidDataException
displayAsList
- Set to TRUE to display as a selection list or
set to FALSE to display as radio buttons/check-boxes.PermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- Neverpublic int getHeight()
public void setHeight(int height) throws PermissionDeniedException, InvalidDataException
height
- The height in charactersPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the height is less than onepublic int getWidth()
public void setWidth(int width) throws PermissionDeniedException, InvalidDataException
width
- The width in charactersPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the width is less than onepublic String getDefaultValue()
getValueType()
setting.public void setDefaultValue(String defaultValue) throws PermissionDeniedException, InvalidDataException
getValueType()
setting.defaultValue
- The default value for new annotation.PermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the default value is longer than
MAX_DEFAULT_VALUE_LENGTH
public boolean isEnabledForItem(Item itemType)
itemType
- The Item
typepublic void enableForItem(Item itemType) throws PermissionDeniedException, InvalidDataException
itemType
- The Item
type to enable this annotation type forPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the item type is null, or
not represents an annotatable itempublic void disableForItem(Item itemType) throws PermissionDeniedException, InvalidDataException
itemType
- The Item
type to disable this annotation type forPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the item type is nullpublic Set<Item> getEnabledItems()
Item
types this annotation type is enabled for.Set
of Item
:spublic void setItemTypes(Collection<Item> items)
public boolean isProtocolParameter()
public void setProtocolParameter(boolean isProtocolParameter) throws PermissionDeniedException
isProtocolParameter
- TRUE to use the annotation type as a protocol
parameter, FALSE to use it as a regular annotation typePermissionDeniedException
- If the logged in user doesn't
have write permissionpublic boolean isProtocolParameter(Protocol protocol)
isProtocolParameter()
.protocol
- The protocol to check, null always return falseProtocol.isParameter(AnnotationType)
public boolean getDisableLogOfValues()
public void setDisableLogOfValues(boolean disableLogOfValues) throws PermissionDeniedException
PermissionDeniedException
- If the logged in user doesn't
have write permissionpublic boolean getDisableInheritance()
public void setDisableInheritance(boolean disableInheritance) throws PermissionDeniedException
PermissionDeniedException
- If the logged in user doesn't
have write permissionpublic boolean getProjectAnnotations()
SessionControl.getActiveProjectId()
controls which annotation values that are visible.public void setProjectAnnotations(boolean projectAnnotations) throws PermissionDeniedException
SessionControl.getActiveProjectId()
controls which annotation values that are visible.
Note that it is not possible to change this flag from TRUE to FALSE
if there are existing projec-specific annotations for this annotation
type.PermissionDeniedException
- If the logged in user doesn't
have write permissionpublic long countProjectSpecificAnnotations()
public Long getMinValueLong()
INT
or LONG
value typepublic void setMinValueLong(Long minValue) throws PermissionDeniedException, InvalidDataException
minValue
- The minimum allowed value or null if no limit is specifiedPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If this annotation type hasn't an INT
or
LONG
value typepublic Long getMaxValueLong()
INT
or LONG
value typepublic void setMaxValueLong(Long maxValue) throws PermissionDeniedException, InvalidDataException
maxValue
- The maximum allowed value or null if no limit is specifiedPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If this annotation type hasn't an INT
value typepublic Double getMinValueDouble()
Type.FLOAT
or Type.DOUBLE
annotation.FLOAT
or DOUBLE
value typepublic void setMinValueDouble(Double minValue) throws PermissionDeniedException, InvalidDataException
Type.FLOAT
or Type.DOUBLE
annotation.minValue
- The minimum allowed value or null if no limit is specifiedPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If this annotation type hasn't a FLOAT
or DOUBLE
value typepublic Double getMaxValueDouble()
Type.FLOAT
or Type.DOUBLE
annotation.FLOAT
or DOUBLE
value typepublic void setMaxValueDouble(Double maxValue) throws PermissionDeniedException, InvalidDataException
Type.FLOAT
or Type.DOUBLE
annotation.maxValue
- The maximum allowed value or null if no limit is specifiedPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If this annotation type hasn't a FLOAT
or DOUBLE
value typepublic Integer getMaxLength()
Type.STRING
annotation.STRING
value typepublic void setMaxLength(Integer maxLength) throws PermissionDeniedException, InvalidDataException
Type.STRING
annotation.maxLength
- The maximum allowed value or null if no limit is specifiedPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If this annotation type hasn't a STRING
value typepublic List<?> getValues() throws BaseException
List
with the allowed values or null if this annotation type
is not an enumeration or no values has been specifiedBaseException
- If there is an errorisEnumeration()
public void setValues(List<?> values) throws PermissionDeniedException, InvalidDataException
values
- The list of allowed values, or null to clear the valuesPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the list contains values of the wrong type
as checked by the Type.validate(List)
methodpublic String findValue(String value, boolean ignoreCase, boolean trim)
value
- The value to look forignoreCase
- TRUE to ignore casetrim
- TRUE to trim white-space from the start and end of stringInteger getIntOption(String name, Integer defaultValue)
Long getLongOption(String name, Long defaultValue)
Float getFloatOption(String name, Float defaultValue)
Double getDoubleOption(String name, Double defaultValue)
boolean getBooleanOption(String name, boolean defaultValue)
void setOption(String name, String value) throws InvalidDataException
InvalidDataException
public void validateAnnotationValue(Object value) throws InvalidDataException
value
- The object to be validatedInvalidDataException
- If the value object can not be used.validateAnnotationValue(Object, Unit)
,
getDefaultUnit()
public Object validateAnnotationValue(Object value, Unit unit) throws InvalidDataException
Float
if getValueType()
returns Type.FLOAT
, etc.
NOTE! If a unit is specified it is only required that the
value is a Number
. It will automatically be converted
to the correct class after unit conversion has taken place.
value
- The object to be validatedunit
- The unit if the value, this parameter is ignored if
the value type doesn't support units (eg. strings) or if the
no default unit has been set for this annotation typeInvalidDataException
- If the value object can not be used.