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

java.lang.Object
  extended by com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
      extended by com.atlassian.jira.issue.customfields.impl.LabelsCFType
All Implemented Interfaces:
ProjectImportableCustomField, ProjectImportableCustomFieldParser, CustomFieldValueParser, CustomFieldType, SortableCustomField<java.util.Set<Label>>

public class LabelsCFType
extends AbstractCustomFieldType
implements SortableCustomField<java.util.Set<Label>>, ProjectImportableCustomFieldParser, ProjectImportableCustomField

Labels Custom field

Since:
v4.2

Nested Class Summary
static interface LabelsCFType.Visitor<T>
           
 
Nested classes/interfaces inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
AbstractCustomFieldType.VisitorBase<T>
 
Field Summary
 
Fields inherited from interface com.atlassian.jira.imports.project.parser.CustomFieldValueParser
CUSTOM_FIELD_VALUE_ENTITY_NAME
 
Fields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE
 
Constructor Summary
LabelsCFType(JiraAuthenticationContext authenticationContext, IssueManager issueManager, GenericConfigManager genericConfigManager, LabelUtil labelUtil, LabelManager labelManager)
           
 
Method Summary
 java.lang.Object accept(AbstractCustomFieldType.VisitorBase visitor)
           
 int compare(java.util.Set<Label> customFieldObjectValue1, java.util.Set<Label> customFieldObjectValue2, FieldConfig fieldConfig)
          Compares the two custom field objects.
 void createValue(CustomField field, Issue issue, java.lang.Object value)
           
 java.lang.String getChangelogValue(CustomField field, java.lang.Object value)
          Returns a values to be stored in the change log, example is the id of the changed item.
 java.lang.Object getDefaultValue(FieldConfig fieldConfig)
          Retrieves the Object representing the default CustomField value for the Custom Field.
 java.lang.String getEntityName()
          The table name of the ofbiz entity (read database table) in which the custom field values for this custom field type are persisted
 EntityRepresentation getEntityRepresentation(ExternalCustomFieldValueImpl customFieldValue)
          Gets an EntityRepresentation that contains the correct attributes based on the populated fields in the provided custom field value.
 ProjectCustomFieldImporter getProjectImporter()
          Returns the object that will perform the actual project import functions for the custom field type.
 java.lang.Object getSingularObjectFromString(java.lang.String string)
          Returns a Singular Object, given the string value as passed by the presentation tier.
 java.lang.String getStringFromSingularObject(java.lang.Object singularObject)
          Returns the String representation of a single value within the CustomFieldType.
 java.lang.Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
          Return the String value object from the CustomFieldParams.
 java.lang.Object getValueFromCustomFieldParams(CustomFieldParams customFieldParams)
          Retrieves the Object representing the CustomField value instance from the CustomFieldParams of Strings.
 java.lang.Object getValueFromIssue(CustomField field, Issue issue)
          Retrieves the Object representing the current CustomField value for the given issue.
 java.util.Map<java.lang.String,java.lang.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).
 ExternalCustomFieldValueImpl parse(java.util.Map attributes)
          Parses the custom field value data from the backup XML.
 java.util.Set<java.lang.Long> remove(CustomField field)
          Performs additional tasks when a CustomField of this type is being removed CustomField.remove().
 void setDefaultValue(FieldConfig fieldConfig, java.lang.Object value)
          Sets the default value for a Custom Field
 void updateValue(CustomField field, Issue issue, java.lang.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(java.lang.Object v1, java.lang.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.AbstractCustomFieldType
assertObjectImplementsType, availableForBulkEdit, getChangelogString, getConfigurationItemTypes, getDescription, getDescriptor, getI18nBean, getKey, getName, getRelatedIndexers, getVelocityParameters, init, isRenderable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelsCFType

public LabelsCFType(JiraAuthenticationContext authenticationContext,
                    IssueManager issueManager,
                    GenericConfigManager genericConfigManager,
                    LabelUtil labelUtil,
                    LabelManager labelManager)
Method Detail

getVelocityParameters

public java.util.Map<java.lang.String,java.lang.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
Overrides:
getVelocityParameters in class AbstractCustomFieldType
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)

getValueFromIssue

public java.lang.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)

getDefaultValue

public java.lang.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)

setDefaultValue

public void setDefaultValue(FieldConfig fieldConfig,
                            java.lang.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 java.lang.String getChangelogValue(CustomField field,
                                          java.lang.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 java.lang.String getStringFromSingularObject(java.lang.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
Parameters:
singularObject - the object
Returns:
String representation of the Object

getSingularObjectFromString

public java.lang.Object getSingularObjectFromString(java.lang.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 java.util.Set<java.lang.Long> remove(CustomField field)
Description copied from interface: CustomFieldType
Performs additional tasks when a 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,
                        java.lang.Object value)
Specified by:
createValue in interface CustomFieldType

updateValue

public void updateValue(CustomField field,
                        Issue issue,
                        java.lang.Object value)
Specified by:
updateValue in interface CustomFieldType

getValueFromCustomFieldParams

public java.lang.Object getValueFromCustomFieldParams(CustomFieldParams customFieldParams)
                                               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:
customFieldParams - 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 java.lang.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

compare

public int compare(java.util.Set<Label> customFieldObjectValue1,
                   java.util.Set<Label> customFieldObjectValue2,
                   FieldConfig fieldConfig)
Description copied from interface: SortableCustomField
Compares the two custom field objects.

Specified by:
compare in interface SortableCustomField<java.util.Set<Label>>
Parameters:
customFieldObjectValue1 - Never null
customFieldObjectValue2 - Never null
Returns:
0, 1 or -1

getEntityName

public java.lang.String getEntityName()
Description copied from interface: ProjectImportableCustomFieldParser
The table name of the ofbiz entity (read database table) in which the custom field values for this custom field type are persisted

Specified by:
getEntityName in interface ProjectImportableCustomFieldParser
Returns:
The ofbiz table name for this custom field type

parse

public ExternalCustomFieldValueImpl parse(java.util.Map attributes)
                                   throws ParseException
Description copied from interface: CustomFieldValueParser
Parses the custom field value data from the backup XML.

Specified by:
parse in interface CustomFieldValueParser
Parameters:
attributes - is a map of key value pairs that represent the attributes of an ExternalCustomFieldValue. The following attributes are required, otherwise a ParseException will be thrown:
  • id (required)
  • customfield (required)
  • issue (required)
Returns:
an ExternalCustomFieldValue if the attributes contain the required fields
Throws:
ParseException - if the required fields are not found in the attributes map

getEntityRepresentation

public EntityRepresentation getEntityRepresentation(ExternalCustomFieldValueImpl customFieldValue)
Description copied from interface: CustomFieldValueParser
Gets an EntityRepresentation that contains the correct attributes based on the populated fields in the provided custom field value.

Specified by:
getEntityRepresentation in interface CustomFieldValueParser
Parameters:
customFieldValue - contains the populated fields that will end up in the EntityRepresentations map
Returns:
an EntityRepresentation that can be persisted using OfBiz

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.

valuesEqual

public boolean valuesEqual(java.lang.Object v1,
                           java.lang.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

accept

public java.lang.Object accept(AbstractCustomFieldType.VisitorBase visitor)
Overrides:
accept in class AbstractCustomFieldType


Copyright © 2002-2010 Atlassian. All Rights Reserved.