public abstract class

DefaultIssueConversionService

extends Object
implements IssueConversionService
java.lang.Object
   ↳ com.atlassian.jira.bc.subtask.conversion.DefaultIssueConversionService
Known Direct Subclasses

Summary

Fields
protected final FieldLayoutManager fieldLayoutManager
protected final FieldManager fieldManager
protected final IssueTypeSchemeManager issueTypeSchemeManager
protected final JiraAuthenticationContext jiraAuthenticationContext
Public Constructors
DefaultIssueConversionService(PermissionManager permissionManager, WorkflowManager workflowManager, FieldLayoutManager fieldLayoutManager, IssueTypeSchemeManager issueTypeSchemeManager, JiraAuthenticationContext jiraAuthenticationContext, FieldManager fieldManager)
Public Methods
void convertIssue(JiraServiceContext context, Issue currentIssue, MutableIssue updatedIssue)
This is the core method that converts given issue to an issue represented by updatedIssue.
Collection<FieldLayoutItem> getFieldLayoutItems(JiraServiceContext context, Issue originalIssue, Issue targetIssue)
Retrieves the collection of FieldLayoutItem required to be entered from converting issue from given issue to given target issue.
Collection<OrderableField> getRemovedFields(Issue origIssue, Issue targetIssue)
Retrieves the fields that have values on the issue but are no longer needed.
Collection<OrderableField> getRemovedFields(JiraServiceContext context, Issue origIssue, Issue targetIssue)
Retrieves the fields that have values on the issue but are no longer needed.
boolean hasPermission(JiraServiceContext context, Issue issue)
Checks the user's permission to convert given issue.
boolean isStatusChangeRequired(JiraServiceContext context, Issue issue, IssueType issueType)
Determines if the workflow status exists in the target workflow (based on current project and target issue type).
void populateFields(JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, Collection<FieldLayoutItem> fieldLayoutItems)
Populates the operationContext from the params in the webwork.action.ActionContext In case of invalid values, new error messages are added to the context's error collection under the fieldName.
void validateFields(JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, Collection<FieldLayoutItem> fieldLayoutItems)
Validates that all fields inputed have valid values.
void validateTargetStatus(JiraServiceContext context, Status status, String fieldName, Issue issue, IssueType issueType)
Validates that the target status is a valid status for the issue's project and the target issue type.
Protected Methods
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.
int getPermissionNeeded()
Allows sub-classes override to use another permission
String getText(String key, Object param)
Translates a given key using i18n bean, passing in param
String getText(String key)
Translates a given key using i18n bean
String getText(String key, String param0, String param1)
Translates a given key using i18n bean, passing in params
boolean isShouldCheckFieldValue(Issue origIssue, Field field)
JRA-12671 - need to determine if we should call hasValue on the field.
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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.bc.subtask.conversion.IssueConversionService

Fields

protected final FieldLayoutManager fieldLayoutManager

protected final FieldManager fieldManager

protected final IssueTypeSchemeManager issueTypeSchemeManager

protected final JiraAuthenticationContext jiraAuthenticationContext

Public Constructors

public DefaultIssueConversionService (PermissionManager permissionManager, WorkflowManager workflowManager, FieldLayoutManager fieldLayoutManager, IssueTypeSchemeManager issueTypeSchemeManager, JiraAuthenticationContext jiraAuthenticationContext, FieldManager fieldManager)

Public Methods

public void convertIssue (JiraServiceContext context, Issue currentIssue, MutableIssue updatedIssue)

This is the core method that converts given issue to an issue represented by updatedIssue.

Parameters
context jira service context, any error are added here
currentIssue original issue
updatedIssue target issue

public Collection<FieldLayoutItem> getFieldLayoutItems (JiraServiceContext context, Issue originalIssue, Issue targetIssue)

Retrieves the collection of FieldLayoutItem required to be entered from converting issue from given issue to given target issue.

Parameters
context jira service context
originalIssue Current Issue
targetIssue Issue with updated issue type
Returns

public Collection<OrderableField> getRemovedFields (Issue origIssue, Issue targetIssue)

Retrieves the fields that have values on the issue but are no longer needed.

Parameters
origIssue issue
targetIssue issue
Returns

public Collection<OrderableField> getRemovedFields (JiraServiceContext context, Issue origIssue, Issue targetIssue)

Retrieves the fields that have values on the issue but are no longer needed.

Parameters
context jira service context
origIssue issue
targetIssue issue
Returns

public boolean hasPermission (JiraServiceContext context, Issue issue)

Checks the user's permission to convert given issue. User is retrieved from the context.

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

public boolean isStatusChangeRequired (JiraServiceContext context, Issue issue, IssueType issueType)

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.

Parameters
context jira service context
issue issue to convert
issueType target issue type
Returns
  • true if status change is needed, otherwise false

public void populateFields (JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, Collection<FieldLayoutItem> fieldLayoutItems)

Populates the operationContext from the params in the webwork.action.ActionContext In case of invalid values, new error messages are added to the context's error collection under the fieldName.

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

public void validateFields (JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, Collection<FieldLayoutItem> fieldLayoutItems)

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.

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

public void validateTargetStatus (JiraServiceContext context, Status status, String fieldName, Issue issue, IssueType issueType)

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.

Parameters
context jira service context
status target status
fieldName form field name
issue issue to convert
issueType target issue type

Protected Methods

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.

protected int getPermissionNeeded ()

Allows sub-classes override to use another permission

Returns
  • permission to check

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

protected String getText (String key)

Translates a given key using i18n bean

Parameters
key key to translate
Returns
  • i18n string for given key

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

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.

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