Class MultiSelectCFType
java.lang.Object
com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType<Collection<S>,S>
com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType<Option>
com.atlassian.jira.issue.customfields.impl.MultiSelectCFType
- All Implemented Interfaces:
ProjectImportableCustomField,CustomFieldType<Collection<Option>,,Option> GroupSelectorField,MultipleCustomFieldType<Collection<Option>,,Option> MultipleSettableCustomFieldType<Collection<Option>,,Option> SortableCustomField<List<String>>,ExportableCustomFieldType,RestAwareCustomFieldType,RestCustomFieldTypeOperations
public class MultiSelectCFType
extends AbstractMultiCFType<Option>
implements MultipleSettableCustomFieldType<Collection<Option>,Option>, SortableCustomField<List<String>>, GroupSelectorField, ProjectImportableCustomField, RestAwareCustomFieldType, RestCustomFieldTypeOperations, ExportableCustomFieldType
Multiple Select Type allows selecting of multiple Options
- Transport Object Type
Collection<Option>- Singular Object Type
Option- Database Storage Type
Stringof option id
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSupport interface to delay the data input text evaluation to vm-processing time.static interfaceNested classes/interfaces inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
AbstractCustomFieldType.VisitorBase<X> -
Field Summary
FieldsFields inherited from class com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType
customFieldValuePersister, genericConfigManagerFields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE, RESOURCE_PREVIEW -
Constructor Summary
ConstructorsConstructorDescriptionMultiSelectCFType(OptionsManager optionsManager, CustomFieldValuePersister valuePersister, GenericConfigManager genericConfigManager, JiraBaseUrls jiraBaseUrls, SearchService searchService, FeatureManager featureManager, JiraAuthenticationContext jiraAuthenticationContext) -
Method Summary
Modifier and TypeMethodDescriptionintcompare(List<String> customFieldObjectValue1, List<String> customFieldObjectValue2, FieldConfig fieldConfig) Compares the two custom field objects.protected OptionconvertDbValueToType(Object dbValue) Converts a given db value to Single form of Transport Objectprotected ObjectconvertTypeToDbValue(Option value) Converts a given underlying type to its db storage value.static Collection<String>Parses the given comma-separated String value into a Collection.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.Returns a List ofFieldConfigItemTypeobjects.protected PersistenceFieldTypeType of database field needed to store this field.getDefaultValue(FieldConfig fieldConfig) Retrieves the Object representing the default CustomField value for the Custom Field.getFieldTypeInfo(FieldTypeInfoContext fieldTypeInfoContext) Returns lower level Information about the field.getIdentifiersForGroup(String groupName) This method should be implemented in your custom type to return a List of identifiers of your group.getIssueIdsWithValue(CustomField field, Option option) Returns a Set of issue ids (Long) that have the given option selected.getJsonDefaultValue(IssueContext issueCtx, CustomField field) Return The default data for this system field.getJsonFromIssue(CustomField field, Issue issue, boolean renderedVersionRequested, FieldLayoutItem fieldLayoutItem) Return a JsonData representation of the field valuegetJsonSchema(CustomField customField) Return a description of the shape of this field when represented as JSON.Returns an instance ofNonNullCustomFieldProviderthat Jira will use to optimize indexing performance.getOptions(FieldConfig fieldConfig) Returns all possible Options for this field.getOptions(FieldConfig fieldConfig, JiraContextNode jiraContextNode) Returns all possible Options for this field.Returns the object that will perform the actual project import functions for the custom field type.getRepresentationFromIssue(Issue issue, CustomFieldExportContext context) Get the custom field representation of the issue, this object contains the column headers and values for each of theFieldExportPart.getRestFieldOperation(CustomField field) Returns the RestFieldOperationsHandler for this field.getSingularObjectFromString(String string) Returns a Singular Object, given the string value as passed by the presentation tier.getStringFromSingularObject(Option optionObject) Returns theStringrepresentation of a single value within the CustomFieldType.static StringgetStringFromTransferObject(Collection<String> collection) Takes a Collection of values and creates a comma-separated String that represents this Collection.getStringValueFromCustomFieldParams(CustomFieldParams parameters) Return the String value object from the CustomFieldParams.protected Comparator<Option>Returns a comparator for underlying type of this custom field.getValueFromCustomFieldParams(CustomFieldParams parameters) Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.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).remove(CustomField field) called when removing a field.voidremoveValue(CustomField field, Issue issue, Option option) Perform any actions required if the option selected by the issue is removed.voidsetDefaultValue(FieldConfig fieldConfig, Collection<Option> value) Sets the default value for a Custom Field.voidvalidateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config) Ensures that theCustomFieldParamsof Strings is a valid representation of the Custom Field values.booleanvaluesEqual(Collection<Option> v1, Collection<Option> v2) Used to compare 2 field values and work out whether a change item should be generatedMethods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType
convertDbObjectToTypes, convertTypesToDbObjects, createValue, getChangelogValue, getValueFromIssue, getValueFromIssue, updateValueMethods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
assertObjectImplementsType, availableForBulkEdit, getDescription, getDescriptor, getI18nBean, getKey, getName, getRelatedIndexers, getVelocityParameters, init, isRenderableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
areAllRequiredParametersPresent, availableForBulkEdit, createValue, getChangelogValue, getCloneOptionConfiguration, getCloneValue, getDescription, getDescriptor, getKey, getName, getRelatedIndexers, getValueFromIssue, init, isRenderable, isUserInputRequiredForMove, requiresAdditionalParams, updateValue
-
Field Details
-
COMMA_REPLACEMENT
- See Also:
-
-
Constructor Details
-
MultiSelectCFType
public MultiSelectCFType(OptionsManager optionsManager, CustomFieldValuePersister valuePersister, GenericConfigManager genericConfigManager, JiraBaseUrls jiraBaseUrls, SearchService searchService, FeatureManager featureManager, JiraAuthenticationContext jiraAuthenticationContext)
-
-
Method Details
-
remove
Description copied from class:AbstractMultiCFTypecalled 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:
removein interfaceCustomFieldType<Collection<Option>,Option> - Overrides:
removein classAbstractMultiCFType<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<Long>of issue ids that has been affected
-
getOptions
Description copied from interface:MultipleCustomFieldTypeReturns all possible Options for this field.- Specified by:
getOptionsin interfaceMultipleCustomFieldType<Collection<Option>,Option> - Parameters:
fieldConfig- configuration for this fieldjiraContextNode- context (not used in any of the current implementations)- Returns:
- all possible Options for this field.
-
getOptions
Description copied from interface:MultipleCustomFieldTypeReturns all possible Options for this field.- Specified by:
getOptionsin interfaceMultipleCustomFieldType<Collection<Option>,Option> - Parameters:
fieldConfig- configuration for this field- Returns:
- all possible Options for this field.
-
removeValue
Description copied from interface:MultipleSettableCustomFieldTypePerform any actions required if the option selected by the issue is removed.- Specified by:
removeValuein interfaceMultipleSettableCustomFieldType<Collection<Option>,Option> - Parameters:
field- being editedissue- to remove stuff fromoption- option being removed.
-
getIssueIdsWithValue
Description copied from interface:MultipleSettableCustomFieldTypeReturns a Set of issue ids (Long) that have the given option selected.- Specified by:
getIssueIdsWithValuein interfaceMultipleSettableCustomFieldType<Collection<Option>,Option> - Parameters:
field- the CustomField to search onoption- the Object representing a single value to search on.- Returns:
- Set of Longs
-
getDatabaseType
Description copied from class:AbstractMultiCFTypeType of database field needed to store this field.- Specified by:
getDatabaseTypein classAbstractMultiCFType<Option>- Returns:
- One of the predefined
PersistenceFieldTypetypes.
-
convertDbValueToType
Description copied from class:AbstractMultiCFTypeConverts a given db value to Single form of Transport Object- Specified by:
convertDbValueToTypein classAbstractMultiCFType<Option>- Parameters:
dbValue- db representation as returned byAbstractMultiCFType.convertTypeToDbValue(Object)- Returns:
- Single form of Transport Object
-
convertTypeToDbValue
Description copied from class:AbstractMultiCFTypeConverts a given underlying type to its db storage value. Must be compatable withPersistenceFieldTypereturned byAbstractMultiCFType.getDatabaseType()- Specified by:
convertTypeToDbValuein classAbstractMultiCFType<Option>- Parameters:
value- Single form of Transport Object- Returns:
- database representation of given Transport Object.
-
getTypeComparator
Description copied from class:AbstractMultiCFTypeReturns a comparator for underlying type of this custom field. Used e.g. for sorting values retrieved from the Database- Specified by:
getTypeComparatorin classAbstractMultiCFType<Option>- Returns:
- a comparator, null if can't be compared without extra context
-
setDefaultValue
Description copied from class:AbstractMultiCFTypeSets the default value for a Custom Field.- Specified by:
setDefaultValuein interfaceCustomFieldType<Collection<Option>,Option> - Overrides:
setDefaultValuein classAbstractMultiCFType<Option>- Parameters:
fieldConfig- CustomField for which the default is being storedvalue- Transport Object representing the value instance of the CustomField.- See Also:
-
getDefaultValue
Description copied from interface:CustomFieldTypeRetrieves the Object representing the default CustomField value for the Custom Field.- Specified by:
getDefaultValuein interfaceCustomFieldType<Collection<Option>,Option> - Overrides:
getDefaultValuein classAbstractMultiCFType<Option>- Parameters:
fieldConfig- CustomField for default value- Returns:
- Transport Object of the Default Value
- See Also:
-
getValueFromCustomFieldParams
public Collection<Option> getValueFromCustomFieldParams(CustomFieldParams parameters) throws FieldValidationException Description copied from interface:CustomFieldTypeRetrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.- Specified by:
getValueFromCustomFieldParamsin interfaceCustomFieldType<Collection<Option>,Option> - Parameters:
parameters- CustomFieldParams of String objects. Will contain one value for Singular field types.- Returns:
- Transport Object matching the Object parameter of
CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, T),CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, T) - Throws:
FieldValidationException- if the String value fails to convert into Objects- See Also:
-
CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, Object)CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, Object)CustomFieldType.getValueFromIssue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue)
-
getStringValueFromCustomFieldParams
Description copied from interface:CustomFieldTypeReturn 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.- Specified by:
getStringValueFromCustomFieldParamsin interfaceCustomFieldType<Collection<Option>,Option> - Parameters:
parameters- - CustomFieldParams containing String values- Returns:
- String value object from the CustomFieldParams
-
validateFromParams
public void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config) Description copied from interface:CustomFieldTypeEnsures that theCustomFieldParamsof Strings is a valid representation of the Custom Field values. Any errors should be added to theErrorCollectionunder the appropriate key as required.- Specified by:
validateFromParamsin interfaceCustomFieldType<Collection<Option>,Option> - Parameters:
relevantParams- parameter object of StringserrorCollectionToAddTo- errorCollection to which any errors should be added (never null)config- FieldConfig
-
getChangelogString
Description copied from interface:CustomFieldTypeReturns 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:
getChangelogStringin interfaceCustomFieldType<Collection<Option>,Option> - Overrides:
getChangelogStringin classAbstractCustomFieldType<Collection<Option>,Option> - Parameters:
field- CustomField that the value belongs tovalue- Transport Object representing the value instance of the CustomField- Returns:
- Change log string.
-
getSingularObjectFromString
Description copied from interface:CustomFieldTypeReturns 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:
getSingularObjectFromStringin interfaceCustomFieldType<Collection<Option>,Option> - Parameters:
string- the String- Returns:
- singularObject instance
- Throws:
FieldValidationException- if the string is an invalid representation of the Object.
-
getStringFromSingularObject
Description copied from interface:CustomFieldTypeReturns theStringrepresentation 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 theCollectionorMap- Specified by:
getStringFromSingularObjectin interfaceCustomFieldType<Collection<Option>,Option> - Parameters:
optionObject- the object- Returns:
- String representation of the Object
-
getConfigurationItemTypes
Description copied from interface:CustomFieldTypeReturns a List ofFieldConfigItemTypeobjects. Can not be immutable. This opens up possibilities for configurable custom fields.- Specified by:
getConfigurationItemTypesin interfaceCustomFieldType<Collection<Option>,Option> - Overrides:
getConfigurationItemTypesin classAbstractCustomFieldType<Collection<Option>,Option> - Returns:
- List of
FieldConfigItemType
-
compare
public int compare(@Nonnull List<String> customFieldObjectValue1, @Nonnull List<String> customFieldObjectValue2, FieldConfig fieldConfig) Description copied from interface:SortableCustomFieldCompares the two custom field objects.- Specified by:
comparein interfaceSortableCustomField<List<String>>- Parameters:
customFieldObjectValue1- Never nullcustomFieldObjectValue2- Never null- Returns:
- 0, 1 or -1
-
getProjectImporter
Description copied from interface:ProjectImportableCustomFieldReturns the object that will perform the actual project import functions for the custom field type.- Specified by:
getProjectImporterin interfaceProjectImportableCustomField- Returns:
- the object that will perform the actual project import functions for the custom field type.
-
extractTransferObjectFromString
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.
- See Also:
-
getStringFromTransferObject
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
- Parameters:
collection- a collection of Strings to be comma separated
-
valuesEqual
Description copied from interface:CustomFieldTypeUsed to compare 2 field values and work out whether a change item should be generated- Specified by:
valuesEqualin interfaceCustomFieldType<Collection<Option>,Option> - Overrides:
valuesEqualin classAbstractCustomFieldType<Collection<Option>,Option> - Parameters:
v1- current valuev2- new value- Returns:
- true if the change item should be generated, false otherwise
-
accept
- Overrides:
acceptin classAbstractMultiCFType<Option>
-
getIdentifiersForGroup
Description copied from interface:GroupSelectorFieldThis method should be implemented in your custom type to return a List of identifiers of your group. Usually the identifier is just thegroupName. However, some custom fields, such asSelectCFTypeassign ids to their values and index the ids. In such a case, the custom field should return all the ids under which thegroupNamewas indexed. These should match the values that were used in the implementation ofFieldIndexer.addIndex(Document, Issue, CustomFieldPrefetchedData)- Specified by:
getIdentifiersForGroupin interfaceGroupSelectorField- Parameters:
groupName- The name of the group- Returns:
- The group identifier that will be used to search for this group in the index
-
getRepresentationFromIssue
Description copied from interface:ExportableCustomFieldTypeGet the custom field representation of the issue, this object contains the column headers and values for each of theFieldExportPart.- Specified by:
getRepresentationFromIssuein interfaceExportableCustomFieldType- Parameters:
issue- to get the representation forcontext- which contains information such as the i18nHelper and field- Returns:
- the exportable parts of this issue
-
getNonNullCustomFieldProvider
Description copied from interface:CustomFieldTypeReturns an instance ofNonNullCustomFieldProviderthat Jira will use to optimize indexing performance.- Specified by:
getNonNullCustomFieldProviderin interfaceCustomFieldType<Collection<Option>,Option>
-
getFieldTypeInfo
Description copied from interface:RestAwareCustomFieldTypeReturns lower level Information about the field. This information contains allowed values and/or the autocomplete url- Specified by:
getFieldTypeInfoin interfaceRestAwareCustomFieldType- Parameters:
fieldTypeInfoContext- context information for generating theFieldTypeInfo.- Returns:
- Low level information about the field.
-
getJsonSchema
Description copied from interface:RestAwareCustomFieldTypeReturn a description of the shape of this field when represented as JSON.- Specified by:
getJsonSchemain interfaceRestAwareCustomFieldType
-
getJsonFromIssue
public FieldJsonRepresentation getJsonFromIssue(CustomField field, Issue issue, boolean renderedVersionRequested, @Nullable FieldLayoutItem fieldLayoutItem) Description copied from interface:RestAwareCustomFieldTypeReturn a JsonData representation of the field value- Specified by:
getJsonFromIssuein interfaceRestAwareCustomFieldType- Parameters:
field- configuration of the current fieldissue- to get field data fromrenderedVersionRequested- whether the use requested the return of rendered/pretty data as well as raw datafieldLayoutItem- 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.
-
getJsonDefaultValue
Description copied from interface:RestCustomFieldTypeOperationsReturn The default data for this system field. May be null if there is no default.- Specified by:
getJsonDefaultValuein interfaceRestCustomFieldTypeOperations- 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.
-
getRestFieldOperation
Description copied from interface:RestCustomFieldTypeOperationsReturns the RestFieldOperationsHandler for this field.- Specified by:
getRestFieldOperationin interfaceRestCustomFieldTypeOperations- Parameters:
field- the Custom Field- Returns:
- the RestFieldOperationsHandler for this field.
-
getVelocityParameters
@Nonnull public Map<String,Object> getVelocityParameters(@Nullable Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem) Description copied from interface:CustomFieldTypeThe 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)
- Specified by:
getVelocityParametersin interfaceCustomFieldType<Collection<Option>,Option> - Overrides:
getVelocityParametersin classAbstractCustomFieldType<Collection<Option>,Option> - Parameters:
issue- The issue currently in context (Note: this will be null in cases like 'default value')field- CustomFieldfieldLayoutItem- FieldLayoutItem- Returns:
- A
Mapof parameters to add to the velocity context, or an empty Map otherwise (never null)
-