com.atlassian.jira.action.issue.customfields
Class MockCustomFieldType

java.lang.Object
  extended by com.atlassian.jira.action.issue.customfields.MockCustomFieldType
All Implemented Interfaces:
CustomFieldType

public class MockCustomFieldType
extends Object
implements CustomFieldType

Mocks a CustomFieldType

Since:
v3.13

Field Summary
 
Fields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE, RESOURCE_PREVIEW
 
Constructor Summary
MockCustomFieldType()
           
MockCustomFieldType(String key, String name)
           
MockCustomFieldType(String key, String name, String description)
           
 
Method Summary
 String availableForBulkEdit(BulkEditBean bulkEditBean)
          Allow the custom field type perform a specific check as to its availability for bulk editing.
 void createValue(CustomField field, Issue issue, Object value)
          Save the value for this Custom Field in a particular issue to the database.
 String getChangelogString(CustomField field, Object value)
          Returns a String of representing values to be stored in the change log, an example is the name of a version field that a version id will resolve to within JIRA.
 String getChangelogValue(CustomField field, Object value)
          Returns a values to be stored in the change log, example is the id of the changed item.
 List<FieldConfigItemType> getConfigurationItemTypes()
          Returns a List of FieldConfigItemType objects.
 Object getDefaultValue(FieldConfig fieldConfig)
          Retrieves the Object representing the default CustomField value for the Custom Field.
 String getDescription()
           
 CustomFieldTypeModuleDescriptor getDescriptor()
           
 String getKey()
          Returns the full key of the CustomFieldType.
 String getName()
           
 List<FieldIndexer> getRelatedIndexers(CustomField customField)
          Returns a list of indexers that will be used for the field.
 Object getSingularObjectFromString(String string)
          Returns a Singular Object, given the string value as passed by the presentation tier.
 String getStringFromSingularObject(Object singularObject)
          Returns the String representation of a single value within the CustomFieldType.
 Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
          Return the String value object from the CustomFieldParams.
 Object getValueFromCustomFieldParams(CustomFieldParams parameters)
          Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.
 Object getValueFromIssue(CustomField field, Issue issue)
          Retrieves the Transport Object representing the current CustomField value for the given issue.
 Map<String,Object> getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)
          The custom field may wish to pass parameters to the velocity context beyond the getValueFromIssue methods (eg managers).
 void init(CustomFieldTypeModuleDescriptor customFieldTypeModuleDescriptor)
          Initialises the CustomFieldType with the given descriptor.
 boolean isRenderable()
          This is a mirror of the method from the RenderableField interface and is needed to bridge the gap between CustomFields and CustomFieldTypes.
 Set<Long> remove(CustomField field)
          Performs additional tasks when an entire CustomField of this type is being removed CustomField.remove().
 MockCustomFieldType setConfigurationItemTypes(List<FieldConfigItemType> itemTypes)
           
 void setDefaultValue(FieldConfig fieldConfig, Object value)
          Sets the default value for a Custom Field
 void setKey(String key)
           
 void setName(String name)
           
 String toString()
           
 void updateValue(CustomField field, Issue issue, Object value)
          Upadte the value for this Custom Field in a particular issue currently stored in the database.
 void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)
          Ensures that the CustomFieldParams of Strings is a valid representation of the Custom Field values.
 boolean valuesEqual(Object v1, Object v2)
          Used to compare 2 field values and work out whether a change item should be generated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MockCustomFieldType

public MockCustomFieldType()

MockCustomFieldType

public MockCustomFieldType(String key,
                           String name)

MockCustomFieldType

public MockCustomFieldType(String key,
                           String name,
                           String description)
Method Detail

getKey

public String getKey()
Description copied from interface: CustomFieldType
Returns the full key of the CustomFieldType. Typically, this will be prefixed with "com.atlassian.jira.plugin.system.customfieldtypes:"

Specified by:
getKey in interface CustomFieldType
Returns:
CustomFieldType Key prefixed with the Package

setKey

public void setKey(String key)

getName

public String getName()
Specified by:
getName in interface CustomFieldType

setName

public void setName(String name)

init

public void init(CustomFieldTypeModuleDescriptor customFieldTypeModuleDescriptor)
Description copied from interface: CustomFieldType
Initialises the CustomFieldType with the given descriptor.

Specified by:
init in interface CustomFieldType
Parameters:
customFieldTypeModuleDescriptor - CustomFieldTypeModuleDescriptor

getDescription

public String getDescription()
Specified by:
getDescription in interface CustomFieldType

getDescriptor

public CustomFieldTypeModuleDescriptor getDescriptor()
Specified by:
getDescriptor in interface CustomFieldType

getStringFromSingularObject

public String getStringFromSingularObject(Object singularObject)
Description copied from interface: CustomFieldType
Returns the String representation of a single value within the CustomFieldType. This is the value that is passed to the presentation tier for editing. For single CustomFieldTypes the Singular Object is the same as a Transport Object. However, for multi-dimensional CustomFieldTypes, the Singular Object is the Object contained within the Collection or Map

Specified by:
getStringFromSingularObject in interface CustomFieldType
Parameters:
singularObject - the object
Returns:
String representation of the Object

getSingularObjectFromString

public Object getSingularObjectFromString(String string)
                                   throws FieldValidationException
Description copied from interface: CustomFieldType
Returns a Singular Object, given the string value as passed by the presentation tier. Throws FieldValidationException if the string is an invalid representation of the Object.

Specified by:
getSingularObjectFromString in interface CustomFieldType
Parameters:
string - the String
Returns:
singularObject instance
Throws:
FieldValidationException - if the string is an invalid representation of the Object.

remove

public Set<Long> remove(CustomField field)
Description copied from interface: CustomFieldType
Performs additional tasks when an entire CustomField of this type is being removed CustomField.remove(). This includes removal of values & options.

Specified by:
remove in interface CustomFieldType
Parameters:
field - The custom field that is being removed, so any data stored for any issues for that field can be deleted.
Returns:
Set of issue ids that has been affected

validateFromParams

public void validateFromParams(CustomFieldParams relevantParams,
                               ErrorCollection errorCollectionToAddTo,
                               FieldConfig config)
Description copied from interface: CustomFieldType
Ensures that the CustomFieldParams of Strings is a valid representation of the Custom Field values. Any errors should be added to the ErrorCollection under the appropriate key as required.

Specified by:
validateFromParams in interface CustomFieldType
Parameters:
relevantParams - parameter object of Strings
errorCollectionToAddTo - errorCollection to which any erros should be added (never null)
config - FieldConfig

createValue

public void createValue(CustomField field,
                        Issue issue,
                        Object value)
Description copied from interface: CustomFieldType
Save the value for this Custom Field in a particular issue to the database.

Specified by:
createValue in interface CustomFieldType
Parameters:
field - CustomField for which the value is being stored
issue - The Issue to be stored against.
value - Transport Object representing the value instance of the CustomField.

updateValue

public void updateValue(CustomField field,
                        Issue issue,
                        Object value)
Description copied from interface: CustomFieldType
Upadte the value for this Custom Field in a particular issue currently stored in the database.

Specified by:
updateValue in interface CustomFieldType
Parameters:
field - CustomField for which the value is being stored
issue - The Issue to be stored against.
value - Transport Object representing the value instance of the CustomField.

getValueFromCustomFieldParams

public Object getValueFromCustomFieldParams(CustomFieldParams parameters)
                                     throws FieldValidationException
Description copied from interface: CustomFieldType
Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.

Specified by:
getValueFromCustomFieldParams in interface CustomFieldType
Parameters:
parameters - CustomFieldParams of String objects. Will contain one value for Singular field types.
Returns:
Transport Object matching the Object parameter of CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, T), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, T)
Throws:
FieldValidationException - if the String value fails to convert into Objects
See Also:
CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, Object), CustomFieldType.getValueFromIssue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue)

getStringValueFromCustomFieldParams

public Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
Description copied from interface: CustomFieldType
Return the String value object from the CustomFieldParams. The object may be a single String (e.g. TextCFType, List of Strings (e.g. MultiSelectCFType) or CustomFieldParams of Strings (e.g. CascadingSelectCFType). Among other things these values are passed to Velocity for rendering edit screens.

Specified by:
getStringValueFromCustomFieldParams in interface CustomFieldType
Parameters:
parameters - - CustomFieldParams containing String values
Returns:
String value object from the CustomFieldParams

getValueFromIssue

public Object getValueFromIssue(CustomField field,
                                Issue issue)
Description copied from interface: CustomFieldType
Retrieves the Transport Object representing the current CustomField value for the given issue.

Specified by:
getValueFromIssue in interface CustomFieldType
Parameters:
field - Custom field for which to retrieve the value
issue - Issue from which to retrieve the value
Returns:
Transport Object matching the Object parameter of CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, T), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, T)

getDefaultValue

public Object getDefaultValue(FieldConfig fieldConfig)
Description copied from interface: CustomFieldType
Retrieves the Object representing the default CustomField value for the Custom Field.

Specified by:
getDefaultValue in interface CustomFieldType
Parameters:
fieldConfig - CustomField for default value
Returns:
Transport Object of the Default Value

setDefaultValue

public void setDefaultValue(FieldConfig fieldConfig,
                            Object value)
Description copied from interface: CustomFieldType
Sets the default value for a Custom Field

Specified by:
setDefaultValue in interface CustomFieldType
Parameters:
fieldConfig - CustomField for which the default is being stored
value - Transport Object representing the value instance of the CustomField

getChangelogValue

public String getChangelogValue(CustomField field,
                                Object value)
Description copied from interface: CustomFieldType
Returns a values to be stored in the change log, example is the id of the changed item.

Specified by:
getChangelogValue in interface CustomFieldType
Parameters:
field - CustomField that the value belongs to
value - Transport Object representing the value instance of the CustomField
Returns:
Change log value.

getChangelogString

public String getChangelogString(CustomField field,
                                 Object value)
Description copied from interface: CustomFieldType
Returns a String of representing values to be stored in the change log, an example is the name of a version field that a version id will resolve to within JIRA.

Specified by:
getChangelogString in interface CustomFieldType
Parameters:
field - CustomField that the value belongs to
value - Transport Object representing the value instance of the CustomField
Returns:
Change log string.

getVelocityParameters

@Nonnull
public Map<String,Object> getVelocityParameters(Issue issue,
                                                        CustomField field,
                                                        FieldLayoutItem fieldLayoutItem)
Description copied from interface: CustomFieldType
The custom field may wish to pass parameters to the velocity context beyond the getValueFromIssue methods (eg managers).

The values are added to the context for all velocity views (edit, search, view, xml)

Specified by:
getVelocityParameters in interface CustomFieldType
Parameters:
issue - The issue currently in context (Note: this will be null in cases like 'default value')
field - CustomField
fieldLayoutItem - FieldLayoutItem
Returns:
A Map of parameters to add to the velocity context, or an empty Map otherwise (never null)

getConfigurationItemTypes

@Nonnull
public List<FieldConfigItemType> getConfigurationItemTypes()
Description copied from interface: CustomFieldType
Returns a List of FieldConfigItemType objects. Can not be immutable. This opens up possibilties for configurable custom fields.

Specified by:
getConfigurationItemTypes in interface CustomFieldType
Returns:
List of FieldConfigItemType

setConfigurationItemTypes

public MockCustomFieldType setConfigurationItemTypes(List<FieldConfigItemType> itemTypes)

getRelatedIndexers

public List<FieldIndexer> getRelatedIndexers(CustomField customField)
Description copied from interface: CustomFieldType
Returns a list of indexers that will be used for the field.

Specified by:
getRelatedIndexers in interface CustomFieldType
Parameters:
customField - the custom field to get the related indexers of.
Returns:
List of instantiated and initialised FieldIndexer objects. Null if no related indexers.

isRenderable

public boolean isRenderable()
Description copied from interface: CustomFieldType
This is a mirror of the method from the RenderableField interface and is needed to bridge the gap between CustomFields and CustomFieldTypes.

Specified by:
isRenderable in interface CustomFieldType
Returns:
true if the field is configurable for use with the renderers, a text based field, false otherwise.

valuesEqual

public boolean valuesEqual(Object v1,
                           Object v2)
Description copied from interface: CustomFieldType
Used to compare 2 field values and work out whether a change item should be generated

Specified by:
valuesEqual in interface CustomFieldType
Parameters:
v1 - current value
v2 - new value
Returns:
true if the change item should be generated, false otherwise

availableForBulkEdit

public String availableForBulkEdit(BulkEditBean bulkEditBean)
Description copied from interface: CustomFieldType
Allow the custom field type perform a specific check as to its availability for bulk editing.

Specified by:
availableForBulkEdit in interface CustomFieldType
Parameters:
bulkEditBean - BulkEditBean
Returns:
null if available for bulk edit or appropriate unavailable message

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2014 Atlassian. All Rights Reserved.