com.atlassian.jira.bc.subtask.conversion
Class DefaultIssueConversionService

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

public abstract class DefaultIssueConversionService
extends java.lang.Object
implements IssueConversionService


Field Summary
protected  FieldLayoutManager fieldLayoutManager
           
protected  FieldManager fieldManager
           
protected  IssueTypeSchemeManager issueTypeSchemeManager
           
protected  JiraAuthenticationContext jiraAuthenticationContext
           
 
Constructor Summary
DefaultIssueConversionService(PermissionManager permissionManager, WorkflowManager workflowManager, FieldLayoutManager fieldLayoutManager, IssueTypeSchemeManager issueTypeSchemeManager, JiraAuthenticationContext jiraAuthenticationContext, FieldManager fieldManager)
           
 
Method Summary
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.
 void convertIssue(JiraServiceContext context, Issue currentIssue, MutableIssue updatedIssue)
          This is the core method that converts given issue to an issue represented by updatedIssue.
 java.util.Collection 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.
protected  int getPermissionNeeded()
          Allows sub-classes override to use another permission
 java.util.Collection getRemovedFields(JiraServiceContext context, Issue origIssue, Issue targetIssue)
          Retrieves the fields that have values on the issue but are no longer needed.
protected  java.lang.String getText(java.lang.String key)
          Translates a given key using i18n bean
protected  java.lang.String getText(java.lang.String key, java.lang.Object param)
          Translates a given key using i18n bean, passing in param
protected  java.lang.String getText(java.lang.String key, java.lang.String param0, java.lang.String param1)
          Translates a given key using i18n bean, passing in params
 boolean hasPermission(JiraServiceContext context, Issue issue)
          Checks the user's permission to convert given issue.
protected  boolean isShouldCheckFieldValue(JiraServiceContext context, Issue origIssue, Field field)
          JRA-12671 - need to determine if we should call hasValue on the field.
 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).
protected  boolean isStatusInWorkflowForProjectAndIssueType(Status status, java.lang.Long projectId, java.lang.String issueTypeId)
          Retrieves the workflow for given project and issue type combination and checks whether the given status is in this workflow.
 void populateFields(JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, java.util.Collection fieldLayoutItems)
          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.
 void validateFields(JiraServiceContext context, OperationContext operationContext, I18nHelper i18nHelper, Issue targetIssue, java.util.Collection fieldLayoutItems)
          Validates that all fields inputed have valid values.
 void validateTargetStatus(JiraServiceContext context, Status status, java.lang.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, wait
 
Methods inherited from interface com.atlassian.jira.bc.subtask.conversion.IssueConversionService
canConvertIssue, preStoreUpdates, validateTargetIssueType
 

Field Detail

fieldLayoutManager

protected final FieldLayoutManager fieldLayoutManager

issueTypeSchemeManager

protected final IssueTypeSchemeManager issueTypeSchemeManager

jiraAuthenticationContext

protected final JiraAuthenticationContext jiraAuthenticationContext

fieldManager

protected final FieldManager fieldManager
Constructor Detail

DefaultIssueConversionService

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

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 int 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,
                                 java.lang.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,
                                                           java.lang.Long projectId,
                                                           java.lang.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 java.util.Collection getFieldLayoutItems(JiraServiceContext context,
                                                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:
context - jira service context
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,
                           java.util.Collection 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 java.util.Collection getRemovedFields(JiraServiceContext context,
                                             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:
context - jira service context
origIssue - issue
targetIssue - issue
Returns:
collection of OrderableField, never null

isShouldCheckFieldValue

protected boolean isShouldCheckFieldValue(JiraServiceContext context,
                                          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:
context - The service context needed for the remote user
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,
                           java.util.Collection 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 java.lang.String getText(java.lang.String key)
Translates a given key using i18n bean

Parameters:
key - key to translate
Returns:
i18n string for given key

getText

protected java.lang.String getText(java.lang.String key,
                                   java.lang.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 java.lang.String getText(java.lang.String key,
                                   java.lang.String param0,
                                   java.lang.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


Copyright © 2002-2010 Atlassian. All Rights Reserved.