Class CachingCustomFieldManager
- All Implemented Interfaces:
InitializingComponent
,CustomFieldManager
-
Constructor Summary
ConstructorsConstructorDescriptionCachingCustomFieldManager
(com.atlassian.plugin.PluginAccessor pluginAccessor, QueryDslAccessor dbConnectionManager, FieldConfigSchemeManager fieldConfigSchemeManager, ConstantsManager constantsManager, ProjectManager projectManager, FieldConfigContextPersister contextPersister, FieldScreenManager fieldScreenManager, CustomFieldValuePersister customFieldValuePersister, NotificationSchemeManager notificationSchemeManager, FieldManager fieldManager, com.atlassian.event.api.EventPublisher eventPublisher, CustomFieldFactory customFieldFactory, CustomFieldTypeModuleDescriptors customFieldTypeModuleDescriptors, CustomFieldSearcherModuleDescriptors customFieldSearcherModuleDescriptors, CustomFieldSearcherManager customFieldSearcherManager, com.atlassian.cache.CacheManager cacheManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called after all the beans are constructed and the ApplicationContext is fully populated.protected boolean
areConfigSchemesEqual
(List<FieldConfigScheme> schemes, List<FieldConfigScheme> otherSchemes) void
clear()
clear the cachecreateCustomField
(String fieldName, String description, CustomFieldType fieldType, CustomFieldSearcher customFieldSearcher, List<JiraContextNode> contexts, List<IssueType> 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
Returns true if this customfield actually exists.getCustomFieldInstance
(org.ofbiz.core.entity.GenericValue customFieldGv) Converts a customfieldGenericValue
to aCustomField
instance.Get a CustomField by ID.Get a CustomField by its text key (eg 'customfield_10000').getCustomFieldObjectByName
(String customFieldName) Retrieve the first custom field object with the specified name.Returns all custom fields.getCustomFieldObjects
(Issue issue) Get allCustomField
s in scope for this issue's project/type.getCustomFieldObjects
(SearchContext searchContext) Returns all customfields in a particularSearchContext
.getCustomFieldObjects
(Long projectId, String issueTypeId) Gets a list of custom fields for a particular project and issue type.getCustomFieldObjects
(Long projectId, List<String> issueTypeIds) Returns the same asCustomFieldManager.getCustomFieldObjects(Long, String)
but allows to specify a list of issueTypes.getCustomFieldObjects
(org.ofbiz.core.entity.GenericValue issue) Deprecated.getCustomFieldObjectsByName
(String customFieldName) Retrieve custom field(s) of a certain name.getCustomFieldObjectsByNameIgnoreCase
(String customFieldName) Retrieve custom field(s) of a certain name ignoring case.Retrieve a custom field searcher by its type key.Class
<? extends CustomFieldSearcher> Retrieve a custom field searcher by its type key.getCustomFieldSearchers
(CustomFieldType customFieldType) Retrieves all the searchers registered for a particular custom Field.getCustomFieldsWithValue
(Issue issue) Returns a set ofCustomField
s that have value stored in database for particular issue.getCustomFieldType
(String key) Retrieve a custom field type by its type key.List
<CustomFieldType<?, ?>> Retrieve all customfieldtypes registered in the system.getDefaultSearcher
(CustomFieldType<?, ?> type) Return the defaultCustomFieldSearcher
for the passedCustomFieldType
.Returns a list of custom fields where theCustomField.isGlobal()
is true.boolean
isCustomField
(String id) Returns true if this ID is in the Custom Field format.void
onClearCache
(ClearCacheEvent event) void
void
refresh()
reloads all customfields into the cache from the DB, this is an expensive operation, so avoid it if you can.void
void
refreshConfigurationSchemes
(Long customFieldId) Causes a reload of the field configuration scheme for a specified custom field id Call when the configuration scheme changesvoid
removeCustomField
(CustomField customField) Removes the customfield supplied including all associations and values.void
removeCustomFieldPossiblyLeavingOrphanedData
(Long customFieldId) Removes the customfield supplied.void
removeCustomFieldValues
(org.ofbiz.core.entity.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
updateCustomField
(Long id, String name, String description, CustomFieldSearcher searcher) Updates the given custom field.
-
Constructor Details
-
CachingCustomFieldManager
public CachingCustomFieldManager(com.atlassian.plugin.PluginAccessor pluginAccessor, QueryDslAccessor dbConnectionManager, FieldConfigSchemeManager fieldConfigSchemeManager, ConstantsManager constantsManager, ProjectManager projectManager, FieldConfigContextPersister contextPersister, FieldScreenManager fieldScreenManager, CustomFieldValuePersister customFieldValuePersister, NotificationSchemeManager notificationSchemeManager, FieldManager fieldManager, com.atlassian.event.api.EventPublisher eventPublisher, CustomFieldFactory customFieldFactory, CustomFieldTypeModuleDescriptors customFieldTypeModuleDescriptors, CustomFieldSearcherModuleDescriptors customFieldSearcherModuleDescriptors, CustomFieldSearcherManager customFieldSearcherManager, com.atlassian.cache.CacheManager cacheManager)
-
-
Method Details
-
afterInstantiation
Description copied from interface:InitializingComponent
Called after all the beans are constructed and the ApplicationContext is fully populated. Order of execution is order of bean creation, driven by InitializingComponentProcessor.- Specified by:
afterInstantiation
in interfaceInitializingComponent
- Throws:
Exception
-
createCustomField
public CustomField createCustomField(String fieldName, String description, CustomFieldType fieldType, CustomFieldSearcher customFieldSearcher, List<JiraContextNode> contexts, List<IssueType> issueTypes) throws org.ofbiz.core.entity.GenericEntityException Description copied from interface:CustomFieldManager
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.- Specified by:
createCustomField
in interfaceCustomFieldManager
- Returns:
- the newly created CustomField.
- Throws:
org.ofbiz.core.entity.GenericEntityException
- if the CustomField could not be created.
-
getCustomFieldTypes
Description copied from interface:CustomFieldManager
Retrieve all customfieldtypes registered in the system.- Specified by:
getCustomFieldTypes
in interfaceCustomFieldManager
- Returns:
- a list of
CustomFieldType
s
-
getCustomFieldType
Description copied from interface:CustomFieldManager
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'.- Specified by:
getCustomFieldType
in interfaceCustomFieldManager
- Parameters:
key
- Type identifier constructed from plugin XML.- Returns:
- the CustomFieldType for the given key
-
getCustomFieldSearchers
Description copied from interface:CustomFieldManager
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"invalid input: '>'
- Specified by:
getCustomFieldSearchers
in interfaceCustomFieldManager
- Parameters:
customFieldType
- the CustomFieldType- Returns:
- A list of
CustomFieldSearcher
s
-
getCustomFieldSearcher
Description copied from interface:CustomFieldManager
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'.- Specified by:
getCustomFieldSearcher
in interfaceCustomFieldManager
- Parameters:
key
- Type identifier constructed from plugin XML.- Returns:
- the CustomFieldSearcher for the given key
-
getDefaultSearcher
Description copied from interface:CustomFieldManager
Return the defaultCustomFieldSearcher
for the passedCustomFieldType
. The default searcher can be null if there is no searcher associated with the type.- Specified by:
getDefaultSearcher
in interfaceCustomFieldManager
- Parameters:
type
- theCustomFieldType
to query.- Returns:
- the default searcher for the passed
CustomFieldType
. Can be null if the type has no associated searcher.
-
getCustomFieldSearcherClass
Description copied from interface:CustomFieldManager
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'.- Specified by:
getCustomFieldSearcherClass
in interfaceCustomFieldManager
- Parameters:
key
- Type identifier constructed from plugin XML.
-
getCustomFieldObjects
Get allCustomField
s in scope for this issue's project/type.- Specified by:
getCustomFieldObjects
in interfaceCustomFieldManager
- Parameters:
issue
- AIssue
object- Returns:
- A list of
CustomField
s
-
getCustomFieldObjects
Deprecated.Description copied from interface:CustomFieldManager
Returns a list ofCustomField
s that apply to a particular issue.- Specified by:
getCustomFieldObjects
in interfaceCustomFieldManager
- Parameters:
issue
- AGenericValue
of the issue- Returns:
- A list of
CustomField
s
-
getCustomFieldObjects
Description copied from interface:CustomFieldManager
Gets a list of custom fields for a particular project and issue type.- Specified by:
getCustomFieldObjects
in interfaceCustomFieldManager
- Parameters:
projectId
- Id of the projectissueTypeId
- An issue type. SeeConstantsManager.ALL_ISSUE_TYPES
,ConstantsManager.ALL_STANDARD_ISSUE_TYPES
andConstantsManager.ALL_SUB_TASK_ISSUE_TYPES
- Returns:
- A list of
CustomField
s
-
getCustomFieldObjects
Description copied from interface:CustomFieldManager
Returns the same asCustomFieldManager.getCustomFieldObjects(Long, String)
but allows to specify a list of issueTypes.- Specified by:
getCustomFieldObjects
in interfaceCustomFieldManager
- Parameters:
projectId
- Id of the project. It can be null, in which case means that we are looking for "any project" (acts like a wildcard).issueTypeIds
- A list of issue types. It can be null or empty, in which case means that we are looking for "any issue type" (acts like a wildcard). SeeConstantsManager.ALL_ISSUE_TYPES
,ConstantsManager.ALL_STANDARD_ISSUE_TYPES
andConstantsManager.ALL_SUB_TASK_ISSUE_TYPES
- Returns:
- A list of
CustomField
s
-
getCustomFieldObjects
Description copied from interface:CustomFieldManager
Returns all customfields in a particularSearchContext
. Also seeCustomField.isInScope(com.atlassian.jira.issue.search.SearchContext)
.- Specified by:
getCustomFieldObjects
in interfaceCustomFieldManager
- Parameters:
searchContext
- the SearchContext- Returns:
- A list of
CustomField
s
-
getCustomFieldObject
Description copied from interface:CustomFieldManager
Get a CustomField by ID.- Specified by:
getCustomFieldObject
in interfaceCustomFieldManager
- Parameters:
id
- ID of field, eg. 10000- Returns:
- The
CustomField
or null.
-
getCustomFieldObject
Description copied from interface:CustomFieldManager
Get a CustomField by its text key (eg 'customfield_10000').- Specified by:
getCustomFieldObject
in interfaceCustomFieldManager
- Parameters:
key
- Eg. 'customfield_10000'- Returns:
- The
CustomField
or null if not found.
-
isCustomField
Description copied from interface:CustomFieldManager
Returns true if this ID is in the Custom Field format.Note that this does not check if the Custom Field actually exists. It just checks whether the given ID looks like Custom Field ID (eg starts with "customfield_").
- Specified by:
isCustomField
in interfaceCustomFieldManager
- Parameters:
id
- The Field ID- Returns:
- true if this is an ID for a Custom Field.
- See Also:
-
exists
Description copied from interface:CustomFieldManager
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"- Specified by:
exists
in interfaceCustomFieldManager
- Parameters:
key
- Eg. 'customfield_10000'- Returns:
- true if the custom field is returned
- See Also:
-
getCustomFieldObjectByName
Description copied from interface:CustomFieldManager
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. UseCustomFieldManager.getCustomFieldObjectsByName(String)
to retrieve all custom fields.- Specified by:
getCustomFieldObjectByName
in interfaceCustomFieldManager
- Parameters:
customFieldName
- the Name- Returns:
- The first named
CustomField
, or null if not found.
-
getCustomFieldObjectsByName
Description copied from interface:CustomFieldManager
Retrieve custom field(s) of a certain name.- Specified by:
getCustomFieldObjectsByName
in interfaceCustomFieldManager
- Parameters:
customFieldName
- custom field name- Returns:
- A collection of
CustomField
s.
-
getCustomFieldObjectsByNameIgnoreCase
Description copied from interface:CustomFieldManager
Retrieve custom field(s) of a certain name ignoring case.- Specified by:
getCustomFieldObjectsByNameIgnoreCase
in interfaceCustomFieldManager
- Parameters:
customFieldName
- custom field name- Returns:
- A collection of
CustomField
s.
-
getCustomFieldObjects
Description copied from interface:CustomFieldManager
Returns all custom fields.- Specified by:
getCustomFieldObjects
in interfaceCustomFieldManager
- Returns:
- A list of all
CustomField
s.
-
getGlobalCustomFieldObjects
Description copied from interface:CustomFieldManager
Returns a list of custom fields where theCustomField.isGlobal()
is true.- Specified by:
getGlobalCustomFieldObjects
in interfaceCustomFieldManager
- Returns:
- A list of
CustomField
s
-
refresh
public void refresh()Description copied from interface:CustomFieldManager
reloads all customfields into the cache from the DB, this is an expensive operation, so avoid it if you can.- Specified by:
refresh
in interfaceCustomFieldManager
-
refreshConfigurationSchemes
Description copied from interface:CustomFieldManager
Causes a reload of the field configuration scheme for a specified custom field id Call when the configuration scheme changes- Specified by:
refreshConfigurationSchemes
in interfaceCustomFieldManager
- Parameters:
customFieldId
- the custom field ID
-
refreshConfiguration
public void refreshConfiguration() -
clear
public void clear()Description copied from interface:CustomFieldManager
clear the cache- Specified by:
clear
in interfaceCustomFieldManager
-
removeCustomFieldPossiblyLeavingOrphanedData
Description copied from interface:CustomFieldManager
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 theCustomFieldManager.removeCustomField(com.atlassian.jira.issue.fields.CustomField)
method, which will not leave any orphaned data behind.NOTE: Generally you should use the
CustomFieldManager.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
CustomFieldValuePersister.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).- Specified by:
removeCustomFieldPossiblyLeavingOrphanedData
in interfaceCustomFieldManager
- Parameters:
customFieldId
- The id of the customField to be removed.- Throws:
RemoveException
- On any error removing the custom field
-
removeCustomField
Description copied from interface:CustomFieldManager
Removes the customfield supplied including all associations and values.- Specified by:
removeCustomField
in interfaceCustomFieldManager
- Parameters:
customField
- TheCustomField
to be removed.- Throws:
RemoveException
- On any error removing the custom field
-
removeCustomFieldValues
public void removeCustomFieldValues(org.ofbiz.core.entity.GenericValue issue) throws org.ofbiz.core.entity.GenericEntityException Description copied from interface:CustomFieldManager
Removes the values stored by customfields for a particular Issue.- Specified by:
removeCustomFieldValues
in interfaceCustomFieldManager
- Parameters:
issue
- The issueGenericValue
- Throws:
org.ofbiz.core.entity.GenericEntityException
- DB error
-
getCustomFieldsWithValue
Description copied from interface:CustomFieldManager
Returns a set ofCustomField
s that have value stored in database for particular issue.- Specified by:
getCustomFieldsWithValue
in interfaceCustomFieldManager
- Parameters:
issue
- AnIssue
object- Returns:
- A set of
CustomField
s
-
updateCustomField
public void updateCustomField(Long id, String name, String description, CustomFieldSearcher searcher) Description copied from interface:CustomFieldManager
Updates the given custom field.- Specified by:
updateCustomField
in interfaceCustomFieldManager
- Parameters:
id
- the custom field IDname
- the new namedescription
- the new descriptionsearcher
- the new Searcher
-
areConfigSchemesEqual
protected boolean areConfigSchemesEqual(List<FieldConfigScheme> schemes, List<FieldConfigScheme> otherSchemes) -
getCustomFieldInstance
Description copied from interface:CustomFieldManager
Converts a customfieldGenericValue
to aCustomField
instance.- Specified by:
getCustomFieldInstance
in interfaceCustomFieldManager
- Parameters:
customFieldGv
-- Returns:
- a
CustomField
instance
-
removeProjectAssociations
Description copied from interface:CustomFieldManager
Used if a project is deleted to remove the project field associations.- Specified by:
removeProjectAssociations
in interfaceCustomFieldManager
- Parameters:
project
- The project being deleted.
-
onClearCache
-
onTerminologyCacheClearedEvent
-
getCustomFieldObjects(com.atlassian.jira.issue.Issue)