public class

MockCustomField

extends Object
implements CustomField
java.lang.Object
   ↳ com.atlassian.jira.issue.fields.MockCustomField

Class Overview

Simple implementation of CustomField for.

Summary

[Expand]
Inherited Constants
From interface com.atlassian.jira.issue.fields.CustomField
From interface com.atlassian.jira.issue.fields.NavigableField
From interface com.atlassian.jira.issue.fields.OrderableField
Public Constructors
MockCustomField()
MockCustomField(String id, String name, CustomFieldType customFieldType)
Public Methods
String availableForBulkEdit(BulkEditBean bulkEditBean)
Determines whether the field is available for bulk editing given the BulkEditBean.
boolean canRemoveValueFromIssueObject(Issue issue)
Returns true if a call to removeValueFromIssueObject(com.atlassian.jira.issue.MutableIssue) will actually remove the value.
int compare(Issue issue1, Issue issue2)
This method compares the values of this custom field in two given issues.
int compareTo(Object o)
SearchHandler createAssociatedSearchHandler()
Return SearchHandler for the field.
MockCustomFieldType createCustomFieldType()
void createValue(Issue issue, Object value)
List<IssueType> getAssociatedIssueTypeObjects()
Returns a list of issue types associated with this custom field.
List<IssueType> getAssociatedIssueTypes()
Returns a list of issue types associated with this custom field.
List<Project> getAssociatedProjectObjects()
Returns a list of projects associated with this custom field.
String getBulkEditHtml(OperationContext operationContext, Action action, BulkEditBean bulkEditBean, Map displayParameters)
Returns HTML that should be shown when the issue is being bulk edited.
ClauseNames getClauseNames()
Return the JQL clause names that this custom field should be recognized by.
String getColumnCssClass()
String getColumnHeadingKey()
String getColumnViewHtml(FieldLayoutItem fieldLayoutItem, Map displayParams, Issue issue)
List<FieldConfigItemType> getConfigurationItemTypes()
Returns a List of FieldConfigItemType objects.
List<FieldConfigScheme> getConfigurationSchemes()
Returns a list of configuration schemes.
String getCreateHtml(FieldLayoutItem fieldLayoutItem, OperationContext operationContext, Action action, Issue issue, Map displayParameters)
Returns the HTML that should be shown when the issue is being created.
String getCreateHtml(FieldLayoutItem fieldLayoutItem, OperationContext operationContext, Action action, Issue issue)
Returns the HTML that should be shown when the issue is being created.
CustomFieldSearcher getCustomFieldSearcher()
Retrieves the CustomFieldSearcher for this custom field.
CustomFieldType getCustomFieldType()
Looks up the CustomFieldType.
CustomFieldParams getCustomFieldValues(Map customFieldValuesHolder)
Get the custom field string values that are relevant to this particular custom field
String getDefaultSortOrder()
The order in which to sort the field when it is sorted for the first time.
Object getDefaultValue(Issue issue)
The value that should be set on the issue if the field is not shown for some reason.
String getDescription()
Returns the 1i8n'ed description of this custom field.
@Nonnull RenderableProperty getDescriptionProperty()
Returns a RenderableProperty for rendering this custom field's description.
String getEditHtml(FieldLayoutItem fieldLayoutItem, OperationContext operationContext, Action action, Issue issue, Map displayParameters)
Returns HTML that should be shown when the issue is being edited.
String getEditHtml(FieldLayoutItem fieldLayoutItem, OperationContext operationContext, Action action, Issue issue)
Returns HTML that should be shown when the issue is being edited.
String getFieldName()
Returns the title of this custom field.
FieldTypeInfo getFieldTypeInfo(FieldTypeInfoContext fieldTypeInfoContext)
Returns lower level Information about the field.
GenericValue getGenericValue()
Returns a generic value that represents this custom field
String getHiddenFieldId()
Returns the id of the field to check for visibility.
String getId()
Returns the identifier for this RenderableField.
Long getIdAsLong()
Returns ID of this custom field.
JsonData getJsonDefaultValue(IssueContext issueCtx)
Return The default data for this system field.
FieldJsonRepresentation getJsonFromIssue(Issue issue, boolean renderedVersionRequested, FieldLayoutItem fieldLayoutItem)
Return a FieldJsonDataPair containing a json representation of the raw data for this field, and if required, a json representation of the rendered data for easy display.
JsonType getJsonSchema()
Return a description of the shape of this field when represented as JSON.
String getName()
Returns i18n'ed name of the field.
String getNameKey()
The i18n key that is used to lookup the field's name when it is displayed
Options getOptions(String key, FieldConfig config, JiraContextNode contextNode)
Returns options for this custom field if it is of MultipleCustomFieldType type.
Options getOptions(String key, JiraContextNode jiraContextNode)
Returns options for this custom field if it is of MultipleCustomFieldType type.
PropertySet getPropertySet()
FieldConfig getRelevantConfig(Issue issue)
Returns a relevant FieldConfig for the given issue.
FieldConfig getRelevantConfig(IssueContext issueContext)
Returns the relevant field config of this custom field for the give issue context
FieldConfig getReleventConfig(SearchContext searchContext)
The FieldConfig that is relevent to all issue contexts in the search context Checks that all configs within search context are the same - i.e.
RestFieldOperationsHandler getRestFieldOperation()
FieldComparatorSource getSortComparatorSource()
A sortComparatorSource object to be used for sorting columns in a table.
List<SortField> getSortFields(boolean sortOrder)
Return a list of Lucene SortFields to be used for sorting search results.
LuceneFieldSorter getSorter()
A sorter to be used when sorting columns in a table.
String getUntranslatedDescription()
Returns the description of this custom field by reading ENTITY_DESCRIPTION of the underlying generic value.
@Nonnull RenderableProperty getUntranslatedDescriptionProperty()
Returns a RenderableProperty for rendering this custom field's untranslated description, for admin.
String getUntranslatedName()
Returns the name of this custom field by reading ENTITY_NAME of the underlying generic value.
Object getValue(Issue issue)
Retrieves and returns the Object representing the this CustomField value for the given issue.
String getValueFromIssue(Issue issue)
Gets the value stored for this field on the provided issue.
Object getValueFromParams(Map params)
Get a field value from the map of parameters passed.
String getViewHtml(FieldLayoutItem fieldLayoutItem, Action action, Issue issue)
String getViewHtml(FieldLayoutItem fieldLayoutItem, Action action, Issue issue, Object value, Map displayParameters)
String getViewHtml(FieldLayoutItem fieldLayoutItem, Action action, Issue issue, Map displayParameters)
boolean hasParam(Map parameters)
boolean hasValue(Issue issue)
Determines if the field has a value for the given issue.
boolean isAllIssueTypes()
Returns true if it applies for all issue types, false otherwise.
boolean isAllProjects()
Checks whether this custom field applies for all projects.
boolean isEditable()
Returns true if this custom field can be edited, false otherwise.
boolean isEnabled()
Returns true if all configuration schemes returned by getConfigurationSchemes() are enabled.
boolean isGlobal()
Returns true if this custom field applies for all projects and all issue types.
boolean isInScope(Project project, List<String> issueTypeIds)
Determines if this custom field is within the scope of the given project, and list of Issue Types.
boolean isInScope(long projectId, String issueTypeId)
Determines if this custom field is within the scope of the given project, and Issue Type.
boolean isInScope(SearchContext searchContext)
Determines whether this custom field is in scope.
boolean isInScopeForSearch(Project project, List<String> issueTypeIds)
Determines if this custom field is within the scope of the given project, and list of Issue Types.
boolean isRelevantForIssueContext(IssueContext issueContext)
Returns true if the custom field has a config for the Project and Issue Type of the given IssueContext.
boolean isRenderable()
Defines if a field determines itself as renderable.
boolean isShown(Issue issue)
Tests field specific way to determine if it should be shown or not.
MessagedResult needsMove(Collection originalIssues, Issue targetIssue, FieldLayoutItem targetFieldLayoutItem)
Used to determine if the field needs input from user to be moved to the new project and/or issue type.
void populateDefaults(Map fieldValuesHolder, Issue issue)
void populateForMove(Map<StringObject> fieldValuesHolder, Issue originalIssue, Issue targetIssue)
Used to populate the fieldValueHolder with parameters for move issue screen.
void populateFromIssue(Map fieldValuesHolder, Issue issue)
void populateFromParams(Map fieldValuesHolder, Map parameters)
void populateParamsFromString(Map fieldValuesHolder, String stringValue, Issue issue)
String prettyPrintChangeHistory(String changeHistory, I18nHelper i18nHelper)
Used for email notification templates - allows changelog to be displayed in language of the recipient.
String prettyPrintChangeHistory(String changeHistory)
Set<Long> remove()
Removes this custom field and returns a set of issue IDs of all issues that are affected by removal of this custom field.
void removeValueFromIssueObject(MutableIssue issue)
Removes the field value from the given MutableIssue object.
MockCustomField setCustomFieldType(CustomFieldType type)
MockCustomField setId(String id)
String toString()
void updateIssue(FieldLayoutItem fieldLayoutItem, MutableIssue issue, Map fieldValueHolder)
Record the value on the issue (not saving it to the database, see updateValue).
void updateValue(FieldLayoutItem fieldLayoutItem, Issue issue, ModifiedValue modifiedValue, IssueChangeHolder issueChangeHolder)
Update the issue in the data store.
void validateFromActionParams(Map actionParameters, ErrorCollection errorCollection, FieldConfig config)
Validates relevant parameters on custom field type of this custom field.
void validateParams(OperationContext operationContext, ErrorCollection errorCollectionToAddTo, I18nHelper i18n, Issue issue, FieldScreenRenderLayoutItem fieldScreenRenderLayoutItem)
Ensure that the parameters are valid
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.issue.fields.ConfigurableField
From interface com.atlassian.jira.issue.fields.CustomField
From interface com.atlassian.jira.issue.fields.Field
From interface com.atlassian.jira.issue.fields.NavigableField
From interface com.atlassian.jira.issue.fields.OrderableField
From interface com.atlassian.jira.issue.fields.SearchableField
From interface com.atlassian.jira.issue.fields.renderer.RenderableField
From interface com.atlassian.jira.issue.fields.rest.RestAwareField
From interface com.atlassian.jira.issue.fields.rest.RestFieldOperations
From interface java.lang.Comparable

Public Constructors

public MockCustomField ()

public MockCustomField (String id, String name, CustomFieldType customFieldType)

Public Methods

public String availableForBulkEdit (BulkEditBean bulkEditBean)

Determines whether the field is available for bulk editing given the BulkEditBean.

Parameters
bulkEditBean holds the state of the bulk-edit wizard (e.g. the selected issues for bulk editing)
Returns
  • null if the field is available for bulk-editing or an i18n key of the error message to show as why the field is not available.

public boolean canRemoveValueFromIssueObject (Issue issue)

Returns true if a call to removeValueFromIssueObject(com.atlassian.jira.issue.MutableIssue) will actually remove the value.

There a few different reasons why this method may return false:

  • The OrderableField can sometimes remove the value, but it decides that it is not relevant for this Issue. eg: Security Level will ignore remove requests on a subtask, as the subtask Security is not set explicitly (it is always inherited from its parent issue).
  • It may possible to remove this value, but the OrderableField does not actually do the job, it is done through some special mechanism. eg Attachments.
  • This field is some special system field which it is invalid to remove. eg Project. In these cases calling removeValueFromIssueObject() would normally raise an UnsupportedOperationException.
In general it is safe to call removeValueFromIssueObject() even if this method returns false, as the request will be silently ignored. However there are a couple of special fields where calling removeValueFromIssueObject() will throw an UnsupportedOperationException - eg if you try to remove the Project.

Parameters
issue The Issue object.
Returns

public int compare (Issue issue1, Issue issue2)

This method compares the values of this custom field in two given issues.

Returns a negative integer, zero, or a positive integer as the value of first issue is less than, equal to, or greater than the value of the second issue.

If either of given issues is null a IllegalArgumentException is thrown.

Parameters
issue1 issue to compare
issue2 issue to compare
Returns
  • a negative integer, zero, or a positive integer as the value of first issue is less than, equal to, or greater than the value of the second issue

public int compareTo (Object o)

public SearchHandler createAssociatedSearchHandler ()

Return SearchHandler for the field. This object tells JIRA how to search for values within the field.

Returns
  • the SearchHandler associated with the field. Can return null when no searcher is associated with the field. This will mainly happen when a customfield is configured to have no searcher.

public MockCustomFieldType createCustomFieldType ()

public void createValue (Issue issue, Object value)

public List<IssueType> getAssociatedIssueTypeObjects ()

Returns a list of issue types associated with this custom field. Will be null if the field is global

Returns
  • List of issue type generic values

public List<IssueType> getAssociatedIssueTypes ()

Returns a list of issue types associated with this custom field. Will be null if the field is global

Returns
  • List of issue type generic values

public List<Project> getAssociatedProjectObjects ()

Returns a list of projects associated with this custom field. Will be null if the field is global

Returns
  • a list of projects associated with this custom field.

public String getBulkEditHtml (OperationContext operationContext, Action action, BulkEditBean bulkEditBean, Map displayParameters)

Returns HTML that should be shown when the issue is being bulk edited.

Parameters
operationContext OperationContext
action Action
bulkEditBean BulkEditBean
displayParameters Map of display parameters.
Returns
  • HTML that should be shown when the issue is being edited.

public ClauseNames getClauseNames ()

Return the JQL clause names that this custom field should be recognized by.

Returns
  • the clause names this custom field should be recognized by.

public String getColumnCssClass ()

public String getColumnHeadingKey ()

public String getColumnViewHtml (FieldLayoutItem fieldLayoutItem, Map displayParams, Issue issue)

public List<FieldConfigItemType> getConfigurationItemTypes ()

Returns a List of FieldConfigItemType objects. This opens up possibilties for configurable custom fields

Returns

public List<FieldConfigScheme> getConfigurationSchemes ()

Returns a list of configuration schemes.

Returns

public String getCreateHtml (FieldLayoutItem fieldLayoutItem, OperationContext operationContext, Action action, Issue issue, Map displayParameters)

Returns the HTML that should be shown when the issue is being created.

Parameters
fieldLayoutItem FieldLayoutItem
operationContext OperationContext
action Action
issue Issue
displayParameters Map of display parameters.
Returns
  • the HTML that should be shown when the issue is being created.

public String getCreateHtml (FieldLayoutItem fieldLayoutItem, OperationContext operationContext, Action action, Issue issue)

Returns the HTML that should be shown when the issue is being created.

Parameters
fieldLayoutItem FieldLayoutItem
operationContext OperationContext
action Action
issue Issue
Returns
  • the HTML that should be shown when the issue is being created.

public CustomFieldSearcher getCustomFieldSearcher ()

Retrieves the CustomFieldSearcher for this custom field. The searcher, if found is initialized with this custom field before it is returned.

Returns
  • found custom field searcher or null, if none found

public CustomFieldType getCustomFieldType ()

Looks up the CustomFieldType. It can return null if the custom field type cannot be found in the CustomFieldManager.

Returns
  • custom field type

public CustomFieldParams getCustomFieldValues (Map customFieldValuesHolder)

Get the custom field string values that are relevant to this particular custom field

Parameters
customFieldValuesHolder containing all params
Returns

public String getDefaultSortOrder ()

The order in which to sort the field when it is sorted for the first time.

Returns

public Object getDefaultValue (Issue issue)

The value that should be set on the issue if the field is not shown for some reason.

For example: The user does not have permission to see the field, or the field is not part of the create screen.

Parameters
issue the Issue.
Returns
  • The default value. It can be null.

public String getDescription ()

Returns the 1i8n'ed description of this custom field. To render views for the custom field description, prefer getDescriptionProperty().

Returns
  • the description of this custom field

@Nonnull public RenderableProperty getDescriptionProperty ()

Returns a RenderableProperty for rendering this custom field's description.

Returns
  • a read-only RenderableProperty

public String getEditHtml (FieldLayoutItem fieldLayoutItem, OperationContext operationContext, Action action, Issue issue, Map displayParameters)

Returns HTML that should be shown when the issue is being edited.

Parameters
fieldLayoutItem FieldLayoutItem
operationContext OperationContext
action Action
issue Issue
displayParameters Map of display parameters.
Returns
  • HTML that should be shown when the issue is being edited.

public String getEditHtml (FieldLayoutItem fieldLayoutItem, OperationContext operationContext, Action action, Issue issue)

Returns HTML that should be shown when the issue is being edited.

Parameters
fieldLayoutItem FieldLayoutItem
operationContext OperationContext
action Action
issue Issue
Returns
  • HTML that should be shown when the issue is being edited.

public String getFieldName ()

Returns the title of this custom field.

Returns
  • the title of this custom field

public FieldTypeInfo getFieldTypeInfo (FieldTypeInfoContext fieldTypeInfoContext)

Returns lower level Information about the field. This information contains allowed values and/or the autocomplete url

Parameters
fieldTypeInfoContext the FieldTypeInfoContext contains context information that is relevant to generate the FieldTypeInfo

public GenericValue getGenericValue ()

Returns a generic value that represents this custom field

Returns
  • generic value of this custom field

public String getHiddenFieldId ()

Returns the id of the field to check for visibility. For example, with original estimate field need to ensure that the timetracking field is not hidden. With most fields, this is the same as their id.

public String getId ()

Returns the identifier for this RenderableField.

Returns
  • the identifier for this RenderableField.

public Long getIdAsLong ()

Returns ID of this custom field.

Returns
  • ID of this custom field

public JsonData getJsonDefaultValue (IssueContext issueCtx)

Return The default data for this system field. May be null if there is no default.

Parameters
issueCtx Issue (This should really only need to be an issue context, but for historical reasons we need an issue object.

public FieldJsonRepresentation getJsonFromIssue (Issue issue, boolean renderedVersionRequested, FieldLayoutItem fieldLayoutItem)

Return a FieldJsonDataPair containing a json representation of the raw data for this field, and if required, a json representation of the rendered data for easy display.

Parameters
issue to get field data from
renderedVersionRequested whether the use requested the return of rendered/pretty data as well as raw data
fieldLayoutItem field layout for this field. Will only be supplied if the field is also an ordereable field.
Returns
  • FieldJsonDataPair containing a json representation of the raw data for this field, and if required, a json representation of the rendered data for easy display.

public JsonType getJsonSchema ()

Return a description of the shape of this field when represented as JSON.

public String getName ()

Returns i18n'ed name of the field.

public String getNameKey ()

The i18n key that is used to lookup the field's name when it is displayed

public Options getOptions (String key, FieldConfig config, JiraContextNode contextNode)

Returns options for this custom field if it is of MultipleCustomFieldType type. Otherwise returns null.

As this is just used by the view layer, it can be a list of objects

Parameters
key not used
config relevant field config
contextNode JIRA context node
Returns

public Options getOptions (String key, JiraContextNode jiraContextNode)

Returns options for this custom field if it is of MultipleCustomFieldType type. Otherwise returns null.

As this is just used by the view layer, it can be a list of objects

Parameters
key not used
jiraContextNode JIRA context node
Returns

public PropertySet getPropertySet ()

public FieldConfig getRelevantConfig (Issue issue)

Returns a relevant FieldConfig for the given issue. If the field has a config for the issue then one will be returned, otherwise null is returned.

For example, if we have 2 projects: project A and project B, and a custom field is configured to be only applicable to project A, calling getRelevantConfig with an issue from project A should return the config (i.e. not null). Calling this method with an issue from project B should return null.

Parameters
issue issue whose project and issue type will be used to check if the field has a config
Returns
  • an instance of FieldConfig representing the configuration of the field for issue's project/issue type. If the field does not have a config for issue's project/issue type, null is returned.

public FieldConfig getRelevantConfig (IssueContext issueContext)

Returns the relevant field config of this custom field for the give issue context

Parameters
issueContext issue context to find the relevant field config for
Returns
  • the relevant field config of this custom field for the give issue context

public FieldConfig getReleventConfig (SearchContext searchContext)

The FieldConfig that is relevent to all issue contexts in the search context Checks that all configs within search context are the same - i.e. all null or all the same config.

Returns null if any two configs are different.

Note: null config is not equal to non-null config. Previously, a non-null config was returned even if the first config(s) was null.

Parameters
searchContext search context
Returns
  • null if any two configs are different

public RestFieldOperationsHandler getRestFieldOperation ()

public FieldComparatorSource getSortComparatorSource ()

A sortComparatorSource object to be used for sorting columns in a table. In most cases this will use a MappedSortComparator using the getSorter() method. However, fields can provide any sorting mechanism that they wish.

If a field can be sorted directly using terms in the Lucene index then the field should implement getSortFields(boolean) rather than this method.

In large installations custom sorting may incur a maor performance penalty.

Returns
  • A SortComparatorSource that can be used to sort, or null if this field does not use custom sorting

public List<SortField> getSortFields (boolean sortOrder)

Return a list of Lucene SortFields to be used for sorting search results.

Using this method allows the field to specify the most performant way to perform a search. If a field can be sorted directly using the term in the index then this should just return a singleton list with the sort field.

return Collections.singletonList(new SortField(fieldName, sortOrder));

The default implementation builds this using the FieldComparatorSource returned by getSortComparatorSource()

If you implement this method there is no need to implement getSortComparatorSource().

Returns
  • The name of the indexed term to be used for native Lucene sorting.

public LuceneFieldSorter getSorter ()

A sorter to be used when sorting columns in a table. This sort uses the Lucene Document Collection and is therefore a lot faster than sorting the issues in memory.

Returns

public String getUntranslatedDescription ()

Returns the description of this custom field by reading ENTITY_DESCRIPTION of the underlying generic value.

Returns
  • the description of this custom field

@Nonnull public RenderableProperty getUntranslatedDescriptionProperty ()

Returns a RenderableProperty for rendering this custom field's untranslated description, for admin.

Returns
  • a read-only RenderableProperty

public String getUntranslatedName ()

Returns the name of this custom field by reading ENTITY_NAME of the underlying generic value.

Returns
  • the name of this custom field

public Object getValue (Issue issue)

Retrieves and returns the Object representing the this CustomField value for the given issue. See getValueFromIssue(CustomField, Issue). This is only used to communicate with the 'view' JSP. Multiselects will return a list, dates a date, etc.

Parameters
issue issue to retrieve the value from
Returns
  • Object representing the this CustomField value for the given issue

public String getValueFromIssue (Issue issue)

Gets the value stored for this field on the provided issue.

Parameters
issue identifies the issue that will contain the value for this field.
Returns
  • the value stored on this issue for this field, null if not applicable.

public Object getValueFromParams (Map params)

Get a field value from the map of parameters passed. The params map may contain other parameters that are not relevant to this custom field.

Parameters
params the map of parameters.
Returns
  • Value for this field from the map of parameters.

public String getViewHtml (FieldLayoutItem fieldLayoutItem, Action action, Issue issue)

public String getViewHtml (FieldLayoutItem fieldLayoutItem, Action action, Issue issue, Object value, Map displayParameters)

public String getViewHtml (FieldLayoutItem fieldLayoutItem, Action action, Issue issue, Map displayParameters)

public boolean hasParam (Map parameters)

public boolean hasValue (Issue issue)

Determines if the field has a value for the given issue.

Parameters
issue the Issue.
Returns
  • true if the given Issue has a value for this field.

public boolean isAllIssueTypes ()

Returns true if it applies for all issue types, false otherwise.

Returns
  • true if it applies for all issue types, false otherwise.

public boolean isAllProjects ()

Checks whether this custom field applies for all projects. It returns true if it applies for all projects for any field configuration scheme, false otherwise.

Returns
  • true if it applies for all projects for any field configuration scheme, false otherwise.

public boolean isEditable ()

Returns true if this custom field can be edited, false otherwise.

Returns
  • true if this custom field can be edited, false otherwise

public boolean isEnabled ()

Returns true if all configuration schemes returned by getConfigurationSchemes() are enabled.

Returns
  • true if all configuration schemes are enabled, false otherwise

public boolean isGlobal ()

Returns true if this custom field applies for all projects and all issue types.

Returns
  • true if it is in all projects and all issue types, false otherwise.

public boolean isInScope (Project project, List<String> issueTypeIds)

Determines if this custom field is within the scope of the given project, and list of Issue Types.

Parameters
project The project.
issueTypeIds A list of IssueType ids.
Returns
  • true if this custom field is within the given scope.

public boolean isInScope (long projectId, String issueTypeId)

Determines if this custom field is within the scope of the given project, and Issue Type.

Parameters
projectId The project.
issueTypeId The issueTypeId
Returns
  • true if this custom field is within the given scope.

public boolean isInScope (SearchContext searchContext)

Determines whether this custom field is in scope.

Parameters
searchContext search context
Returns
  • true if this field is in scope

public boolean isInScopeForSearch (Project project, List<String> issueTypeIds)

Determines if this custom field is within the scope of the given project, and list of Issue Types.

If the project is null, then it is treated as any project. If the issueTypeIds list is null or an empty list, then it is treated as any issue type.

If the passed project is any project, this method will search in all the FieldConfigScheme of this custom field, ignoring the projects that they apply to (since the given project is any) and looking for at least one of them that applies to at least one of the given issue type ids.

If the passed list of issue types is any issue type, this method will search for at least one FieldConfigScheme that applies to the given project, ignoring the issue types that it applies to (since the given issue type ids are any).

If both the project and issue types are any, the question being asked is "is this custom field in the scope of any project and any issue type?", which will always be true.

public boolean isRelevantForIssueContext (IssueContext issueContext)

Returns true if the custom field has a config for the Project and Issue Type of the given IssueContext.

This is equivalent to calling

  getRelevantConfig(issueContext) != null
but in general can run faster because it does not have to resolve the actual FieldConfig.

Parameters
issueContext IssueContext whose project and issue type will be used to check if the field has a config
Returns
  • an instance of FieldConfig representing the configuration of the field for issue's project/issue type. If the field does not have a config for issue's project/issue type, null is returned.

public boolean isRenderable ()

Defines if a field determines itself as renderable. This is needed because of the way that customfields are implemented. Since all the real work is done in CustomFieldTypes, if we want to treat system fields and custom fields the same way in the renderers then all custom fields must implement this interface. We therefore provide this method so that the CustomFieldImpl can delegate to the CustomFieldTypes to determine if a given custom field is renderable.

Returns
  • true if the field is renderable, false otherwise.

public boolean isShown (Issue issue)

Tests field specific way to determine if it should be shown or not.

Parameters
issue The Issue.
Returns
  • true if it should be shown.

public MessagedResult needsMove (Collection originalIssues, Issue targetIssue, FieldLayoutItem targetFieldLayoutItem)

Used to determine if the field needs input from user to be moved to the new project and/or issue type. This method is called only if the field is visible in the target project/issue type.

Parameters
originalIssues Collection of original Issues.
targetIssue Target Issue.
targetFieldLayoutItem FieldLayoutItem
Returns
  • A MessagedResult with result=true if the field needs input to be moved.

public void populateDefaults (Map fieldValuesHolder, Issue issue)

public void populateForMove (Map<StringObject> fieldValuesHolder, Issue originalIssue, Issue targetIssue)

Used to populate the fieldValueHolder with parameters for move issue screen. This field is only called if the issue needs to be updated during move, i.e. needsMove(java.util.Collection, com.atlassian.jira.issue.Issue, com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem) returned true, and the remote user (the one performing the move) has the permission to actually update this field.

Parameters
fieldValuesHolder Map of field Values.
originalIssue orignal Issue
targetIssue target Issue

public void populateFromIssue (Map fieldValuesHolder, Issue issue)

public void populateFromParams (Map fieldValuesHolder, Map parameters)

public void populateParamsFromString (Map fieldValuesHolder, String stringValue, Issue issue)

public String prettyPrintChangeHistory (String changeHistory, I18nHelper i18nHelper)

Used for email notification templates - allows changelog to be displayed in language of the recipient.

Returns
  • String change history formatted according to locale in i18nHelper

public String prettyPrintChangeHistory (String changeHistory)

public Set<Long> remove ()

Removes this custom field and returns a set of issue IDs of all issues that are affected by removal of this custom field.

Returns
  • a set of issue IDs of affected issues

public void removeValueFromIssueObject (MutableIssue issue)

Removes the field value from the given MutableIssue object.

Note that this operation does not actually persist the change, it just clears the value from the given Issue object. The caller will still need to call #updateValue() in order to persist the change.

Some Fields may choose to quietly ignore this request. eg The SecurityLevel Field will not remove Security Level from subtasks because the subtask must always take the Security Level of its parent issue.

Parameters
issue The issue object to be effected.

public MockCustomField setCustomFieldType (CustomFieldType type)

public MockCustomField setId (String id)

public String toString ()

public void updateIssue (FieldLayoutItem fieldLayoutItem, MutableIssue issue, Map fieldValueHolder)

Record the value on the issue (not saving it to the database, see updateValue).

Parameters
fieldLayoutItem FieldLayoutItem
issue MutableIssue
fieldValueHolder Field Value Holder Map

public void updateValue (FieldLayoutItem fieldLayoutItem, Issue issue, ModifiedValue modifiedValue, IssueChangeHolder issueChangeHolder)

Update the issue in the data store.

Fields that are simply stored in the JIRAISSUE DB table, need not do anything here as this table is written to one time to include all fields that changed. Fields using other DB tables must update that table with the appropriate values.

Parameters
fieldLayoutItem for this field within this context
issue Issue this field is part of
modifiedValue new value to set field to. Cannot be null.
issueChangeHolder an object to record any changes made to the issue by this method.

public void validateFromActionParams (Map actionParameters, ErrorCollection errorCollection, FieldConfig config)

Validates relevant parameters on custom field type of this custom field. Any errors found are added to the given errorCollection. See validateFromParams(CustomFieldParams, ErrorCollection, FieldConfig)

Parameters
actionParameters action parameters
errorCollection error collection to add errors to
config field config

public void validateParams (OperationContext operationContext, ErrorCollection errorCollectionToAddTo, I18nHelper i18n, Issue issue, FieldScreenRenderLayoutItem fieldScreenRenderLayoutItem)

Ensure that the parameters are valid

Parameters
operationContext OperationContext
errorCollectionToAddTo ErrorCollection to add to.
i18n I18nHelper
issue This is passed to get the value of other fields that may or may not have been modified.
fieldScreenRenderLayoutItem FieldScreenRenderLayoutItem