public class

DefaultCustomFieldManager

extends Object
implements CustomFieldManager
java.lang.Object
   ↳ com.atlassian.jira.issue.managers.DefaultCustomFieldManager

Summary

[Expand]
Inherited Constants
From interface com.atlassian.jira.issue.CustomFieldManager
Public Constructors
DefaultCustomFieldManager(PluginAccessor pluginAccessor, OfBizDelegator delegator, FieldConfigSchemeManager fieldConfigSchemeManager, JiraAuthenticationContext authenticationContext, ConstantsManager constantsManager, ProjectManager projectManager, PermissionManager permissionManager, FieldConfigContextPersister contextPersister, FieldScreenManager fieldScreenManager, RendererManager rendererManager, CustomFieldValuePersister customFieldValuePersister, NotificationSchemeManager notificationSchemeManager, FieldManager fieldManager, FieldConfigSchemeClauseContextUtil fieldConfigSchemeClauseContextUtil, EventPublisher eventPublisher, CustomFieldDescription customFieldDescription, I18nHelper.BeanFactory i18nFactory, FeatureManager featureManager, TranslationManager translationManager, CacheManager cacheManager)
Public Methods
void associateCustomFieldContext(CustomField customField, List<JiraContextNode> contexts, List<GenericValue> issueTypes)
void clear()
clear the cache
CustomField createCustomField(String fieldName, String description, CustomFieldType fieldType, CustomFieldSearcher customFieldSearcher, List contexts, List issueTypes)
Creates a custom field with the given name and description of the given CustomFieldType using the given CustomFieldSearcher that is displayed in the given list of contexts available to the given list of issueTypes.
boolean exists(String key)
Returns true if this customfield actually exists.
CustomField getCustomFieldInstance(GenericValue customFieldGv)
Converts a customfield GenericValue to a CustomField instance.
@Nullable CustomField getCustomFieldObject(String key)
Get a CustomField by its text key (eg 'customfield_10000').
@Nullable CustomField getCustomFieldObject(Long id)
Get a CustomField by ID.
@Nullable CustomField getCustomFieldObjectByName(String customFieldName)
Retrieve the first custom field object with the specified name.
List<CustomField> getCustomFieldObjects(SearchContext searchContext)
Returns all customfields in a particular SearchContext.
List<CustomField> getCustomFieldObjects(GenericValue issue)
List<CustomField> getCustomFieldObjects(Long projectId, List<String> issueTypeIds)
Returns the same as getCustomFieldObjects(Long, String) but allows to specify a list of issueTypes.
List<CustomField> getCustomFieldObjects(Long projectId, String issueTypeId)
Gets a list of custom fields for a particular project and issue type.
List<CustomField> getCustomFieldObjects(Issue issue)
Get all CustomFields in scope for this issue's project/type.
List<CustomField> getCustomFieldObjects()
Returns all custom fields.
Collection<CustomField> getCustomFieldObjectsByName(String customFieldName)
Retrieve custom field(s) of a certain name.
CustomFieldSearcher getCustomFieldSearcher(String key)
Retrieve a custom field searcher by its type key.
Class<? extends CustomFieldSearcher> getCustomFieldSearcherClass(String key)
Retrieve a custom field searcher by its type key.
@Nonnull List<CustomFieldSearcher> getCustomFieldSearchers(CustomFieldType customFieldType)
Retrieves all the searchers registered for a particular custom Field.
CustomFieldType getCustomFieldType(String key)
Retrieve a custom field type by its type key.
@Nonnull List<CustomFieldType<?, ?>> getCustomFieldTypes()
Retrieve all customfieldtypes registered in the sytem.
@Nullable CustomFieldSearcher getDefaultSearcher(CustomFieldType<?, ?> type)
Return the default CustomFieldSearcher for the passed CustomFieldType.
List<CustomField> getGlobalCustomFieldObjects()
Returns a list of custom fields where the isGlobal() is true.
@EventListener void onClearCache(ClearCacheEvent event)
void refresh()
reloads all customfields into the cache from the DB, this is an expensive operation, so avoid it if you can.
void refreshConfigurationSchemes(Long customFieldId)
Causes a reload of the field configuration scheme for a specified custom field id Call when the configuration scheme changes
void removeCustomField(CustomField customField)
Removes the customfield supplied including all associations and values.
void removeCustomFieldPossiblyLeavingOrphanedData(Long customFieldId)
Removes the customfield supplied.
void removeCustomFieldValues(GenericValue issue)
Removes the values stored by customfields for a particular Issue.
void removeProjectAssociations(Project project)
Used if a project is deleted to remove the project field associations.
void removeProjectAssociations(GenericValue project)
Used if a project is deleted to remove the project field associations.
void removeProjectCategoryAssociations(ProjectCategory projectCategory)
Used if a project category is deleted to remove the field associations.
void updateCustomField(CustomField customField)
Updates the supplied custom field, refreshes the underlying cache
Protected Methods
boolean areConfigSchemesEqual(List<FieldConfigScheme> schemes, List<FieldConfigScheme> otherSchemes)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.issue.CustomFieldManager

Public Constructors

public DefaultCustomFieldManager (PluginAccessor pluginAccessor, OfBizDelegator delegator, FieldConfigSchemeManager fieldConfigSchemeManager, JiraAuthenticationContext authenticationContext, ConstantsManager constantsManager, ProjectManager projectManager, PermissionManager permissionManager, FieldConfigContextPersister contextPersister, FieldScreenManager fieldScreenManager, RendererManager rendererManager, CustomFieldValuePersister customFieldValuePersister, NotificationSchemeManager notificationSchemeManager, FieldManager fieldManager, FieldConfigSchemeClauseContextUtil fieldConfigSchemeClauseContextUtil, EventPublisher eventPublisher, CustomFieldDescription customFieldDescription, I18nHelper.BeanFactory i18nFactory, FeatureManager featureManager, TranslationManager translationManager, CacheManager cacheManager)

Public Methods

public void associateCustomFieldContext (CustomField customField, List<JiraContextNode> contexts, List<GenericValue> issueTypes)

public void clear ()

clear the cache

public CustomField createCustomField (String fieldName, String description, CustomFieldType fieldType, CustomFieldSearcher customFieldSearcher, List contexts, List issueTypes)

Creates a custom field with the given name and description of the given CustomFieldType using the given CustomFieldSearcher that is displayed in the given list of contexts available to the given list of issueTypes.

Returns
  • the newly created CustomField.
Throws
GenericEntityException

public boolean exists (String key)

Returns true if this customfield actually exists. This saves unnecessary copying of custom field objects when all we want to know is "does it exist"

Parameters
key Eg. 'customfield_10000'
Returns
  • true if the custom field is returned

public CustomField getCustomFieldInstance (GenericValue customFieldGv)

Converts a customfield GenericValue to a CustomField instance.

Returns

@Nullable public CustomField getCustomFieldObject (String key)

Get a CustomField by its text key (eg 'customfield_10000').

Parameters
key Eg. 'customfield_10000'
Returns

@Nullable public CustomField getCustomFieldObject (Long id)

Get a CustomField by ID.

Parameters
id ID of field, eg. 10000
Returns

@Nullable public CustomField getCustomFieldObjectByName (String customFieldName)

Retrieve the first custom field object with the specified name. WARNING: Custom Field names are no longer guaranteed to be unique. This method returns the first named custom field. Use getCustomFieldObjectsByName(String) to retrieve all custom fields.

Parameters
customFieldName the Name
Returns

public List<CustomField> getCustomFieldObjects (SearchContext searchContext)

Parameters
searchContext the SearchContext
Returns

public List<CustomField> getCustomFieldObjects (GenericValue issue)

This method is deprecated.
Use getCustomFieldObjects(com.atlassian.jira.issue.Issue)

Returns a list of CustomFields that apply to a particular issue.

Parameters
issue A GenericValue of the issue
Returns

public List<CustomField> getCustomFieldObjects (Long projectId, List<String> issueTypeIds)

Returns the same as getCustomFieldObjects(Long, String) but allows to specify a list of issueTypes.

Parameters
projectId Id of the project
issueTypeIds A list of issue types. See ALL_ISSUE_TYPES, ALL_STANDARD_ISSUE_TYPES and ALL_SUB_TASK_ISSUE_TYPES
Returns

public List<CustomField> getCustomFieldObjects (Long projectId, String issueTypeId)

Gets a list of custom fields for a particular project and issue type.

Parameters
projectId Id of the project
issueTypeId An issue type. See ALL_ISSUE_TYPES, ALL_STANDARD_ISSUE_TYPES and ALL_SUB_TASK_ISSUE_TYPES
Returns

public List<CustomField> getCustomFieldObjects (Issue issue)

Get all CustomFields in scope for this issue's project/type.

Parameters
issue A Issue object
Returns

public List<CustomField> getCustomFieldObjects ()

Returns all custom fields.

Returns

public Collection<CustomField> getCustomFieldObjectsByName (String customFieldName)

Retrieve custom field(s) of a certain name.

Returns

public CustomFieldSearcher getCustomFieldSearcher (String key)

Retrieve a custom field searcher by its type key.

The key is the "full plugin module key". That is, the plugin key for the plugin it comes from, a colon separator, and then the module key. e.g. the system types are specified in system-customfieldtypes-plugin.xml:

 <atlassian-plugin key="com.atlassian.jira.plugin.system.customfieldtypes" name="Custom Field Types & Searchers">
     ...
     <customfield-type key="float" name="Number Field"
     ...
 
To access the 'Number Field' type, the key would then be 'com.atlassian.jira.plugin.system.customfieldtypes:float'.

Parameters
key Type identifier constructed from plugin XML.
Returns
  • the CustomFieldSearcher for the given key

public Class<? extends CustomFieldSearcher> getCustomFieldSearcherClass (String key)

Retrieve a custom field searcher by its type key.

The key is the "full plugin module key". That is, the plugin key for the plugin it comes from, a colon separator, and then the module key. e.g. the system types are specified in system-customfieldtypes-plugin.xml:

 <atlassian-plugin key="com.atlassian.jira.plugin.system.customfieldtypes" name="Custom Field Types & Searchers">
     ...
     <customfield-type key="float" name="Number Field"
     ...
 
To access the 'Number Field' type, the key would then be 'com.atlassian.jira.plugin.system.customfieldtypes:float'.

Parameters
key Type identifier constructed from plugin XML.

@Nonnull public List<CustomFieldSearcher> getCustomFieldSearchers (CustomFieldType customFieldType)

Retrieves all the searchers registered for a particular custom Field. Searchers may be registred via:

   <customfield-searcher key="daterange" name="Date Range picker"
                     i18n-name-key="admin.customfield.searcher.daterange.name"
                     class="com.atlassian.jira.issue.customfields.searchers.DateRangeSearcher">
 

Parameters
customFieldType the CustomFieldType
Returns

public CustomFieldType getCustomFieldType (String key)

Retrieve a custom field type by its type key.

The key is the "full plugin module key". That is, the plugin key for the plugin it comes from, a colon separator, and then the module key. e.g. the system types are specified in system-customfieldtypes-plugin.xml:

 <atlassian-plugin key="com.atlassian.jira.plugin.system.customfieldtypes" name="Custom Field Types & Searchers">
     ...
     <customfield-type key="float" name="Number Field"
     ...
 
To access the 'Number Field' type, the key would then be 'com.atlassian.jira.plugin.system.customfieldtypes:float'.

Parameters
key Type identifier constructed from plugin XML.
Returns
  • the CustomFieldType for the given key

@Nonnull public List<CustomFieldType<?, ?>> getCustomFieldTypes ()

Retrieve all customfieldtypes registered in the sytem.

Returns

@Nullable public CustomFieldSearcher getDefaultSearcher (CustomFieldType<?, ?> type)

Return the default CustomFieldSearcher for the passed CustomFieldType. The default searcher can be null if there is no searcher associated with the type.

Parameters
type the CustomFieldType to query.
Returns
  • the default searcher for the passed CustomFieldType. Can be null if the type has no associated searcher.

public List<CustomField> getGlobalCustomFieldObjects ()

Returns a list of custom fields where the isGlobal() is true.

Returns

@EventListener public void onClearCache (ClearCacheEvent event)

public void refresh ()

reloads all customfields into the cache from the DB, this is an expensive operation, so avoid it if you can.

public void refreshConfigurationSchemes (Long customFieldId)

Causes a reload of the field configuration scheme for a specified custom field id Call when the configuration scheme changes

public void removeCustomField (CustomField customField)

Removes the customfield supplied including all associations and values.

Parameters
customField The CustomField to be removed.

public void removeCustomFieldPossiblyLeavingOrphanedData (Long customFieldId)

Removes the customfield supplied. This method will try to lookup the customfield object via the manager first. If the customfield object can be retrieved this way, it simply delegates the removal to the removeCustomField(com.atlassian.jira.issue.fields.CustomField) method, which will not leave any orphaned data behind.

NOTE: Generally you should use the removeCustomField(com.atlassian.jira.issue.fields.CustomField) method to remove a custom field, as it is guaranteed to remove all data. This method should only be used if a customfield needs to be removed when the customfieldtype for that field is no longer available!

If however the customfield object cannot be retrieved via the manager, which may be the case if the custom field type is no longer available (a plugin may have been removed), then this method will try to lookup the custom field directly in the database. If it doesn't exist in the database, an IllegalArgumentException will be thrown. Otherwise, the customfield and all associated configurations will be removed. This method will also call to the removeAllValues(String) method to delete any values. Please note however, that if your custom field stores any other values (such as options for example), they will have to be removed by the caller of this method, as the custom field type is not accessible (which is usually responsible for removing such values).

Parameters
customFieldId The id of the customField to be removed.

public void removeCustomFieldValues (GenericValue issue)

Removes the values stored by customfields for a particular Issue.

Parameters
issue The issue GenericValue
Throws
GenericEntityException

public void removeProjectAssociations (Project project)

Used if a project is deleted to remove the project field associations.

Parameters
project The project being deleted.

public void removeProjectAssociations (GenericValue project)

Used if a project is deleted to remove the project field associations.

Parameters
project The project being deleted.

public void removeProjectCategoryAssociations (ProjectCategory projectCategory)

Used if a project category is deleted to remove the field associations.

Parameters
projectCategory The project category being deleted.

public void updateCustomField (CustomField customField)

Updates the supplied custom field, refreshes the underlying cache

Parameters
customField updated Custom field

Protected Methods

protected boolean areConfigSchemesEqual (List<FieldConfigScheme> schemes, List<FieldConfigScheme> otherSchemes)