@PublicSpi public abstract class AbstractSingleFieldType<T> extends AbstractCustomFieldType<T,T>
FIELD_TYPE_STRING
FIELD_TYPE_TEXT
FIELD_TYPE_NUMBER
FIELD_TYPE_DATE
User
or a GenericValue
representing a project.Modifier and Type | Class and Description |
---|---|
static interface |
AbstractSingleFieldType.Visitor<X> |
AbstractCustomFieldType.VisitorBase<X>
Modifier and Type | Field and Description |
---|---|
protected CustomFieldValuePersister |
customFieldValuePersister |
protected static String |
FIELD_TYPE_DATE |
protected static String |
FIELD_TYPE_NUMBER |
protected static String |
FIELD_TYPE_STRING |
protected static String |
FIELD_TYPE_TEXT |
protected GenericConfigManager |
genericConfigManager |
protected static org.apache.log4j.Logger |
log |
DEFAULT_VALUE_TYPE, RESOURCE_PREVIEW
Modifier | Constructor and Description |
---|---|
protected |
AbstractSingleFieldType(CustomFieldValuePersister customFieldValuePersister,
GenericConfigManager genericConfigManager) |
Modifier and Type | Method and Description |
---|---|
Object |
accept(AbstractCustomFieldType.VisitorBase visitor) |
void |
createValue(CustomField field,
Issue issue,
T value)
At this point we know that the value doesn't exist, and that
|
String |
getChangelogValue(CustomField field,
T value)
Returns a values to be stored in the change log, example is the id of the changed item.
|
protected abstract PersistenceFieldType |
getDatabaseType()
Type of database field needed to store this field.
|
protected abstract Object |
getDbValueFromObject(T customFieldObject)
Returns the database representation of the Java object as stored for that CustomField.
|
T |
getDefaultValue(FieldConfig fieldConfig)
Retrieves the Object representing the default CustomField value for the Custom Field.
|
JsonData |
getJsonDefaultValue(IssueContext issueCtx,
CustomField field) |
protected abstract T |
getObjectFromDbValue(Object databaseValue)
Returns the Transport Object for the given Custom Field value as represented by the value
stored in the database
|
Object |
getStringValueFromCustomFieldParams(CustomFieldParams parameters)
Return the String value object from the CustomFieldParams.
|
T |
getValueFromCustomFieldParams(CustomFieldParams relevantParams)
Retrieves the Transport Object representing the CustomField value instance from the CustomFieldParams of Strings.
|
T |
getValueFromIssue(CustomField field,
Issue issue)
Retrieves the Transport Object representing the current CustomField value for the given issue.
|
protected T |
getValueFromIssue(CustomField field,
Long issueId,
String issueKey)
Retrieve the current value of the customfield in the DB based on issue id.
|
Set<Long> |
remove(CustomField field)
called when removing a field.
|
void |
setDefaultValue(FieldConfig fieldConfig,
T value)
Sets the default value for a Custom Field
|
void |
updateValue(CustomField customField,
Issue issue,
T value)
the value does exist, and the new value is different than the
existing one.
|
void |
validateFromParams(CustomFieldParams relevantParams,
ErrorCollection errorCollectionToAddTo,
FieldConfig config)
Ensures that the
CustomFieldParams of Strings is a valid representation of the Custom Field values. |
assertObjectImplementsType, availableForBulkEdit, getChangelogString, getConfigurationItemTypes, getDescription, getDescriptor, getI18nBean, getKey, getName, getRelatedIndexers, getVelocityParameters, getVelocityParameters, init, isRenderable, valuesEqual
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCloneOptionConfiguration, getCloneValue, getSingularObjectFromString, getStringFromSingularObject, isUserInputRequiredForMove
protected static final org.apache.log4j.Logger log
protected static final String FIELD_TYPE_STRING
protected static final String FIELD_TYPE_TEXT
protected static final String FIELD_TYPE_DATE
protected static final String FIELD_TYPE_NUMBER
protected final CustomFieldValuePersister customFieldValuePersister
protected final GenericConfigManager genericConfigManager
protected AbstractSingleFieldType(CustomFieldValuePersister customFieldValuePersister, GenericConfigManager genericConfigManager)
@Nullable public T getValueFromIssue(CustomField field, Issue issue)
CustomFieldType
field
- Custom field for which to retrieve the valueissue
- Issue from which to retrieve the valueCustomFieldType.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)
protected T getValueFromIssue(@Nonnull CustomField field, @Nullable Long issueId, @Nullable String issueKey)
Could be used directly in sub-classes when we don't have the full issue object.
field
- the customfieldissueId
- the id of the issueissueKey
- the issue key. optional, only used for logging purposepublic Set<Long> remove(CustomField field)
Subclasses should override this if they have specific cleanup that they need to do (such as removing select list values)
field
- The custom field that is being removed, so any data stored for
any issues for that field can be deleted.Set
of issue ids that has been affectedpublic void createValue(CustomField field, Issue issue, @Nonnull T value)
field
- CustomField
for which the value is being storedissue
- The Issue
to be stored against.value
- Transport Object representing the value instance of the CustomField.
Can not be null
.public void updateValue(CustomField customField, Issue issue, T value)
customField
- CustomField
for which the value is being storedissue
- The Issue
to be stored against.value
- Transport Object representing the value instance of the CustomField.public void setDefaultValue(FieldConfig fieldConfig, T value)
CustomFieldType
fieldConfig
- CustomField for which the default is being storedvalue
- Transport Object representing the value instance of the CustomFieldpublic T getDefaultValue(FieldConfig fieldConfig)
CustomFieldType
fieldConfig
- CustomField for default valuepublic void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)
CustomFieldType
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.relevantParams
- parameter object of StringserrorCollectionToAddTo
- errorCollection to which any errors should be added (never null)config
- FieldConfigpublic T getValueFromCustomFieldParams(CustomFieldParams relevantParams) throws FieldValidationException
CustomFieldType
relevantParams
- CustomFieldParams of String objects. Will contain one value for Singular field types.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)
FieldValidationException
- if the String value fails to convert into ObjectsCustomFieldType.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)
public Object getStringValueFromCustomFieldParams(CustomFieldParams parameters)
CustomFieldType
parameters
- - CustomFieldParams containing String valuespublic String getChangelogValue(CustomField field, T value)
CustomFieldType
field
- CustomField that the value belongs tovalue
- Transport Object representing the value instance of the CustomField@Nonnull protected abstract PersistenceFieldType getDatabaseType()
PersistenceFieldType
types.@Nullable protected abstract Object getDbValueFromObject(T customFieldObject)
getDatabaseType()
customFieldObject
- the Transport Object@Nullable protected abstract T getObjectFromDbValue(@Nonnull Object databaseValue) throws FieldValidationException
databaseValue
- - String, Double or Date objects as returned from getDbValueFromObject(Object)
FieldValidationException
- if field validation fails.public Object accept(AbstractCustomFieldType.VisitorBase visitor)
accept
in class AbstractCustomFieldType<T,T>
public JsonData getJsonDefaultValue(IssueContext issueCtx, CustomField field)
Copyright © 2002-2017 Atlassian. All Rights Reserved.