com.atlassian.jira.issue
Interface CustomFieldManager

All Known Implementing Classes:
DefaultCustomFieldManager

public interface CustomFieldManager

Functions for working with CustomFields.


Field Summary
static java.lang.String PLUGIN_KEY
           
 
Method Summary
 CustomField createCustomField(java.lang.String fieldName, java.lang.String description, CustomFieldType fieldType, CustomFieldSearcher customFieldSearcher, java.util.List contexts, java.util.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(java.lang.Long id)
          Get a CustomField by ID.
 CustomField getCustomFieldObject(java.lang.String id)
          Get a CustomField by its text key (eg 'customfield_10000').
 CustomField getCustomFieldObjectByName(java.lang.String customFieldName)
          Retrieve the first custom field object with the specified name.
 java.util.List<CustomField> getCustomFieldObjects()
          Returns all custom fields.
 java.util.List<CustomField> getCustomFieldObjects(org.ofbiz.core.entity.GenericValue issue)
          Returns a list of CustomFields that apply to a particular issue.
 java.util.List<CustomField> getCustomFieldObjects(Issue issue)
          Returns a list of CustomFields that apply to a particular issue.
 java.util.List<CustomField> getCustomFieldObjects(java.lang.Long projectId, java.util.List<java.lang.String> issueTypes)
          Returns the same as getCustomFieldObjects(Long,String) but allows to specify a list of issueTypes.
 java.util.List<CustomField> getCustomFieldObjects(java.lang.Long projectId, java.lang.String issueType)
          Gets a list of custom fields for a particular project and issue type.
 java.util.List<CustomField> getCustomFieldObjects(SearchContext searchContext)
          Returns all customfields in a particular SearchContext.
 java.util.Collection<CustomField> getCustomFieldObjectsByName(java.lang.String customFieldName)
          Retrieve custom field(s) of a certain name.
 CustomFieldSearcher getCustomFieldSearcher(java.lang.String key)
          Retrieve a custom field searcher by its type key.
 java.lang.Class getCustomFieldSearcherClass(java.lang.String key)
          Retrieve a custom field searcher by its type key.
 java.util.List getCustomFieldSearchers(CustomFieldType customFieldType)
          Retrieves all the searchers registered for a particular custom Field.
 CustomFieldType getCustomFieldType(java.lang.String key)
          Retrieve a custom field type by its type key.
 java.util.List getCustomFieldTypes()
          Retrieve all customfieldtypes registered in the sytem.
 java.util.List<CustomField> getGlobalCustomFieldObjects()
          Returns a list of custom fields where the CustomField.isGlobal() is true.
 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(java.lang.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.
 

Field Detail

PLUGIN_KEY

static final java.lang.String PLUGIN_KEY
See Also:
Constant Field Values
Method Detail

getCustomFieldObjectsByName

java.util.Collection<CustomField> getCustomFieldObjectsByName(java.lang.String customFieldName)
Retrieve custom field(s) of a certain name.

Parameters:
customFieldName -
Returns:
A collection of CustomFields.

getCustomFieldObjectByName

CustomField getCustomFieldObjectByName(java.lang.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 -
Returns:
The first named CustomField, or null if not found.

getCustomFieldObject

CustomField getCustomFieldObject(java.lang.Long id)
Get a CustomField by ID.

Parameters:
id - ID of field, eg. 10000
Returns:
The CustomField or null.

getCustomFieldObject

CustomField getCustomFieldObject(java.lang.String id)
Get a CustomField by its text key (eg 'customfield_10000').

Parameters:
id - Eg. 'customfield_10000'
Returns:
The CustomField or null if not found.

getCustomFieldObjects

java.util.List<CustomField> getCustomFieldObjects()
Returns all custom fields.

Returns:
A list of all CustomFields.

getGlobalCustomFieldObjects

java.util.List<CustomField> getGlobalCustomFieldObjects()
Returns a list of custom fields where the CustomField.isGlobal() is true.

Returns:
A list of CustomFields

getCustomFieldObjects

java.util.List<CustomField> getCustomFieldObjects(java.lang.Long projectId,
                                                  java.lang.String issueType)
Gets a list of custom fields for a particular project and issue type.

Parameters:
projectId - Id of the project
issueType - 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

java.util.List<CustomField> getCustomFieldObjects(java.lang.Long projectId,
                                                  java.util.List<java.lang.String> issueTypes)
Returns the same as getCustomFieldObjects(Long,String) but allows to specify a list of issueTypes.

Parameters:
projectId - Id of the project
issueTypes - 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

java.util.List<CustomField> getCustomFieldObjects(SearchContext searchContext)
Returns all customfields in a particular SearchContext. Also see CustomField.isInScope(com.opensymphony.user.User,com.atlassian.jira.issue.search.SearchContext).

Parameters:
searchContext -
Returns:
A list of CustomFields

getCustomFieldObjects

java.util.List<CustomField> getCustomFieldObjects(org.ofbiz.core.entity.GenericValue issue)
Returns a list of CustomFields that apply to a particular issue.

Parameters:
issue - A GenericValue of the issue
Returns:
A list of CustomFields

getCustomFieldObjects

java.util.List<CustomField> getCustomFieldObjects(Issue issue)
Returns a list of CustomFields that apply to a particular issue.

Parameters:
issue - A Issue object
Returns:
A list of CustomFields

getCustomFieldTypes

java.util.List getCustomFieldTypes()
Retrieve all customfieldtypes registered in the sytem.

Returns:
a list og CustomFieldTypes

getCustomFieldType

CustomFieldType getCustomFieldType(java.lang.String key)
Retrieve a custom field type by its type key.

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

java.util.List 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 -
Returns:
A list of CustomFieldSearchers

getCustomFieldSearcher

CustomFieldSearcher getCustomFieldSearcher(java.lang.String key)
Retrieve a custom field searcher by its type key.

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).

createCustomField

CustomField createCustomField(java.lang.String fieldName,
                              java.lang.String description,
                              CustomFieldType fieldType,
                              CustomFieldSearcher customFieldSearcher,
                              java.util.List contexts,
                              java.util.List issueTypes)
                              throws org.ofbiz.core.entity.GenericEntityException
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:
org.ofbiz.core.entity.GenericEntityException - if the CustomField could not be created.

removeCustomFieldPossiblyLeavingOrphanedData

void removeCustomFieldPossiblyLeavingOrphanedData(java.lang.Long customFieldId)
                                                  throws RemoveException,
                                                         java.lang.IllegalArgumentException
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 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).

Parameters:
customFieldId - The id of the customField to be removed.
Throws:
RemoveException - On any error removing the custom field
java.lang.IllegalArgumentException - If no customfield matching the customFieldId can be found

removeCustomField

void removeCustomField(CustomField customField)
                       throws RemoveException
Removes the customfield supplied including all associations and values.

Parameters:
customField - The CustomField to be removed.
Throws:
RemoveException - On any error removing the custom field

removeCustomFieldValues

void removeCustomFieldValues(org.ofbiz.core.entity.GenericValue issue)
                             throws org.ofbiz.core.entity.GenericEntityException
Removes the values stored by customfields for a particular Issue.

Parameters:
issue - The issue GenericValue
Throws:
org.ofbiz.core.entity.GenericEntityException

removeProjectAssociations

void removeProjectAssociations(org.ofbiz.core.entity.GenericValue project)
Used if a project is deleted to remove the project field associations.

Parameters:
project - The project being deleted.

removeProjectCategoryAssociations

void removeProjectCategoryAssociations(org.ofbiz.core.entity.GenericValue projectCategory)
Used if a project category is deleted to remove the field associations.

Parameters:
projectCategory - The project category being deleted.

getCustomFieldInstance

CustomField getCustomFieldInstance(org.ofbiz.core.entity.GenericValue customFieldGv)
Converts a customfield GenericValue to a CustomField instance.

Parameters:
customFieldGv -
Returns:
a CustomField instance

refresh

void refresh()
reloads all customfields into the cache from the DB.


getCustomFieldSearcherClass

java.lang.Class getCustomFieldSearcherClass(java.lang.String key)
Retrieve a custom field searcher by its type key.

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).


Copyright © 2002-2010 Atlassian. All Rights Reserved.