Class DefaultIssueConversionService

java.lang.Object
com.atlassian.jira.bc.subtask.conversion.DefaultIssueConversionService
All Implemented Interfaces:
IssueConversionService
Direct Known Subclasses:
DefaultIssueToSubTaskConversionService, DefaultSubTaskToIssueConversionService

public abstract class DefaultIssueConversionService extends Object implements IssueConversionService
  • Field Details

  • Constructor Details

  • Method Details

    • hasPermission

      public boolean hasPermission(JiraServiceContext context, Issue issue)
      Description copied from interface: IssueConversionService
      Checks the user's permission to convert given issue. User is retrieved from the context.
      Specified by:
      hasPermission in interface IssueConversionService
      Parameters:
      context - jira service context
      issue - issue to check the permission on
      Returns:
      true if user is granted permission to convert given issue, false otherwise
    • getPermissionNeeded

      protected ProjectPermissionKey getPermissionNeeded()
      Allows sub-classes override to use another permission
      Returns:
      permission to check
    • isStatusChangeRequired

      public boolean isStatusChangeRequired(JiraServiceContext context, Issue issue, IssueType issueType)
      Description copied from interface: IssueConversionService
      Determines if the workflow status exists in the target workflow (based on current project and target issue type).
      Returns true if the issue's status is not a valid status for the target issue type workflow in the issue's project - issue's status needs to change, false otherwise.
      Specified by:
      isStatusChangeRequired in interface IssueConversionService
      Parameters:
      context - jira service context
      issue - issue to convert
      issueType - target issue type
      Returns:
      true if status change is needed, otherwise false
    • validateTargetStatus

      public void validateTargetStatus(JiraServiceContext context, Status status, String fieldName, Issue issue, IssueType issueType)
      Description copied from interface: IssueConversionService
      Validates that the target status is a valid status for the issue's project and the target issue type. In case of invalid status a new error message is added to the context's error collection under the given fieldName.
      Specified by:
      validateTargetStatus in interface IssueConversionService
      Parameters:
      context - jira service context
      status - target status
      fieldName - form field name
      issue - issue to convert
      issueType - target issue type
    • isStatusInWorkflowForProjectAndIssueType

      protected boolean isStatusInWorkflowForProjectAndIssueType(Status status, Long projectId, String issueTypeId)
      Retrieves the workflow for given project and issue type combination and checks whether the given status is in this workflow.
      Parameters:
      status - issue status
      projectId - project id
      issueTypeId - issue type id
      Returns:
      true if given status is in workflow specified by given project id and issue type id, false otherwise
    • getFieldLayoutItems

      public Collection<FieldLayoutItem> getFieldLayoutItems(Issue originalIssue, Issue targetIssue)
      Description copied from interface: IssueConversionService
      Retrieves the collection of FieldLayoutItem required to be entered from converting issue from given issue to given target issue.
      Specified by:
      getFieldLayoutItems in interface IssueConversionService
      Parameters:
      originalIssue - Current Issue
      targetIssue - Issue with updated issue type
      Returns:
      A Collection of FieldLayoutItem that require values, never null
    • canIssueSecurityFieldIgnore

      protected abstract boolean canIssueSecurityFieldIgnore()
      For an issue to subtask conversion, we can safely ignore the issue security field since the subtask will always take the security level of the parent issue. This however is not the case for subtask to issue conversion
      Returns:
      true if it is safe to ignore the security field.
    • populateFields

      public void populateFields(JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, Collection<FieldLayoutItem> fieldLayoutItems)
      Description copied from interface: IssueConversionService
      Populates the operationContext from the params in the ActionContext In case of invalid values, new error messages are added to the context's error collection under the fieldName.
      Specified by:
      populateFields in interface IssueConversionService
      Parameters:
      context - jira service context
      operationContext - contains Map (CustomFieldValuesHolder) where field values will be populated
      i18nHelper - helper bean for i18n (needed by fields)
      targetIssue - Current issue with updated parent, issue type and status
      fieldLayoutItems - Collection of FieldLayoutItem that required input
    • getRemovedFields

      public Collection<OrderableField> getRemovedFields(Issue origIssue, Issue targetIssue)
      Description copied from interface: IssueConversionService
      Retrieves the fields that have values on the issue but are no longer needed.
      Specified by:
      getRemovedFields in interface IssueConversionService
      Parameters:
      origIssue - issue
      targetIssue - issue
      Returns:
      collection of OrderableField, never null
    • isShouldCheckFieldValue

      protected boolean isShouldCheckFieldValue(Issue origIssue, Field field)
      JRA-12671 - need to determine if we should call hasValue on the field. For calculated custom fields, that are not in scope this isn't the case. This should prevent us from calling hasValue on calculated custom fields.

      protected to make it testable.

      Parameters:
      origIssue - The original issue in which we'll check the context
      field - The field in question.
      Returns:
      true, if the field is not a custom value, or it is in scope in the original issue.
    • validateFields

      public void validateFields(JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, Collection<FieldLayoutItem> fieldLayoutItems)
      Description copied from interface: IssueConversionService
      Validates that all fields inputed have valid values. In case of invalid values, new error messages are added to the context's error collection under the fieldName.
      Specified by:
      validateFields in interface IssueConversionService
      Parameters:
      context - jira service context
      operationContext - contains Map (CustomFieldValuesHolder) containing values to be validated
      i18nHelper - helper bean for i18n (needed by fields)
      targetIssue - Current issue with updated parent, issue type and status
      fieldLayoutItems - Collection of FieldLayoutItem that required input
    • convertIssue

      public void convertIssue(JiraServiceContext context, Issue currentIssue, MutableIssue updatedIssue)
      Description copied from interface: IssueConversionService
      This is the core method that converts given issue to an issue represented by updatedIssue.
      Specified by:
      convertIssue in interface IssueConversionService
      Parameters:
      context - jira service context, any error are added here
      currentIssue - original issue
      updatedIssue - target issue
    • getText

      protected String getText(String key)
      Translates a given key using i18n bean
      Parameters:
      key - key to translate
      Returns:
      i18n string for given key
    • getText

      protected String getText(String key, Object param)
      Translates a given key using i18n bean, passing in param
      Parameters:
      key - key to transkate
      param - param to insert into property
      Returns:
      i18n string for given key, with param inserted
    • getText

      protected String getText(String key, String param0, String param1)
      Translates a given key using i18n bean, passing in params
      Parameters:
      key - key to transkate
      param0 - 1st param to insert into property
      param1 - 2nd param to insert into property
      Returns:
      i18n string for given key, with params inserted