Class DataObjectMetadataImpl

java.lang.Object
org.kuali.rice.krad.data.metadata.impl.MetadataCommonBase
org.kuali.rice.krad.data.metadata.impl.DataObjectMetadataImpl
All Implemented Interfaces:
Serializable, DataObjectMetadata, DataObjectMetadataInternal, MetadataCommonInternal, MetadataCommon

public class DataObjectMetadataImpl extends MetadataCommonBase implements DataObjectMetadataInternal
Base implementation class for the metadata related to the data object as a whole.

Contains lists of all child elements.

Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
  • Field Details

  • Constructor Details

    • DataObjectMetadataImpl

      public DataObjectMetadataImpl()
  • Method Details

    • getUniqueKeyForMerging

      public Object getUniqueKeyForMerging()
      Returns the object's name without relying on embedded metadata. To override, this name must be set.
      Specified by:
      getUniqueKeyForMerging in interface MetadataCommonInternal
      Overrides:
      getUniqueKeyForMerging in class MetadataCommonBase
    • getType

      public Class<?> getType()
      Gets metadata object type.

      The type represented by this metadata object. Usually this will simply contain the class name created by the persistence layer when it is loaded from the database.

      Specified by:
      getType in interface DataObjectMetadata
      Returns:
      metadata object type. Will never return null.
    • setType

      public void setType(Class<?> type)
      Sets unknown class to determine type.
      Parameters:
      type - unknown class
    • getTypeClassName

      public String getTypeClassName()
      Gets type based on unknown class.
      Returns:
      class type or null
    • setTypeClassName

      public void setTypeClassName(String typeClassName)
      This is really a helper method for cases where these objects may need to be built up via Spring XML.
      Parameters:
      typeClassName - class type
    • getPrimaryKeyAttributeNames

      public List<String> getPrimaryKeyAttributeNames()
      Get the list of primary key attribute names for this data object.
      Specified by:
      getPrimaryKeyAttributeNames in interface DataObjectMetadata
      Returns:
      primary key attribute names.
    • setPrimaryKeyAttributeNames

      public void setPrimaryKeyAttributeNames(List<String> primaryKeyAttributeNames)
      Sets list of primary attribute names which make up key.
      Parameters:
      primaryKeyAttributeNames - list of attribute names.
    • getBusinessKeyAttributeNames

      public List<String> getBusinessKeyAttributeNames()
      List of attribute names which form a "user friendly" key. (As opposed to a sequence number as used by some parts of the system).

      An example here would be the KIM Role object where the Role ID is the primary key, but the Namespace and Name properties form the user-visible and enterable key.

      Specified by:
      getBusinessKeyAttributeNames in interface DataObjectMetadata
      Returns:
      a list containing the business key attributes names for the data object.
    • setBusinessKeyAttributeNames

      public void setBusinessKeyAttributeNames(List<String> businessKeyAttributeNames)
      Sets list of attribute names that make up business key.
      Parameters:
      businessKeyAttributeNames - attribute names
    • hasDistinctBusinessKey

      public Boolean hasDistinctBusinessKey()
      Returns true if the list of primary key names and business key attribute names are different.
      Specified by:
      hasDistinctBusinessKey in interface DataObjectMetadata
      Returns:
      true if the list of primary key names and business key attributes are different, false if they are the same.
    • getPrimaryDisplayAttributeName

      public String getPrimaryDisplayAttributeName()
      Gets primary display attribute name

      This is the field on the object which best represents it on displays. It will be used to build inquiry links and determine where to place quickfinder links. Usually this will be the the primary key or the last field of the primary key if there are multiple fields.

      If not specified by the provider, the base implementation will default it to the last attribute in the primaryKeyAttributeNames list.

      Specified by:
      getPrimaryDisplayAttributeName in interface DataObjectMetadata
      Returns:
      the name of the attribute to use for primary display purposes.
    • setPrimaryDisplayAttributeName

      public void setPrimaryDisplayAttributeName(String primaryDisplayAttributeName)
      Sets list of attribute names used for display.
      Parameters:
      primaryDisplayAttributeName - list of attribute names.
    • orderAttributesByDefinedOrder

      public List<DataObjectAttribute> orderAttributesByDefinedOrder(List<DataObjectAttribute> attributes)
      Orders attributes by defined order.

      First looks to see if attributes are inherited, then looks at the declared fields based on the attribute type.

      Parameters:
      attributes - list of data object attributes
      Returns:
      re-ordered list of data object attributes
    • getAttributes

      public List<DataObjectAttribute> getAttributes()
      Gets attributes defined on the data object.

      Gets all the attributes defined on the data object in the order given by the MetadataProvider. This may or may not be the same as the backing object's (table) and is most likely the order in which they appear in the source persistence metadata (XML or annotations).

      Specified by:
      getAttributes in interface DataObjectMetadata
      Returns:
      Data object attributes. Will never return null. Will return an empty list if no attributes defined.
    • setAttributes

      public void setAttributes(List<DataObjectAttribute> attributes)
      Sets attributes.

      Looks at merge actions when adding, so not all attributes are added.

      Parameters:
      attributes - list of data object attributes
    • getCollections

      public List<DataObjectCollection> getCollections()
      Gets child collections.

      Gets all the child collections defined on the data object in the order given by the MetadataProvider.

      Specified by:
      getCollections in interface DataObjectMetadata
      Returns:
      Child collections. Will never return null. Will return an empty list if no collections defined.
    • setCollections

      public void setCollections(List<DataObjectCollection> collections)
      Sets collections.

      Looks at merge actions when adding, so not all collections are added.

      Parameters:
      collections - list of data object collections or null
    • getRelationships

      public List<DataObjectRelationship> getRelationships()
      Gets child relationships.

      Gets all the child relationships defined on the data object in the order given by the MetadataProvider.

      Specified by:
      getRelationships in interface DataObjectMetadata
      Returns:
      Child relationships. Will never return null. Will return an empty list if no relationships defined.
    • setRelationships

      public void setRelationships(List<DataObjectRelationship> relationships)
      Sets relationships.

      Looks at merge actions and whether the relationship is empty when adding, so not all relationships are added.

      Parameters:
      relationships - list of data object relationships or null
    • getAttribute

      public DataObjectAttribute getAttribute(String attributeName)
      Gets attribute metadata.

      Get the named attribute's metadata from the data object.

      Specified by:
      getAttribute in interface DataObjectMetadata
      Returns:
      null if the attributeName does not exist, the associated DataObjectAttribute otherwise.
    • getCollection

      public DataObjectCollection getCollection(String collectionName)
      Gets the named collection's metadata from the data object.

      The name is the property on the data object which holds the Collection.

      Specified by:
      getCollection in interface DataObjectMetadata
      Returns:
      null if the attributeName does not exist, the associated DataObjectCollection otherwise.
    • getRelationship

      public DataObjectRelationship getRelationship(String relationshipName)
      Gets the named relationship's metadata from the data object.

      The name is the property on the data object which holds the related business object's instance.

      Specified by:
      getRelationship in interface DataObjectMetadata
      Returns:
      null if the attributeName does not exist, the associated DataObjectRelationship otherwise.
    • getRelationshipsInvolvingAttribute

      public List<DataObjectRelationship> getRelationshipsInvolvingAttribute(String attributeName)
      Gets attribute relationships.

      Returns all relationships of which the given attribute is part of the foreign key relationship.

      Specified by:
      getRelationshipsInvolvingAttribute in interface DataObjectMetadata
      Returns:
      The list of relationship metadata objects or an empty list if none found.
    • getRelationshipByLastAttributeInRelationship

      public DataObjectRelationship getRelationshipByLastAttributeInRelationship(String attributeName)
      Gets relationship of last attribute.

      Returns a single relationship for which the given attribute is the last in the foreign key relationship.

      Specified by:
      getRelationshipByLastAttributeInRelationship in interface DataObjectMetadata
      Returns:
      null if no relationship's foreign key set ends wit the given field. The DataObjectRelationship otherwise.
    • getEmbedded

      public DataObjectMetadataInternal getEmbedded()
      The embedded DataObjectMetadata which will be used to fill in values not specified by this DataObjectMetadata.
      Specified by:
      getEmbedded in interface DataObjectMetadataInternal
      Returns:
      the embedded metadata, or no if no metadata is embedded
    • setEmbedded

      public void setEmbedded(DataObjectMetadataInternal embedded)
      Sets the embedded DataObjectMetadata.
      Specified by:
      setEmbedded in interface DataObjectMetadataInternal
      Parameters:
      embedded - or null
    • getProviderName

      public String getProviderName()
      Gets the metadata source.

      Helper property to allow identification of the source of metadata. Value is transient, so it will not survive serialization.

      Returns:
      metadata source
    • setProviderName

      public void setProviderName(String providerName)
      Sets provider name.
      Parameters:
      providerName - name of provider
    • toString

      public String toString()
      Overrides:
      toString in class MetadataCommonBase
    • isSupportsOptimisticLocking

      public boolean isSupportsOptimisticLocking()
      Determines whether optimistic locking is supported.

      Returns true if the underlying ORM tool performs optimistic locking checks on this object before saving. Under the KNS, this was done via the versionNumber property and appropriate OJB configuration. In JPA, this is linked to the @Version annotation.

      Specified by:
      isSupportsOptimisticLocking in interface DataObjectMetadata
      Returns:
      true if this data object is configured for optimistic locking.
    • setSupportsOptimisticLocking

      public void setSupportsOptimisticLocking(boolean supportsOptimisticLocking)
      Sets whether optimistic locking is supported.
      Parameters:
      supportsOptimisticLocking - whether optimistic locking is supported
    • getOrderedAttributeList

      public List<String> getOrderedAttributeList()
      Gets sorted attribute list.
      Returns:
      ordered attribute list
    • setOrderedAttributeList

      public void setOrderedAttributeList(List<String> orderedAttributeList)
      Sets sorted attribute list.
      Parameters:
      orderedAttributeList - sorted attributes