com.atlassian.jira.issue.fields
Class TimeTrackingSystemField

java.lang.Object
  extended by com.atlassian.jira.issue.fields.AbstractField
      extended by com.atlassian.jira.issue.fields.AbstractOrderableField
          extended by com.atlassian.jira.issue.fields.TimeTrackingSystemField
All Implemented Interfaces:
Field, HideableField, OrderableField, RequirableField, RestAwareField, RestFieldOperations, SearchableField, Comparable

public class TimeTrackingSystemField
extends AbstractOrderableField
implements HideableField, RequirableField, RestAwareField, RestFieldOperations

The TimeTrackingSystemField is responsible for "maintaining" the 2 estimates values, namely Original Estimate and Remaining Estimate.

Since 4.2 it has two modes of operation, the older legacy mode that keeps original and remaining estimate tied together while work is not logged and the more modern mode that allows the 2 values to be edited and set independently. NOTES: Whenever you see the targetSubField mentioned its because the UpdateIssueFieldFunction tries to jam 1 value into this field. in the past this kinda worked but in the post separation world, it becomes more complicated. So we keep track of the "target" that wants to be updated and then we spend lots of effort making sure only that sub field gets updated.


Nested Class Summary
static interface TimeTrackingSystemField.TimeTrackingValue
          This interface is used as a value object for TimeTracking information.

 
Field Summary
static String TIMETRACKING_ORIGINALESTIMATE
           
static String TIMETRACKING_REMAININGESTIMATE
           
static String TIMETRACKING_TARGETSUBFIELD
          When this input parameter is specified then we are only wanted to set a specific sub field of time tracking.
 
Fields inherited from class com.atlassian.jira.issue.fields.AbstractField
authenticationContext
 
Fields inherited from interface com.atlassian.jira.issue.fields.OrderableField
MOVE_ISSUE_PARAM_KEY, NO_HEADER_PARAM_KEY, TEMPLATE_DIRECTORY_PATH
 
Constructor Summary
TimeTrackingSystemField(VelocityTemplatingEngine templatingEngine, ApplicationProperties applicationProperties, IssueManager issueManager, JiraAuthenticationContext authenticationContext, PermissionManager permissionManager, JiraDurationUtils jiraDurationUtils)
           
 
Method Summary
 String availableForBulkEdit(BulkEditBean bulkEditBean)
          Determines whether the field is available for bulk editing given the BulkEditBean.
 boolean canRemoveValueFromIssueObject(Issue issue)
          Returns true if a call to OrderableField.removeValueFromIssueObject(com.atlassian.jira.issue.MutableIssue) will actually remove the value.
 void createValue(Issue issue, Object value)
          Create the value of the issue in the data store.
 String getBulkEditHtml(OperationContext operationContext, webwork.action.Action action, BulkEditBean bulkEditBean, Map displayParameters)
          Returns HTML that should be shown when the issue is being bulk edited.
 String getCreateHtml(FieldLayoutItem fieldLayoutItem, OperationContext operationContext, webwork.action.Action action, Issue issue, Map displayParameters)
          Returns the HTML that should be shown when the issue is being created.
 Object getDefaultValue(Issue issue)
          The value that should be set on the issue if the field is not shown for some reason.
 String getEditHtml(FieldLayoutItem fieldLayoutItem, OperationContext operationContext, webwork.action.Action action, Issue issue, Map displayParameters)
          Returns HTML that should be shown when the issue is being edited.
 FieldTypeInfo getFieldTypeInfo(FieldTypeInfoContext fieldTypeInfoContext)
          Returns lower level Information about the field.
 JsonData getJsonDefaultValue(IssueContext issueCtx)
          Return The default data for this system field.
 FieldJsonRepresentation getJsonFromIssue(Issue issue, boolean renderedVersionRequested, FieldLayoutItem fieldLayoutItem)
          Return a FieldJsonDataPair containing a json representation of the raw data for this field, and if required, a json representation of the rendered data for easy display.
 JsonType getJsonSchema()
          Return a description of the shape of this field when represented as JSON.
protected  Object getRelevantParams(Map<String,String[]> inputParameters)
          This is implemented in response to use being an AbstractOrderableField.
 RestFieldOperationsHandler getRestFieldOperation()
           
 Object getValueFromParams(Map fieldValueHolder)
          This is called from BulkEdit/BulkWorkflowTransition to get an value object from a input set of values.
 String getViewHtml(FieldLayoutItem fieldLayoutItem, webwork.action.Action action, Issue issue, Map displayParameters)
           
 String getViewHtml(FieldLayoutItem fieldLayoutItem, webwork.action.Action action, Issue issue, Object value, Map displayParameters)
           
 boolean hasParam(Map parameters)
          Basic implementation where the relevant params object is null if no elements are present.
 boolean hasValue(Issue issue)
          Determines if the field has a value for the given issue.
 boolean hasWorkStarted(Issue issue)
           
 boolean isShown(Issue issue)
          Tests field specific way to determine if it should be shown or not.
 MessagedResult needsMove(Collection originalIssues, Issue targetIssue, FieldLayoutItem targetFieldLayoutItem)
          Used to determine if the field needs input from user to be moved to the new project and/or issue type.
 void populateDefaults(Map<String,Object> fieldValuesHolder, Issue issue)
          We don't return any default for the TimeTracking field.
 void populateForMove(Map<String,Object> fieldValuesHolder, Issue originalIssue, Issue targetIssue)
          Used to populate the fieldValueHolder with parameters for move issue screen.
 void populateFromIssue(Map<String,Object> fieldValuesHolder, Issue issue)
          This is called to populate the field values holder with the current state of the Issue object.
 void populateFromParams(Map<String,Object> fieldValuesHolder, Map<String,String[]> inputParameters)
          This will populate the field values holder map with the time tracking value contained within the map of (typically but not always web) parameters.
 void populateParamsFromString(Map<String,Object> fieldValuesHolder, String stringValue, Issue issue)
          This is called by Jelly code to map a value into a field values holder.
 void removeValueFromIssueObject(MutableIssue issue)
          Removes the field value from the given MutableIssue object.
 void updateIssue(FieldLayoutItem fieldLayoutItem, MutableIssue issue, Map fieldValueHolder)
           This is called to back update the MutableIssue with the value object we previously stuffed into the field values holder.
 void updateValue(FieldLayoutItem fieldLayoutItem, Issue issue, ModifiedValue modifiedValue, IssueChangeHolder issueChangeHolder)
          This is called after the issue has been stored on disk and allows us a chance to create change records for the update.
 void validateParams(OperationContext operationContext, ErrorCollection errorCollection, I18nHelper i18n, Issue issue, FieldScreenRenderLayoutItem fieldScreenRenderLayoutItem)
          Ensure that the parameters are valid
 
Methods inherited from class com.atlassian.jira.issue.fields.AbstractOrderableField
createAssociatedSearchHandler, getApplicationProperties, getCreateHtml, getEditHtml, getPermissionManager, getVelocityParams, getVelocityParams, getViewHtml, hasBulkUpdatePermission, hasPermission, isHidden, rendererTypesEqual, renderTemplate, valuesEqual
 
Methods inherited from class com.atlassian.jira.issue.fields.AbstractField
compareTo, equals, getAuthenticationContext, getId, getName, getNameKey, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.issue.fields.Field
getId, getName, getNameKey
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

TIMETRACKING_TARGETSUBFIELD

public static final String TIMETRACKING_TARGETSUBFIELD
When this input parameter is specified then we are only wanted to set a specific sub field of time tracking. This parameter will say which one.

This is used by the UpdateIssueFieldFunction so that it can set say original estimate only for example.

See Also:
Constant Field Values

TIMETRACKING_ORIGINALESTIMATE

public static final String TIMETRACKING_ORIGINALESTIMATE
See Also:
Constant Field Values

TIMETRACKING_REMAININGESTIMATE

public static final String TIMETRACKING_REMAININGESTIMATE
See Also:
Constant Field Values
Constructor Detail

TimeTrackingSystemField

public TimeTrackingSystemField(VelocityTemplatingEngine templatingEngine,
                               ApplicationProperties applicationProperties,
                               IssueManager issueManager,
                               JiraAuthenticationContext authenticationContext,
                               PermissionManager permissionManager,
                               JiraDurationUtils jiraDurationUtils)
Method Detail

getCreateHtml

public String getCreateHtml(FieldLayoutItem fieldLayoutItem,
                            OperationContext operationContext,
                            webwork.action.Action action,
                            Issue issue,
                            Map displayParameters)
Description copied from interface: OrderableField
Returns the HTML that should be shown when the issue is being created.

Specified by:
getCreateHtml in interface OrderableField
Parameters:
fieldLayoutItem - FieldLayoutItem
operationContext - OperationContext
action - Action
issue - Issue
displayParameters - Map of display parameters.
Returns:
the HTML that should be shown when the issue is being created.

getEditHtml

public String getEditHtml(FieldLayoutItem fieldLayoutItem,
                          OperationContext operationContext,
                          webwork.action.Action action,
                          Issue issue,
                          Map displayParameters)
Description copied from interface: OrderableField
Returns HTML that should be shown when the issue is being edited.

Specified by:
getEditHtml in interface OrderableField
Parameters:
fieldLayoutItem - FieldLayoutItem
operationContext - OperationContext
action - Action
issue - Issue
displayParameters - Map of display parameters.
Returns:
HTML that should be shown when the issue is being edited.

getBulkEditHtml

public String getBulkEditHtml(OperationContext operationContext,
                              webwork.action.Action action,
                              BulkEditBean bulkEditBean,
                              Map displayParameters)
Description copied from class: AbstractOrderableField
Returns HTML that should be shown when the issue is being bulk edited. By default calls the OrderableField.getEditHtml(com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem, com.atlassian.jira.issue.customfields.OperationContext, webwork.action.Action, com.atlassian.jira.issue.Issue, java.util.Map) method with null for FieldLayoutItem and the first issue in the collection}

Specified by:
getBulkEditHtml in interface OrderableField
Overrides:
getBulkEditHtml in class AbstractOrderableField
Parameters:
operationContext - OperationContext
action - Action
bulkEditBean - BulkEditBean
displayParameters - Map of display parameters.
Returns:
HTML that should be shown when the issue is being edited.

getViewHtml

public String getViewHtml(FieldLayoutItem fieldLayoutItem,
                          webwork.action.Action action,
                          Issue issue,
                          Map displayParameters)
Specified by:
getViewHtml in interface OrderableField

getViewHtml

public String getViewHtml(FieldLayoutItem fieldLayoutItem,
                          webwork.action.Action action,
                          Issue issue,
                          Object value,
                          Map displayParameters)
Specified by:
getViewHtml in interface OrderableField

createValue

public void createValue(Issue issue,
                        Object value)
Description copied from interface: OrderableField
Create the value of the issue in the data store.

Specified by:
createValue in interface OrderableField
Parameters:
issue - Issue this field is part of
value - Value to store in this field (eg. Collection for Version fields). Cannot be null.

getDefaultValue

public Object getDefaultValue(Issue issue)
Description copied from interface: OrderableField
The value that should be set on the issue if the field is not shown for some reason.

For example: The user does not have permission to see the field, or the field is not part of the create screen.

Specified by:
getDefaultValue in interface OrderableField
Parameters:
issue - the Issue.
Returns:
The default Value.

populateDefaults

public void populateDefaults(Map<String,Object> fieldValuesHolder,
                             Issue issue)
We don't return any default for the TimeTracking field.

Specified by:
populateDefaults in interface OrderableField
Parameters:
fieldValuesHolder - The fieldValuesHolder Map to be populated.
issue - The issue in play.

populateParamsFromString

public void populateParamsFromString(Map<String,Object> fieldValuesHolder,
                                     String stringValue,
                                     Issue issue)
                              throws FieldValidationException
This is called by Jelly code to map a value into a field values holder.

Specified by:
populateParamsFromString in interface OrderableField
Parameters:
fieldValuesHolder - Map of field Values.
stringValue - user friendly string value.
issue - the issue in play.
Throws:
FieldValidationException

populateForMove

public void populateForMove(Map<String,Object> fieldValuesHolder,
                            Issue originalIssue,
                            Issue targetIssue)
Description copied from interface: OrderableField
Used to populate the fieldValueHolder with parameters for move issue screen. This field is only called if the issue needs to be updated during move, i.e. OrderableField.needsMove(java.util.Collection,com.atlassian.jira.issue.Issue,com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem) returned true, and the remote user (the one performing the move) has the permission to actually update this field.

Specified by:
populateForMove in interface OrderableField
Parameters:
fieldValuesHolder - Map of field Values.
originalIssue - orignal Issue
targetIssue - target Issue

hasParam

public boolean hasParam(Map parameters)
Description copied from class: AbstractOrderableField
Basic implementation where the relevant params object is null if no elements are present. Some fields need to override this because of their innate complex behaviour.

Specified by:
hasParam in interface OrderableField
Overrides:
hasParam in class AbstractOrderableField
Parameters:
parameters - Map of parameters.
Returns:
True if a relevant parameter is available in the input.

populateFromParams

public void populateFromParams(Map<String,Object> fieldValuesHolder,
                               Map<String,String[]> inputParameters)
This will populate the field values holder map with the time tracking value contained within the map of (typically but not always web) parameters.

We override this so we can see this happen. This helps for debugging reasons. Damn you class hierarchies, you are confusing me!

This will end up calling getRelevantParams(java.util.Map) by the way.

Specified by:
populateFromParams in interface OrderableField
Overrides:
populateFromParams in class AbstractOrderableField
Parameters:
fieldValuesHolder - the writable map of field values in play.
inputParameters - the input parameters.

getRelevantParams

protected Object getRelevantParams(Map<String,String[]> inputParameters)
This is implemented in response to use being an AbstractOrderableField. It is actually called via populateFromParams so that we can place our relevant value object into the field values holder map. See above for the code entry point.

Specified by:
getRelevantParams in class AbstractOrderableField
Parameters:
inputParameters - the input parameters.
Returns:
the object to be placed into a field values holder map under our id.

populateFromIssue

public void populateFromIssue(Map<String,Object> fieldValuesHolder,
                              Issue issue)
This is called to populate the field values holder with the current state of the Issue object. For example this will be called when the issue is edited.

Specified by:
populateFromIssue in interface OrderableField
Parameters:
fieldValuesHolder - The fieldValuesHolder Map to be populated.
issue - The issue in play.

validateParams

public void validateParams(OperationContext operationContext,
                           ErrorCollection errorCollection,
                           I18nHelper i18n,
                           Issue issue,
                           FieldScreenRenderLayoutItem fieldScreenRenderLayoutItem)
Description copied from interface: OrderableField
Ensure that the parameters are valid

Specified by:
validateParams in interface OrderableField
Parameters:
operationContext - OperationContext
errorCollection - ErrorCollection to add to.
i18n - I18nHelper
issue - This is passed to get the value of other fields that may or may not have been modified.
fieldScreenRenderLayoutItem - FieldScreenRenderLayoutItem

getValueFromParams

public Object getValueFromParams(Map fieldValueHolder)
This is called from BulkEdit/BulkWorkflowTransition to get an value object from a input set of values.

Specified by:
getValueFromParams in interface OrderableField
Parameters:
fieldValueHolder - the map of parameters.
Returns:
a parsed long or null if not in the input.

updateIssue

public void updateIssue(FieldLayoutItem fieldLayoutItem,
                        MutableIssue issue,
                        Map fieldValueHolder)

This is called to back update the MutableIssue with the value object we previously stuffed into the field values holder.

This is called prior to the issue being stored on disk.

Specified by:
updateIssue in interface OrderableField
Parameters:
fieldLayoutItem - FieldLayoutItem in play.
issue - MutableIssue in play.
fieldValueHolder - Field Value Holder Map.
See Also:
OrderableField.updateValue(com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem, com.atlassian.jira.issue.Issue, com.atlassian.jira.issue.ModifiedValue, com.atlassian.jira.issue.util.IssueChangeHolder)

updateValue

public void updateValue(FieldLayoutItem fieldLayoutItem,
                        Issue issue,
                        ModifiedValue modifiedValue,
                        IssueChangeHolder issueChangeHolder)
This is called after the issue has been stored on disk and allows us a chance to create change records for the update.

Specified by:
updateValue in interface OrderableField
Parameters:
fieldLayoutItem - for this field within this context.
issue - Issue this field is part of.
modifiedValue - new value to set field to. Cannot be null.
issueChangeHolder - an object to record any changes made to the issue by this method.

needsMove

public MessagedResult needsMove(Collection originalIssues,
                                Issue targetIssue,
                                FieldLayoutItem targetFieldLayoutItem)
Description copied from interface: OrderableField
Used to determine if the field needs input from user to be moved to the new project and/or issue type. This method is called only if the field is visible in the target project/issue type.

Specified by:
needsMove in interface OrderableField
Parameters:
originalIssues - Collection of original Issues.
targetIssue - Target Issue.
targetFieldLayoutItem - FieldLayoutItem
Returns:
A MessagedResult with result=true if the field needs input to be moved.

removeValueFromIssueObject

public void removeValueFromIssueObject(MutableIssue issue)
Description copied from interface: OrderableField
Removes the field value from the given MutableIssue object.

Note that this operation does not actually persist the change, it just clears the value from the given Issue object. The caller will still need to call #updateValue() in order to persist the change.

Some Fields may choose to quietly ignore this request. eg The SecurityLevel Field will not remove Security Level from subtasks because the subtask must always take the Security Level of its parent issue.

Specified by:
removeValueFromIssueObject in interface OrderableField
Parameters:
issue - The issue object to be effected.
See Also:
OrderableField.canRemoveValueFromIssueObject(com.atlassian.jira.issue.Issue), OrderableField.updateValue(com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem, com.atlassian.jira.issue.Issue, com.atlassian.jira.issue.ModifiedValue, com.atlassian.jira.issue.util.IssueChangeHolder)

isShown

public boolean isShown(Issue issue)
Description copied from interface: OrderableField
Tests field specific way to determine if it should be shown or not.

Specified by:
isShown in interface OrderableField
Parameters:
issue - The Issue.
Returns:
true if it should be shown.

canRemoveValueFromIssueObject

public boolean canRemoveValueFromIssueObject(Issue issue)
Description copied from interface: OrderableField
Returns true if a call to OrderableField.removeValueFromIssueObject(com.atlassian.jira.issue.MutableIssue) will actually remove the value.

There a few different reasons why this method may return false:

In general it is safe to call removeValueFromIssueObject() even if this method returns false, as the request will be silently ignored. However there are a couple of special fields where calling removeValueFromIssueObject() will throw an UnsupportedOperationException - eg if you try to remove the Project.

Specified by:
canRemoveValueFromIssueObject in interface OrderableField
Parameters:
issue - The Issue object.
Returns:
true if a call to OrderableField.removeValueFromIssueObject(com.atlassian.jira.issue.MutableIssue) will actually remove the value.
See Also:
OrderableField.removeValueFromIssueObject(com.atlassian.jira.issue.MutableIssue)

hasValue

public boolean hasValue(Issue issue)
Description copied from interface: OrderableField
Determines if the field has a value for the given issue.

Specified by:
hasValue in interface OrderableField
Parameters:
issue - the Issue.
Returns:
true if the given Issue has a value for this field.

availableForBulkEdit

public String availableForBulkEdit(BulkEditBean bulkEditBean)
Description copied from interface: OrderableField
Determines whether the field is available for bulk editing given the BulkEditBean.

Specified by:
availableForBulkEdit in interface OrderableField
Parameters:
bulkEditBean - holds the state of the bulk-edit wizard (e.g. the selected issues for bulk editing)
Returns:
null if the field is available for bulk-editing or an i18n key of the error message to show as why the field is not available.

hasWorkStarted

public boolean hasWorkStarted(Issue issue)

getFieldTypeInfo

public FieldTypeInfo getFieldTypeInfo(FieldTypeInfoContext fieldTypeInfoContext)
Description copied from interface: RestAwareField
Returns lower level Information about the field. This information contains allowed values and/or the autocomplete url

Specified by:
getFieldTypeInfo in interface RestAwareField
Parameters:
fieldTypeInfoContext - the FieldTypeInfoContext contains context information that is relevant to generate the FieldTypeInfo

getJsonSchema

public JsonType getJsonSchema()
Description copied from interface: RestAwareField
Return a description of the shape of this field when represented as JSON.

Specified by:
getJsonSchema in interface RestAwareField

getJsonFromIssue

public FieldJsonRepresentation getJsonFromIssue(Issue issue,
                                                boolean renderedVersionRequested,
                                                @Nullable
                                                FieldLayoutItem fieldLayoutItem)
Description copied from interface: RestAwareField
Return a FieldJsonDataPair containing a json representation of the raw data for this field, and if required, a json representation of the rendered data for easy display.

Specified by:
getJsonFromIssue in interface RestAwareField
Parameters:
issue - to get field data from
renderedVersionRequested - whether the use requested the return of rendered/pretty data as well as raw data
fieldLayoutItem - field layout for this field. Will only be supplied if the field is also an ordereable field.
Returns:
FieldJsonDataPair containing a json representation of the raw data for this field, and if required, a json representation of the rendered data for easy display.

getRestFieldOperation

public RestFieldOperationsHandler getRestFieldOperation()
Specified by:
getRestFieldOperation in interface RestFieldOperations
Returns:
the RestFieldOperationsHandler for this field.

getJsonDefaultValue

public JsonData getJsonDefaultValue(IssueContext issueCtx)
Description copied from interface: RestFieldOperations
Return The default data for this system field. May be null if there is no default.

Specified by:
getJsonDefaultValue in interface RestFieldOperations
Parameters:
issueCtx - Issue (This should really only need to be an issue context, but for historical reasons we need an issue object.


Copyright © 2002-2014 Atlassian. All Rights Reserved.