public class

MockFieldManager

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

Summary

[Expand]
Inherited Constants
From interface com.atlassian.jira.issue.fields.FieldManager
Public Constructors
MockFieldManager()
Public Methods
MockFieldManager addField(Field field)
MockCustomField addMockCustomField(int id)
MockOrderableField addMockOrderableField(int id)
MockFieldManager addUnavilableField(Field field)
MockFieldManager clear()
Set<NavigableField> getAllAvailableNavigableFields()
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)
Set<NavigableField> getAvailableNavigableFieldsWithScope(ApplicationUser user)
Gets all the available fields that the user can see, this is providing no context scope.
Set<NavigableField> getAvailableNavigableFieldsWithScope(ApplicationUser user, QueryContext queryContext)
Gets all the available fields within the defined scope of the QueryContext.
ColumnLayoutManager getColumnLayoutManager()
ConfigurableField getConfigurableField(String id)
@Nullable CustomField getCustomField(String id)
Get a CustomField by its text key (eg 'customfield_10000').
Field getField(String id)
Get a field by its id.
FieldLayoutManager getFieldLayoutManager()
HideableField getHideableField(String id)
IssueTypeField getIssueTypeField()
Retrieve the IssueType system Field.
NavigableField getNavigableField(String id)
Set<NavigableField> getNavigableFields()
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 id)
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(String id)
boolean isNavigableField(Field field)
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.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.issue.fields.FieldManager

Public Constructors

public MockFieldManager ()

Public Methods

public MockFieldManager addField (Field field)

public MockCustomField addMockCustomField (int id)

public MockOrderableField addMockOrderableField (int id)

public MockFieldManager addUnavilableField (Field field)

public MockFieldManager clear ()

public Set<NavigableField> getAllAvailableNavigableFields ()

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)

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.

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

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

Parameters
user 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 ColumnLayoutManager getColumnLayoutManager ()

public ConfigurableField getConfigurableField (String id)

@Nullable public CustomField getCustomField (String id)

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

Parameters
id 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 FieldLayoutManager getFieldLayoutManager ()

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

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

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

Parameters
id 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 (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 (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.

public String toString ()