|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.core.BasicItem<D> net.sf.basedb.core.OwnedItem<D> net.sf.basedb.core.SharedItem<D> net.sf.basedb.core.CommonItem<AnnotationTypeData> net.sf.basedb.core.AnnotationType
public class AnnotationType
Objects of this class defines an annotation type. An
annotation type is always of a specific 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
Field Summary | |
---|---|
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. |
Fields inherited from interface net.sf.basedb.core.Nameable |
---|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH |
Constructor Summary | |
---|---|
AnnotationType(AnnotationTypeData annotationTypeData)
|
Method Summary | |
---|---|
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. |
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. |
(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. |
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 |
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()
Get the maximum allowed value for an Type.INT or Type.LONG annotation. |
Double |
getMinValueDouble()
Get the minumum allowed value for a Type.FLOAT or Type.DOUBLE
annotation. |
Long |
getMinValueLong()
Get the minumum allowed value for an Type.INT or Type.LONG
annotation. |
int |
getMultiplicity()
Get the multiplicity. |
static AnnotationType |
getNew(DbControl dc,
Type valueType)
Create a new AnnotationType item. |
(package private) String |
getOption(String name)
Get an option. |
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 |
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 |
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)
Set the maximum allowed value for an Type.INT or Type.LONG annotation. |
void |
setMinValueDouble(Double minValue)
Set the minimum allowed value for a Type.FLOAT or Type.DOUBLE annotation. |
void |
setMinValueLong(Long minValue)
Set the minimum allowed value for an Type.INT or Type.LONG annotation. |
void |
setMultiplicity(int multiplicity)
Set the multiplicity. |
(package private) void |
setOption(String name,
String value)
Set an option. |
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. |
AnnotationTypeInfo |
toTransferable(AnnotationTypeInfo info)
Transfer the internal state to a transferable object. |
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. |
Methods inherited from class net.sf.basedb.core.CommonItem |
---|
getDescription, getName, isRemoved, setDescription, setName, setRemoved, toTransferable |
Methods inherited from class net.sf.basedb.core.SharedItem |
---|
getItemKey, getProjectKey, initPermissions, isShared, onBeforeCommit, setItemKey, setProjectKey, toTransferable |
Methods inherited from class net.sf.basedb.core.OwnedItem |
---|
getOwner, isOwner, setOwner, takeOwnership, toTransferable |
Methods inherited from class net.sf.basedb.core.BasicItem |
---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.basedb.core.Identifiable |
---|
getId, getVersion |
Methods inherited from interface net.sf.basedb.core.AccessControlled |
---|
checkPermission, getPermissions, hasPermission |
Methods inherited from interface net.sf.basedb.core.Ownable |
---|
getOwner, isOwner, setOwner, takeOwnership |
Field Detail |
---|
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
Constructor Detail |
---|
AnnotationType(AnnotationTypeData annotationTypeData)
Method Detail |
---|
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 use
AnnotationType
item
BaseException
- 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 load
AnnotationType
item
ItemNotFoundException
- If an item with the specified
id is not found
PermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the item
BaseException
- 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 returned
itemType
- Optional, limit the annotation types to those
that are enabled for the specified item
ItemQuery
objectpublic 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<AnnotationTypeData>
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems()
getUsingItems
in class BasicItem<AnnotationTypeData>
BasicItem.addUsingItems(Set, Item, org.hibernate.Query)
public AnnotationTypeInfo toTransferable(AnnotationTypeInfo info)
ToTransferable
toTransferable
in interface ToTransferable<AnnotationTypeInfo>
info
- The transferable object to use
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 check
public 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 add
PermissionDeniedException
- If the logged in user
doesn't have write permission for the annotation type or
use permission for the unit
InvalidDataException
- If the unit is nullpublic void removeUsableUnit(Unit unit)
unit
- The unit to remove from the set of usable units
PermissionDeniedException
- If the
logged in user doesn't have Permission.WRITE
permission for the annotation type
InvalidDataException
- 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 id
PermissionDeniedException
- If the logged in user doesn't have
write permission
InvalidDataException
- If the string is too longpublic void addCategory(AnnotationTypeCategory category) throws PermissionDeniedException, InvalidDataException
category
- The category to add
PermissionDeniedException
- If the logged in user doesn't have write
permission for the annotation type and use permission for the category
InvalidDataException
- If the category is nullpublic void removeCategory(AnnotationTypeCategory category) throws PermissionDeniedException, InvalidDataException
category
- The category to remove
PermissionDeniedException
- If the logged in user doesn't have write permission
for the annotation type
InvalidDataException
- If the category is nullpublic boolean isMember(AnnotationTypeCategory category)
category
- The category to check
public ItemQuery<AnnotationTypeCategory> getCategories()
ItemQuery object
public 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 permission
InvalidDataException
- 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 otherwise
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- 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 permission
InvalidDataException
- Neverpublic int getHeight()
public void setHeight(int height) throws PermissionDeniedException, InvalidDataException
height
- The height in characters
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the height is less than onepublic int getWidth()
public void setWidth(int width) throws PermissionDeniedException, InvalidDataException
width
- The width in characters
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- 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 permission
InvalidDataException
- If the default value is longer than
MAX_DEFAULT_VALUE_LENGTH
public boolean isEnabledForItem(Item itemType)
itemType
- The Item
type
public void enableForItem(Item itemType) throws PermissionDeniedException, InvalidDataException
itemType
- The Item
type to enable this annotation type for
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- 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 for
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If the item type is nullpublic Set<Item> getEnabledItems()
Item
types this annotation type is enabled for.
Set
of Item
:spublic 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 type
PermissionDeniedException
- If the logged in user doesn't
have write permissionpublic boolean isProtocolParameter(Protocol protocol)
isProtocolParameter()
.
protocol
- The protocol to check, null always return false
Protocol.isParameter(AnnotationType)
public Long getMinValueLong()
Type.INT
or Type.LONG
annotation.
INT
or LONG
value typepublic void setMinValueLong(Long minValue) throws PermissionDeniedException, InvalidDataException
Type.INT
or Type.LONG
annotation.
minValue
- The minimum allowed value or null if no limit is specified
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- If this annotation type hasn't an INT
or
LONG
value typepublic Long getMaxValueLong()
Type.INT
or Type.LONG
annotation.
INT
or LONG
value typepublic void setMaxValueLong(Long maxValue) throws PermissionDeniedException, InvalidDataException
Type.INT
or Type.LONG
annotation.
maxValue
- The maximum allowed value or null if no limit is specified
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- 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 specified
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- 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 specified
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- 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 specified
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- 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 specified
BaseException
- If there is an errorisEnumeration()
public void setValues(List<?> values) throws PermissionDeniedException, InvalidDataException
values
- The list of allowed values, or null to clear the values
PermissionDeniedException
- If the logged in user doesn't
have write permission
InvalidDataException
- 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 string
String getOption(String name)
Integer 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 validated
InvalidDataException
- 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 type
InvalidDataException
- If the value object can not be used.
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |