com.atlassian.jira.issue.customfields.impl
Class SelectCFType

java.lang.Object
  extended by com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType<T,T>
      extended by com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType<Option>
          extended by com.atlassian.jira.issue.customfields.impl.SelectCFType
All Implemented Interfaces:
ProjectImportableCustomField, CustomFieldType<Option,Option>, GroupSelectorField, MultipleCustomFieldType<Option,Option>, MultipleSettableCustomFieldType<Option,Option>, SortableCustomField<String>, RestAwareCustomFieldType, RestCustomFieldTypeOperations

public class SelectCFType
extends AbstractSingleFieldType<Option>
implements MultipleSettableCustomFieldType<Option,Option>, SortableCustomField<String>, GroupSelectorField, ProjectImportableCustomField, RestAwareCustomFieldType, RestCustomFieldTypeOperations

Select Custom Field Type allows selecting of a single Option. Transport Object is Option dl>

Transport Object Type
Option
Database Storage Type
String of Option ID


Nested Class Summary
static interface SelectCFType.Visitor<T>
           
 
Nested classes/interfaces inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
AbstractCustomFieldType.VisitorBase<X>
 
Field Summary
 
Fields inherited from class com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType
customFieldValuePersister, FIELD_TYPE_DATE, FIELD_TYPE_NUMBER, FIELD_TYPE_STRING, FIELD_TYPE_TEXT, genericConfigManager
 
Fields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE
 
Constructor Summary
SelectCFType(CustomFieldValuePersister customFieldValuePersister, OptionsManager optionsManager, GenericConfigManager genericConfigManager, JiraBaseUrls jiraBaseUrls)
           
SelectCFType(CustomFieldValuePersister customFieldValuePersister, StringConverter stringConverter, SelectConverter selectConverter, OptionsManager optionsManager, GenericConfigManager genericConfigManager, JiraBaseUrls jiraBaseUrls)
          Deprecated. Use SelectCFType(com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister, com.atlassian.jira.issue.customfields.manager.OptionsManager, com.atlassian.jira.issue.customfields.manager.GenericConfigManager, com.atlassian.jira.issue.fields.rest.json.beans.JiraBaseUrls) instead. Since v5.0.
 
Method Summary
 Object accept(AbstractCustomFieldType.VisitorBase visitor)
           
 int compare(String customFieldObjectValue1, String customFieldObjectValue2, FieldConfig fieldConfig)
          Compares the two custom field objects.
 String getChangelogString(CustomField field, Option value)
          Returns a String of representing values to be stored in the change log, an example is the name of a version field that a version id will resolve to within JIRA.
 List<FieldConfigItemType> getConfigurationItemTypes()
          Returns a List of FieldConfigItemType objects.
protected  PersistenceFieldType getDatabaseType()
          Type of database field needed to store this field.
protected  Object getDbValueFromObject(Option customFieldObject)
          Returns the database representation of the Java object as stored for that CustomField.
 Option getDefaultValue(FieldConfig fieldConfig)
          Retrieves the Object representing the default CustomField value for the Custom Field.
 FieldTypeInfo getFieldTypeInfo(FieldTypeInfoContext fieldTypeInfoContext)
          Returns lower level Information about the field.
 Set<Long> getIssueIdsWithValue(CustomField field, Option option)
          Returns a Set of issue ids (Long) that have the given option selected.
 JsonData getJsonDefaultValue(IssueContext issueCtx, CustomField field)
          Return The default data for this system field.
 FieldJsonRepresentation getJsonFromIssue(CustomField field, Issue issue, boolean renderedVersionRequested, FieldLayoutItem fieldLayoutItem)
          Return a JsonData representation of the field value
 JsonType getJsonSchema(CustomField customField)
          Return a description of the shape of this field when represented as JSON.
protected  Option getObjectFromDbValue(Object databaseValue)
          Returns the Transport Object for the given Custom Field value as represented by the value stored in the database
 Options getOptions(FieldConfig config, JiraContextNode jiraContextNode)
          Returns all possible Options for this field.
 ProjectCustomFieldImporter getProjectImporter()
          Returns the object that will perform the actual project import functions for the custom field type.
 org.apache.lucene.search.Query getQueryForGroup(String fieldID, String groupName)
          This method should be implemented in your custom type to return a Query.
 RestFieldOperationsHandler getRestFieldOperation(CustomField field)
          Returns the RestFieldOperationsHandler for this field.
 Option getSingularObjectFromString(String string)
          Returns a Singular Object, given the string value as passed by the presentation tier.
 String getStringFromSingularObject(Option optionObject)
          Returns the String representation of a single value within the CustomFieldType.
 Set<Long> remove(CustomField field)
          called when removing a field.
 void removeValue(CustomField field, Issue issue, Option option)
          This default implementation will remove all values from the custom field for an issue.
 void setDefaultValue(FieldConfig fieldConfig, Option option)
          Sets the default value for a Custom Field
 void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)
          Ensures that the CustomFieldParams of Strings is a valid representation of the Custom Field values.
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType
createValue, getChangelogValue, getStringValueFromCustomFieldParams, getValueFromCustomFieldParams, getValueFromIssue, updateValue
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
assertObjectImplementsType, availableForBulkEdit, getDescription, getDescriptor, getI18nBean, getKey, getName, getRelatedIndexers, getVelocityParameters, getVelocityParameters, init, isRenderable, valuesEqual
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
availableForBulkEdit, createValue, getChangelogValue, getDescription, getDescriptor, getKey, getName, getRelatedIndexers, getStringValueFromCustomFieldParams, getValueFromCustomFieldParams, getValueFromIssue, getVelocityParameters, init, isRenderable, updateValue, valuesEqual
 

Constructor Detail

SelectCFType

public SelectCFType(CustomFieldValuePersister customFieldValuePersister,
                    OptionsManager optionsManager,
                    GenericConfigManager genericConfigManager,
                    JiraBaseUrls jiraBaseUrls)

SelectCFType

@Deprecated
public SelectCFType(CustomFieldValuePersister customFieldValuePersister,
                               StringConverter stringConverter,
                               SelectConverter selectConverter,
                               OptionsManager optionsManager,
                               GenericConfigManager genericConfigManager,
                               JiraBaseUrls jiraBaseUrls)
Deprecated. Use SelectCFType(com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister, com.atlassian.jira.issue.customfields.manager.OptionsManager, com.atlassian.jira.issue.customfields.manager.GenericConfigManager, com.atlassian.jira.issue.fields.rest.json.beans.JiraBaseUrls) instead. Since v5.0.

Method Detail

remove

public Set<Long> remove(CustomField field)
Description copied from class: AbstractSingleFieldType
called when removing a field. return issue IDs affected.

Subclasses should override this if they have specific cleanup that they need to do (such as removing select list values)

Specified by:
remove in interface CustomFieldType<Option,Option>
Overrides:
remove in class AbstractSingleFieldType<Option>
Parameters:
field - The custom field that is being removed, so any data stored for any issues for that field can be deleted.
Returns:
Set of issue ids that has been affected

getDatabaseType

@NotNull
protected PersistenceFieldType getDatabaseType()
Description copied from class: AbstractSingleFieldType
Type of database field needed to store this field.

Specified by:
getDatabaseType in class AbstractSingleFieldType<Option>
Returns:
One of the predefined PersistenceFieldType types.

getDbValueFromObject

protected Object getDbValueFromObject(Option customFieldObject)
Description copied from class: AbstractSingleFieldType
Returns the database representation of the Java object as stored for that CustomField. (eg. ProjectId if the Value represents a project). Must be compatable with type returned by AbstractSingleFieldType.getDatabaseType()

Specified by:
getDbValueFromObject in class AbstractSingleFieldType<Option>
Parameters:
customFieldObject - the Transport Object
Returns:
String, Double or Date

getObjectFromDbValue

protected Option getObjectFromDbValue(@NotNull
                                      Object databaseValue)
                               throws FieldValidationException
Description copied from class: AbstractSingleFieldType
Returns the Transport Object for the given Custom Field value as represented by the value stored in the database

Specified by:
getObjectFromDbValue in class AbstractSingleFieldType<Option>
Parameters:
databaseValue - - String, Double or Date objects as returned from AbstractSingleFieldType.getDbValueFromObject(Object)
Returns:
Domain object or GenericValue
Throws:
FieldValidationException - if field validation fails.

removeValue

public void removeValue(CustomField field,
                        Issue issue,
                        Option option)
This default implementation will remove all values from the custom field for an issue. Since there can only be one value for each CustomField instance, this implementation can safely ignore the objectValue

Specified by:
removeValue in interface MultipleSettableCustomFieldType<Option,Option>
Parameters:
option - - ignored
field - being edited
issue - to remove stuff from

getSingularObjectFromString

public Option getSingularObjectFromString(String string)
                                   throws FieldValidationException
Description copied from interface: CustomFieldType
Returns a Singular Object, given the string value as passed by the presentation tier. Throws FieldValidationException if the string is an invalid representation of the Object.

Specified by:
getSingularObjectFromString in interface CustomFieldType<Option,Option>
Parameters:
string - the String
Returns:
singularObject instance
Throws:
FieldValidationException - if the string is an invalid representation of the Object.

getStringFromSingularObject

public String getStringFromSingularObject(Option optionObject)
Description copied from interface: CustomFieldType
Returns the String representation of a single value within the CustomFieldType. This is the value that is passed to the presentation tier for editing. For single CustomFieldTypes the Singular Object is the same as a Transport Object. However, for multi-dimensional CustomFieldTypes, the Singular Object is the Object contained within the Collection or Map

Specified by:
getStringFromSingularObject in interface CustomFieldType<Option,Option>
Parameters:
optionObject - the object
Returns:
String representation of the Object

getIssueIdsWithValue

public Set<Long> getIssueIdsWithValue(CustomField field,
                                      Option option)
Description copied from interface: MultipleSettableCustomFieldType
Returns a Set of issue ids (Long) that have the given option selected.

Specified by:
getIssueIdsWithValue in interface MultipleSettableCustomFieldType<Option,Option>
Parameters:
field - the CustomField to search on
option - the Object representing a single value to search on.
Returns:
Set of Longs

getConfigurationItemTypes

@NotNull
public List<FieldConfigItemType> getConfigurationItemTypes()
Description copied from interface: CustomFieldType
Returns a List of FieldConfigItemType objects. Can not be immutable. This opens up possibilties for configurable custom fields.

Specified by:
getConfigurationItemTypes in interface CustomFieldType<Option,Option>
Overrides:
getConfigurationItemTypes in class AbstractCustomFieldType<Option,Option>
Returns:
List of FieldConfigItemType

validateFromParams

public void validateFromParams(CustomFieldParams relevantParams,
                               ErrorCollection errorCollectionToAddTo,
                               FieldConfig config)
Description copied from interface: CustomFieldType
Ensures that the CustomFieldParams of Strings is a valid representation of the Custom Field values. Any errors should be added to the ErrorCollection under the appropriate key as required.

Specified by:
validateFromParams in interface CustomFieldType<Option,Option>
Overrides:
validateFromParams in class AbstractSingleFieldType<Option>
Parameters:
relevantParams - parameter object of Strings
errorCollectionToAddTo - errorCollection to which any erros should be added (never null)
config - FieldConfig

setDefaultValue

public void setDefaultValue(FieldConfig fieldConfig,
                            Option option)
Description copied from interface: CustomFieldType
Sets the default value for a Custom Field

Specified by:
setDefaultValue in interface CustomFieldType<Option,Option>
Overrides:
setDefaultValue in class AbstractSingleFieldType<Option>
Parameters:
fieldConfig - CustomField for which the default is being stored
option - Transport Object representing the value instance of the CustomField

getDefaultValue

public Option getDefaultValue(FieldConfig fieldConfig)
Description copied from interface: CustomFieldType
Retrieves the Object representing the default CustomField value for the Custom Field.

Specified by:
getDefaultValue in interface CustomFieldType<Option,Option>
Overrides:
getDefaultValue in class AbstractSingleFieldType<Option>
Parameters:
fieldConfig - CustomField for default value
Returns:
Transport Object of the Default Value

getChangelogString

public String getChangelogString(CustomField field,
                                 Option value)
Description copied from interface: CustomFieldType
Returns a String of representing values to be stored in the change log, an example is the name of a version field that a version id will resolve to within JIRA.

Specified by:
getChangelogString in interface CustomFieldType<Option,Option>
Overrides:
getChangelogString in class AbstractCustomFieldType<Option,Option>
Parameters:
field - CustomField that the value belongs to
value - Transport Object representing the value instance of the CustomField
Returns:
Change log string.

getOptions

public Options getOptions(FieldConfig config,
                          @Nullable
                          JiraContextNode jiraContextNode)
Description copied from interface: MultipleCustomFieldType
Returns all possible Options for this field.

Specified by:
getOptions in interface MultipleCustomFieldType<Option,Option>
Parameters:
config - configuration for this field
jiraContextNode - context
Returns:
all possible Options for this field.

compare

public int compare(@NotNull
                   String customFieldObjectValue1,
                   @NotNull
                   String customFieldObjectValue2,
                   FieldConfig fieldConfig)
Description copied from interface: SortableCustomField
Compares the two custom field objects.

Specified by:
compare in interface SortableCustomField<String>
Parameters:
customFieldObjectValue1 - Never null
customFieldObjectValue2 - Never null
Returns:
0, 1 or -1

getProjectImporter

public ProjectCustomFieldImporter getProjectImporter()
Description copied from interface: ProjectImportableCustomField
Returns the object that will perform the actual project import functions for the custom field type.

Specified by:
getProjectImporter in interface ProjectImportableCustomField
Returns:
the object that will perform the actual project import functions for the custom field type.

accept

public Object accept(AbstractCustomFieldType.VisitorBase visitor)
Overrides:
accept in class AbstractSingleFieldType<Option>

getQueryForGroup

public org.apache.lucene.search.Query getQueryForGroup(String fieldID,
                                                       String groupName)
Description copied from interface: GroupSelectorField
This method should be implemented in your custom type to return a Query. Generally you should return a TermQuery in the form of fieldName:groupName. However some custom fields, such as (@Link SelectCFType) manipulate the field identifiers and values before storing in the index. In cases like this you will have to implement the method such that it searches the correct fields.

Specified by:
getQueryForGroup in interface GroupSelectorField
Parameters:
fieldID - the id of the custom field
groupName - the name of the group to filter on
Returns:
the (@Link Query) to pass to the searcher

getFieldTypeInfo

public FieldTypeInfo getFieldTypeInfo(FieldTypeInfoContext fieldTypeInfoContext)
Description copied from interface: RestAwareCustomFieldType
Returns lower level Information about the field. This information contains allowed values and/or the autocomplete url

Specified by:
getFieldTypeInfo in interface RestAwareCustomFieldType
Parameters:
fieldTypeInfoContext - context information for generating the FieldTypeInfo.
Returns:
Low level information about the field.

getJsonSchema

public JsonType getJsonSchema(CustomField customField)
Description copied from interface: RestAwareCustomFieldType
Return a description of the shape of this field when represented as JSON.

Specified by:
getJsonSchema in interface RestAwareCustomFieldType

getJsonFromIssue

public FieldJsonRepresentation getJsonFromIssue(CustomField field,
                                                Issue issue,
                                                boolean renderedVersionRequested,
                                                @Nullable
                                                FieldLayoutItem fieldLayoutItem)
Description copied from interface: RestAwareCustomFieldType
Return a JsonData representation of the field value

Specified by:
getJsonFromIssue in interface RestAwareCustomFieldType
Parameters:
field - configuration of the current field
issue - to get field data from
renderedVersionRequested - whether the use requested the return of rendered/pretty data as well as raw data
fieldLayoutItem - field layout for this field.
Returns:
FieldJsonDataPair containing a json representation of the raw data for this field, and if required, a json representation of the rendered data for easy display.

getRestFieldOperation

public RestFieldOperationsHandler getRestFieldOperation(CustomField field)
Description copied from interface: RestCustomFieldTypeOperations
Returns the RestFieldOperationsHandler for this field.

Specified by:
getRestFieldOperation in interface RestCustomFieldTypeOperations
Parameters:
field - the Custom Field
Returns:
the RestFieldOperationsHandler for this field.

getJsonDefaultValue

public JsonData getJsonDefaultValue(IssueContext issueCtx,
                                    CustomField field)
Description copied from interface: RestCustomFieldTypeOperations
Return The default data for this system field. May be null if there is no default.

Specified by:
getJsonDefaultValue in interface RestCustomFieldTypeOperations
Overrides:
getJsonDefaultValue in class AbstractSingleFieldType<Option>
Parameters:
issueCtx - Issue (This should really only need to be an issue context, but for historical reasons we need an issue object.
field - the Custom Field
Returns:
The default data for this system field.


Copyright © 2002-2012 Atlassian. All Rights Reserved.