org.itracker.model
Class CustomField

java.lang.Object
  extended by org.itracker.model.AbstractEntity
      extended by org.itracker.model.CustomField
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Entity>, Entity

public class CustomField
extends AbstractEntity
implements Comparable<Entity>

A custom field that can be added to an Issue.

Allows the user to dynamically extend the set of attributes/properties of the Issue class.

A CustomField must be configured to be used in a Project in order to extend the attributes/properties of all Issues created for that project. A CustomField may be used in more than 1 project. (Project - CustomField is a M-N relathionship).

A CustomField has a type, which indicates the data type of its value.
The special type LIST, allows to associate a list of string options to a CustomField, which are the enumeration of possible values for that field.
Each option value is represented by a CustomFieldValue instance. There's a 1-N relationship between CustomField - CustomFieldValue. A CustomFieldValue can only belong to 1 CustomField (composition).

A value of a CustomField for a given Issue is represented by an IssueField instance. (CustomField - IssueField is a 1-N relationship).

Author:
ready
See Also:
CustomFieldValue, IssueField, Serialized Form

Nested Class Summary
static class CustomField.DateFormat
          Date format for fields of type DATE.
static class CustomField.NameComparator
           
static class CustomField.Type
          Enumeration of possible data types.
 
Nested classes/interfaces inherited from class org.itracker.model.AbstractEntity
AbstractEntity.CreateDateComparator, AbstractEntity.IdComparator, AbstractEntity.LastModifiedDateComparator
 
Field Summary
static SimpleDateFormat DEFAULT_DATE_FORMAT
          Dateformat able to parse datepicker generated date string (dd/MM/yyyy)
static Comparator<CustomField> NAME_COMPARATOR
           
 
Fields inherited from class org.itracker.model.AbstractEntity
CREATE_DATE_COMPARATOR, ID_COMPARATOR, LAST_MODIFIED_DATE_COMPARATOR
 
Constructor Summary
CustomField()
          Default constructor (required by Hibernate).
CustomField(String name, CustomField.Type type)
          Deprecated. 
 
Method Summary
 void addOption(String value, String label)
          Deprecated. this can not be in the entity, replace by Utility or service.
 void checkAssignable(String value, Locale locale, ResourceBundle bundle)
          Checks if the given value is assignable to this custom field.
 String getDateFormat()
           
 CustomField.Type getFieldType()
           
 String getOptionNameByValue(String optionValue)
          Deprecated. this can not be in the entity, replace by Utility or service. FIXME: Don't know, this seems not to be working. Removed use from FormatCustomFieldTag
 List<CustomFieldValue> getOptions()
           
 boolean isRequired()
           
 boolean isSortOptionsByName()
           
 void setDateFormat(String dateFormat)
           
 void setFieldType(CustomField.Type type)
           
 void setOptions(List<CustomFieldValue> options)
           
 void setRequired(boolean required)
           
 void setSortOptionsByName(boolean sortOptionsByName)
           
 String toString()
           
 
Methods inherited from class org.itracker.model.AbstractEntity
clone, compareTo, equals, getCreateDate, getId, getLastModifiedDate, hashCode, isNew, setCreateDate, setId, setLastModifiedDate
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

NAME_COMPARATOR

public static final Comparator<CustomField> NAME_COMPARATOR

DEFAULT_DATE_FORMAT

public static final SimpleDateFormat DEFAULT_DATE_FORMAT
Dateformat able to parse datepicker generated date string (dd/MM/yyyy)

Constructor Detail

CustomField

public CustomField()
Default constructor (required by Hibernate).

PENDING: should be private so that it can only be used by Hibernate, to ensure that the fields which form an instance's identity are always initialized/never null.


CustomField

@Deprecated
public CustomField(String name,
                              CustomField.Type type)
Deprecated. 

Method Detail

getFieldType

public CustomField.Type getFieldType()

setFieldType

public void setFieldType(CustomField.Type type)

getDateFormat

public String getDateFormat()

setDateFormat

public void setDateFormat(String dateFormat)

isRequired

public boolean isRequired()

setRequired

public void setRequired(boolean required)

getOptions

public List<CustomFieldValue> getOptions()

setOptions

public void setOptions(List<CustomFieldValue> options)

addOption

public void addOption(String value,
                      String label)
Deprecated. this can not be in the entity, replace by Utility or service.

Adds a new option value/name to the custom field.

New options are put at the end of the list even if they should be sorted.
This method is mainly used to build a new custom field so it can be saved later.

Parameters:
value - the option value
label - the label/name for the new option

getOptionNameByValue

public String getOptionNameByValue(String optionValue)
Deprecated. this can not be in the entity, replace by Utility or service. FIXME: Don't know, this seems not to be working. Removed use from FormatCustomFieldTag

Returns the name for a particular option value.

Parameters:
optionValue - the value to lookup the name for
Returns:
the localized name for the supplied value

isSortOptionsByName

public boolean isSortOptionsByName()

setSortOptionsByName

public void setSortOptionsByName(boolean sortOptionsByName)
Parameters:
sortOptionsByName -

toString

public String toString()
Overrides:
toString in class Object

checkAssignable

public void checkAssignable(String value,
                            Locale locale,
                            ResourceBundle bundle)
                     throws IssueException
Checks if the given value is assignable to this custom field.

Parameters:
value - custom field data
locale -
bundle -
Throws:
IssueException - if it isn't
See Also:
IssueField.setValue(String, Locale, ResourceBundle)


Copyright © 2002-2012 itracker. All Rights Reserved.