java.lang.Object
   ↳ com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType<T, S>
     ↳ com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType<S>
       ↳ com.atlassian.jira.issue.customfields.impl.MultiSelectCFType

Class Overview

Multiple Select Type allows selecting of multiple Options

Transport Object Type
Collection
Singular Object Type
Option
Database Storage Type
String of option id

Summary

Nested Classes
interface MultiSelectCFType.InputTextProvider Support interface to delay the data input text evaluation to vm-processing time. 
interface MultiSelectCFType.Visitor<T>  
Constants
String COMMA_REPLACEMENT
[Expand]
Inherited Constants
From interface com.atlassian.jira.issue.customfields.CustomFieldType
[Expand]
Inherited Fields
From class com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType
Public Constructors
MultiSelectCFType(OptionsManager optionsManager, CustomFieldValuePersister valuePersister, GenericConfigManager genericConfigManager, JiraBaseUrls jiraBaseUrls, SearchService searchService, FeatureManager featureManager)
Public Methods
Object accept(VisitorBase visitor)
int compare(List<String> customFieldObjectValue1, List<String> customFieldObjectValue2, FieldConfig fieldConfig)
static Collection<String> extractTransferObjectFromString(String value)
Parses the given comma-separated String value into a Collection.
String getChangelogString(CustomField field, Collection<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.
@Nonnull List<FieldConfigItemType> getConfigurationItemTypes()
Returns a List of FieldConfigItemType objects.
Collection<Option> getDefaultValue(FieldConfig fieldConfig)
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.
Options getOptions(FieldConfig fieldConfig, 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.
Query getQueryForGroup(String fieldName, 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)
static String getStringFromTransferObject(Collection<String> collection)
Takes a Collection of values and creates a comma-separated String that represents this Collection.
Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
Return the String value object from the CustomFieldParams.
Collection<Option> getValueFromCustomFieldParams(CustomFieldParams parameters)
Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.
@Nonnull Map<StringObject> getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)
The custom field may wish to pass parameters to the velocity context beyond the getValueFromIssue methods (eg managers).
Set<Long> remove(CustomField field)
called when removing a field.
void removeValue(CustomField field, Issue issue, Option option)
Perform any actions required if the option selected by the issue is removed.
void setDefaultValue(FieldConfig fieldConfig, Collection<Option> value)
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.
boolean valuesEqual(Collection<Option> v1, Collection<Option> v2)
Used to compare 2 field values and work out whether a change item should be generated
Protected Methods
Option convertDbValueToType(Object dbValue)
Converts a given db value to Single form of Transport Object
Object convertTypeToDbValue(Option value)
Converts a given underlying type to its db storage value.
@Nonnull PersistenceFieldType getDatabaseType()
Type of database field needed to store this field.
Comparator<Option> getTypeComparator()
Returns a comparator for underlying type of this custom field.
[Expand]
Inherited Methods
From class com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType
From class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
From class java.lang.Object
From interface com.atlassian.jira.imports.project.customfield.ProjectImportableCustomField
From interface com.atlassian.jira.issue.customfields.CustomFieldType
From interface com.atlassian.jira.issue.customfields.GroupSelectorField
From interface com.atlassian.jira.issue.customfields.MultipleCustomFieldType
From interface com.atlassian.jira.issue.customfields.MultipleSettableCustomFieldType
From interface com.atlassian.jira.issue.customfields.SortableCustomField
From interface com.atlassian.jira.issue.fields.rest.RestAwareCustomFieldType
From interface com.atlassian.jira.issue.fields.rest.RestCustomFieldTypeOperations

Constants

public static final String COMMA_REPLACEMENT

Constant Value: ","

Public Constructors

public MultiSelectCFType (OptionsManager optionsManager, CustomFieldValuePersister valuePersister, GenericConfigManager genericConfigManager, JiraBaseUrls jiraBaseUrls, SearchService searchService, FeatureManager featureManager)

Public Methods

public Object accept (VisitorBase visitor)

public int compare (List<String> customFieldObjectValue1, List<String> customFieldObjectValue2, FieldConfig fieldConfig)

public static Collection<String> extractTransferObjectFromString (String value)

Parses the given comma-separated String value into a Collection. Whitespace is trimmed and blank fields are discarded. If literal commas are required, then they can be escaped with a backslash. Therefore the input String "red, white\, and blue" would produce two tokens in its list:

  • red
  • white, and blue

Parameters
value The comma-separated input String.
Returns
  • Collection of tokens parsed from the input value.

public String getChangelogString (CustomField field, Collection<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.

Parameters
field CustomField that the value belongs to
value Transport Object representing the value instance of the CustomField
Returns
  • Change log string.

@Nonnull public List<FieldConfigItemType> getConfigurationItemTypes ()

Returns a List of FieldConfigItemType objects. Can not be immutable. This opens up possibilities for configurable custom fields.

Returns

public Collection<Option> getDefaultValue (FieldConfig fieldConfig)

public FieldTypeInfo getFieldTypeInfo (FieldTypeInfoContext fieldTypeInfoContext)

Returns lower level Information about the field. This information contains allowed values and/or the autocomplete url

Parameters
fieldTypeInfoContext context information for generating the FieldTypeInfo.
Returns
  • Low level information about the field.

public Set<Long> getIssueIdsWithValue (CustomField field, Option option)

Returns a Set of issue ids (Long) that have the given option selected.

Parameters
field the CustomField to search on
option the Object representing a single value to search on.
Returns
  • Set of Longs

public JsonData getJsonDefaultValue (IssueContext issueCtx, CustomField field)

Return The default data for this system field. May be null if there is no default.

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.

public FieldJsonRepresentation getJsonFromIssue (CustomField field, Issue issue, boolean renderedVersionRequested, FieldLayoutItem fieldLayoutItem)

Return a JsonData representation of the field value

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.

public JsonType getJsonSchema (CustomField customField)

Return a description of the shape of this field when represented as JSON.

public Options getOptions (FieldConfig fieldConfig, JiraContextNode jiraContextNode)

Returns all possible Options for this field.

Parameters
fieldConfig configuration for this field
jiraContextNode context
Returns
  • all possible Options for this field.

public ProjectCustomFieldImporter getProjectImporter ()

Returns the object that will perform the actual project import functions for the custom field type.

Returns
  • the object that will perform the actual project import functions for the custom field type.

public Query getQueryForGroup (String fieldName, String groupName)

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.

Parameters
fieldName the id of the custom field
groupName the name of the group to filter on
Returns
  • the (@Link Query) to pass to the searcher

public RestFieldOperationsHandler getRestFieldOperation (CustomField field)

Returns the RestFieldOperationsHandler for this field.

Parameters
field the Custom Field
Returns
  • the RestFieldOperationsHandler for this field.

public Option getSingularObjectFromString (String string)

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.

Parameters
string the String
Returns
  • singularObject instance

public String getStringFromSingularObject (Option optionObject)

public static String getStringFromTransferObject (Collection<String> collection)

Takes a Collection of values and creates a comma-separated String that represents this Collection.

If any items in the collection include literal commas, then these commas are escaped with a prepended backslash. eg a list that looks like:

  • All sorts
  • Tom, Dick, and Harry
Will be turned into a string that looks like "All sorts,Tom\, Dick\, and Harry"

Parameters
collection a collection of Strings to be comma separated

public Object getStringValueFromCustomFieldParams (CustomFieldParams parameters)

Return the String value object from the CustomFieldParams. The object may be a single String (e.g. TextCFType, List of Strings (e.g. MultiSelectCFType) or CustomFieldParams of Strings (e.g. CascadingSelectCFType). Among other things these values are passed to Velocity for rendering edit screens.

Parameters
parameters - CustomFieldParams containing String values
Returns
  • String value object from the CustomFieldParams

public Collection<Option> getValueFromCustomFieldParams (CustomFieldParams parameters)

Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.

Parameters
parameters CustomFieldParams of String objects. Will contain one value for Singular field types.
Returns

@Nonnull public Map<StringObject> getVelocityParameters (Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)

The custom field may wish to pass parameters to the velocity context beyond the getValueFromIssue methods (eg managers).

The values are added to the context for all velocity views (edit, search, view, xml)

Parameters
issue The issue currently in context (Note: this will be null in cases like 'default value')
field CustomField
fieldLayoutItem FieldLayoutItem
Returns
  • A Map of parameters to add to the velocity context, or an empty Map otherwise (never null)

public Set<Long> remove (CustomField field)

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)

public void removeValue (CustomField field, Issue issue, Option option)

Perform any actions required if the option selected by the issue is removed.

Parameters
field being edited
issue to remove stuff from
option option being removed.

public void setDefaultValue (FieldConfig fieldConfig, Collection<Option> value)

Sets the default value for a Custom Field.

Parameters
fieldConfig CustomField for which the default is being stored
value Transport Object representing the value instance of the CustomField.

public void validateFromParams (CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)

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.

Parameters
relevantParams parameter object of Strings
errorCollectionToAddTo errorCollection to which any erros should be added (never null)
config FieldConfig

public boolean valuesEqual (Collection<Option> v1, Collection<Option> v2)

Used to compare 2 field values and work out whether a change item should be generated

Parameters
v1 current value
v2 new value
Returns
  • true if the change item should be generated, false otherwise

Protected Methods

protected Option convertDbValueToType (Object dbValue)

Converts a given db value to Single form of Transport Object

Parameters
dbValue db representation as returned by convertTypeToDbValue(Object)
Returns
  • Single form of Transport Object

protected Object convertTypeToDbValue (Option value)

Converts a given underlying type to its db storage value. Must be compatable with PersistenceFieldType returned by getDatabaseType()

Parameters
value Single form of Transport Object
Returns
  • database representation of given Transport Object.

@Nonnull protected PersistenceFieldType getDatabaseType ()

Type of database field needed to store this field.

Returns

protected Comparator<Option> getTypeComparator ()

Returns a comparator for underlying type of this custom field. Used e.g. for sorting values retrieved from the Database

Returns
  • a comparator, null if can't be compared without extra context