public class

DefaultFieldManager

extends Object
implements FieldManager
java.lang.Object
   ↳ com.atlassian.jira.issue.fields.DefaultFieldManager

Summary

[Expand]
Inherited Constants
From interface com.atlassian.jira.issue.fields.FieldManager
Public Constructors
DefaultFieldManager()
Public Methods
Set<NavigableField> getAllAvailableNavigableFields()
Returns a set of Fields that are NOT hidden in AT LEAST ONE project in the system.
Set<SearchableField> getAllSearchableFields()
Return all the searchable fields in the system.
Set<CustomField> getAvailableCustomFields(ApplicationUser remoteUser, Issue issue)
Retrieves custom fields in scope for the given issue
Set<NavigableField> getAvailableNavigableFields(ApplicationUser remoteUser)
Returns a set of Fields that are NOT hidden in AT LEAST ONE project that the remote user can see (has BROWSE permission for).
Set<NavigableField> getAvailableNavigableFieldsWithScope(ApplicationUser remoteUser, QueryContext queryContext)
Gets all the available fields within the defined scope of the QueryContext.
Set<NavigableField> getAvailableNavigableFieldsWithScope(ApplicationUser user)
Gets all the available fields that the user can see, this is providing no context scope.
@Nullable ConfigurableField getConfigurableField(String id)
@Nullable CustomField getCustomField(String key)
Get a CustomField by its text key (eg 'customfield_10000').
Field getField(String id)
Get a field by its id.
HideableField getHideableField(String id)
IssueTypeField getIssueTypeField()
Retrieve the IssueType system Field.
NavigableField getNavigableField(String id)
Set<NavigableField> getNavigableFields()
@Nullable OrderableField getOrderableField(String id)
Set<OrderableField> getOrderableFields()
ProjectField getProjectField()
Retrieve the Project system Field.
RequirableField getRequiredField(String id)
Set<SearchableField> getSystemSearchableFields()
Return all the searchable systems fields.
Set<Field> getUnavailableFields()
Set<FieldLayout> getVisibleFieldLayouts(ApplicationUser user)
Returns all the visible FieldLayouts for the given user.
boolean isCustomField(String key)
Returns true if the given ID is a Custom Field that actually exists in JIRA.
boolean isCustomField(Field field)
boolean isCustomFieldId(String id)
Returns true if the given field ID is in the custom field format.
boolean isExistingCustomField(String id)
Returns true if the given ID is a Custom Field that actually exists in JIRA.
boolean isFieldHidden(ApplicationUser remoteUser, String fieldId)
Determines whether the field with id of fieldId is NOT hidden in AT LEAST one FieldLayout that the user can see (assigned to projects for which the user has the BROWSE_PROJECTS permission).
boolean isFieldHidden(ApplicationUser remoteUser, Field field)
boolean isFieldHidden(Set<FieldLayout> fieldLayouts, Field field)
Checks whether the given field is hidden in all of the given Field Layouts.
boolean isHideableField(String id)
boolean isHideableField(Field field)
boolean isMandatoryField(String id)
boolean isMandatoryField(Field field)
boolean isNavigableField(Field field)
boolean isNavigableField(String id)
boolean isOrderableField(String id)
boolean isOrderableField(Field field)
boolean isRenderableField(String id)
boolean isRenderableField(Field field)
boolean isRequirableField(Field field)
boolean isRequirableField(String id)
boolean isTimeTrackingOn()
boolean isUnscreenableField(String id)
boolean isUnscreenableField(Field field)
void refresh()
Invalidates all field-related caches in JIRA.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.issue.fields.FieldManager

Public Constructors

public DefaultFieldManager ()

Public Methods

public Set<NavigableField> getAllAvailableNavigableFields ()

Returns a set of Fields that are NOT hidden in AT LEAST ONE project in the system.

NOTE: This method is used in the Admin interface, as admins should be able to configure the default ColumnLayouts irrespective of their permissions. They should be able to see all fields that are not hidden in at least one FieldLayout in the system

Throws
FieldException if cannot retrieve the projects the user can see, or if cannot retrieve the field layouts for the viewable projects

public Set<SearchableField> getAllSearchableFields ()

Return all the searchable fields in the system. This set will included all defined custom fields.

Returns
  • the set of all searchable fields in the system.

public Set<CustomField> getAvailableCustomFields (ApplicationUser remoteUser, Issue issue)

Retrieves custom fields in scope for the given issue

Parameters
remoteUser Remote com.atlassian.jira.user.ApplicationUser
issue Issue
Returns
  • custom fields in scope for the given issue

public Set<NavigableField> getAvailableNavigableFields (ApplicationUser remoteUser)

Returns a set of Fields that are NOT hidden in AT LEAST ONE project that the remote user can see (has BROWSE permission for).

The returned set of fields contains all custom fields that are not hidden in AT LEAST one FieldLayout that the user can see.

NOTE: This method is primarily used for configuring user's ColumnLayout, as the user should be able to add any field (including custom field) to it that they can see in the system. THe scope of custom fields is ignored here as the user configures the ColumnLayout outside of scope.

Parameters
remoteUser the remote user
Throws
FieldException if cannot retrieve the projects the user can see, or if cannot retrieve the field layouts for the viewable projects

public Set<NavigableField> getAvailableNavigableFieldsWithScope (ApplicationUser remoteUser, QueryContext queryContext)

Gets all the available fields within the defined scope of the QueryContext.

Parameters
remoteUser the user making the request
queryContext the context of the search request.
Returns
  • a set of NavigableFields that can be show because their visibility/configuration fall within the specified context

public Set<NavigableField> getAvailableNavigableFieldsWithScope (ApplicationUser user)

Gets all the available fields that the user can see, this is providing no context scope.

Parameters
user the remote user.
Returns
  • a set of NavigableFields that can be show because their visibility/configuration fall within what the user can see.

@Nullable public ConfigurableField getConfigurableField (String id)

@Nullable public CustomField getCustomField (String key)

Get a CustomField by its text key (eg 'customfield_10000').

Parameters
key Eg. 'customfield_10000'
Returns

public Field getField (String id)

Get a field by its id.

Parameters
id An IssueFieldConstants constant, or custom field key (eg. "customfield_10010")
Returns
  • the Field

public HideableField getHideableField (String id)

public IssueTypeField getIssueTypeField ()

Retrieve the IssueType system Field.

Returns
  • the IssueType system Field.

public NavigableField getNavigableField (String id)

public Set<NavigableField> getNavigableFields ()

@Nullable public OrderableField getOrderableField (String id)

public Set<OrderableField> getOrderableFields ()

public ProjectField getProjectField ()

Retrieve the Project system Field.

Returns
  • the Project system Field.

public RequirableField getRequiredField (String id)

public Set<SearchableField> getSystemSearchableFields ()

Return all the searchable systems fields. This set will *NOT* include defined custom fields.

Returns
  • the set of all searchable systems fields defined.

public Set<Field> getUnavailableFields ()

public Set<FieldLayout> getVisibleFieldLayouts (ApplicationUser user)

Returns all the visible FieldLayouts for the given user.

This is used in conjunction with isFieldHidden(Set, Field) as a performance optimisation in usages that want to call isFieldHidden(com.atlassian.jira.user.ApplicationUser, Field) multiple times. Instead, it is more efficient to do something like:

     Set fieldLayouts = fieldManager.getVisibleFieldLayouts(loggedInUser);
     for (Field field: myFields)
     {
       if (fieldManager.isFieldHidden(fieldLayouts1, field))
       {
           ...
       }
     }
 

Parameters
user the user whose project browsing permissions are used to limit visible FieldLayouts.
Returns
  • all the visible FieldLayouts for the given user.

public boolean isCustomField (String key)

Returns true if the given ID is a Custom Field that actually exists in JIRA.

Parameters
key the field ID
Returns
  • true if the given ID is a Custom Field that actually exists in JIRA.

public boolean isCustomField (Field field)

public boolean isCustomFieldId (String id)

Returns true if the given field ID is in the custom field format.

This method just checks that the ID looks like a Custom Field (it starts with "customfield_") but not that the custom field actually exists (it could have been deleted).

Parameters
id the field ID
Returns
  • true if the given ID is a Custom Field that actually exists in JIRA.

public boolean isExistingCustomField (String id)

Returns true if the given ID is a Custom Field that actually exists in JIRA.

Checking for existance comes with a performance price, so use where possible.

Parameters
id the field ID
Returns
  • true if the given ID is a Custom Field that actually exists in JIRA.

public boolean isFieldHidden (ApplicationUser remoteUser, String fieldId)

Determines whether the field with id of fieldId is NOT hidden in AT LEAST one FieldLayout that the user can see (assigned to projects for which the user has the BROWSE_PROJECTS permission).

Parameters
remoteUser the remote user.
fieldId The Field ID

public boolean isFieldHidden (ApplicationUser remoteUser, Field field)

public boolean isFieldHidden (Set<FieldLayout> fieldLayouts, Field field)

Checks whether the given field is hidden in all of the given Field Layouts.

This method can be used in conjunction with getVisibleFieldLayouts(com.atlassian.jira.user.ApplicationUser) to provide a more performant way of looking up isFieldHidden(com.atlassian.jira.user.ApplicationUser, Field) multiple times. Instead, it is more efficient to do something like:

     Set fieldLayouts = fieldManager.getVisibleFieldLayouts(loggedInUser);
     for (Field field: myFields)
     {
       if (fieldManager.isFieldHidden(fieldLayouts1, field))
       {
           ...
       }
     }
 

Parameters
fieldLayouts The FieldLayouts to check
field The field to check
Returns
  • true if the given field is hidden in all of the given Field Layouts.

public boolean isHideableField (String id)

public boolean isHideableField (Field field)

public boolean isMandatoryField (String id)

public boolean isMandatoryField (Field field)

public boolean isNavigableField (Field field)

public boolean isNavigableField (String id)

public boolean isOrderableField (String id)

public boolean isOrderableField (Field field)

public boolean isRenderableField (String id)

public boolean isRenderableField (Field field)

public boolean isRequirableField (Field field)

public boolean isRequirableField (String id)

public boolean isTimeTrackingOn ()

public boolean isUnscreenableField (String id)

public boolean isUnscreenableField (Field field)

public void refresh ()

Invalidates all field-related caches in JIRA.

WARNING

This method invalidates a whole lot of JIRA caches, which means that JIRA performance significantly degrades after this method has been called. For this reason, you should avoid calling this method at all costs.

The correct approach to invalidate the cache entries is to do it in the "store" inside the FooStore.updateFoo() method, where you can invalidate a single cache entry. If the cache lives in another class then the store should raise a FooUpdatedEvent which that class can listen to in order to keep its caches up to date.

If you add any calls to this method in JIRA I will hunt you down and subject you to a Spanish inquisition.