Last update: 2011-06-23

org.proteios.core
Class AnnotationType

java.lang.Object
  extended by org.proteios.core.BasicItem<D>
      extended by org.proteios.core.OwnedItem<D>
          extended by org.proteios.core.SharedItem<D>
              extended by org.proteios.core.CommonItem<AnnotationTypeData>
                  extended by org.proteios.core.AnnotationType
All Implemented Interfaces:
AccessControlled, Identifiable, Nameable, Ownable, Removable, Shareable

public class AnnotationType
extends CommonItem<AnnotationTypeData>

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.

Version:
2.0
Author:
Nicklas
See Also:
Annotatable, Annotation
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Field Summary
static int MAX_ADDEDPARAMETERNAME_LENGTH
          The maximum length of the addedParameterName value.
static int MAX_ADDEDPARAMETERTYPE_LENGTH
          The maximum length of the addedParameterType value.
static int MAX_ADDEDPARAMETERVALUE_LENGTH
          The maximum length of the addedParameterValue value.
static int MAX_DEFAULT_VALUE_LENGTH
          The maximum length of the default value.
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 org.proteios.core.Nameable
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
 
Method Summary
 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 getAddedParameterName()
          Get the addedParameterName value.
 String getAddedParameterType()
          Get the addedParameterType value.
 String getAddedParameterValue()
          Get the addedParameterValue value.
 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.
 Set<Item> getEnabledItems()
          Get the Item types this annotation type is enabled for.
 int getHeight()
          Get the recommended height in characters a client application should use to render an input field for annotations of this annotation type.
 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 ItemQuery<AnnotationType> getQuery(Item itemType)
          Get a ItemQuery that returns annotation types.
 Item getType()
          Get the type of item represented by the object.
 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 isAddedParameterType(String argType)
          Check if the AddedParameterType is of a specific 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 isRequiredForMiame()
          Check an annotation of this annotation type required for an item to be compliant with the MIAME recommendation.
 boolean isUsed()
          Checks if: Annotations of this type exists
 void setAddedParameterName(String addedParameterName)
          Set the addedParameterName value for new annotation of this annotation type.
 void setAddedParameterType(String addedParameterType)
          Set the addedParameterTypevalue for new annotation of this annotation type.
 void setAddedParameterValue(String addedParameterValue)
          Set the addedParameterValue value for new annotation of 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 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.
 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 setValueType(Type 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.
 void validateAnnotationValue(Object value)
          Validate an annotation value.
 
Methods inherited from class org.proteios.core.CommonItem
getDescription, getName, isRemoved, setDescription, setName, setRemoved
 
Methods inherited from class org.proteios.core.SharedItem
getItemKey, getProjectKey, isShared, setItemKey, setProjectKey
 
Methods inherited from class org.proteios.core.OwnedItem
getOwner, setOwner
 
Methods inherited from class org.proteios.core.BasicItem
checkPermission, equals, getDbControl, getId, getPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.proteios.core.Identifiable
getId, getVersion
 
Methods inherited from interface org.proteios.core.AccessControlled
checkPermission, hasPermission
 
Methods inherited from interface org.proteios.core.Ownable
getOwner, setOwner
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.ANNOTATIONTYPE, getType()

MAX_DEFAULT_VALUE_LENGTH

public static final int MAX_DEFAULT_VALUE_LENGTH
The maximum length of the default value.

See Also:
Constant Field Values

MAX_OPTION_LENGTH

public static final int MAX_OPTION_LENGTH
The maximum length of an option.

See Also:
Constant Field Values

MAX_ADDEDPARAMETERTYPE_LENGTH

public static final int MAX_ADDEDPARAMETERTYPE_LENGTH
The maximum length of the addedParameterType value.

See Also:
Constant Field Values

MAX_ADDEDPARAMETERNAME_LENGTH

public static final int MAX_ADDEDPARAMETERNAME_LENGTH
The maximum length of the addedParameterName value.

See Also:
Constant Field Values

MAX_ADDEDPARAMETERVALUE_LENGTH

public static final int MAX_ADDEDPARAMETERVALUE_LENGTH
The maximum length of the addedParameterValue value.

See Also:
Constant Field Values
Method Detail

getQuery

public static ItemQuery<AnnotationType> getQuery(Item itemType)
Get a ItemQuery that returns annotation types. If the itemType parameter is null, annotation types for all item types will be returned

Parameters:
itemType - Optional, limit the annotation types to those that are enabled for the specified item
Returns:
An ItemQuery object

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 the Item enumeration.

Returns:
A value indicating the type of item

isUsed

public boolean isUsed()
               throws BaseException
Checks if:

Specified by:
isUsed in class BasicItem<AnnotationTypeData>
Returns:
TRUE if this item is used, FALSE otherwise
Throws:
BaseException

getValueType

public Type getValueType()
Get the value type for this annotation type. It can't be change once the object has been created.


getMultiplicity

public int getMultiplicity()
Get the multiplicity. The multiplicity tells the core how many valus an annotation of this annotation type may contain. The default is one. Zero denotes unlimited values.


setMultiplicity

public void setMultiplicity(int multiplicity)
                     throws PermissionDeniedException,
                            InvalidDataException
Set the multiplicity. The multiplicity tells the core how many valus an annotation of this annotation type may contain. The default is one. Zero denotes unlimited values.

Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the multiplicit is lower than zero

isRequiredForMiame

public boolean isRequiredForMiame()
Check an annotation of this annotation type required for an item to be compliant with the MIAME recommendation.

See Also:
MIAME

setRequiredForMiame

public void setRequiredForMiame(boolean required)
                         throws PermissionDeniedException
Set if an annotation of this annotation type is required for an item to be compliant with the MIAME recommendation.

Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
See Also:
MIAME

isEnumeration

public boolean isEnumeration()
Check if this annotation type provides a list of predefined allowed values.


setEnumeration

public void setEnumeration(boolean isEnumeration)
                    throws PermissionDeniedException,
                           InvalidDataException
Set if this annotation type should provide a list of predefined allowed values.

Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the value type doesn't support enumerations, see Type.canEnumerate

getDisplayAsList

public boolean getDisplayAsList()
Check if the enumeration values should be displayed as a selection list or as radio buttons/checkboxes by the client application. The client application may decide to use some other display format that better suits the situation.


setDisplayAsList

public void setDisplayAsList(boolean displayAsList)
                      throws PermissionDeniedException,
                             InvalidDataException
Set if the enumeration values should be displayed as a selection list or as radio buttons/checkboxes by the client application. The client application may decide to use some other display format that better suits the situation.

Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - Never

getHeight

public int getHeight()
Get the recommended height in characters a client application should use to render an input field for annotations of this annotation type. A client application is not required to use this value if it is not appropriate for the situation.


setHeight

public void setHeight(int height)
               throws PermissionDeniedException,
                      InvalidDataException
Set the recommended height in characters a client application should use to render an input field for annotations of this annotation type. A client application is not required to use this value if it is not appropriate for the situation.

Parameters:
height - The height in characters
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the height is less than one

getWidth

public int getWidth()
Get the recommended width in characters a client application should use to render an input field for annotations of this annotation type. A client application is not required to use this value if it is not appropriate for the situation.


setWidth

public void setWidth(int width)
              throws PermissionDeniedException,
                     InvalidDataException
Set the recommended width in characters a client application should use to render an input field for annotations of this annotation type. A client application is not required to use this value if it is not appropriate for the situation.

Parameters:
width - The width in characters
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the width is less than one

getDefaultValue

public String getDefaultValue()
Get the recommended default value for new annotations of this annotation type. It is not certain that the string represents a value that can be converted to the correct value type as specified by the getValueType() setting.


setDefaultValue

public void setDefaultValue(String defaultValue)
                     throws PermissionDeniedException,
                            InvalidDataException
Set the recommended default value for new annotation of this annotation type. It is not checked that the string can be converted to the correct value type as specified by the getValueType() setting.

Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the default value is longer than MAX_DEFAULT_VALUE_LENGTH

isEnabledForItem

public boolean isEnabledForItem(Item itemType)
Check if this annotation type can be used to annotate item of the specified type.

Parameters:
itemType - The Item type
Returns:
TRUE if annotations are possible, FALSE otherwise

enableForItem

public void enableForItem(Item itemType)
                   throws PermissionDeniedException,
                          InvalidDataException
Enable this annotation type to be used for items of the specified type.

Parameters:
itemType - The Item type to enable this annotation type for
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the item type is null, or not represents an annotatable item

disableForItem

public void disableForItem(Item itemType)
                    throws PermissionDeniedException,
                           InvalidDataException
Disable this annotation type to be used for items of the specified type.

Parameters:
itemType - The Item type to disable this annotation type for
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the item type is null

getEnabledItems

public Set<Item> getEnabledItems()
Get the Item types this annotation type is enabled for.

Returns:
A Set of Item:s

getMinValueLong

public Long getMinValueLong()
Get the minumum allowed value for an Type.INT or Type.LONG annotation.

Returns:
The minimum allowed value or null if none has been specfied or if this annotation type hasn't an INT or LONG value type

setMinValueLong

public void setMinValueLong(Long minValue)
                     throws PermissionDeniedException,
                            InvalidDataException
Set the minimum allowed value for an Type.INT or Type.LONG annotation.

Parameters:
minValue - The minimum allowed value or null if no limit is specified
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If this annotation type hasn't an INT or LONG value type

getMaxValueLong

public Long getMaxValueLong()
Get the maximum allowed value for an Type.INT or Type.LONG annotation.

Returns:
The maximum allowed value or null if none has been specfied or if this annotation type hasn't an INT or LONG value type

setMaxValueLong

public void setMaxValueLong(Long maxValue)
                     throws PermissionDeniedException,
                            InvalidDataException
Set the maximum allowed value for an Type.INT or Type.LONG annotation.

Parameters:
maxValue - The maximum allowed value or null if no limit is specified
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If this annotation type hasn't an INT value type

getMinValueDouble

public Double getMinValueDouble()
Get the minumum allowed value for a Type.FLOAT or Type.DOUBLE annotation.

Returns:
The minimum allowed value or null if none has been specfied or if this annotation type hasn't a FLOAT or DOUBLE value type

setMinValueDouble

public void setMinValueDouble(Double minValue)
                       throws PermissionDeniedException,
                              InvalidDataException
Set the minimum allowed value for a Type.FLOAT or Type.DOUBLE annotation.

Parameters:
minValue - The minimum allowed value or null if no limit is specified
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If this annotation type hasn't a FLOAT or DOUBLE value type

getMaxValueDouble

public Double getMaxValueDouble()
Get the maximum allowed value for a Type.FLOAT or Type.DOUBLE annotation.

Returns:
The maximum allowed value or null if none has been specfied or if this annotation type hasn't a FLOAT or DOUBLE value type

setMaxValueDouble

public void setMaxValueDouble(Double maxValue)
                       throws PermissionDeniedException,
                              InvalidDataException
Set the maximum allowed value for a Type.FLOAT or Type.DOUBLE annotation.

Parameters:
maxValue - The maximum allowed value or null if no limit is specified
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If this annotation type hasn't a FLOAT or DOUBLE value type

getMaxLength

public Integer getMaxLength()
Get the maximum allowed string length for a Type.STRING annotation.

Returns:
The maximum allowed string length or null if none has been specfied or if this annotation type hasn't an STRING value type

setMaxLength

public void setMaxLength(Integer maxLength)
                  throws PermissionDeniedException,
                         InvalidDataException
Set the maximum allowed string length for a Type.STRING annotation.

Parameters:
maxLength - The maximum allowed value or null if no limit is specified
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If this annotation type hasn't a STRING value type

getValues

public List<?> getValues()
                  throws BaseException
Get the list of allowed values if this annotation type is an enumeration.

Returns:
A List with the allowed values or null if this annotation type is not an enumeration or no values has been specified
Throws:
BaseException - If there is an error
See Also:
isEnumeration()

setValues

public void setValues(List<?> values)
               throws PermissionDeniedException,
                      InvalidDataException
Set the list of allowed values for an enumerated annotation type.

Parameters:
values - The list of allowed values, or null to clear the values
Throws:
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) method

validateAnnotationValue

public void validateAnnotationValue(Object value)
                             throws InvalidDataException
Validate an annotation value. We check the following:

Throws:
InvalidDataException

getAddedParameterType

public String getAddedParameterType()
Get the addedParameterType value. An added parameter is a triplet of String Type, Name, and Value, representing a specific parameter. An example is a cvParam XML block, that contains String data for cvLabel, accession, name, and value. The name will be stored as the name of the annotationType and the value as the annotation value. The annotation is marked as being a cvParam annotation by having the following additional parameters set to non-null: addedParameterType = "cvParam" addedParameterName = cvLabel (the value from the cvParam XML tag) addedParameterValue = accession (the value from the cvParam XML tag)

Returns:
addedParameterType String the addedParameterType value.

setAddedParameterType

public void setAddedParameterType(String addedParameterType)
                           throws PermissionDeniedException,
                                  InvalidDataException
Set the addedParameterTypevalue for new annotation of this annotation type.

Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the addedParameterType value is longer than MAX_ADDEDPARAMETERTYPE_LENGTH

getAddedParameterName

public String getAddedParameterName()
Get the addedParameterName value.

Returns:
addedParameterName String the addedParameterName value.

setAddedParameterName

public void setAddedParameterName(String addedParameterName)
                           throws PermissionDeniedException,
                                  InvalidDataException
Set the addedParameterName value for new annotation of this annotation type.

Parameters:
addedParameterName - String the addedParameterName to set.
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the addedParameterName value is longer than MAX_ADDEDPARAMETERNAME_LENGTH

getAddedParameterValue

public String getAddedParameterValue()
Get the addedParameterValue value.

Returns:
addedParameterValue String the addedParameterValue value.

setAddedParameterValue

public void setAddedParameterValue(String addedParameterValue)
                            throws PermissionDeniedException,
                                   InvalidDataException
Set the addedParameterValue value for new annotation of this annotation type.

Parameters:
addedParameterValue - String the addedParameterValue to set.
Throws:
PermissionDeniedException - If the logged in user doesn't have write permission
InvalidDataException - If the addedParameterValue value is longer than MAX_ADDEDPARAMETERVALUE_LENGTH

isAddedParameterType

public boolean isAddedParameterType(String argType)
Check if the AddedParameterType is of a specific type.

Parameters:
argType - String the AddedParameterType to check for.
Returns:
boolean True if addedParameterType equals non-null argType, else false.

setValueType

public void setValueType(Type type)

Last update: 2011-06-23