Class DefaultEntityModel

java.lang.Object
ch.tocco.nice2.model.entity.api.DefaultModelBase
ch.tocco.nice2.model.entity.api.DefaultEntityModel
All Implemented Interfaces:
NiceActionHolder, EntityModel, ModelElement, ModuleTracker
Direct Known Subclasses:
EntityModelImpl

public abstract class DefaultEntityModel extends DefaultModelBase implements EntityModel
  • Constructor Details

    • DefaultEntityModel

      public DefaultEntityModel()
  • Method Details

    • getName

      public String getName()
      Description copied from interface: EntityModel
      It's the "name" attribute of the entityModel tag.
      Specified by:
      getName in interface EntityModel
      Overrides:
      getName in class DefaultModelBase
      Returns:
      The entity name of this entity, for example "Address".
    • setName

      public void setName(String name)
      Specified by:
      setName in interface EntityModel
      Overrides:
      setName in class DefaultModelBase
      Parameters:
      name - the name, non-null
    • isDisabled

      public boolean isDisabled()
      Specified by:
      isDisabled in interface EntityModel
      Returns:
      Tells if this entity is disabled and thus ignored.
    • setDisabled

      public void setDisabled(boolean disabled)
      Description copied from interface: EntityModel
      Sets if this entity is disabled and thus ignored.
      Specified by:
      setDisabled in interface EntityModel
      Parameters:
      disabled - if disabled
    • getTarget

      public String getTarget()
      Description copied from interface: EntityModel
      It's the "target" attribute of the entityModel tag.
      Specified by:
      getTarget in interface EntityModel
      Returns:
      The internal target of this entity, eg the table name.
    • setTarget

      public void setTarget(String target)
      Specified by:
      setTarget in interface EntityModel
      Parameters:
      target - targent-name, non-null
    • setEntityType

      public void setEntityType(EntityType entityType)
      Specified by:
      setEntityType in interface EntityModel
      Parameters:
      entityType - The type of entity.
    • getEntityType

      public EntityType getEntityType()
      Specified by:
      getEntityType in interface EntityModel
      Returns:
      The entity type.
    • getKey

      public FieldModel getKey()
      Specified by:
      getKey in interface EntityModel
      Returns:
      The primary key field.
    • getFields

      public List<FieldModel> getFields()
      Specified by:
      getFields in interface EntityModel
      Returns:
      The fields including those part of the primary keys (see EntityModel.getKey()).
    • getFieldsTargets

      public List<String> getFieldsTargets(List<FieldModel> fields)
      Description copied from interface: EntityModel
      Example: myEntityModel.getFieldsTargets( myEntityModel.getKeys() )
      Specified by:
      getFieldsTargets in interface EntityModel
      Parameters:
      fields - The fields to loop.
      Returns:
      The targets of the passed in fields.
    • getFieldsNames

      public List<String> getFieldsNames(List<FieldModel> fields)
      Description copied from interface: EntityModel
      Example: myEntityModel.getFieldsNames( myEntityModel.getKeys() )
      Specified by:
      getFieldsNames in interface EntityModel
      Parameters:
      fields - The fields to loop.
      Returns:
      The names of the passed in fields.
    • hasField

      public boolean hasField(String fieldName)
      Description copied from interface: EntityModel
      Included are key fields, but not relations.
      Specified by:
      hasField in interface EntityModel
      Parameters:
      fieldName - The field name to look for.
      Returns:
      Tells if this model has a field by that name.
      See Also:
    • getFieldByName

      @Nullable public @Nullable FieldModel getFieldByName(String name)
      Description copied from interface: EntityModel
      Get a field by its name. Note: If the field is multilingual then provide the complete name for the strategy in use, which may look something like "somename" or "somename_fr".
      Specified by:
      getFieldByName in interface EntityModel
      Parameters:
      name - The complete field's name (including possible localized suffix), not empty.
      Returns:
      The field, or null if this field doesn't exists!
      See Also:
    • getFieldsByType

      public List<FieldModel> getFieldsByType(String type)
      Description copied from interface: EntityModel
      Returns all fields of the data type specified.
      Specified by:
      getFieldsByType in interface EntityModel
      Returns:
      May be empty.
    • getFieldsByBaseType

      public List<FieldModel> getFieldsByBaseType(String baseType)
      Description copied from interface: EntityModel
      Returns all fields that have the specified data type as base type.
      Specified by:
      getFieldsByBaseType in interface EntityModel
      Returns:
      May be empty.
    • getFirstFieldOfType

      @Nullable public @Nullable FieldModel getFirstFieldOfType(String type)
      Description copied from interface: EntityModel
      version, createts, updateuser ...
      Specified by:
      getFirstFieldOfType in interface EntityModel
      Returns:
      The first field as returned by getFieldsByType(), or null.
    • getFirstFieldOfBaseType

      @Nullable public @Nullable FieldModel getFirstFieldOfBaseType(String baseType)
      Specified by:
      getFirstFieldOfBaseType in interface EntityModel
      Returns:
      The first field as returned by getFieldsByBaseType(), or null.
    • addField

      public void addField(FieldModel f) throws IllegalArgumentException
      Adds a field to this entity model.

      WARNING: This implementation currently does not check for duplicates, or fields with the same name. This is currently left up to you, but might change in the future.

      Specified by:
      addField in interface EntityModel
      Parameters:
      f - The field
      Throws:
      IllegalArgumentException
    • addRelation

      public void addRelation(RelationModel relation)
      Specified by:
      addRelation in interface EntityModel
      Parameters:
      relation - The relation.
      See Also:
    • getRelations

      public Collection<RelationModel> getRelations()
      Description copied from interface: EntityModel
      Get all relations FROM this entity TO other entities; only one way. There seems to be no method for the opposite yet.
      Specified by:
      getRelations in interface EntityModel
    • getRelationByName

      @Nullable public @Nullable RelationModel getRelationByName(String name)
      Description copied from interface: EntityModel
      Get a relation by its name.
      Specified by:
      getRelationByName in interface EntityModel
      Parameters:
      name - The name.
      Returns:
      The relation or null if this relation doesn't exists!
    • hasRelation

      public boolean hasRelation(String relName)
      Specified by:
      hasRelation in interface EntityModel
      Parameters:
      relName - The relation name to look for, eg "relFoo".
      Returns:
      Tells if this model has a relation by that name.
      See Also: