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(User remoteUser, Issue issue)
Retrieves custom fields in scope for the given issue
Set<NavigableField> getAvailableNavigableFields(User 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(User user)
Gets all the available fields that the user can see, this is providing no context scope.
Set<NavigableField> getAvailableNavigableFieldsWithScope(User remoteUser, QueryContext queryContext)
Gets all the available fields within the defined scope of the QueryContext.
@Deprecated ColumnLayoutManager getColumnLayoutManager()
This method is deprecated. Declare your dependency and let PicoContainer resolve it instead
@Nullable ConfigurableField getConfigurableField(String id)
CustomField getCustomField(String key)
Get a CustomField by its text key (eg 'customfield_10000').
Field getField(String id)
Get a field by its id.
@Deprecated FieldLayoutManager getFieldLayoutManager()
This method is deprecated. Declare your dependency and let PicoContainer resolve it instead
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(User user)
Returns all the visible FieldLayouts for the given user.
boolean isCustomField(Field field)
boolean isCustomField(String key)
boolean isFieldHidden(User 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 permission).
boolean isFieldHidden(Set<FieldLayout> fieldLayouts, Field field)
Checks whether the given field is hidden in all of the given Field Layouts.
boolean isFieldHidden(User remoteUser, Field field)
boolean isHideableField(Field field)
boolean isHideableField(String id)
boolean isMandatoryField(Field field)
boolean isMandatoryField(String id)
boolean isNavigableField(String id)
boolean isNavigableField(Field field)
boolean isOrderableField(String id)
boolean isOrderableField(Field field)
boolean isRenderableField(String id)
boolean isRenderableField(Field field)
boolean isRequirableField(String id)
boolean isRequirableField(Field field)
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 (User remoteUser, Issue issue)

Retrieves custom fields in scope for the given issue

Parameters
remoteUser Remote User
issue Issue
Returns
  • custom fields in scope for the given issue

public Set<NavigableField> getAvailableNavigableFields (User 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 (User 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.

public Set<NavigableField> getAvailableNavigableFieldsWithScope (User 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

@Deprecated public ColumnLayoutManager getColumnLayoutManager ()

This method is deprecated.
Declare your dependency and let PicoContainer resolve it instead

@Nullable public ConfigurableField getConfigurableField (String id)

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

@Deprecated public FieldLayoutManager getFieldLayoutManager ()

This method is deprecated.
Declare your dependency and let PicoContainer resolve it instead

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 (User 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(User, 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 (Field field)

public boolean isCustomField (String key)

public boolean isFieldHidden (User 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 permission).

Parameters
remoteUser the remote user.
fieldId The Field ID

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.crowd.embedded.api.User) to provide a more performant way of looking up isFieldHidden(com.atlassian.crowd.embedded.api.User, 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 isFieldHidden (User remoteUser, Field field)

public boolean isHideableField (Field field)

public boolean isHideableField (String id)

public boolean isMandatoryField (Field field)

public boolean isMandatoryField (String id)

public boolean isNavigableField (String id)

public boolean isNavigableField (Field field)

public boolean isOrderableField (String id)

public boolean isOrderableField (Field field)

public boolean isRenderableField (String id)

public boolean isRenderableField (Field field)

public boolean isRequirableField (String id)

public boolean isRequirableField (Field field)

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.