com.atlassian.jira.issue.managers
Class DefaultCustomFieldManager

java.lang.Object
  extended by com.atlassian.jira.issue.managers.DefaultCustomFieldManager
All Implemented Interfaces:
Startable, CustomFieldManager

public class DefaultCustomFieldManager
extends Object
implements CustomFieldManager, Startable


Field Summary
 
Fields inherited from interface com.atlassian.jira.issue.CustomFieldManager
PLUGIN_KEY
 
Constructor Summary
DefaultCustomFieldManager(com.atlassian.plugin.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, com.atlassian.event.api.EventPublisher eventPublisher)
           
 
Method Summary
 void associateCustomFieldContext(CustomField customField, List contexts, List issueTypes)
           
 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.
 CustomField getCustomFieldInstance(org.ofbiz.core.entity.GenericValue customFieldGv)
          Converts a customfield GenericValue to a CustomField instance.
 CustomField getCustomFieldObject(Long id)
          Get a CustomField by ID.
 CustomField getCustomFieldObject(String key)
          Get a CustomField by its text key (eg 'customfield_10000').
 CustomField getCustomFieldObjectByName(String customFieldName)
          Retrieve the first custom field object with the specified name.
 List<CustomField> getCustomFieldObjects()
          Returns all custom fields.
 List<CustomField> getCustomFieldObjects(org.ofbiz.core.entity.GenericValue issue)
          Deprecated. Use getCustomFieldObjects(com.atlassian.jira.issue.Issue)
 List<CustomField> getCustomFieldObjects(Issue issue)
          Get all CustomFields in scope for this issue's project/type.
 List<CustomField> getCustomFieldObjects(Long projectId, List<String> issueTypeIds)
          Returns the same as CustomFieldManager.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(SearchContext searchContext)
          Returns all customfields in a particular SearchContext.
 Collection<CustomField> getCustomFieldObjectsByName(String customFieldName)
          Retrieve custom field(s) of a certain name.
 List getCustomFields(String issueType, Long projectId, int customFieldType)
           
 CustomFieldSearcher getCustomFieldSearcher(String key)
          Retrieve a custom field searcher by its type key.
 Class getCustomFieldSearcherClass(String key)
          Retrieve a custom field searcher by its type key.
 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.
 List getCustomFieldTypes()
          Retrieve all customfieldtypes registered in the sytem.
 List<CustomField> getGlobalCustomFieldObjects()
          Returns a list of custom fields where the CustomField.isGlobal() is true.
 void onClearCache(ClearCacheEvent event)
           
 void refresh()
          reloads all customfields into the cache from the DB.
 void 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(org.ofbiz.core.entity.GenericValue project)
          Used if a project is deleted to remove the project field associations.
 void removeProjectCategoryAssociations(org.ofbiz.core.entity.GenericValue projectCategory)
          Used if a project category is deleted to remove the field associations.
 void start()
          This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCustomFieldManager

public DefaultCustomFieldManager(com.atlassian.plugin.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,
                                 com.atlassian.event.api.EventPublisher eventPublisher)
Method Detail

start

public void start()
           throws Exception
Description copied from interface: Startable
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.

Specified by:
start in interface Startable
Throws:
Exception - Allows implementations to throw an Exception.

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

createCustomField

public CustomField createCustomField(String fieldName,
                                     String description,
                                     CustomFieldType fieldType,
                                     CustomFieldSearcher customFieldSearcher,
                                     List contexts,
                                     List 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 interface CustomFieldManager
Returns:
the newly created CustomField.
Throws:
org.ofbiz.core.entity.GenericEntityException - if the CustomField could not be created.

associateCustomFieldContext

public void associateCustomFieldContext(CustomField customField,
                                        List contexts,
                                        List issueTypes)

getCustomFieldTypes

public List getCustomFieldTypes()
Description copied from interface: CustomFieldManager
Retrieve all customfieldtypes registered in the sytem.

Specified by:
getCustomFieldTypes in interface CustomFieldManager
Returns:
a list og CustomFieldTypes

getCustomFieldType

public CustomFieldType getCustomFieldType(String key)
Description copied from interface: CustomFieldManager
Retrieve a custom field type by its type key.

Specified by:
getCustomFieldType in interface CustomFieldManager
Parameters:
key - Type identifier constructed from plugin XML. Eg. the system types are specified in system-customfiedltypes-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' (the first part can be referred to via CreateCustomField.FIELD_TYPE_PREFIX).

getCustomFieldSearchers

public List<CustomFieldSearcher> getCustomFieldSearchers(CustomFieldType customFieldType)
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">
 

Specified by:
getCustomFieldSearchers in interface CustomFieldManager
Returns:
A list of CustomFieldSearchers

getCustomFieldSearcher

public CustomFieldSearcher getCustomFieldSearcher(String key)
Description copied from interface: CustomFieldManager
Retrieve a custom field searcher by its type key.

Specified by:
getCustomFieldSearcher in interface CustomFieldManager
Parameters:
key - Type identifier constructed from plugin XML. Eg. the system types are specified in system-customfiedltypes-plugin.xml:
                                                                              <atlassian-plugin key="com.atlassian.jira.plugin.system.customfieldtypes" name="Custom Field Types & Searchers">
                                                                                ...
                                                                                 <customfield-searcher key="exactnumber" name="Number Searcher"
                       

...

To access the 'Number Searcher' searcher, the key would then be 'com.atlassian.jira.plugin.system.customfieldtypes:exactnumber' (the first part can be referred to via CreateCustomField.FIELD_TYPE_PREFIX).

getCustomFieldSearcherClass

public Class getCustomFieldSearcherClass(String key)
Description copied from interface: CustomFieldManager
Retrieve a custom field searcher by its type key.

Specified by:
getCustomFieldSearcherClass in interface CustomFieldManager
Parameters:
key - Type identifier constructed from plugin XML. Eg. the system types are specified in system-customfiedltypes-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' (the first part can be referred to via CreateCustomField.FIELD_TYPE_PREFIX).

getCustomFieldObjects

public List<CustomField> getCustomFieldObjects(Issue issue)
Get all CustomFields in scope for this issue's project/type.

Specified by:
getCustomFieldObjects in interface CustomFieldManager
Parameters:
issue - A Issue object
Returns:
A list of CustomFields

getCustomFieldObjects

public List<CustomField> getCustomFieldObjects(org.ofbiz.core.entity.GenericValue issue)
Deprecated. Use getCustomFieldObjects(com.atlassian.jira.issue.Issue)

Description copied from interface: CustomFieldManager
Returns a list of CustomFields that apply to a particular issue.

Specified by:
getCustomFieldObjects in interface CustomFieldManager
Parameters:
issue - A GenericValue of the issue
Returns:
A list of CustomFields

getCustomFieldObjects

public List<CustomField> getCustomFieldObjects(Long projectId,
                                               String issueTypeId)
Description copied from interface: CustomFieldManager
Gets a list of custom fields for a particular project and issue type.

Specified by:
getCustomFieldObjects in interface CustomFieldManager
Parameters:
projectId - Id of the project
issueTypeId - An issue type. See ConstantsManager.ALL_ISSUE_TYPES, ConstantsManager.ALL_STANDARD_ISSUE_TYPES and ConstantsManager.ALL_SUB_TASK_ISSUE_TYPES
Returns:
A list of CustomFields

getCustomFieldObjects

public List<CustomField> getCustomFieldObjects(Long projectId,
                                               List<String> issueTypeIds)
Description copied from interface: CustomFieldManager
Returns the same as CustomFieldManager.getCustomFieldObjects(Long,String) but allows to specify a list of issueTypes.

Specified by:
getCustomFieldObjects in interface CustomFieldManager
Parameters:
projectId - Id of the project
issueTypeIds - A list of issue types. See ConstantsManager.ALL_ISSUE_TYPES, ConstantsManager.ALL_STANDARD_ISSUE_TYPES and ConstantsManager.ALL_SUB_TASK_ISSUE_TYPES
Returns:
A list of CustomFields

getCustomFieldObjects

public List<CustomField> getCustomFieldObjects(SearchContext searchContext)
Description copied from interface: CustomFieldManager
Returns all customfields in a particular SearchContext. Also see CustomField.isInScope(com.opensymphony.user.User,com.atlassian.jira.issue.search.SearchContext).

Specified by:
getCustomFieldObjects in interface CustomFieldManager
Returns:
A list of CustomFields

getCustomFieldObject

public CustomField getCustomFieldObject(Long id)
Description copied from interface: CustomFieldManager
Get a CustomField by ID.

Specified by:
getCustomFieldObject in interface CustomFieldManager
Parameters:
id - ID of field, eg. 10000
Returns:
The CustomField or null.

getCustomFieldObject

public CustomField getCustomFieldObject(String key)
Description copied from interface: CustomFieldManager
Get a CustomField by its text key (eg 'customfield_10000').

Specified by:
getCustomFieldObject in interface CustomFieldManager
Parameters:
key - Eg. 'customfield_10000'
Returns:
The CustomField or null if not found.

getCustomFieldObjectByName

public CustomField getCustomFieldObjectByName(String customFieldName)
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. Use CustomFieldManager.getCustomFieldObjectsByName(String) to retrieve all custom fields.

Specified by:
getCustomFieldObjectByName in interface CustomFieldManager
Returns:
The first named CustomField, or null if not found.

getCustomFieldObjectsByName

public Collection<CustomField> getCustomFieldObjectsByName(String customFieldName)
Description copied from interface: CustomFieldManager
Retrieve custom field(s) of a certain name.

Specified by:
getCustomFieldObjectsByName in interface CustomFieldManager
Returns:
A collection of CustomFields.

getCustomFieldObjects

public List<CustomField> getCustomFieldObjects()
Description copied from interface: CustomFieldManager
Returns all custom fields.

Specified by:
getCustomFieldObjects in interface CustomFieldManager
Returns:
A list of all CustomFields.

getGlobalCustomFieldObjects

public List<CustomField> getGlobalCustomFieldObjects()
Description copied from interface: CustomFieldManager
Returns a list of custom fields where the CustomField.isGlobal() is true.

Specified by:
getGlobalCustomFieldObjects in interface CustomFieldManager
Returns:
A list of CustomFields

refresh

public void refresh()
Description copied from interface: CustomFieldManager
reloads all customfields into the cache from the DB.

Specified by:
refresh in interface CustomFieldManager

getCustomFields

public List getCustomFields(String issueType,
                            Long projectId,
                            int customFieldType)
                     throws org.ofbiz.core.entity.GenericEntityException
Throws:
org.ofbiz.core.entity.GenericEntityException

removeCustomFieldPossiblyLeavingOrphanedData

public void removeCustomFieldPossiblyLeavingOrphanedData(Long customFieldId)
                                                  throws RemoveException
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 the CustomFieldManager.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 interface CustomFieldManager
Parameters:
customFieldId - The id of the customField to be removed.
Throws:
RemoveException - On any error removing the custom field

removeCustomField

public void removeCustomField(CustomField customField)
                       throws RemoveException
Description copied from interface: CustomFieldManager
Removes the customfield supplied including all associations and values.

Specified by:
removeCustomField in interface CustomFieldManager
Parameters:
customField - The CustomField 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 interface CustomFieldManager
Parameters:
issue - The issue GenericValue
Throws:
org.ofbiz.core.entity.GenericEntityException

getCustomFieldInstance

public CustomField getCustomFieldInstance(org.ofbiz.core.entity.GenericValue customFieldGv)
Description copied from interface: CustomFieldManager
Converts a customfield GenericValue to a CustomField instance.

Specified by:
getCustomFieldInstance in interface CustomFieldManager
Returns:
a CustomField instance

removeProjectAssociations

public void removeProjectAssociations(org.ofbiz.core.entity.GenericValue project)
Description copied from interface: CustomFieldManager
Used if a project is deleted to remove the project field associations.

Specified by:
removeProjectAssociations in interface CustomFieldManager
Parameters:
project - The project being deleted.

removeProjectCategoryAssociations

public void removeProjectCategoryAssociations(org.ofbiz.core.entity.GenericValue projectCategory)
Description copied from interface: CustomFieldManager
Used if a project category is deleted to remove the field associations.

Specified by:
removeProjectCategoryAssociations in interface CustomFieldManager
Parameters:
projectCategory - The project category being deleted.


Copyright © 2002-2010 Atlassian. All Rights Reserved.