com.atlassian.jira.issue.customfields.impl
Class MultiSelectCFType

java.lang.Object
  extended by com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
      extended by com.atlassian.jira.issue.customfields.impl.AbstractMultiSettableCFType
          extended by com.atlassian.jira.issue.customfields.impl.MultiSelectCFType
All Implemented Interfaces:
ProjectImportableCustomField, CustomFieldType, GroupSelectorField, MultipleCustomFieldType, MultipleSettableCustomFieldType, SortableCustomField

public class MultiSelectCFType
extends AbstractMultiSettableCFType
implements MultipleSettableCustomFieldType, MultipleCustomFieldType, SortableCustomField, GroupSelectorField, ProjectImportableCustomField

Multiple Select Type

Transport Object Type
Collection
Singular Object Type
String


Field Summary
static String COMMA_REPLACEMENT
           
 
Fields inherited from class com.atlassian.jira.issue.customfields.impl.AbstractMultiSettableCFType
customFieldValuePersister, genericConfigManager, optionsManager
 
Fields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE
 
Constructor Summary
MultiSelectCFType(OptionsManager optionsManager, CustomFieldValuePersister valuePersister, GenericConfigManager genericConfigManager)
           
 
Method Summary
 int compare(Object customFieldObjectValue1, Object customFieldObjectValue2, FieldConfig fieldConfig)
          Compares the two custom field objects.
 void createValue(CustomField customField, Issue issue, Object value)
          Create a select-list CF value for an issue
static Collection extractTransferObjectFromString(String value)
          Parses the given comma-separated String value into a Collection.
 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 getConfigurationItemTypes()
          Returns a List of FieldConfigItemType objects.
 Object getDefaultValue(FieldConfig fieldConfig)
          Retrieves the Object representing the default CustomField value for the Custom Field.
 Set getIssueIdsWithValue(CustomField field, Option option)
          Returns a Set with of Long Objects representing the issue ids that the value has been set for
 ProjectCustomFieldImporter getProjectImporter()
          Returns the object that will perform the actual project import functions for the custom field type.
 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.
static String getStringFromTransferObject(Collection collection)
          Takes a Collection of values and creates a comma-separated String that represents this Collection.
 Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
          Return the String value object from the CustomFieldParams.
 Object getValueFromCustomFieldParams(CustomFieldParams parameters)
          Retrieves the Object representing the CustomField value instance from the CustomFieldParams of Strings.
 Object getValueFromIssue(CustomField field, Issue issue)
          Retrieves the Object representing the current CustomField value for the given issue.
 void removeValue(CustomField field, Issue issue, Option option)
           
 void setDefaultValue(FieldConfig fieldConfig, Object value)
          Sets the default value for a Custom Field
 void updateValue(CustomField customField, Issue issue, Object value)
           
 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 com.atlassian.jira.issue.customfields.impl.AbstractMultiSettableCFType
getOptions, remove
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
assertObjectImplementsType, availableForBulkEdit, getChangelogString, getDescription, getDescriptor, getI18nBean, getKey, getName, getRelatedIndexers, getVelocityParameters, getVelocityParameters, init, isRenderable
 
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.issue.customfields.MultipleCustomFieldType
getOptions
 
Methods inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
availableForBulkEdit, getChangelogString, getDescription, getDescriptor, getKey, getName, getRelatedIndexers, getVelocityParameters, init, isRenderable, remove
 

Field Detail

COMMA_REPLACEMENT

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

MultiSelectCFType

public MultiSelectCFType(OptionsManager optionsManager,
                         CustomFieldValuePersister valuePersister,
                         GenericConfigManager genericConfigManager)
Method Detail

getIssueIdsWithValue

public Set getIssueIdsWithValue(CustomField field,
                                Option option)
Description copied from interface: MultipleSettableCustomFieldType
Returns a Set with of Long Objects representing the issue ids that the value has been set for

Specified by:
getIssueIdsWithValue in interface MultipleSettableCustomFieldType
Parameters:
field - the CustomField to search on
option - the Object representing a single value to search on.
Returns:
Set of Longs

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

getDefaultValue

public Object getDefaultValue(FieldConfig fieldConfig)
Description copied from interface: CustomFieldType
Retrieves the Object representing the default CustomField value for the Custom Field. See CustomFieldType.getValueFromCustomFieldParams(com.atlassian.jira.issue.customfields.view.CustomFieldParams) for more detailed notes.

Specified by:
getDefaultValue in interface CustomFieldType
Parameters:
fieldConfig - CustomField for default value
Returns:
Transport Object matching the Object parameter of CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object)

getValueFromCustomFieldParams

public Object getValueFromCustomFieldParams(CustomFieldParams parameters)
                                     throws FieldValidationException
Description copied from interface: CustomFieldType
Retrieves the Object representing the CustomField value instance from the CustomFieldParams of Strings. This return type must exactly match that of the value Object parameter in the persistance methods (CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object)) and Object returned from CustomFieldType.getValueFromIssue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue).

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, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object)
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, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.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)

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

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)

createValue

public void createValue(CustomField customField,
                        Issue issue,
                        Object value)
Create a select-list CF value for an issue

Specified by:
createValue in interface CustomFieldType
Parameters:
value - A Collection.

updateValue

public void updateValue(CustomField customField,
                        Issue issue,
                        Object value)
Specified by:
updateValue in interface CustomFieldType

removeValue

public void removeValue(CustomField field,
                        Issue issue,
                        Option option)
Specified by:
removeValue in interface MultipleSettableCustomFieldType

getValueFromIssue

public Object getValueFromIssue(CustomField field,
                                Issue issue)
Description copied from interface: CustomFieldType
Retrieves the Object representing the current CustomField value for the given issue. See CustomFieldType.getValueFromCustomFieldParams(com.atlassian.jira.issue.customfields.view.CustomFieldParams) for more detailed notes.

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, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, com.atlassian.jira.issue.Issue, java.lang.Object)
See Also:
CustomFieldType.getValueFromCustomFieldParams(com.atlassian.jira.issue.customfields.view.CustomFieldParams)

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.

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 will 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 CustomFieldParams

Specified by:
getStringFromSingularObject in interface CustomFieldType
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
Returns:
singularObject instance
Throws:
FieldValidationException

getConfigurationItemTypes

public List getConfigurationItemTypes()
Description copied from interface: CustomFieldType
Returns a List of FieldConfigItemType objects. This opens up possibilties for configurable custom fields

Specified by:
getConfigurationItemTypes in interface CustomFieldType
Overrides:
getConfigurationItemTypes in class AbstractCustomFieldType
Returns:
List of FieldConfigItemType

compare

public int compare(Object customFieldObjectValue1,
                   Object customFieldObjectValue2,
                   FieldConfig fieldConfig)
Description copied from interface: SortableCustomField
Compares the two custom field objects.

Specified by:
compare in interface SortableCustomField
Parameters:
customFieldObjectValue1 - Never null
customFieldObjectValue2 - Never null
Returns:
0, 1 or -1

getProjectImporter

public ProjectCustomFieldImporter getProjectImporter()
Description copied from interface: ProjectImportableCustomField
Returns the object that will perform the actual project import functions for the custom field type.

Specified by:
getProjectImporter in interface ProjectImportableCustomField
Returns:
the object that will perform the actual project import functions for the custom field type.

extractTransferObjectFromString

public static Collection extractTransferObjectFromString(String value)
Parses the given comma-separated String value into a Collection. Whitespace is trimmed and blank fields are discarded. If literal commas are required, then they can be escaped with a backslash. Therefore the input String "red, white\, and blue" would produce two tokens in its list:

Parameters:
value - The comma-separated input String.
Returns:
Collection of tokens parsed from the input value.
See Also:
getStringFromTransferObject(java.util.Collection)

getStringFromTransferObject

public static String getStringFromTransferObject(Collection collection)
Takes a Collection of values and creates a comma-separated String that represents this Collection.

If any items in the collection include literal commas, then these commas are escaped with a prepended backslash. eg a list that looks like:

Will be turned into a string that looks like "All sorts,Tom\, Dick\, and Harry"

Parameters:
collection -
Returns:

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
Overrides:
valuesEqual in class AbstractCustomFieldType
Parameters:
v1 - current value
v2 - new value
Returns:
true if teh change item should be generated, false otherwise


Copyright © 2002-2008 Atlassian. All Rights Reserved.