Class EntityRelationshipDef

All Implemented Interfaces:
DataExceptionContributor, JsonSerializable, RecordSerializable, XmlSerializable, SchemaProblemsSupplier, JavaCodeGenerator, Serializable, Cloneable

public class EntityRelationshipDef extends SchemaPart implements Cloneable, SchemaProblemsSupplier
The metadata model for relating two entities in a schema.
See Also:
  • Constructor Details

    • EntityRelationshipDef

      public EntityRelationshipDef()
    • EntityRelationshipDef

      public EntityRelationshipDef(String name)
  • Method Details

    • getSchemaProblems

      public void getSchemaProblems(List<SchemaProblem> problems, boolean includeChildren)
      Description copied from interface: SchemaProblemsSupplier
      Adds this element's problems to the list, plus those of its children when includeChildren is true; the default adds none.
      Specified by:
      getSchemaProblems in interface SchemaProblemsSupplier
    • clone

      public EntityRelationshipDef clone()
      Overrides:
      clone in class FoundationObject
    • generateJavaCode

      public void generateJavaCode(JavaCodeBuilder code)
      Description copied from interface: JavaCodeGenerator
      Appends Java source code representing this object to the given builder.
      Specified by:
      generateJavaCode in interface JavaCodeGenerator
    • getSchemaDef

      public SchemaDef getSchemaDef()
      Description copied from class: SchemaPart
      Returns the schema containing this part (itself for a SchemaDef) or null if the part is not in a schema.
      Specified by:
      getSchemaDef in class SchemaPart
    • setSchemaDef

      protected EntityRelationshipDef setSchemaDef(SchemaDef schemaDef)
      Sets the parent schema; called by SchemaDef when this relationship is added to it.
    • getSchemaPartContainer

      public SchemaPart getSchemaPartContainer()
      Description copied from class: SchemaPart
      Returns the schema part containing this one or null if there is none.
      Specified by:
      getSchemaPartContainer in class SchemaPart
    • getSchemaPartType

      public SchemaPartType getSchemaPartType()
      Description copied from class: SchemaPart
      Returns the kind of part this is, such as SchemaPartType.ENTITY.
      Specified by:
      getSchemaPartType in class SchemaPart
    • getSchemaPartName

      public String getSchemaPartName()
      Description copied from class: SchemaPart
      Returns the name identifying this part, such as an entity's name or an index field's field name.
      Specified by:
      getSchemaPartName in class SchemaPart
    • getName

      public String getName()
    • setName

      public EntityRelationshipDef setName(String name)
    • getQualifiedName

      public String getQualifiedName()
      Returns the fully qualified name that includes the name of this entity relationship and all names in its hierarchy separated by period.
    • getDescription

      public String getDescription()
    • setDescription

      public EntityRelationshipDef setDescription(String description)
    • getCardinality

      public RelationshipCardinality getCardinality()
    • setCardinality

      public EntityRelationshipDef setCardinality(RelationshipCardinality cardinality)
    • getPrimaryEntityName

      public String getPrimaryEntityName()
      Returns the name of the entity whose primary key the foreign key fields reference.
    • setPrimaryEntityName

      public EntityRelationshipDef setPrimaryEntityName(String primaryEntityName)
      Sets the name of the entity whose primary key the foreign key fields reference.
    • getPrimaryEntity

      public EntityDef getPrimaryEntity()
      Returns the primary entity from the parent schema or null if this relationship has no schema or the entity is not found.
    • getForeignEntityName

      public String getForeignEntityName()
      Returns the name of the entity that holds the foreign key fields.
    • setForeignEntityName

      public EntityRelationshipDef setForeignEntityName(String foreignEntityName)
      Sets the name of the entity that holds the foreign key fields.
    • getForeignEntity

      public EntityDef getForeignEntity()
      Returns the foreign entity from the parent schema or null if this relationship has no schema or the entity is not found.
    • containsForeignKeyFieldName

      public boolean containsForeignKeyFieldName(String name)
      Returns true if the foreign key field names include the given name, ignoring case.
    • getForeignKeyFieldNames

      public List<String> getForeignKeyFieldNames(boolean create)
      Returns the foreign key field names, creating the list if it is null and create is true.
    • getForeignKeyFieldNames

      public List<String> getForeignKeyFieldNames()
      Returns the names of the foreign entity's fields that reference the primary entity's key, in key order, or null if none were added.
    • getForeignKeyFields

      public List<FieldDef> getForeignKeyFields()
      Returns the foreign entity's fields named in getForeignKeyFieldNames(), skipping names it does not define; empty if the foreign entity cannot be found.
    • setForeignKeyFieldNames

      public EntityRelationshipDef setForeignKeyFieldNames(List<String> foreignKeyFieldNames)
      Sets the names of the foreign entity's fields that reference the primary entity's key, in key order.
    • setForeignKeyFieldNames

      public EntityRelationshipDef setForeignKeyFieldNames(String... foreignKeyFieldNames)
      Sets the foreign key field names, in key order, copying them into a new list.
    • addForeignKeyFieldNames

      public EntityRelationshipDef addForeignKeyFieldNames(String foreignKeyFieldName)
      Appends one foreign key field name; null is rejected.
    • getPrimaryKeyFields

      public List<FieldDef> getPrimaryKeyFields()
      Returns the primary entity's primary key fields in key order or null if the primary entity cannot be found.
    • getOnUpdateAction

      public ForeignKeyAction getOnUpdateAction()
    • setOnUpdateAction

      public EntityRelationshipDef setOnUpdateAction(ForeignKeyAction onUpdateAction)
    • getOnDeleteAction

      public ForeignKeyAction getOnDeleteAction()
    • setOnDeleteAction

      public EntityRelationshipDef setOnDeleteAction(ForeignKeyAction onDeleteAction)
    • indexOfForeignKeyFieldName

      public int indexOfForeignKeyFieldName(String name)
      Returns the zero-based position of the given foreign key field name, ignoring case, or -1 if it is not found.
    • getAttributes

      public Attributes getAttributes()
      User-defined key-value pairs to attached arbitrary metadata to this entityRelationShip.
    • setAttributes

      public EntityRelationshipDef setAttributes(Attributes attributes)
      Sets the user-defined key-value pairs attached to this relationship (null is treated as empty).
    • getTags

      public Tags getTags()
      The set of labels used to organize, filter, and classify this entityRelationShip.
    • setTags

      public EntityRelationshipDef setTags(Tags tags)
      Sets the labels used to organize, filter, and classify this relationship (null is treated as empty).
    • toXmlElement

      public Element toXmlElement(Document document)
      Description copied from interface: XmlSerializable
      Returns an element, created with document, describing this object; the default implementation throws a DataException.
      Specified by:
      toXmlElement in interface XmlSerializable
    • fromXmlElement

      public EntityRelationshipDef fromXmlElement(Element entityRelationShipDefElement)
      Specified by:
      fromXmlElement in interface XmlSerializable
    • toRecord

      public Record toRecord()
      Description copied from interface: RecordSerializable
      Converts this object's state to a record that RecordSerializable.fromRecord(Record) can load.
      Specified by:
      toRecord in interface RecordSerializable
      Overrides:
      toRecord in class Bean
    • fromRecord

      public EntityRelationshipDef fromRecord(Record source)
      Description copied from interface: RecordSerializable
      Loads this instance's state from a record and returns this (for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.
      Specified by:
      fromRecord in interface RecordSerializable
      Overrides:
      fromRecord in class Bean
      Parameters:
      source -
      Returns:
      this instance.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object