Class CascadingSelectCFType
java.lang.Object
com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType<Map<String,Option>,Option>
com.atlassian.jira.issue.customfields.impl.CascadingSelectCFType
- All Implemented Interfaces:
ProjectImportableCustomField
,CustomFieldType<Map<String,
,Option>, Option> MultipleCustomFieldType<Map<String,
,Option>, Option> MultipleSettableCustomFieldType<Map<String,
,Option>, Option> SortableCustomField<Map<String,
,Option>> ExportableCustomFieldType
,RestAwareCustomFieldType
,RestCustomFieldTypeOperations
public class CascadingSelectCFType
extends AbstractCustomFieldType<Map<String,Option>,Option>
implements MultipleSettableCustomFieldType<Map<String,Option>,Option>, SortableCustomField<Map<String,Option>>, ProjectImportableCustomField, RestAwareCustomFieldType, RestCustomFieldTypeOperations, ExportableCustomFieldType
Cascading Select Custom Field Type allows for multiple dependent select lists.
- Transport Object Type
- {@link Map<String, Option>, Option} The key in the map represents the field depth of the select list. eg. a key of null is the root parent, and key of "1" is the first level select list. As at JIRA 3.0, there can only be one level.
- Singular Object Type
Option
- Database Storage Type
String
of option id
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
AbstractCustomFieldType.VisitorBase<X>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PersistenceFieldType
static final String
static final String
static final String
Fields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE, RESOURCE_PREVIEW
-
Constructor Summary
ConstructorsConstructorDescriptionCascadingSelectCFType
(OptionsManager optionsManager, CustomFieldValuePersister customFieldValuePersister, GenericConfigManager genericConfigManager, JiraBaseUrls jiraBaseUrls) -
Method Summary
Modifier and TypeMethodDescriptionboolean
areAllRequiredParametersPresent
(Map<String, Object> params, String customFieldId) This method validates if all the obligatory parameters of a given custom field type have been set when the custom field is set to be required.int
Compares the two custom field objects.int
compareOption
(Option option1, Option option2) void
createValue
(CustomField field, Issue issue, Map<String, Option> cascadingOptions) Create a cascading select-list instance for an issue.getChangelogValue
(CustomField field, Map<String, Option> cascadingOptions) Returns a values to be stored in the change log, example is the id of the changed item.Returns a List ofFieldConfigItemType
objects.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.getIssueIdsWithValue
(CustomField field, Option option) Returns a list of Issue Ids matching the "value" note that the value in this instance is the single objectgetJsonDefaultValue
(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 ofNonNullCustomFieldProvider
that 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 theString
representation of a single value within the CustomFieldType.getStringValueFromCustomFieldParams
(CustomFieldParams parameters) Return the String value object from the CustomFieldParams.getValueFromCustomFieldParams
(CustomFieldParams relevantParams) Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.getValueFromIssue
(CustomField field, Issue issue) Retrieves the Transport Object representing the current CustomField value for the given issue.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) Performs additional tasks when an entire CustomField of this type is being removedCustomField.remove()
.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, Map<String, Option> cascadingOptions) Sets the default value for a Custom Fieldvoid
updateValue
(CustomField field, Issue issue, Map<String, Option> cascadingOptions) Update the value for this Custom Field in a particular issue currently stored in the database.void
validateFromParams
(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config) Ensures that theCustomFieldParams
of Strings is a valid representation of the Custom Field values.Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
assertObjectImplementsType, availableForBulkEdit, getChangelogString, getDescription, getDescriptor, getI18nBean, getKey, getName, getRelatedIndexers, 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, getChangelogString, getCloneOptionConfiguration, getCloneValue, getDescription, getDescriptor, getKey, getName, getRelatedIndexers, init, isRenderable, isUserInputRequiredForMove, requiresAdditionalParams, valuesEqual
-
Field Details
-
PARENT_KEY
-
CHILD_KEY
- See Also:
-
HIERARCHY_SEPARATOR
- See Also:
-
CASCADE_VALUE_TYPE
-
-
Constructor Details
-
CascadingSelectCFType
public CascadingSelectCFType(OptionsManager optionsManager, CustomFieldValuePersister customFieldValuePersister, GenericConfigManager genericConfigManager, JiraBaseUrls jiraBaseUrls)
-
-
Method Details
-
removeValue
Description copied from interface:MultipleSettableCustomFieldType
Perform any actions required if the option selected by the issue is removed.- Specified by:
removeValue
in interfaceMultipleSettableCustomFieldType<Map<String,
Option>, Option> - Parameters:
field
- being editedissue
- to remove stuff fromoption
- option being removed.
-
remove
Description copied from interface:CustomFieldType
Performs additional tasks when an entire CustomField of this type is being removedCustomField.remove()
. This includes removal of values & options. -
getOptions
Description copied from interface:MultipleCustomFieldType
Returns all possible Options for this field.- Specified by:
getOptions
in interfaceMultipleCustomFieldType<Map<String,
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:MultipleCustomFieldType
Returns all possible Options for this field.- Specified by:
getOptions
in interfaceMultipleCustomFieldType<Map<String,
Option>, Option> - Parameters:
fieldConfig
- configuration for this field- Returns:
- all possible Options for this field.
-
getIssueIdsWithValue
Returns a list of Issue Ids matching the "value" note that the value in this instance is the single object- Specified by:
getIssueIdsWithValue
in interfaceMultipleSettableCustomFieldType<Map<String,
Option>, Option> - Parameters:
field
- the CustomField to search onoption
- the Object representing a single value to search on.- Returns:
- Set of Longs
-
validateFromParams
public void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config) Description copied from interface:CustomFieldType
Ensures that theCustomFieldParams
of Strings is a valid representation of the Custom Field values. Any errors should be added to theErrorCollection
under the appropriate key as required.- Specified by:
validateFromParams
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
relevantParams
- parameter object of StringserrorCollectionToAddTo
- errorCollection to which any errors should be added (never null)config
- FieldConfig
-
areAllRequiredParametersPresent
Description copied from interface:CustomFieldType
This method validates if all the obligatory parameters of a given custom field type have been set when the custom field is set to be required. In the general case, we are checking if a validated custom field is present in the parameters map and has the value assigned. Depending on the custom field type we may want to extend the validation for additional requirements. For e.g. "Select List (cascading)" requires to have set only the parent option if no children options are configured for the parent, and both parent and child options are to be set otherwise.- Specified by:
areAllRequiredParametersPresent
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
params
- A map of parameters attached to an issue create/edit action.customFieldId
- An ID of a custom field which is being validated e.g. "customfield_10101".- Returns:
- Returns true if parameters map contains customFieldId as key, and the CustomFieldParams value for the key is not null, false otherwise.
-
createValue
public void createValue(CustomField field, Issue issue, @Nonnull Map<String, Option> cascadingOptions) Create a cascading select-list instance for an issue.- Specified by:
createValue
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
cascadingOptions
-field
-CustomField
for which the value is being storedissue
- TheIssue
to be stored against.
-
updateValue
Description copied from interface:CustomFieldType
Update the value for this Custom Field in a particular issue currently stored in the database.- Specified by:
updateValue
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
field
-CustomField
for which the value is being storedissue
- TheIssue
to be stored against.cascadingOptions
- Transport Object representing the value instance of the CustomField.
-
getValueFromIssue
Description copied from interface:CustomFieldType
Retrieves the Transport Object representing the current CustomField value for the given issue.- Specified by:
getValueFromIssue
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
field
- Custom field for which to retrieve the valueissue
- Issue from which to retrieve the value- 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)
-
getValueFromCustomFieldParams
public Map<String,Option> getValueFromCustomFieldParams(CustomFieldParams relevantParams) throws FieldValidationException Description copied from interface:CustomFieldType
Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.- Specified by:
getValueFromCustomFieldParams
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
relevantParams
- 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:CustomFieldType
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.- Specified by:
getStringValueFromCustomFieldParams
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
parameters
- - CustomFieldParams containing String values- Returns:
- String value object from the CustomFieldParams
-
getDefaultValue
Description copied from interface:CustomFieldType
Retrieves the Object representing the default CustomField value for the Custom Field.- Specified by:
getDefaultValue
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
fieldConfig
- CustomField for default value- Returns:
- Transport Object of the Default Value
-
setDefaultValue
Description copied from interface:CustomFieldType
Sets the default value for a Custom Field- Specified by:
setDefaultValue
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
fieldConfig
- CustomField for which the default is being storedcascadingOptions
- Transport Object representing the value instance of the CustomField
-
getChangelogValue
Description copied from interface:CustomFieldType
Returns a values to be stored in the change log, example is the id of the changed item.- Specified by:
getChangelogValue
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
field
- CustomField that the value belongs tocascadingOptions
- Transport Object representing the value instance of the CustomField- Returns:
- Change log value.
-
getStringFromSingularObject
Description copied from interface:CustomFieldType
Returns theString
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 theCollection
orMap
- Specified by:
getStringFromSingularObject
in interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
optionObject
- the object- Returns:
- String representation of the Object
-
getSingularObjectFromString
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 interfaceCustomFieldType<Map<String,
Option>, Option> - Parameters:
string
- the String- Returns:
- singularObject instance
- Throws:
FieldValidationException
- if the string is an invalid representation of the Object.
-
getConfigurationItemTypes
Description copied from interface:CustomFieldType
Returns a List ofFieldConfigItemType
objects. Can not be immutable. This opens up possibilities for configurable custom fields.- Specified by:
getConfigurationItemTypes
in interfaceCustomFieldType<Map<String,
Option>, Option> - Overrides:
getConfigurationItemTypes
in classAbstractCustomFieldType<Map<String,
Option>, Option> - Returns:
- List of
FieldConfigItemType
-
getVelocityParameters
@Nonnull public Map<String,Object> getVelocityParameters(@Nullable Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem) Description copied from interface:CustomFieldType
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)
- Specified by:
getVelocityParameters
in interfaceCustomFieldType<Map<String,
Option>, Option> - Overrides:
getVelocityParameters
in classAbstractCustomFieldType<Map<String,
Option>, Option> - Parameters:
issue
- The issue currently in context (Note: this will be null in cases like 'default value')field
- CustomFieldfieldLayoutItem
- FieldLayoutItem- Returns:
- A
Map
of parameters to add to the velocity context, or an empty Map otherwise (never null)
-
compare
public int compare(@Nonnull Map<String, Option> o1, @Nonnull Map<String, Option> o2, FieldConfig fieldConfig) Description copied from interface:SortableCustomField
Compares the two custom field objects.- Specified by:
compare
in interfaceSortableCustomField<Map<String,
Option>> - Parameters:
o1
- Never nullo2
- Never null- Returns:
- 0, 1 or -1
-
compareOption
-
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 interfaceProjectImportableCustomField
- Returns:
- the object that will perform the actual project import functions for the custom field type.
-
accept
-
getRepresentationFromIssue
Description copied from interface:ExportableCustomFieldType
Get the custom field representation of the issue, this object contains the column headers and values for each of theFieldExportPart
.- Specified by:
getRepresentationFromIssue
in 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:CustomFieldType
Returns an instance ofNonNullCustomFieldProvider
that Jira will use to optimize indexing performance.- Specified by:
getNonNullCustomFieldProvider
in interfaceCustomFieldType<Map<String,
Option>, Option>
-
getFieldTypeInfo
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 interfaceRestAwareCustomFieldType
- Parameters:
fieldTypeInfoContext
- context information for generating theFieldTypeInfo
.- Returns:
- Low level information about the field.
-
getJsonSchema
Description copied from interface:RestAwareCustomFieldType
Return a description of the shape of this field when represented as JSON.- Specified by:
getJsonSchema
in interfaceRestAwareCustomFieldType
-
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 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.
-
getRestFieldOperation
Description copied from interface:RestCustomFieldTypeOperations
Returns the RestFieldOperationsHandler for this field.- Specified by:
getRestFieldOperation
in interfaceRestCustomFieldTypeOperations
- Parameters:
field
- the Custom Field- Returns:
- the RestFieldOperationsHandler for this field.
-
getJsonDefaultValue
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 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.
-