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 Summary
FieldsModifier and TypeFieldDescriptionprotected final FieldLayoutManagerprotected final FieldManagerprotected final IssueTypeSchemeManagerprotected final JiraAuthenticationContext -
Constructor Summary
ConstructorsConstructorDescriptionDefaultIssueConversionService(PermissionManager permissionManager, WorkflowManager workflowManager, FieldLayoutManager fieldLayoutManager, IssueTypeSchemeManager issueTypeSchemeManager, JiraAuthenticationContext jiraAuthenticationContext, FieldManager fieldManager, IssueEventManager issueEventManager, IssueEventBundleFactory issueEventBundleFactory, TxnAwareEventFactory txnAwareEventFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleanFor 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.voidconvertIssue(JiraServiceContext context, Issue currentIssue, MutableIssue updatedIssue) This is the core method that converts given issue to an issue represented by updatedIssue.getFieldLayoutItems(Issue originalIssue, Issue targetIssue) Retrieves the collection ofFieldLayoutItemrequired to be entered from converting issue from given issue to given target issue.protected ProjectPermissionKeyAllows sub-classes override to use another permissiongetRemovedFields(Issue origIssue, Issue targetIssue) Retrieves the fields that have values on the issue but are no longer needed.protected StringTranslates a given key using i18n beanprotected StringTranslates a given key using i18n bean, passing in paramprotected StringTranslates a given key using i18n bean, passing in paramsbooleanhasPermission(JiraServiceContext context, Issue issue) Checks the user's permission to convert given issue.protected booleanisShouldCheckFieldValue(Issue origIssue, Field field) JRA-12671 - need to determine if we should call hasValue on the field.booleanisStatusChangeRequired(JiraServiceContext context, Issue issue, IssueType issueType) Determines if the workflow status exists in the target workflow (based on current project and target issue type).protected booleanisStatusInWorkflowForProjectAndIssueType(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.voidpopulateFields(JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, Collection<FieldLayoutItem> fieldLayoutItems) Populates the operationContext from the params in theActionContextIn case of invalid values, new error messages are added to the context's error collection under the fieldName.voidvalidateFields(JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, Collection<FieldLayoutItem> fieldLayoutItems) Validates that all fields inputed have valid values.voidvalidateTargetStatus(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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.jira.bc.subtask.conversion.IssueConversionService
canConvertIssue, preStoreUpdates, validateTargetIssueType
-
Field Details
-
fieldLayoutManager
-
issueTypeSchemeManager
-
jiraAuthenticationContext
-
fieldManager
-
-
Constructor Details
-
DefaultIssueConversionService
public DefaultIssueConversionService(PermissionManager permissionManager, WorkflowManager workflowManager, FieldLayoutManager fieldLayoutManager, IssueTypeSchemeManager issueTypeSchemeManager, JiraAuthenticationContext jiraAuthenticationContext, FieldManager fieldManager, IssueEventManager issueEventManager, IssueEventBundleFactory issueEventBundleFactory, TxnAwareEventFactory txnAwareEventFactory)
-
-
Method Details
-
hasPermission
Description copied from interface:IssueConversionServiceChecks the user's permission to convert given issue. User is retrieved from the context.- Specified by:
hasPermissionin interfaceIssueConversionService- Parameters:
context- jira service contextissue- issue to check the permission on- Returns:
- true if user is granted permission to convert given issue, false otherwise
-
getPermissionNeeded
Allows sub-classes override to use another permission- Returns:
- permission to check
-
isStatusChangeRequired
Description copied from interface:IssueConversionServiceDetermines 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:
isStatusChangeRequiredin interfaceIssueConversionService- Parameters:
context- jira service contextissue- issue to convertissueType- 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:IssueConversionServiceValidates 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:
validateTargetStatusin interfaceIssueConversionService- Parameters:
context- jira service contextstatus- target statusfieldName- form field nameissue- issue to convertissueType- 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 statusprojectId- project idissueTypeId- issue type id- Returns:
- true if given status is in workflow specified by given project id and issue type id, false otherwise
-
getFieldLayoutItems
Description copied from interface:IssueConversionServiceRetrieves the collection ofFieldLayoutItemrequired to be entered from converting issue from given issue to given target issue.- Specified by:
getFieldLayoutItemsin interfaceIssueConversionService- Parameters:
originalIssue- Current IssuetargetIssue- Issue with updated issue type- Returns:
- A Collection of
FieldLayoutItemthat 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:IssueConversionServicePopulates the operationContext from the params in theActionContextIn case of invalid values, new error messages are added to the context's error collection under the fieldName.- Specified by:
populateFieldsin interfaceIssueConversionService- Parameters:
context- jira service contextoperationContext- contains Map (CustomFieldValuesHolder) where field values will be populatedi18nHelper- helper bean for i18n (needed by fields)targetIssue- Current issue with updated parent, issue type and statusfieldLayoutItems- Collection ofFieldLayoutItemthat required input
-
getRemovedFields
Description copied from interface:IssueConversionServiceRetrieves the fields that have values on the issue but are no longer needed.- Specified by:
getRemovedFieldsin interfaceIssueConversionService- Parameters:
origIssue- issuetargetIssue- issue- Returns:
- collection of
OrderableField, never null
-
isShouldCheckFieldValue
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 contextfield- 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:IssueConversionServiceValidates 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:
validateFieldsin interfaceIssueConversionService- Parameters:
context- jira service contextoperationContext- contains Map (CustomFieldValuesHolder) containing values to be validatedi18nHelper- helper bean for i18n (needed by fields)targetIssue- Current issue with updated parent, issue type and statusfieldLayoutItems- Collection ofFieldLayoutItemthat required input
-
convertIssue
Description copied from interface:IssueConversionServiceThis is the core method that converts given issue to an issue represented by updatedIssue.- Specified by:
convertIssuein interfaceIssueConversionService- Parameters:
context- jira service context, any error are added herecurrentIssue- original issueupdatedIssue- target issue
-
getText
Translates a given key using i18n bean- Parameters:
key- key to translate- Returns:
- i18n string for given key
-
getText
Translates a given key using i18n bean, passing in param- Parameters:
key- key to transkateparam- param to insert into property- Returns:
- i18n string for given key, with param inserted
-
getText
Translates a given key using i18n bean, passing in params- Parameters:
key- key to transkateparam0- 1st param to insert into propertyparam1- 2nd param to insert into property- Returns:
- i18n string for given key, with params inserted
-