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

java.lang.Object
  extended by com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType<Collection<S>,S>
      extended by com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType<ApplicationUser>
          extended by com.atlassian.jira.issue.customfields.impl.MultiUserCFType
All Implemented Interfaces:
ProjectImportableCustomField, CustomFieldType<Collection<ApplicationUser>,ApplicationUser>, SortableCustomField<String>, RestAwareCustomFieldType, RestCustomFieldTypeOperations, UserField, UserCFNotificationTypeAware

public class MultiUserCFType
extends AbstractMultiCFType<ApplicationUser>
implements UserCFNotificationTypeAware, ProjectImportableCustomField, UserField, SortableCustomField<String>, RestAwareCustomFieldType, RestCustomFieldTypeOperations

Multiple User Type allows selection of multiple users. For single User select use UserCFType

Transport Object Type
Collection
Singular Object Type
ApplicationUser
Database Storage Type
String of user name


Nested Class Summary
static interface MultiUserCFType.Visitor<T>
           
 
Nested classes/interfaces inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
AbstractCustomFieldType.VisitorBase<X>
 
Field Summary
protected  MultiUserConverter multiUserConverter
           
 
Fields inherited from class com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType
customFieldValuePersister, genericConfigManager
 
Fields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE
 
Constructor Summary
MultiUserCFType(CustomFieldValuePersister customFieldValuePersister, GenericConfigManager genericConfigManager, MultiUserConverter multiUserConverter, ApplicationProperties applicationProperties, JiraAuthenticationContext authenticationContext, UserPickerSearchService searchService, FieldVisibilityManager fieldVisibilityManager, JiraBaseUrls jiraBaseUrls)
           
 
Method Summary
 Object accept(AbstractCustomFieldType.VisitorBase visitor)
           
 int compare(String customFieldObjectValue1, String customFieldObjectValue2, FieldConfig fieldConfig)
          Compares the two custom field objects.
protected  ApplicationUser convertDbValueToType(Object string)
          Converts a given db value to Single form of Transport Object
protected  Object convertTypeToDbValue(ApplicationUser value)
          Converts a given underlying type to its db storage value.
 String getChangelogString(CustomField field, Collection<ApplicationUser> 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, Collection<ApplicationUser> values)
          Returns a string representation of the value if not null.
protected  PersistenceFieldType getDatabaseType()
          Type of database field needed to store this field.
 FieldTypeInfo getFieldTypeInfo(FieldTypeInfoContext fieldTypeInfoContext)
          Returns lower level Information about the field.
 JsonData getJsonDefaultValue(IssueContext issueCtx, CustomField field)
          Return The default data for this system field.
 FieldJsonRepresentation getJsonFromIssue(CustomField field, Issue issue, boolean renderedVersionRequested, FieldLayoutItem fieldLayoutItem)
          Return a JsonData representation of the field value
 JsonType getJsonSchema(CustomField customField)
          Return a description of the shape of this field when represented as JSON.
 ProjectCustomFieldImporter getProjectImporter()
          Returns the object that will perform the actual project import functions for the custom field type.
 List getRelatedIndexers(CustomField customField)
          Returns a list of indexers that will be used for the field.
 RestFieldOperationsHandler getRestFieldOperation(CustomField field)
          Returns the RestFieldOperationsHandler for this field.
 ApplicationUser getSingularObjectFromString(String s)
          Returns a Singular Object, given the string value as passed by the presentation tier.
 String getStringFromSingularObject(ApplicationUser o)
          Returns the String representation of a single value within the CustomFieldType.
 Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
          Return the String value object from the CustomFieldParams.
protected  Comparator<ApplicationUser> getTypeComparator()
          Returns a comparator for underlying type of this custom field.
 Collection<ApplicationUser> getValueFromCustomFieldParams(CustomFieldParams parameters)
          Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.
 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 updateValue(CustomField customField, Issue issue, Collection<ApplicationUser> value)
          Update a multi-select value for an issue.
 void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)
          Ensures that the CustomFieldParams of Strings is a valid representation of the Custom Field values.
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractMultiCFType
convertDbObjectToTypes, convertTypesToDbObjects, createValue, getDefaultValue, getValueFromIssue, remove, setDefaultValue
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
assertObjectImplementsType, availableForBulkEdit, getConfigurationItemTypes, getDescription, getDescriptor, getI18nBean, getKey, getName, getVelocityParameters, init, isRenderable, valuesEqual
 
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.notification.type.UserCFNotificationTypeAware
getValueFromIssue
 

Field Detail

multiUserConverter

protected final MultiUserConverter multiUserConverter
Constructor Detail

MultiUserCFType

public MultiUserCFType(CustomFieldValuePersister customFieldValuePersister,
                       GenericConfigManager genericConfigManager,
                       MultiUserConverter multiUserConverter,
                       ApplicationProperties applicationProperties,
                       JiraAuthenticationContext authenticationContext,
                       UserPickerSearchService searchService,
                       FieldVisibilityManager fieldVisibilityManager,
                       JiraBaseUrls jiraBaseUrls)
Method Detail

getTypeComparator

protected Comparator<ApplicationUser> getTypeComparator()
Description copied from class: AbstractMultiCFType
Returns a comparator for underlying type of this custom field. Used e.g. for sorting values retrieved from the Database

Specified by:
getTypeComparator in class AbstractMultiCFType<ApplicationUser>
Returns:
a comparator, null if can't be compared without extra context

updateValue

public void updateValue(CustomField customField,
                        Issue issue,
                        Collection<ApplicationUser> value)
Description copied from class: AbstractMultiCFType
Update a multi-select value for an issue.

Specified by:
updateValue in interface CustomFieldType<Collection<ApplicationUser>,ApplicationUser>
Overrides:
updateValue in class AbstractMultiCFType<ApplicationUser>
Parameters:
customField - CustomField for which the value is being stored
issue - The Issue.
value - Transport Object representing the value instance of the CustomField.
See Also:
CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField,com.atlassian.jira.issue.Issue,Object)

getChangelogValue

public String getChangelogValue(CustomField field,
                                Collection<ApplicationUser> values)
Description copied from class: AbstractMultiCFType
Returns a string representation of the value if not null.

Specified by:
getChangelogValue in interface CustomFieldType<Collection<ApplicationUser>,ApplicationUser>
Overrides:
getChangelogValue in class AbstractMultiCFType<ApplicationUser>
Parameters:
field - not used
values - value to create a change log for
Returns:
string representaion of value if not null, empty string otherwise

getChangelogString

public String getChangelogString(CustomField field,
                                 Collection<ApplicationUser> 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<Collection<ApplicationUser>,ApplicationUser>
Overrides:
getChangelogString in class AbstractCustomFieldType<Collection<ApplicationUser>,ApplicationUser>
Parameters:
field - CustomField that the value belongs to
value - Transport Object representing the value instance of the CustomField
Returns:
Change log string.

getValueFromCustomFieldParams

public Collection<ApplicationUser> 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<Collection<ApplicationUser>,ApplicationUser>
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<Collection<ApplicationUser>,ApplicationUser>
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<Collection<ApplicationUser>,ApplicationUser>
Parameters:
relevantParams - parameter object of Strings
errorCollectionToAddTo - errorCollection to which any erros should be added (never null)
config - FieldConfig

getStringFromSingularObject

public String getStringFromSingularObject(ApplicationUser o)
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<Collection<ApplicationUser>,ApplicationUser>
Parameters:
o - the object
Returns:
String representation of the Object

getSingularObjectFromString

public ApplicationUser getSingularObjectFromString(String s)
                                            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<Collection<ApplicationUser>,ApplicationUser>
Parameters:
s - the String
Returns:
singularObject instance
Throws:
FieldValidationException - if the string is an invalid representation of the Object.

getDatabaseType

@NotNull
protected PersistenceFieldType getDatabaseType()
Description copied from class: AbstractMultiCFType
Type of database field needed to store this field.

Specified by:
getDatabaseType in class AbstractMultiCFType<ApplicationUser>
Returns:
One of the predefined PersistenceFieldType types.

getRelatedIndexers

public List 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<Collection<ApplicationUser>,ApplicationUser>
Overrides:
getRelatedIndexers in class AbstractCustomFieldType<Collection<ApplicationUser>,ApplicationUser>
Parameters:
customField - the custom field to get the related indexers of.
Returns:
List of instantiated and initialised FieldIndexer objects. Null if no related indexers.

convertTypeToDbValue

protected Object convertTypeToDbValue(ApplicationUser value)
Description copied from class: AbstractMultiCFType
Converts a given underlying type to its db storage value. Must be compatable with PersistenceFieldType returned by AbstractMultiCFType.getDatabaseType()

Specified by:
convertTypeToDbValue in class AbstractMultiCFType<ApplicationUser>
Parameters:
value - Single form of Transport Object
Returns:
database representation of given Transport Object.

convertDbValueToType

protected ApplicationUser convertDbValueToType(Object string)
Description copied from class: AbstractMultiCFType
Converts a given db value to Single form of Transport Object

Specified by:
convertDbValueToType in class AbstractMultiCFType<ApplicationUser>
Parameters:
string - db representation as returned by AbstractMultiCFType.convertTypeToDbValue(Object)
Returns:
Single form of Transport Object

getVelocityParameters

@NotNull
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<Collection<ApplicationUser>,ApplicationUser>
Overrides:
getVelocityParameters in class AbstractCustomFieldType<Collection<ApplicationUser>,ApplicationUser>
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)

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.

compare

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

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

accept

public Object accept(AbstractCustomFieldType.VisitorBase visitor)
Overrides:
accept in class AbstractMultiCFType<ApplicationUser>

getFieldTypeInfo

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

Specified by:
getFieldTypeInfo in interface RestAwareCustomFieldType
Parameters:
fieldTypeInfoContext - context information for generating the FieldTypeInfo.
Returns:
Low level information about the field.

getJsonSchema

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

Specified by:
getJsonSchema in interface RestAwareCustomFieldType

getJsonFromIssue

public FieldJsonRepresentation getJsonFromIssue(CustomField field,
                                                Issue issue,
                                                boolean renderedVersionRequested,
                                                @Nullable
                                                FieldLayoutItem fieldLayoutItem)
Description copied from interface: RestAwareCustomFieldType
Return a JsonData representation of the field value

Specified by:
getJsonFromIssue in interface RestAwareCustomFieldType
Parameters:
field - configuration of the current field
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.
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(CustomField field)
Description copied from interface: RestCustomFieldTypeOperations
Returns the RestFieldOperationsHandler for this field.

Specified by:
getRestFieldOperation in interface RestCustomFieldTypeOperations
Parameters:
field - the Custom Field
Returns:
the RestFieldOperationsHandler for this field.

getJsonDefaultValue

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

Specified by:
getJsonDefaultValue in interface RestCustomFieldTypeOperations
Parameters:
issueCtx - Issue (This should really only need to be an issue context, but for historical reasons we need an issue object.
field - the Custom Field
Returns:
The default data for this system field.


Copyright © 2002-2013 Atlassian. All Rights Reserved.