Interface CustomFieldService

All Known Implementing Classes:
CustomFieldServiceImpl

public interface CustomFieldService
Service for encapsulating custom field logic, especially the rather complex JIRA logic behind creating and working with these things.
Author:
ahennecke
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.atlassian.jira.issue.fields.config.FieldConfigScheme
    associateCustomFieldContext(com.atlassian.jira.issue.fields.CustomField customField, CustomFieldMetadata customFieldMetadata)
    Re-associates the custom field to the specified contexts.
    com.atlassian.jira.issue.fields.config.FieldConfigScheme
    associateCustomFieldContext(com.atlassian.jira.issue.fields.CustomField customField, Collection<IssueTypePrototype> issueTypes)
    Re-associates the custom field to the specified issue type specific contexts.
    com.atlassian.jira.issue.fields.CustomField
    Create a new custom field in JIRA with the given configuration
    com.atlassian.jira.issue.fields.CustomField
     
    com.atlassian.jira.issue.fields.CustomField
     
    <T extends com.atlassian.jira.issue.customfields.CustomFieldType>
    List<com.atlassian.jira.issue.fields.CustomField>
    Return all custom field instances which are of type CustomFieldService (but not sub-classes).
    <T extends com.atlassian.jira.issue.customfields.CustomFieldType>
    List<com.atlassian.jira.issue.fields.CustomField>
    getCustomFields(Class<T> type, boolean strict)
    Return all custom field instances which are of type CustomFieldService, or a subclass of CustomFieldService.
    boolean
    isFieldApplicable(com.atlassian.jira.issue.fields.CustomField customField, com.atlassian.jira.issue.Issue issue)
    Determine whether the given custom field is applicable for (i.e. configured for the context of) the specified issue.
    boolean
    isFieldApplicable(com.atlassian.jira.issue.fields.CustomField customField, Long projectId, String issueTypeId)
    Determine whether the given custom field is applicable for (i.e. configured for the context of) the specified project and issue type.
    boolean
    isFieldVisible(com.atlassian.jira.issue.fields.CustomField customField, com.atlassian.jira.issue.Issue issue)
     
    boolean
    Check whether the passed field name matches a system field name (as used by JQL)
    boolean
    isUniqueFieldName(com.atlassian.jira.issue.fields.CustomField customField)
    Has the custom field a unique name?
    void
    makeFieldRequired(com.atlassian.jira.issue.fields.CustomField field)
    Make the specified field required for all configurations
    void
    removeCustomField(com.atlassian.jira.issue.fields.CustomField customField)
    Removes the custom field and all associated data.
    void
    setOptionsOrderFromMetadata(com.atlassian.jira.issue.fields.CustomField customField, CustomFieldMetadata fieldMetadata)
    Set the order of Options in a CustomField based on the order of the Options in the CustomFieldMetadata.
    boolean
    Checks if a custom field with the given id exists in the database
    boolean
    Checks if a custom field with the given id exists in the database.
  • Field Details

  • Method Details

    • createCustomField

      com.atlassian.jira.issue.fields.CustomField createCustomField(CustomFieldMetadata fieldMetadata)
      Create a new custom field in JIRA with the given configuration
    • associateCustomFieldContext

      com.atlassian.jira.issue.fields.config.FieldConfigScheme associateCustomFieldContext(com.atlassian.jira.issue.fields.CustomField customField, CustomFieldMetadata customFieldMetadata)
      Re-associates the custom field to the specified contexts. Warning - this has not been extensively tested in the case where the custom field already has some contexts. This is intended to be used when the custom field's contexts have been removed due to the removal of an issue type, for example.
      Parameters:
      customField - the field instance
      customFieldMetadata - the metadata which contains context and issue type information
    • associateCustomFieldContext

      com.atlassian.jira.issue.fields.config.FieldConfigScheme associateCustomFieldContext(com.atlassian.jira.issue.fields.CustomField customField, Collection<IssueTypePrototype> issueTypes)
      Re-associates the custom field to the specified issue type specific contexts. Warning - this has not been extensively tested in the case where the custom field already has some contexts. This is intended to be used when the custom field's contexts have been removed due to the removal of an issue type, for example.
      Parameters:
      customField - the field instance
      issueTypes - issue type information
    • getCustomField

      com.atlassian.jira.issue.fields.CustomField getCustomField(Long id)
      Returns:
      the CustomField instance for the given ID, or null if it doesn't exist
    • getCustomField

      com.atlassian.jira.issue.fields.CustomField getCustomField(String id)
      Returns:
      the CustomField instance for the given String ID, or null if it doesn't exist
    • getCustomFields

      <T extends com.atlassian.jira.issue.customfields.CustomFieldType> List<com.atlassian.jira.issue.fields.CustomField> getCustomFields(Class<T> type)
      Return all custom field instances which are of type CustomFieldService (but not sub-classes).
      Type Parameters:
      T - the CustomFieldType to check for. Equality checking is done on the custom field's type.
      Parameters:
      type - the type to retrieve
      Returns:
      the list of custom fields; never null
    • getCustomFields

      <T extends com.atlassian.jira.issue.customfields.CustomFieldType> List<com.atlassian.jira.issue.fields.CustomField> getCustomFields(Class<T> type, boolean strict)
      Return all custom field instances which are of type CustomFieldService, or a subclass of CustomFieldService.
      Type Parameters:
      T - the CustomFieldType to check for. Equality checking is done on the custom field's type.
      Parameters:
      type - the type to retrieve
      strict - set to true to do a strict equality check on the specified type.
      Returns:
      the list of custom fields; never null
    • removeCustomField

      void removeCustomField(com.atlassian.jira.issue.fields.CustomField customField)
      Removes the custom field and all associated data. Note that this requires the custom field to be fully recognisable in JIRA's current state (i.e. the CustomFieldType for this object must still be available).
      Parameters:
      customField - the custom field object
      See Also:
      • CustomFieldManager.removeCustomField(com.atlassian.jira.issue.fields.CustomField)
    • isUniqueFieldName

      boolean isUniqueFieldName(com.atlassian.jira.issue.fields.CustomField customField)
      Has the custom field a unique name? Used whenever creating JQL to decide whether to use the name or the id of the field
    • isSystemFieldName

      boolean isSystemFieldName(String fieldName)
      Check whether the passed field name matches a system field name (as used by JQL)
    • isFieldApplicable

      boolean isFieldApplicable(com.atlassian.jira.issue.fields.CustomField customField, com.atlassian.jira.issue.Issue issue)
      Determine whether the given custom field is applicable for (i.e. configured for the context of) the specified issue.
      Parameters:
      customField - the field
      issue - the issue
      Returns:
      whether or not the field is applicable
    • isFieldApplicable

      boolean isFieldApplicable(com.atlassian.jira.issue.fields.CustomField customField, Long projectId, String issueTypeId)
      Determine whether the given custom field is applicable for (i.e. configured for the context of) the specified project and issue type.
      Parameters:
      customField - the field
      projectId - the project the issue is in
      issueTypeId - the issue type of the issue
      Returns:
      whether or not the field is applicable
    • isFieldVisible

      boolean isFieldVisible(com.atlassian.jira.issue.fields.CustomField customField, com.atlassian.jira.issue.Issue issue)
    • makeFieldRequired

      void makeFieldRequired(com.atlassian.jira.issue.fields.CustomField field)
      Make the specified field required for all configurations
      Parameters:
      field - the custom field.
    • setOptionsOrderFromMetadata

      void setOptionsOrderFromMetadata(com.atlassian.jira.issue.fields.CustomField customField, CustomFieldMetadata fieldMetadata)
      Set the order of Options in a CustomField based on the order of the Options in the CustomFieldMetadata. This is part of the work that is done in createCustomField, but split into a public method so we can fix up the order of Options after the fact in upgrade tasks, etc.
      Parameters:
      customField -
      fieldMetadata -
      Throws:
      CustomFieldException - If the Options in the CustomField do not match the Options in the CustomFieldMetadata. This only re-orders if they have the same options.
    • verifyCustomFieldExistsInDB

      boolean verifyCustomFieldExistsInDB(Long customFieldId)
      Checks if a custom field with the given id exists in the database
      Parameters:
      customFieldId -
      Returns:
    • verifyCustomFieldExistsInDB

      boolean verifyCustomFieldExistsInDB(String customFieldId)
      Checks if a custom field with the given id exists in the database. The id passed is expected to be in the form of "customfield_xxxx". If the given id does not match the expected form, false is returned.
      Parameters:
      customFieldId -
      Returns: