com.atlassian.jira.issue.customfields
Class CustomFieldUtils

java.lang.Object
  extended by com.atlassian.jira.issue.customfields.CustomFieldUtils

public class CustomFieldUtils
extends Object


Field Summary
static String CUSTOM_FIELD_PREFIX
           
static String PARAM_REQUIRE_PROJECT_IDS
          Deprecated. since v6.2.3 use getParamKeyRequireProjectIds() instead.
 
Constructor Summary
CustomFieldUtils()
           
 
Method Summary
static List<org.ofbiz.core.entity.GenericValue> buildIssueTypes(ConstantsManager constantsManager, String[] issueTypes)
           
static List<JiraContextNode> buildJiraIssueContexts(boolean global, Long[] projectCategories, Long[] projects, JiraContextTreeManager treeManager)
           
static Map<String,Object> buildParams(CustomField customField, FieldConfig config, Issue issue, FieldLayoutItem fieldLayoutItem, Object value, Map customFieldValuesHolder, webwork.action.Action action, Map displayParameters)
           
static List<IssueContext> convertToIssueContexts(org.ofbiz.core.entity.GenericValue project, List<String> issueTypeIds)
          Deprecated. Please use convertToIssueContexts(Project, List). Since v4.0
static List<IssueContext> convertToIssueContexts(Project project, List<String> issueTypeIds)
          Converts list of issue type ids to IssueContexts.
static String createSearchParam(String customFieldId, String searchParam)
           
static Long getCustomFieldId(String key)
          Given a custom field key, return its id or null.
static String getCustomFieldKey(String searchParamKey)
           
static String getDateFormat()
          Deprecated. Use DateTimeFormatUtils.getDateFormat() instead. Since v5.0.
static String getDateTimeFormat()
          Deprecated. Use DateTimeFormatUtils.getDateTimeFormat() instead. Since v5.0.
protected static I18nHelper getI18nBean()
           
static String 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.
static String 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).
static Collection<Long> getProjectIdsForUser(ApplicationUser user, Collection<Long> projectIds, PermissionManager permissionManager, UserFilter userFilter)
          If projectIds is 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: If issue is not null and issue.getProjectId() is not null, return a single list with issue.getProjectId() If config is not null, use it to retrieve the list of project id's associated with the current scheme Otherwise, return null
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 issue is not null and issue.getProjectId() is not null, return a single list with issue.getProjectId() If config is not null, use it to retrieve the list of project id's associated with the current scheme Otherwise, return null
static String getSearchParamSuffix(String searchParamKey)
           
static String getTimeFormat()
          Deprecated. Use DateTimeFormatUtils.getTimeFormat() instead. Since v5.0.
static boolean isCollectionNotEmpty(Collection stringCollection)
           
static boolean isShownAndVisible(CustomField customField, com.atlassian.crowd.embedded.api.User user, SearchContext searchContext, FieldVisibilityManager fieldVisibilityManager)
          Checks if the custom field is in the search context scope (using OrderableField.isShown(com.atlassian.jira.issue.Issue)) and visible in all field schemes (using FieldVisibilityManager.isFieldHiddenInAllSchemes(String,SearchContext,User))
static boolean isUserHasPermissionToProjects(CustomField customField, com.atlassian.crowd.embedded.api.User 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 [:]> as key)
static String prettyPrintOptions(Options options)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CUSTOM_FIELD_PREFIX

public static final String CUSTOM_FIELD_PREFIX
See Also:
Constant Field Values

PARAM_REQUIRE_PROJECT_IDS

@Deprecated
public static final String PARAM_REQUIRE_PROJECT_IDS
Deprecated. since v6.2.3 use getParamKeyRequireProjectIds() instead.
Since:
v6.2
See Also:
#getParamKeyRequireProjectIds()}, Constant Field Values
Constructor Detail

CustomFieldUtils

public CustomFieldUtils()
Method Detail

getParamKeyPrefixAtl

public static String 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

public static String 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:

Since:
v6.2.2

getSearchParamSuffix

public static String getSearchParamSuffix(String searchParamKey)

getCustomFieldKey

public static String getCustomFieldKey(String searchParamKey)

createSearchParam

public static String createSearchParam(String customFieldId,
                                       String searchParam)

getCustomFieldId

public static Long getCustomFieldId(String key)
Given a custom field key, return its id or null.

Parameters:
key - eg. "customfield_10000"
Returns:
Id, eg. 10000

isCollectionNotEmpty

public static boolean isCollectionNotEmpty(Collection stringCollection)

parseCustomFieldValuesFromActionParams

public static Map<CustomField,Object> parseCustomFieldValuesFromActionParams(Map actionParameters,
                                                                             List<CustomField> customFields)
Parses action parameters (Map of Collections of Strings with [:]> as key)

Parameters:
actionParameters - map of action parameters
customFields - 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[] projectCategories,
                                                           Long[] projects,
                                                           JiraContextTreeManager treeManager)

buildIssueTypes

public static List<org.ofbiz.core.entity.GenericValue> buildIssueTypes(ConstantsManager constantsManager,
                                                                       String[] issueTypes)

convertToIssueContexts

public static List<IssueContext> convertToIssueContexts(org.ofbiz.core.entity.GenericValue project,
                                                        List<String> issueTypeIds)
Deprecated. Please use convertToIssueContexts(Project, List). Since v4.0

Converts list of issue type ids to IssueContexts.

Parameters:
project - project generic value
issueTypeIds - Type ids as strings, eg. ["3", "4"]
Returns:
a list of issue contexts, never null

convertToIssueContexts

public static List<IssueContext> convertToIssueContexts(Project project,
                                                        List<String> issueTypeIds)
Converts list of issue type ids to IssueContexts.

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

public static boolean isUserHasPermissionToProjects(CustomField customField,
                                                    com.atlassian.crowd.embedded.api.User user)
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 field
user - user
Returns:
true if user has permission to at least one project that falls under this custom field, false otherwise

prettyPrintOptions

public static String prettyPrintOptions(Options options)

buildParams

public static Map<String,Object> buildParams(CustomField customField,
                                             FieldConfig config,
                                             Issue issue,
                                             FieldLayoutItem fieldLayoutItem,
                                             Object value,
                                             Map customFieldValuesHolder,
                                             webwork.action.Action action,
                                             Map displayParameters)

getDateFormat

public static String getDateFormat()
Deprecated. Use DateTimeFormatUtils.getDateFormat() instead. Since v5.0.

Returns the configured Javascript date picker format.

ie the format stored in the "jira.date.picker.javascript.format" application property.

Returns:
the configured Javascript date picker format.

getDateTimeFormat

public static String getDateTimeFormat()
Deprecated. Use DateTimeFormatUtils.getDateTimeFormat() instead. Since v5.0.

Returns the configured Javascript date-time picker format.

ie the format stored in the "jira.date.time.picker.javascript.format" application property.

Returns:
the configured Javascript date-time picker format.

getTimeFormat

public static String getTimeFormat()
Deprecated. Use DateTimeFormatUtils.getTimeFormat() instead. Since v5.0.

Returns "12" or "24" from the Javascript date-time picker format.

Returns:
"12" or "24" from the Javascript date-time picker format.

getI18nBean

protected static I18nHelper getI18nBean()

isShownAndVisible

public static boolean isShownAndVisible(CustomField customField,
                                        com.atlassian.crowd.embedded.api.User user,
                                        SearchContext searchContext,
                                        FieldVisibilityManager fieldVisibilityManager)
Checks if the custom field is in the search context scope (using OrderableField.isShown(com.atlassian.jira.issue.Issue)) and visible in all field schemes (using FieldVisibilityManager.isFieldHiddenInAllSchemes(String,SearchContext,User))

Parameters:
customField - customfield to check visibility of
user - current user
searchContext - search context
fieldVisibilityManager - field visibility bean
Returns:
true if the customfield is in scope and visibile in all schemes in the specified search context
See Also:
OrderableField.isShown(com.atlassian.jira.issue.Issue), FieldVisibilityManager.isFieldHiddenInAllSchemes(String,com.atlassian.jira.issue.search.SearchContext,User)

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:
  1. If issue is not null and issue.getProjectId() is not null, return a single list with issue.getProjectId()
  2. If config is not null, use it to retrieve the list of project id's associated with the current scheme
  3. Otherwise, return null

Since:
v6.2

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:
  1. If issue is not null and issue.getProjectId() is not null, return a single list with issue.getProjectId()
  2. If config is not null, use it to retrieve the list of project id's associated with the current scheme
  3. Otherwise, return null

Since:
v6.2.2

getProjectIdsForUser

public static Collection<Long> getProjectIdsForUser(ApplicationUser user,
                                                    Collection<Long> projectIds,
                                                    PermissionManager permissionManager,
                                                    UserFilter userFilter)
If projectIds is not empty, return it. Otherwise, return the list of project id's that the user could browse.

If projectIds is not provided and userFilter contains no roleIds, the list of browsable project ids will not be computed. An empty list will be returned instead.

Since:
v6.2


Copyright © 2002-2014 Atlassian. All Rights Reserved.