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

java.lang.Object
  extended bycom.atlassian.jira.issue.customfields.impl.AbstractCustomFieldType
      extended bycom.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType
All Implemented Interfaces:
CustomFieldType
Direct Known Subclasses:
DateCFType, DateTimeCFType, NumberCFType, ProjectCFType, StringCFType, VersionCFType

public abstract class AbstractSingleFieldType
extends AbstractCustomFieldType

A abstract class that simplifies creating a CustomField that stores a single values via ofbiz. Possible values to store are:

A custom field value has 3 states that it can be represented as.
In Memory Object
This is used as the primary version of the custom field value. This is what is passed to the view layer. An example would be a User or a GenericValue representing a project.
String representation
When editing a custom field value, it needs to be send to the web browser and received in text format. The in Memory Object mentioned above must have a text representation of itself, and be able to parse it. This is the value passed to the edit template. An example would be a username, or project id.
Database representation (required if storing in a database)
A custom field can be stored in a database, and there needs to be a way of getting from the object value to the database value. An example of this would be the project id.


Field Summary
protected  CustomFieldPersister customFieldPersister
           
protected static java.lang.String FIELD_TYPE_DATE
           
protected static java.lang.String FIELD_TYPE_NUMBER
           
protected static java.lang.String FIELD_TYPE_STRING
           
protected static java.lang.String FIELD_TYPE_TEXT
           
 
Constructor Summary
protected AbstractSingleFieldType(CustomFieldPersister customFieldPersister)
           
 
Method Summary
 void createValue(CustomField field, org.ofbiz.core.entity.GenericValue issue, java.lang.Object value)
          at this point we know that the value doesn't exist, and that is not null.
 java.lang.String getChangelogValue(CustomField field, java.lang.Object value)
          Returns a String of representing values to be stored in the change log.
protected abstract  PersistenceFieldType getDatabaseType()
           
protected abstract  java.lang.Object getDbValueFromObject(java.lang.Object customFieldObject)
          Returns the database representation of the Java object as stored for that CustomField.
 java.lang.Object getDefaultValue(CustomField field)
          Retrieves the Object representing the default CustomField value for the Custom Field.
protected abstract  java.lang.Object getObjectFromDbValue(java.lang.Object databaseValue)
          Returns the Domain Object or GenericValue object representing the given Custom Field value as stored in the database
 java.lang.Object getValueFromCustomFieldParams(CustomFieldParams relevantParams)
          Retrieves the Object representing the CustomField value instance from the CustomFieldParams of Strings.
 java.lang.Object getValueFromIssue(CustomField field, org.ofbiz.core.entity.GenericValue issue)
          Retrieves the Object representing the current CustomField value for the given issue.
 java.util.Set remove(CustomField field)
          called when removing a field.
 void setDefaultValue(CustomField field, java.lang.Object value)
          Sets the default value for a Custom Field
 void updateValue(CustomField customField, org.ofbiz.core.entity.GenericValue issue, java.lang.Object value)
          the value does exist, and the new value is different than the existing one.
 void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo)
          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.AbstractCustomFieldType
assertObjectImplementsType, getDescription, getDescriptor, getKey, getName, getVelocityParameters, init
 
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.CustomFieldType
getSingularObjectFromString, getStringFromSingularObject
 

Field Detail

FIELD_TYPE_STRING

protected static final java.lang.String FIELD_TYPE_STRING
See Also:
Constant Field Values

FIELD_TYPE_TEXT

protected static final java.lang.String FIELD_TYPE_TEXT
See Also:
Constant Field Values

FIELD_TYPE_DATE

protected static final java.lang.String FIELD_TYPE_DATE
See Also:
Constant Field Values

FIELD_TYPE_NUMBER

protected static final java.lang.String FIELD_TYPE_NUMBER
See Also:
Constant Field Values

customFieldPersister

protected final CustomFieldPersister customFieldPersister
Constructor Detail

AbstractSingleFieldType

protected AbstractSingleFieldType(CustomFieldPersister customFieldPersister)
Method Detail

getValueFromIssue

public java.lang.Object getValueFromIssue(CustomField field,
                                          org.ofbiz.core.entity.GenericValue 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.

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

remove

public java.util.Set remove(CustomField field)
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)

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

createValue

public void createValue(CustomField field,
                        org.ofbiz.core.entity.GenericValue issue,
                        java.lang.Object value)
at this point we know that the value doesn't exist, and that is not null.


updateValue

public void updateValue(CustomField customField,
                        org.ofbiz.core.entity.GenericValue issue,
                        java.lang.Object value)
the value does exist, and the new value is different than the existing one.


setDefaultValue

public void setDefaultValue(CustomField field,
                            java.lang.Object value)
Description copied from interface: CustomFieldType
Sets the default value for a Custom Field

Parameters:
field - CustomField for which the default is being stored
value - Transport Object representing the value instance of the CustomField

getDefaultValue

public java.lang.Object getDefaultValue(CustomField field)
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.

Parameters:
field - CustomField for default value
Returns:
Transport Object matching the Object parameter of CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, org.ofbiz.core.entity.GenericValue, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, org.ofbiz.core.entity.GenericValue, java.lang.Object)

validateFromParams

public void validateFromParams(CustomFieldParams relevantParams,
                               ErrorCollection errorCollectionToAddTo)
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.

Parameters:
relevantParams - parameter object of Strings
errorCollectionToAddTo - errorCollection to which any erros should be added (never null)

getValueFromCustomFieldParams

public java.lang.Object getValueFromCustomFieldParams(CustomFieldParams relevantParams)
                                               throws CustomFieldValidationException
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, org.ofbiz.core.entity.GenericValue, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, org.ofbiz.core.entity.GenericValue, java.lang.Object)) and Object returned from CustomFieldType.getValueFromIssue(com.atlassian.jira.issue.fields.CustomField, org.ofbiz.core.entity.GenericValue).

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, org.ofbiz.core.entity.GenericValue, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, org.ofbiz.core.entity.GenericValue, java.lang.Object)
Throws:
CustomFieldValidationException - if the String value fails to convert into Objects
See Also:
CustomFieldType.createValue(com.atlassian.jira.issue.fields.CustomField, org.ofbiz.core.entity.GenericValue, java.lang.Object), CustomFieldType.updateValue(com.atlassian.jira.issue.fields.CustomField, org.ofbiz.core.entity.GenericValue, java.lang.Object), CustomFieldType.getValueFromIssue(com.atlassian.jira.issue.fields.CustomField, org.ofbiz.core.entity.GenericValue)

getChangelogValue

public java.lang.String getChangelogValue(CustomField field,
                                          java.lang.Object value)
Description copied from interface: CustomFieldType
Returns a String of representing values to be stored in the change log.

Parameters:
field - CustomField that the value belongs to
value - Transport Object representing the value instance of the CustomField
Returns:
Change log string.

getDatabaseType

protected abstract PersistenceFieldType getDatabaseType()

getDbValueFromObject

protected abstract java.lang.Object getDbValueFromObject(java.lang.Object customFieldObject)
Returns the database representation of the Java object as stored for that CustomField. (eg. ProjectId if the Value represents a project)

Parameters:
customFieldObject -
Returns:
String, Double or Date

getObjectFromDbValue

protected abstract java.lang.Object getObjectFromDbValue(java.lang.Object databaseValue)
                                                  throws CustomFieldValidationException
Returns the Domain Object or GenericValue object representing the given Custom Field value as stored in the database

Parameters:
databaseValue - - String, Double or Date objects
Returns:
Domain object or GenericValue
Throws:
CustomFieldValidationException


Copyright © 2002-2005 Atlassian. All Rights Reserved.