Class CustomFieldUtils
java.lang.Object
com.atlassian.jira.issue.customfields.CustomFieldUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildIssueTypes(ConstantsManager constantsManager, String[] issueTypes) static List<JiraContextNode>buildJiraIssueContexts(boolean global, Long[] projects, ProjectManager projectManager) static List<JiraContextNode>buildJiraIssueContexts(boolean global, Long[] projectCategories, Long[] projects, JiraContextTreeManager treeManager) Deprecated.buildParams(CustomField customField, FieldConfig config, Issue issue, FieldLayoutItem fieldLayoutItem, Object value, Map customFieldValuesHolder, webwork.action.Action action, Map<String, Object> displayParameters) static List<IssueContext>convertToIssueContexts(Project project, List<String> issueTypeIds) Converts list of issue type ids toIssueContexts.static StringcreateSearchParam(String customFieldId, String searchParam) static LonggetCustomFieldId(String key) Given a custom field key, return its id or null.static StringgetCustomFieldKey(String searchParamKey) protected static I18nHelperstatic StringName of the parameter that stores the issue id in the current context in CustomFieldParams.static StringThe prefix to be used by Atlassian defined custom field parameter names, so that we could avoid naming conflict between Atlassian parameters and parameters used by third party plugin.static StringName of the parameter that stores the project id of the associated issue in the current context in CustomFieldParams.static StringName of the parameter that indicates whether the list of project id's associated with the current context should be loaded, either from the current issue (when editing value of an issue) or from FieldConfig and its FieldConfigScheme (when setting default value).static Collection<Long>getProjectIdsForUser(ApplicationUser user, Collection<Long> projectIds, PermissionManager permissionManager, UserFilter userFilter) IfprojectIdsis not empty, return it.static Collection<Long>getProjectIdsFromIssueOrFieldConfig(Issue issue, FieldConfig config, FieldConfigSchemeManager fieldConfigSchemeManager, ProjectManager projectManager) Retrieve the list of project id's from issue or field config, in the following order: Ifissueis not null and issue.getProjectId() is not null, return a single list with issue.getProjectId() Ifconfigis not null, use it to retrieve the list of project id's associated with the current scheme Otherwise, return nullstatic Collection<Long>getProjectIdsFromProjectOrFieldConfig(Long projectIdFromIssue, FieldConfig config, FieldConfigSchemeManager fieldConfigSchemeManager, ProjectManager projectManager) Retrieve the list of project id's from issue or field config, in the following order: Ifissueis not null and issue.getProjectId() is not null, return a single list with issue.getProjectId() Ifconfigis not null, use it to retrieve the list of project id's associated with the current scheme Otherwise, return nullstatic StringgetSearchParamSuffix(String searchParamKey) static booleanisCollectionNotEmpty(Collection stringCollection) static booleanisCustomFieldId(String key) Checks is passed field key belongs to custom field.static booleanisShownAndVisible(CustomField customField, ApplicationUser user, SearchContext searchContext, FieldVisibilityManager fieldVisibilityManager) Checks if the custom field is in the search context scope (usingOrderableField.isShown(com.atlassian.jira.issue.Issue)) and visible in all field schemes (usingFieldVisibilityManager.isFieldHiddenInAllSchemes(String, SearchContext, ApplicationUser))static booleanisUserHasPermissionToProjects(CustomField customField, ApplicationUser user) Does the user have permission to at least one project that falls under this custom field.static Map<CustomField,Object> parseCustomFieldValuesFromActionParams(Map actionParameters, List<CustomField> customFields) Parses action parameters (Map of Collections of Strings with <customfield_[: ]> as key) static StringprettyPrintOptions(Options options)
-
Field Details
-
CUSTOM_FIELD_PREFIX
- See Also:
-
PARAM_REQUIRE_PROJECT_IDS
Deprecated.since v6.2.3 usegetParamKeyRequireProjectIds()instead.- Since:
- v6.2
- See Also:
-
-
Constructor Details
-
CustomFieldUtils
public CustomFieldUtils()
-
-
Method Details
-
getParamKeyPrefixAtl
The prefix to be used by Atlassian defined custom field parameter names, so that we could avoid naming conflict between Atlassian parameters and parameters used by third party plugin.- Since:
- v6.2.2
-
getParamKeyRequireProjectIds
Name of the parameter that indicates whether the list of project id's associated with the current context should be loaded, either from the current issue (when editing value of an issue) or from FieldConfig and its FieldConfigScheme (when setting default value).This parameter could be used in two places now:
- In
CustomFieldType.getVelocityParameters(com.atlassian.jira.issue.Issue, com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem)to informbuildParams(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.fields.config.FieldConfig, com.atlassian.jira.issue.Issue, com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem, Object, java.util.Map, webwork.action.Action, java.util.Map)that project id's need to be loaded - In
CustomFieldParamsto informCustomFieldType.validateFromParams(com.atlassian.jira.issue.customfields.view.CustomFieldParams, com.atlassian.jira.util.ErrorCollection, com.atlassian.jira.issue.fields.config.FieldConfig)that project id's need to be loaded from field config scheme.
- Since:
- v6.2.2
- In
-
getParamKeyIssueId
Name of the parameter that stores the issue id in the current context in CustomFieldParams. This is useful for getting data such as the previous value.- Since:
- v7.2.5
-
getParamKeyProjectId
Name of the parameter that stores the project id of the associated issue in the current context in CustomFieldParams.- Since:
- v7.2.5
-
getSearchParamSuffix
-
getCustomFieldKey
-
createSearchParam
-
getCustomFieldId
Given a custom field key, return its id or null.- Parameters:
key- eg. "customfield_10000"- Returns:
- Id, eg. 10000
-
isCustomFieldId
Checks is passed field key belongs to custom field.- Parameters:
key- Field key eg. "description", "customfield_123"- Returns:
- true if passed field key belongs to custom field, false otherwise.
-
isCollectionNotEmpty
-
parseCustomFieldValuesFromActionParams
public static Map<CustomField,Object> parseCustomFieldValuesFromActionParams(Map actionParameters, List<CustomField> customFields) Parses action parameters (Map of Collections of Strings with <customfield_[: ]> as key) - Parameters:
actionParameters- map of action parameterscustomFields- a list of custom fields- Returns:
- a map of custom field to its value, never null
- Since:
- 3.1-DEV
-
buildJiraIssueContexts
public static List<JiraContextNode> buildJiraIssueContexts(boolean global, Long[] projects, ProjectManager projectManager) - Since:
- 6.4
-
buildJiraIssueContexts
public static List<JiraContextNode> buildJiraIssueContexts(boolean global, Long[] projectCategories, Long[] projects, JiraContextTreeManager treeManager) Deprecated.UsebuildJiraIssueContexts(boolean, Long[], com.atlassian.jira.project.ProjectManager)instead. Since v6.4. -
buildIssueTypes
public static List<IssueType> buildIssueTypes(ConstantsManager constantsManager, String[] issueTypes) -
convertToIssueContexts
Converts list of issue type ids toIssueContexts.- Parameters:
project- The project (may be null).issueTypeIds- Type ids as strings, eg. ["3", "4"]. May be null or empty.- Returns:
- a list of issue contexts, never null
-
isUserHasPermissionToProjects
Does the user have permission to at least one project that falls under this custom field. If the custom field has not been configured for anything, it won't return true either- Parameters:
customField- custom fielduser- user- Returns:
- true if user has permission to at least one project that falls under this custom field, false otherwise
-
prettyPrintOptions
-
buildParams
public static Map<String,Object> buildParams(CustomField customField, FieldConfig config, Issue issue, FieldLayoutItem fieldLayoutItem, Object value, Map customFieldValuesHolder, webwork.action.Action action, Map<String, Object> displayParameters) -
withDisplayRelatedParams
-
getI18nBean
-
isShownAndVisible
public static boolean isShownAndVisible(CustomField customField, ApplicationUser user, SearchContext searchContext, FieldVisibilityManager fieldVisibilityManager) Checks if the custom field is in the search context scope (usingOrderableField.isShown(com.atlassian.jira.issue.Issue)) and visible in all field schemes (usingFieldVisibilityManager.isFieldHiddenInAllSchemes(String, SearchContext, ApplicationUser))- Parameters:
customField- customfield to check visibility ofuser- current usersearchContext- search contextfieldVisibilityManager- field visibility bean- Returns:
- true if the customfield is in scope and visibile in all schemes in the specified search context
- See Also:
-
getProjectIdsFromIssueOrFieldConfig
public static Collection<Long> getProjectIdsFromIssueOrFieldConfig(Issue issue, FieldConfig config, FieldConfigSchemeManager fieldConfigSchemeManager, ProjectManager projectManager) Retrieve the list of project id's from issue or field config, in the following order:- If
issueis not null and issue.getProjectId() is not null, return a single list with issue.getProjectId() - If
configis not null, use it to retrieve the list of project id's associated with the current scheme - Otherwise, return null
- Since:
- v6.2
- If
-
getProjectIdsFromProjectOrFieldConfig
public static Collection<Long> getProjectIdsFromProjectOrFieldConfig(Long projectIdFromIssue, FieldConfig config, FieldConfigSchemeManager fieldConfigSchemeManager, ProjectManager projectManager) Retrieve the list of project id's from issue or field config, in the following order:- If
issueis not null and issue.getProjectId() is not null, return a single list with issue.getProjectId() - If
configis not null, use it to retrieve the list of project id's associated with the current scheme - Otherwise, return null
- Since:
- v6.2.2
- If
-
getProjectIdsForUser
public static Collection<Long> getProjectIdsForUser(ApplicationUser user, Collection<Long> projectIds, PermissionManager permissionManager, UserFilter userFilter) IfprojectIdsis not empty, return it. Otherwise, return the list of project id's that theusercould browse.If
projectIdsis not provided anduserFiltercontains no roleIds, the list of browsable project ids will not be computed. An empty list will be returned instead.- Since:
- v6.2
-
getParamKeyRequireProjectIds()instead.