public class MockCustomFieldManager extends Object implements CustomFieldManager
Constructor and Description |
---|
MockCustomFieldManager() |
Modifier and Type | Method and Description |
---|---|
void |
addCustomField(CustomField customField) |
void |
addCustomFieldType(String key,
CustomFieldType customFieldType) |
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 id)
Returns true if this customfield actually exists.
|
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 id)
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 |
getCustomFieldObjects()
Returns all custom fields.
|
List |
getCustomFieldObjects(org.ofbiz.core.entity.GenericValue issue)
Returns a list of
CustomField s that apply to a particular issue. |
List |
getCustomFieldObjects(Issue issue)
Returns a list of
CustomField s that apply to a particular issue. |
List |
getCustomFieldObjects(Long projectId,
List issueTypes)
Returns the same as
CustomFieldManager.getCustomFieldObjects(Long, String) but allows to specify a list of issueTypes. |
List |
getCustomFieldObjects(Long projectId,
String issueType)
Gets a list of custom fields for a particular project and issue type.
|
List |
getCustomFieldObjects(SearchContext searchContext)
Returns all customfields in a particular
SearchContext . |
Collection |
getCustomFieldObjectsByName(String customFieldName)
Retrieve custom field(s) of a certain name.
|
Collection<CustomField> |
getCustomFieldObjectsByNameIgnoreCase(String customFieldName)
Retrieve custom field(s) of a certain name ignoring case.
|
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 |
getCustomFieldSearchers(CustomFieldType customFieldType)
Retrieves all the searchers registered for a particular custom Field.
|
Set<CustomField> |
getCustomFieldsWithValue(Issue issue)
Returns a set of
CustomField s that have value stored in database for particular issue. |
CustomFieldType |
getCustomFieldType(String key)
Retrieve a custom field type by its type key.
|
List |
getCustomFieldTypes()
Retrieve all customfieldtypes registered in the system.
|
CustomFieldSearcher |
getDefaultSearcher(CustomFieldType<?,?> type)
Return the default
CustomFieldSearcher for the passed CustomFieldType . |
List |
getGlobalCustomFieldObjects()
Returns a list of custom fields where the
CustomField.isGlobal()
is true. |
boolean |
isCustomField(String id)
Returns true if this ID is in the Custom Field format.
|
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 id)
Removes the customfield supplied.
|
void |
removeCustomFieldValues(org.ofbiz.core.entity.GenericValue genericValue)
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.
|
public List getCustomFieldObjects(SearchContext searchContext)
CustomFieldManager
SearchContext
. Also
see CustomField.isInScope(com.atlassian.jira.issue.search.SearchContext)
.getCustomFieldObjects
in interface CustomFieldManager
searchContext
- the SearchContextCustomField
spublic Class getCustomFieldSearcherClass(String key)
CustomFieldManager
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'.
getCustomFieldSearcherClass
in interface CustomFieldManager
key
- Type identifier constructed from plugin XML.public void refreshConfigurationSchemes(Long customFieldId)
CustomFieldManager
refreshConfigurationSchemes
in interface CustomFieldManager
customFieldId
- the custom field IDpublic void removeProjectAssociations(Project project)
CustomFieldManager
removeProjectAssociations
in interface CustomFieldManager
project
- The project being deleted.public void removeCustomField(CustomField customField)
CustomFieldManager
removeCustomField
in interface CustomFieldManager
customField
- The CustomField
to be removed.public void updateCustomField(Long id, String name, String description, CustomFieldSearcher searcher)
CustomFieldManager
updateCustomField
in interface CustomFieldManager
id
- the custom field IDname
- the new namedescription
- the new descriptionsearcher
- the new Searcherpublic void removeCustomFieldValues(org.ofbiz.core.entity.GenericValue genericValue) throws org.ofbiz.core.entity.GenericEntityException
CustomFieldManager
removeCustomFieldValues
in interface CustomFieldManager
genericValue
- The issue GenericValue
org.ofbiz.core.entity.GenericEntityException
- DB error@Nonnull public Set<CustomField> getCustomFieldsWithValue(@Nonnull Issue issue)
CustomFieldManager
CustomField
s that have value stored in database for particular issue.getCustomFieldsWithValue
in interface CustomFieldManager
issue
- An Issue
objectCustomField
s@Nullable public CustomField getCustomFieldObject(Long id)
CustomFieldManager
getCustomFieldObject
in interface CustomFieldManager
id
- ID of field, eg. 10000CustomField
or null.public boolean exists(String id)
CustomFieldManager
exists
in interface CustomFieldManager
id
- Eg. 'customfield_10000'CustomFieldManager.isCustomField(String)
@Nullable public CustomField getCustomFieldObject(String id)
CustomFieldManager
getCustomFieldObject
in interface CustomFieldManager
id
- Eg. 'customfield_10000'CustomField
or null if not found.public boolean isCustomField(String id)
CustomFieldManager
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_").
isCustomField
in interface CustomFieldManager
id
- The Field IDCustomFieldManager.exists(String)
public List getCustomFieldObjects()
CustomFieldManager
getCustomFieldObjects
in interface CustomFieldManager
CustomField
s.public List getGlobalCustomFieldObjects()
CustomFieldManager
CustomField.isGlobal()
is true.getGlobalCustomFieldObjects
in interface CustomFieldManager
CustomField
spublic void refresh()
CustomFieldManager
refresh
in interface CustomFieldManager
public void clear()
CustomFieldManager
clear
in interface CustomFieldManager
public List getCustomFieldObjects(Long projectId, String issueType)
CustomFieldManager
getCustomFieldObjects
in interface CustomFieldManager
projectId
- Id of the projectissueType
- An issue type. See ConstantsManager.ALL_ISSUE_TYPES
,
ConstantsManager.ALL_STANDARD_ISSUE_TYPES
and ConstantsManager.ALL_SUB_TASK_ISSUE_TYPES
CustomField
spublic List getCustomFieldObjects(Long projectId, List issueTypes)
CustomFieldManager
CustomFieldManager.getCustomFieldObjects(Long, String)
but allows to specify a list of issueTypes.getCustomFieldObjects
in interface CustomFieldManager
projectId
- Id of the project. It can be null, in which case means that we are looking for "any project" (acts like a wildcard).issueTypes
- 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).
See ConstantsManager.ALL_ISSUE_TYPES
, ConstantsManager.ALL_STANDARD_ISSUE_TYPES
and ConstantsManager.ALL_SUB_TASK_ISSUE_TYPES
CustomField
sCustomField#isInScopeForSearch(com.atlassian.jira.project.Project, java.util.List)} for a full description on how wildcards are treated.
public List getCustomFieldObjects(org.ofbiz.core.entity.GenericValue issue)
CustomFieldManager
CustomField
s that apply to a particular issue.getCustomFieldObjects
in interface CustomFieldManager
issue
- A GenericValue
of the issueCustomField
spublic List getCustomFieldObjects(Issue issue)
CustomFieldManager
CustomField
s that apply to a particular issue.getCustomFieldObjects
in interface CustomFieldManager
issue
- A Issue
objectCustomField
s@Nonnull public List getCustomFieldTypes()
CustomFieldManager
getCustomFieldTypes
in interface CustomFieldManager
CustomFieldType
spublic CustomFieldType getCustomFieldType(String key)
CustomFieldManager
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'.
getCustomFieldType
in interface CustomFieldManager
key
- Type identifier constructed from plugin XML.public void addCustomFieldType(String key, CustomFieldType customFieldType)
@Nonnull public List getCustomFieldSearchers(CustomFieldType customFieldType)
CustomFieldManager
<customfield-searcher key="daterange" name="Date Range picker" i18n-name-key="admin.customfield.searcher.daterange.name" class="com.atlassian.jira.issue.customfields.searchers.DateRangeSearcher">
getCustomFieldSearchers
in interface CustomFieldManager
customFieldType
- the CustomFieldTypeCustomFieldSearcher
spublic CustomFieldSearcher getCustomFieldSearcher(String key)
CustomFieldManager
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'.
getCustomFieldSearcher
in interface CustomFieldManager
key
- Type identifier constructed from plugin XML.@Nullable public CustomFieldSearcher getDefaultSearcher(@Nonnull CustomFieldType<?,?> type)
CustomFieldManager
CustomFieldSearcher
for the passed CustomFieldType
. The default searcher can
be null if there is no searcher associated with the type.getDefaultSearcher
in interface CustomFieldManager
type
- the CustomFieldType
to query.CustomFieldType
. Can be null if the type has no associated
searcher.public void addCustomField(CustomField customField)
public CustomField getCustomFieldObjectByName(String customFieldName)
CustomFieldManager
CustomFieldManager.getCustomFieldObjectsByName(String)
to retrieve all custom fields.getCustomFieldObjectByName
in interface CustomFieldManager
customFieldName
- the NameCustomField
, or null if not found.public Collection getCustomFieldObjectsByName(String customFieldName)
CustomFieldManager
getCustomFieldObjectsByName
in interface CustomFieldManager
customFieldName
- custom field nameCustomField
s.public Collection<CustomField> getCustomFieldObjectsByNameIgnoreCase(String customFieldName)
CustomFieldManager
getCustomFieldObjectsByNameIgnoreCase
in interface CustomFieldManager
customFieldName
- custom field nameCustomField
s.public CustomField createCustomField(String fieldName, String description, CustomFieldType fieldType, CustomFieldSearcher customFieldSearcher, List contexts, List issueTypes) throws org.ofbiz.core.entity.GenericEntityException
CustomFieldManager
createCustomField
in interface CustomFieldManager
org.ofbiz.core.entity.GenericEntityException
- if the CustomField could not be created.public void removeCustomFieldPossiblyLeavingOrphanedData(Long id) throws RemoveException
CustomFieldManager
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).
removeCustomFieldPossiblyLeavingOrphanedData
in interface CustomFieldManager
id
- The id of the customField to be removed.RemoveException
- On any error removing the custom fieldpublic CustomField getCustomFieldInstance(org.ofbiz.core.entity.GenericValue customFieldGv)
CustomFieldManager
GenericValue
to a CustomField
instance.getCustomFieldInstance
in interface CustomFieldManager
CustomField
instanceCopyright © 2002-2022 Atlassian. All Rights Reserved.