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

java.lang.Object
  extended by com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType<T,T>
      extended by com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType<ApplicationUser>
          extended by com.atlassian.jira.issue.customfields.impl.UserCFType
All Implemented Interfaces:
ProjectImportableCustomField, CustomFieldType<ApplicationUser,ApplicationUser>, SortableCustomField<ApplicationUser>, RestAwareCustomFieldType, RestCustomFieldTypeOperations, UserField, UserCFNotificationTypeAware

public class UserCFType
extends AbstractSingleFieldType<ApplicationUser>
implements SortableCustomField<ApplicationUser>, UserCFNotificationTypeAware, ProjectImportableCustomField, UserField, RestAwareCustomFieldType, RestCustomFieldTypeOperations

Custom Field allow selection of a single ApplicationUser. For multi-user see MultiUserCFType

Transport Object Type
ApplicationUser
Database Storage Type
String of user name


Nested Class Summary
static interface UserCFType.Visitor<T>
           
 
Nested classes/interfaces inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
AbstractCustomFieldType.VisitorBase<X>
 
Field Summary
static SharedEntity.TypeDescriptor<SharedEntity.Identifier> ENTITY_TYPE
           
 
Fields inherited from class com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType
customFieldValuePersister, FIELD_TYPE_DATE, FIELD_TYPE_NUMBER, FIELD_TYPE_STRING, FIELD_TYPE_TEXT, genericConfigManager, log
 
Fields inherited from interface com.atlassian.jira.issue.customfields.CustomFieldType
DEFAULT_VALUE_TYPE, RESOURCE_PREVIEW
 
Constructor Summary
UserCFType(CustomFieldValuePersister customFieldValuePersister, UserConverter userConverter, GenericConfigManager genericConfigManager, ApplicationProperties applicationProperties, JiraAuthenticationContext authenticationContext, FieldConfigSchemeManager fieldConfigSchemeManager, ProjectManager projectManager, SoyTemplateRendererProvider soyTemplateRendererProvider, GroupManager groupManager, ProjectRoleManager projectRoleManager, UserPickerSearchService searchService, JiraBaseUrls jiraBaseUrls, UserHistoryManager userHistoryManager, UserFilterManager userFilterManager, UserPickerSearchService userPickerSearchService, I18nHelper i18nHelper)
           
 
Method Summary
 Object accept(AbstractCustomFieldType.VisitorBase visitor)
           
 int compare(ApplicationUser customFieldObjectValue1, ApplicationUser customFieldObjectValue2, FieldConfig fieldConfig)
          Compares the two custom field objects.
 String getChangelogString(CustomField field, 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, ApplicationUser 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.
protected  PersistenceFieldType getDatabaseType()
          Type of database field needed to store this field.
protected  Object getDbValueFromObject(ApplicationUser customFieldObject)
          Returns the database representation of the Java object as stored for that CustomField.
 FieldTypeInfo getFieldTypeInfo(FieldTypeInfoContext fieldTypeInfoContext)
          Returns lower level Information about the 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.
protected  ApplicationUser getObjectFromDbValue(Object databaseValue)
          Returns the Transport Object for the given Custom Field value as represented by the value stored in the database
 ProjectCustomFieldImporter getProjectImporter()
          Returns the object that will perform the actual project import functions for the custom field type.
 RestFieldOperationsHandler getRestFieldOperation(CustomField field)
          Returns the RestFieldOperationsHandler for this field.
 ApplicationUser getSingularObjectFromString(String string)
          Returns a Singular Object, given the string value as passed by the presentation tier.
 String getStringFromSingularObject(ApplicationUser value)
          Returns the String representation of a single value within the CustomFieldType.
 ApplicationUser getValueFromCustomFieldParams(CustomFieldParams relevantParams)
          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).
 Set<Long> remove(CustomField field)
          called when removing a field.
 void updateValue(CustomField customField, Issue issue, ApplicationUser user)
          the value does exist, and the new value is different than the existing one.
 void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)
          This method validate the parameters based on the following criteria: If the specified new value is NOT a valid user, it fails. If the previous value is specified (obtained from the issue object in the "issue" key), and the specified new value is the same as the previous value, it succeeds and the rest of the validations are skipped.
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType
createValue, getDefaultValue, getJsonDefaultValue, getStringValueFromCustomFieldParams, getValueFromIssue, getValueFromIssue, setDefaultValue
 
Methods inherited from class com.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
assertObjectImplementsType, availableForBulkEdit, getDescription, getDescriptor, getI18nBean, getKey, getName, getRelatedIndexers, 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
 
Methods inherited from interface com.atlassian.jira.issue.fields.rest.RestCustomFieldTypeOperations
getJsonDefaultValue
 

Field Detail

ENTITY_TYPE

public static final SharedEntity.TypeDescriptor<SharedEntity.Identifier> ENTITY_TYPE
Constructor Detail

UserCFType

public UserCFType(CustomFieldValuePersister customFieldValuePersister,
                  UserConverter userConverter,
                  GenericConfigManager genericConfigManager,
                  ApplicationProperties applicationProperties,
                  JiraAuthenticationContext authenticationContext,
                  FieldConfigSchemeManager fieldConfigSchemeManager,
                  ProjectManager projectManager,
                  SoyTemplateRendererProvider soyTemplateRendererProvider,
                  GroupManager groupManager,
                  ProjectRoleManager projectRoleManager,
                  UserPickerSearchService searchService,
                  JiraBaseUrls jiraBaseUrls,
                  UserHistoryManager userHistoryManager,
                  UserFilterManager userFilterManager,
                  UserPickerSearchService userPickerSearchService,
                  I18nHelper i18nHelper)
Method Detail

updateValue

public void updateValue(CustomField customField,
                        Issue issue,
                        ApplicationUser user)
Description copied from class: AbstractSingleFieldType
the value does exist, and the new value is different than the existing one.

Specified by:
updateValue in interface CustomFieldType<ApplicationUser,ApplicationUser>
Overrides:
updateValue in class AbstractSingleFieldType<ApplicationUser>
Parameters:
customField - CustomField for which the value is being stored
issue - The Issue to be stored against.
user - Transport Object representing the value instance of the CustomField.

getChangelogValue

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

getDbValueFromObject

protected Object getDbValueFromObject(ApplicationUser customFieldObject)
Description copied from class: AbstractSingleFieldType
Returns the database representation of the Java object as stored for that CustomField. (eg. ProjectId if the Value represents a project). Must be compatable with type returned by AbstractSingleFieldType.getDatabaseType()

Specified by:
getDbValueFromObject in class AbstractSingleFieldType<ApplicationUser>
Parameters:
customFieldObject - the Transport Object
Returns:
String, Double or Date

getObjectFromDbValue

protected ApplicationUser getObjectFromDbValue(@Nonnull
                                               Object databaseValue)
                                        throws FieldValidationException
Description copied from class: AbstractSingleFieldType
Returns the Transport Object for the given Custom Field value as represented by the value stored in the database

Specified by:
getObjectFromDbValue in class AbstractSingleFieldType<ApplicationUser>
Parameters:
databaseValue - - String, Double or Date objects as returned from AbstractSingleFieldType.getDbValueFromObject(Object)
Returns:
Domain object or GenericValue
Throws:
FieldValidationException - if field validation fails.

getStringFromSingularObject

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

getSingularObjectFromString

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

validateFromParams

public void validateFromParams(CustomFieldParams relevantParams,
                               ErrorCollection errorCollectionToAddTo,
                               FieldConfig config)
This method validate the parameters based on the following criteria:
  1. If the specified new value is NOT a valid user, it fails.
  2. If the previous value is specified (obtained from the issue object in the "issue" key), and the specified new value is the same as the previous value, it succeeds and the rest of the validations are skipped. This is to be consistent with the Assignee field where even if the user might not pass the validation in the current context, as long as it does not change, we will let it go. This step relies on the caller to set the issue object into a parameter named "issue" in the relevantParams map.
  3. If a "requireProjectIds" parameter is specified and its value is "true", then the specified new value is checked against the user filtering criteria. Failing the check will immediately fail the whole validation. The "requireProjectIds" parameter indicates that the list of project id's is to be obtained from issue object or field config. The list of project id's might be required for validating project roles in the user filtering.
  4. Otherwise, the validation succeeds.

Specified by:
validateFromParams in interface CustomFieldType<ApplicationUser,ApplicationUser>
Overrides:
validateFromParams in class AbstractSingleFieldType<ApplicationUser>
Parameters:
relevantParams - the custom field parameters, containing the new value under the null key, and optionally the previous value (username) as a single String item list under the key "oldValue", and also optionally the list of projectIds in the current context, as a String list under the key "projectIds", and also optionally a value to indicate whether to load project id's from field config with a single boolean item list under the key "requireProjectIds".
errorCollectionToAddTo - any validation errors will be added into this collection
config - the field configuration

getValueFromCustomFieldParams

public ApplicationUser getValueFromCustomFieldParams(CustomFieldParams relevantParams)
                                              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<ApplicationUser,ApplicationUser>
Overrides:
getValueFromCustomFieldParams in class AbstractSingleFieldType<ApplicationUser>
Parameters:
relevantParams - 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)

compare

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

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

getDatabaseType

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

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

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

getConfigurationItemTypes

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<ApplicationUser,ApplicationUser>
Overrides:
getConfigurationItemTypes in class AbstractCustomFieldType<ApplicationUser,ApplicationUser>
Returns:
List of FieldConfigItemType

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.

accept

public Object accept(AbstractCustomFieldType.VisitorBase visitor)
Overrides:
accept in class AbstractSingleFieldType<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.

remove

public Set<Long> remove(CustomField field)
Description copied from class: AbstractSingleFieldType
called when removing a field. return issue IDs affected.

Subclasses should override this if they have specific cleanup that they need to do (such as removing select list values)

Specified by:
remove in interface CustomFieldType<ApplicationUser,ApplicationUser>
Overrides:
remove in class AbstractSingleFieldType<ApplicationUser>
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


Copyright © 2002-2014 Atlassian. All Rights Reserved.