org.tigris.scarab.om
Class Attribute

java.lang.Object
  extended byorg.apache.torque.om.BaseObject
      extended byorg.tigris.scarab.om.BaseAttribute
          extended byorg.tigris.scarab.om.Attribute
All Implemented Interfaces:
Conditioned, org.apache.torque.om.Persistent, org.apache.fulcrum.intake.Retrievable, java.io.Serializable

public class Attribute
extends BaseAttribute
implements org.apache.torque.om.Persistent, Conditioned

This class represents the SCARAB_R_OPTION_OPTION table. Please note that this class caches several pieces of data depending on the methods called. If you would like to clear these caches, it is a good idea to call the doRemoveCaches() method after making any modifications to the ROptionOption, ParentChildAttributeOption, and AttributeOption objects.

Version:
$Id: Attribute.java 10042 2006-04-11 11:28:39Z jorgeuriarte $
Author:
Jon S. Stevens
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.tigris.scarab.om.BaseAttribute
collActivitys, collAttributeOptions, collAttributeValues, collConditions, collRAttributeAttributeGroups, collRIssueTypeAttributes, collRModuleAttributes, collRModuleUserAttributes, collTransitions
 
Fields inherited from class org.apache.torque.om.BaseObject
NEW_ID
 
Constructor Summary
protected Attribute()
          Must call getInstance()
 
Method Summary
 void buildOptionsMap()
          Build a list of options.
static boolean checkForDuplicate(java.lang.String attributeName)
          Checks to see if there is another attribute with the same name already in the database.
static boolean checkForDuplicate(java.lang.String attributeName, Attribute attribute)
           
 Attribute copyAttribute(ScarabUser user)
          Copy the Attribute and its options Make sure the new options have a row in the option join table
 void deleteIssueTypeMappings()
          Delete mappings with global issue types.
 void deleteModuleMappings()
          Delete mappings with all modules and issue types.
(package private)  void doRemoveCaches()
          Clears the internal caches for this object
 java.util.List getActivitys()
          Override autogenerated base class method There should be no actitivites being returned
static java.util.List getAllAttributes()
          get a list of all of the Attributes in the database
static java.util.List getAllAttributeTypes()
          Little method to return a List of all Attribute Type's.
 AttributeOption getAttributeOption(java.lang.Integer pk)
          Gets one of the options belonging to this attribute. if the PrimaryKey does not belong to an option in this attribute null is returned.
 AttributeOption getAttributeOption(java.lang.String optionID)
          Get an option by String id.
 java.util.List getAttributeOptions(boolean includeDeleted)
          Get a list of all attribute options or just the ones that have not been marked as deleted.
 AttributeType getAttributeType()
          Override the base class to provide caching of AttributeType objects and save a hit to the database.
(package private) static java.lang.String getCacheKey(org.apache.torque.om.ObjectKey key)
           
 java.util.List getCompatibleAttributeTypes()
          Method to return compatible Attribute Type's.
 java.util.List getConditions()
          If this collection has already been initialized, returns the collection.
 java.lang.Integer[] getConditionsArray()
          Returns the array of attributeOptionIds that will force the requiment of this attribute if set.
 java.lang.String getCreatedUserName()
          Helper method that takes a Integer
static Attribute getInstance(int id)
          Return an instance based on the passed in attribute id as an int It will return a cached instance if possible.
static Attribute getInstance(java.lang.String attributeName)
          Return an instance based on the passed in attribute name as a String.
 java.util.List getOrderedAttributeOptionList()
          Creates an ordered List of AttributeOptions which are children within this Attribute.
 java.util.List getOrderedROptionOptionList()
          Creates an ordered List of ROptionOption which are children within this Attribute.
 java.util.List getParentChildAttributeOptions()
          This returns a list of ParentChildAttributeOption objects which have been populated with combined join data from ROptionOption and the AttributeOption table.
 AttributeOption getRequiredOption()
          Gets the attributeOption that will force this attribute to be required, in case of being set.
 java.util.List getTransitions()
          Returns the transitions defined for this Attribute
 boolean hasGlobalIssueTypeMappings()
          Refers to global issue types.
 boolean hasGlobalMapping(IssueType issueType)
          Refers to global issue types.
 boolean hasMapping(Module module, IssueType issueType)
           
 boolean hasModuleMappings()
           
 boolean isConditioned()
           
 boolean isDateAttribute()
           
 boolean isIntegerAttribute()
           
 boolean isOptionAttribute()
           
 boolean isRequiredIf(java.lang.Integer optionID)
          Return true if the given attributeOptionId will make the current attribute required.
 boolean isSystemDefined()
          Checks if this attribute is associated with atleast one of the global issue types that is system defined.
 boolean isTextAttribute()
           
 boolean isUserAttribute()
           
 void setConditionsArray(java.lang.Integer[] aOptionId)
          Load the attribute options' IDs from the template combo.
(package private)  void setOrderedAttributeOptionList(java.util.List value)
          package protected method to set the value of the cached list.
(package private)  void setOrderedROptionOptionList(java.util.List value)
          package protected method to set the value of the cached list.
(package private)  void setParentChildAttributeOptions(java.util.List value)
          package protected method to set the value of the cached list.
 
Methods inherited from class org.tigris.scarab.om.BaseAttribute
addActivity, addAttributeOption, addAttributeValue, addCondition, addRAttributeAttributeGroup, addRIssueTypeAttribute, addRModuleAttribute, addRModuleUserAttribute, addTransition, copy, copyInto, getAction, getActivitys, getActivitys, getActivitys, getActivitysJoinActivitySet, getActivitysJoinAttachment, getActivitysJoinAttribute, getActivitysJoinAttributeOptionRelatedByNewOptionId, getActivitysJoinAttributeOptionRelatedByOldOptionId, getActivitysJoinDepend, getActivitysJoinIssue, getActivitysJoinScarabUserImplRelatedByNewUserId, getActivitysJoinScarabUserImplRelatedByOldUserId, getAttributeId, getAttributeOption, getAttributeOption, getAttributeOptions, getAttributeOptions, getAttributeOptions, getAttributeOptions, getAttributeOptionsJoinAttribute, getAttributeType, getAttributeValues, getAttributeValues, getAttributeValues, getAttributeValues, getAttributeValuesJoinAttribute, getAttributeValuesJoinAttributeOption, getAttributeValuesJoinIssue, getAttributeValuesJoinScarabUserImpl, getByName, getByPeerName, getByPosition, getConditions, getConditions, getConditions, getConditionsJoinAttribute, getConditionsJoinAttributeOption, getConditionsJoinRModuleAttribute, getConditionsJoinRModuleIssueType, getConditionsJoinTransition, getCreatedBy, getCreatedDate, getDeleted, getDescription, getFieldNames, getName, getPeer, getPermission, getPrimaryKey, getQueryKey, getRAttributeAttributeGroups, getRAttributeAttributeGroups, getRAttributeAttributeGroups, getRAttributeAttributeGroups, getRAttributeAttributeGroupsJoinAttribute, getRAttributeAttributeGroupsJoinAttributeGroup, getRequiredOptionId, getRIssueTypeAttributes, getRIssueTypeAttributes, getRIssueTypeAttributes, getRIssueTypeAttributes, getRIssueTypeAttributesJoinAttribute, getRIssueTypeAttributesJoinIssueType, getRModuleAttributes, getRModuleAttributes, getRModuleAttributes, getRModuleAttributes, getRModuleAttributesJoinAttribute, getRModuleAttributesJoinIssueType, getRModuleAttributesJoinScarabModule, getRModuleUserAttributes, getRModuleUserAttributes, getRModuleUserAttributes, getRModuleUserAttributes, getRModuleUserAttributesJoinAttribute, getRModuleUserAttributesJoinIssueType, getRModuleUserAttributesJoinMITList, getRModuleUserAttributesJoinScarabModule, getRModuleUserAttributesJoinScarabUserImpl, getScarabUser, getScarabUser, getTransitions, getTransitions, getTransitions, getTransitionsJoinAttribute, getTransitionsJoinAttributeOptionRelatedByFromOptionId, getTransitionsJoinAttributeOptionRelatedByToOptionId, getTypeId, initActivitys, initAttributeOptions, initAttributeValues, initConditions, initRAttributeAttributeGroups, initRIssueTypeAttributes, initRModuleAttributes, initRModuleUserAttributes, initTransitions, isCacheOnSave, save, save, save, setAction, setAttributeId, setAttributeOption, setAttributeOptionKey, setAttributeType, setAttributeTypeKey, setCreatedBy, setCreatedDate, setDeleted, setDescription, setName, setPermission, setPrimaryKey, setPrimaryKey, setQueryKey, setRequiredOptionId, setScarabUser, setScarabUserKey, setTypeId, toString
 
Methods inherited from class org.apache.torque.om.BaseObject
equals, equals, getLog, hashCode, isModified, isNew, resetModified, setModified, setNew, setPrimaryKey
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.torque.om.Persistent
getPrimaryKey, isModified, isNew, save, save, save, setModified, setNew, setPrimaryKey, setPrimaryKey
 

Constructor Detail

Attribute

protected Attribute()
Must call getInstance()

Method Detail

getCacheKey

static java.lang.String getCacheKey(org.apache.torque.om.ObjectKey key)

getInstance

public static Attribute getInstance(int id)
                             throws org.apache.torque.TorqueException
Return an instance based on the passed in attribute id as an int It will return a cached instance if possible.

Throws:
org.apache.torque.TorqueException

getInstance

public static Attribute getInstance(java.lang.String attributeName)
                             throws org.apache.torque.TorqueException
Return an instance based on the passed in attribute name as a String. It will return the first match if the number of Attributes found > 0 Note: The business logic dicates that there should never be duplicate Attributes. Therefore, the checkForDuplicate method will return true if the number of Attributes found is > 0

Throws:
org.apache.torque.TorqueException

checkForDuplicate

public static boolean checkForDuplicate(java.lang.String attributeName)
                                 throws org.apache.torque.TorqueException
Checks to see if there is another attribute with the same name already in the database. Returns true if there is another Attribute of the same name.

Throws:
org.apache.torque.TorqueException

checkForDuplicate

public static boolean checkForDuplicate(java.lang.String attributeName,
                                        Attribute attribute)
                                 throws org.apache.torque.TorqueException
Throws:
org.apache.torque.TorqueException

getCreatedUserName

public java.lang.String getCreatedUserName()
                                    throws org.apache.torque.TorqueException
Helper method that takes a Integer

Throws:
org.apache.torque.TorqueException

doRemoveCaches

void doRemoveCaches()
Clears the internal caches for this object


getAllAttributeTypes

public static java.util.List getAllAttributeTypes()
                                           throws org.apache.torque.TorqueException
Little method to return a List of all Attribute Type's. It is here for convenience with regards to needing this functionality from within a Template.

Throws:
org.apache.torque.TorqueException

getCompatibleAttributeTypes

public java.util.List getCompatibleAttributeTypes()
                                           throws org.apache.torque.TorqueException,
                                                  com.workingdogs.village.DataSetException
Method to return compatible Attribute Type's. if the attribute has not been used at all, all types are compatible. if issues have been entered which use the attribute only text types are compatible with each other It is here for convenience with regards to needing this functionality from within a Template.

Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getAttributeType

public AttributeType getAttributeType()
                               throws org.apache.torque.TorqueException
Override the base class to provide caching of AttributeType objects and save a hit to the database.

Overrides:
getAttributeType in class BaseAttribute
Returns:
the associated AttributeType object
Throws:
org.apache.torque.TorqueException

getAllAttributes

public static java.util.List getAllAttributes()
                                       throws org.apache.torque.TorqueException
get a list of all of the Attributes in the database

Throws:
org.apache.torque.TorqueException

isOptionAttribute

public boolean isOptionAttribute()
                          throws org.apache.torque.TorqueException
Throws:
org.apache.torque.TorqueException

isUserAttribute

public boolean isUserAttribute()
                        throws org.apache.torque.TorqueException
Throws:
org.apache.torque.TorqueException

isTextAttribute

public boolean isTextAttribute()
                        throws org.apache.torque.TorqueException
Throws:
org.apache.torque.TorqueException

isIntegerAttribute

public boolean isIntegerAttribute()
                           throws org.apache.torque.TorqueException
Throws:
org.apache.torque.TorqueException

isDateAttribute

public boolean isDateAttribute()
                        throws org.apache.torque.TorqueException
Throws:
org.apache.torque.TorqueException

getAttributeOption

public AttributeOption getAttributeOption(java.lang.Integer pk)
                                   throws org.apache.torque.TorqueException
Gets one of the options belonging to this attribute. if the PrimaryKey does not belong to an option in this attribute null is returned.

Parameters:
pk - a Integer value
Returns:
an AttributeOption value
Throws:
org.apache.torque.TorqueException

getAttributeOption

public AttributeOption getAttributeOption(java.lang.String optionID)
                                   throws org.apache.torque.TorqueException
Get an option by String id.

Throws:
org.apache.torque.TorqueException - if optionId is empty

setParentChildAttributeOptions

void setParentChildAttributeOptions(java.util.List value)
package protected method to set the value of the cached list. Generally, this is used to set it to null.


getParentChildAttributeOptions

public java.util.List getParentChildAttributeOptions()
                                              throws org.apache.torque.TorqueException
This returns a list of ParentChildAttributeOption objects which have been populated with combined join data from ROptionOption and the AttributeOption table.

Returns:
a List of ParentChildAttributeOption objects
Throws:
org.apache.torque.TorqueException

setOrderedROptionOptionList

void setOrderedROptionOptionList(java.util.List value)
package protected method to set the value of the cached list. Generally, this is used to set it to null.


getOrderedROptionOptionList

public java.util.List getOrderedROptionOptionList()
                                           throws org.apache.torque.TorqueException
Creates an ordered List of ROptionOption which are children within this Attribute. The list is ordered according to the preferred order.

Returns:
a List of ROptionOption's
Throws:
org.apache.torque.TorqueException

setOrderedAttributeOptionList

void setOrderedAttributeOptionList(java.util.List value)
package protected method to set the value of the cached list. Generally, this is used to set it to null.


getOrderedAttributeOptionList

public java.util.List getOrderedAttributeOptionList()
                                             throws org.apache.torque.TorqueException
Creates an ordered List of AttributeOptions which are children within this Attribute. The list is ordered according to the preferred order.

Returns:
a List of AttributeOption's
Throws:
org.apache.torque.TorqueException

getAttributeOptions

public java.util.List getAttributeOptions(boolean includeDeleted)
                                   throws org.apache.torque.TorqueException
Get a list of all attribute options or just the ones that have not been marked as deleted.

Throws:
org.apache.torque.TorqueException

buildOptionsMap

public void buildOptionsMap()
                     throws org.apache.torque.TorqueException
Build a list of options.

Throws:
org.apache.torque.TorqueException

getActivitys

public java.util.List getActivitys()
                            throws org.apache.torque.TorqueException
Override autogenerated base class method There should be no actitivites being returned

Overrides:
getActivitys in class BaseAttribute
Returns:
the collection of associated objects
Throws:
org.apache.torque.TorqueException

copyAttribute

public Attribute copyAttribute(ScarabUser user)
                        throws org.apache.torque.TorqueException
Copy the Attribute and its options Make sure the new options have a row in the option join table

Throws:
org.apache.torque.TorqueException

hasModuleMappings

public boolean hasModuleMappings()
                          throws org.apache.torque.TorqueException,
                                 com.workingdogs.village.DataSetException
Returns:
Whether this attribute is mapped to any modules.
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

hasMapping

public boolean hasMapping(Module module,
                          IssueType issueType)
                   throws org.apache.torque.TorqueException,
                          com.workingdogs.village.DataSetException
Parameters:
module - null to ignore this criterion.
issueType - null to ignore this criterion.
Returns:
Whether this attribute is already mapped to the specified Module and IssueType.
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

hasGlobalIssueTypeMappings

public boolean hasGlobalIssueTypeMappings()
                                   throws org.apache.torque.TorqueException,
                                          com.workingdogs.village.DataSetException
Refers to global issue types.

Returns:
Whether this attribute is mapped to any issue types.
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
See Also:
hasGlobalMapping(IssueType)

hasGlobalMapping

public boolean hasGlobalMapping(IssueType issueType)
                         throws org.apache.torque.TorqueException,
                                com.workingdogs.village.DataSetException
Refers to global issue types.

Parameters:
issueType - A specific IssueType to find associated attributes for, or null to ignore this criterion.
Returns:
Whether there are any mappings for this attribute.
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

deleteModuleMappings

public void deleteModuleMappings()
                          throws org.apache.torque.TorqueException,
                                 ScarabException
Delete mappings with all modules and issue types.

Throws:
org.apache.torque.TorqueException
ScarabException

deleteIssueTypeMappings

public void deleteIssueTypeMappings()
                             throws org.apache.torque.TorqueException
Delete mappings with global issue types.

Throws:
org.apache.torque.TorqueException

isSystemDefined

public boolean isSystemDefined()
                        throws org.apache.torque.TorqueException
Checks if this attribute is associated with atleast one of the global issue types that is system defined.

Returns:
True if the attribute is associated with a System defined global Issue Type.False otherwise.
Throws:
org.apache.torque.TorqueException

getRequiredOption

public AttributeOption getRequiredOption()
Gets the attributeOption that will force this attribute to be required, in case of being set.

Returns:

getConditionsArray

public java.lang.Integer[] getConditionsArray()
Returns the array of attributeOptionIds that will force the requiment of this attribute if set. Used by templates to load the combo.

Specified by:
getConditionsArray in interface Conditioned
Returns:

getConditions

public java.util.List getConditions()
                             throws org.apache.torque.TorqueException
Description copied from class: BaseAttribute
If this collection has already been initialized, returns the collection. Otherwise returns the results of getConditions(new Criteria())

Overrides:
getConditions in class BaseAttribute
Returns:
the collection of associated objects
Throws:
org.apache.torque.TorqueException

setConditionsArray

public void setConditionsArray(java.lang.Integer[] aOptionId)
                        throws org.apache.torque.TorqueException
Load the attribute options' IDs from the template combo.

Specified by:
setConditionsArray in interface Conditioned
Parameters:
aOptionId -
Throws:
org.apache.torque.TorqueException

isRequiredIf

public boolean isRequiredIf(java.lang.Integer optionID)
                     throws org.apache.torque.TorqueException
Return true if the given attributeOptionId will make the current attribute required.

Specified by:
isRequiredIf in interface Conditioned
Parameters:
optionID -
Returns:
Throws:
org.apache.torque.TorqueException

isConditioned

public boolean isConditioned()
Specified by:
isConditioned in interface Conditioned
Returns:
true if there's any condition associated to this object, false if there's not.

getTransitions

public java.util.List getTransitions()
Returns the transitions defined for this Attribute

Overrides:
getTransitions in class BaseAttribute
Returns:
the collection of associated objects


Copyright © 2000-2004 Tigris.org. All Rights Reserved.