Class RelationType

All Implemented Interfaces:
Serializable, Comparable

public class RelationType extends ComposedType
A special composed type describing binary relations between items.

Physically these relations are backed by the Link item. Therefore all relation type instances are subtype of the composed type describing the Link item.

Relation types consists of the source and target (item) type, the source and target type role and a unique relation name. Since it distinguishes between source and target relation types are directed. The relation end points are described as RelationDescriptor belonging to source or target type. This allows accessing a relation as two item collection attributes from both types. Creation and removal of the actual relation tuples (means Link items) is done automatically. Moreove relations may be localized, which means there may exist different relation elements per language.

See Also:
  • Field Details

    • SOURCE_ATTRIBUTE

      public static final String SOURCE_ATTRIBUTE
      The source type attribute attribute string constant.

      This names is the collection attribute which makes the relation accessible from source type.

      See Also:
    • TARGET_ATTRIBUTE

      public static final String TARGET_ATTRIBUTE
      The target type attribute attribute string constant.

      This names is the collection attribute which makes the relation accessible from target type.

      See Also:
    • ORDERING_ATTRIBUTE

      public static final String ORDERING_ATTRIBUTE
      See Also:
    • LOCALIZATION_ATTRIBUTE

      public static final String LOCALIZATION_ATTRIBUTE
      See Also:
    • SOURCE_TYPE

      public static final String SOURCE_TYPE
      The source type attribute string constant.
      See Also:
    • TARGET_TYPE

      public static final String TARGET_TYPE
      The target type attribute string constant.
      See Also:
    • SOURCE_TYPE_ROLE

      public static final String SOURCE_TYPE_ROLE
      The source type role attribute string constant.
      See Also:
    • TARGET_TYPE_ROLE

      public static final String TARGET_TYPE_ROLE
      The target type role attribute string constant.
      See Also:
    • LOCALIZED

      public static final String LOCALIZED
      The localized attribute string constant.
      See Also:
  • Constructor Details

    • RelationType

      public RelationType()
  • Method Details

    • createItem

      protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException
      The generic creator method which requires: . Besides for both ends either an existing attribute has to be provided or its role and type. Usually the following attributes should be defined:
      Overrides:
      createItem in class ComposedType
      Parameters:
      ctx - the current session context which this item is created within
      type - the actual item type ( since subtypes may not provide a own jalo class this may be different from the type which this method was implemented for )
      Returns:
      the new item instance
      Throws:
      JaloBusinessException - indicates an error during creation - any changes will be rollbacked
    • getNonInitialAttributes

      protected Item.ItemAttributeMap getNonInitialAttributes(SessionContext ctx, Item.ItemAttributeMap allAttributes)
      Overrides:
      getNonInitialAttributes in class ComposedType
      Parameters:
      ctx - session context with language = NULL
      allAttributes - a ItemAttributeMap contaning attribute values.
      Returns:
      a ItemAttributeMap containing all attribute values, which belong to non-initial attributes.
    • getXMLDefinition

      public String getXMLDefinition()
      Assembles the XML definition of this relation to put inside items.xml .
      Overrides:
      getXMLDefinition in class ComposedType
      See Also:
    • exportXMLDefinition

      public String exportXMLDefinition(org.znerd.xmlenc.XMLOutputter xout)
      Overrides:
      exportXMLDefinition in class ComposedType
    • appendModfierXMLDefinition

      protected void appendModfierXMLDefinition(RelationDescriptor des, StringBuilder sb)
      Internal helper for getXMLDefinition().
    • appendModfierXMLDefinition

      protected void appendModfierXMLDefinition(RelationDescriptor des, org.znerd.xmlenc.XMLOutputter xout) throws IOException
      Throws:
      IOException
    • isRootRelationType

      public boolean isRootRelationType()
      Tells whether this relation is a root relation type. Only relations with a own deployment are called root relation type.

      To declare a relation as root the deployment has to be defined in items.xml :

              <relation code="MyRelation"
                                       autocreate="true"
                                       generate="false"
                                       localized="false"
                                       deployment="MyRelationDeplpyment">
                      ...
       
    • isLocalized

      public boolean isLocalized()
      Returns:
      true if the relation is localized, means each relation end attribute may have different values per language
    • getSourceAttributeDescriptor

      public RelationDescriptor getSourceAttributeDescriptor()
      Returns the relation attribute belonging to the source type of this relation. This attribute is named after the target type role and holds a collection type with the target type as element type. In case the target type is not navigable there is no AttributeDescriptor and this method returns null.
      See Also:
    • getTargetAttributeDescriptor

      public RelationDescriptor getTargetAttributeDescriptor()
      Returns the relation attribute belonging to the target type of this relation. This attribute is named after the source type role and holds a collection type with the source type as element type. In case the source type is not navigable there is no AttributeDescriptor and this method returns null.
      See Also:
    • isOrdered

      public boolean isOrdered()
    • getOrderingAttribute

      public AttributeDescriptor getOrderingAttribute()
      For 1-n relations only: the attribute which is used to store the element order. This attribute always belongs to the n-end type of the relation.
    • getLocalizationAttribute

      public AttributeDescriptor getLocalizationAttribute()
      For 1-n relations only: the attribute which is used to map elements to different languages. This attribute always belongs to the n-end type of the relation.
    • getSourceTypeRole

      public String getSourceTypeRole()
      Return the role name of the source type within this relation.
    • getTargetTypeRole

      public String getTargetTypeRole()
      Return the role name of the target type within this relation.
    • getSourceType

      public ComposedType getSourceType()
      Returns the source type of this relation.
    • getTargetType

      public ComposedType getTargetType()
      Returns the target type of this relation.
    • isOneToMany

      public boolean isOneToMany()
    • isSourceTypeOne

      public boolean isSourceTypeOne()
    • getSourceTypeCardinality

      public EnumerationValue getSourceTypeCardinality()
    • isTargetTypeOne

      public boolean isTargetTypeOne()
    • getTargetTypeCardinality

      public EnumerationValue getTargetTypeCardinality()
    • isSourceNavigable

      public boolean isSourceNavigable()
    • isTargetNavigable

      public boolean isTargetNavigable()