Interface EntityModel

All Superinterfaces:
ModelElement, ModuleTracker, NiceActionHolder
All Known Implementing Classes:
DefaultEntityModel, EntityModelImpl, TemplateEntityModel

public interface EntityModel extends ModelElement, NiceActionHolder, ModuleTracker
The model for the data-mapping, but with addional information for the nice-system.

State

The state-behavior is like ModelElement
See Also:
  • Method Details

    • getName

      String getName()
      It's the "name" attribute of the entityModel tag.
      Returns:
      The entity name of this entity, for example "Address".
    • getTarget

      String getTarget()
      It's the "target" attribute of the entityModel tag.
      Returns:
      The internal target of this entity, eg the table name.
    • getEntityType

      EntityType getEntityType()
      Returns:
      The entity type.
    • isDisabled

      boolean isDisabled()
      Returns:
      Tells if this entity is disabled and thus ignored.
    • setDisabled

      void setDisabled(boolean disabled)
      Sets if this entity is disabled and thus ignored.
      Parameters:
      disabled - if disabled
    • getKey

      FieldModel getKey()
      Returns:
      The primary key field.
    • getFieldsTargets

      List<String> getFieldsTargets(List<FieldModel> fields)
      Example: myEntityModel.getFieldsTargets( myEntityModel.getKeys() )
      Parameters:
      fields - The fields to loop.
      Returns:
      The targets of the passed in fields.
    • getFieldsNames

      List<String> getFieldsNames(List<FieldModel> fields)
      Example: myEntityModel.getFieldsNames( myEntityModel.getKeys() )
      Parameters:
      fields - The fields to loop.
      Returns:
      The names of the passed in fields.
    • getFields

      List<FieldModel> getFields()
      Returns:
      The fields including those part of the primary keys (see getKey()).
    • hasField

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

      @Nullable @Nullable FieldModel getFieldByName(String name)
      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".
      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:
    • requireFieldByName

      default FieldModel requireFieldByName(String name)
      Get a field by its name.
      Parameters:
      name - The field's name, not empty.
      Throws:
      ModelException - If there is no such field.
      See Also:
    • getFieldsByType

      List<FieldModel> getFieldsByType(String type)
      Returns all fields of the data type specified.
      Returns:
      May be empty.
    • getFieldsByBaseType

      List<FieldModel> getFieldsByBaseType(String baseType)
      Returns all fields that have the specified data type as base type.
      Returns:
      May be empty.
    • getFirstFieldOfType

      @Nullable @Nullable FieldModel getFirstFieldOfType(String type)
      version, createts, updateuser ...
      Returns:
      The first field as returned by getFieldsByType(), or null.
    • getFirstFieldOfBaseType

      @Nullable @Nullable FieldModel getFirstFieldOfBaseType(String baseType)
      Returns:
      The first field as returned by getFieldsByBaseType(), or null.
    • getRelations

      Collection<RelationModel> getRelations()
      Get all relations FROM this entity TO other entities; only one way. There seems to be no method for the opposite yet.
    • getRelationByName

      @Nullable @Nullable RelationModel getRelationByName(String name)
      Get a relation by its name.
      Parameters:
      name - The name.
      Returns:
      The relation or null if this relation doesn't exists!
    • requireRelationByName

      default RelationModel requireRelationByName(String name)
      Get a relation by its name.
      Throws:
      ModelException - If there is no such relation.
      See Also:
    • hasRelation

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

      void setTarget(String target)
      Parameters:
      target - targent-name, non-null
      Throws:
      IllegalStateException - when trying to change the model after finished model-reading
    • setEntityType

      void setEntityType(EntityType entityType)
      Parameters:
      entityType - The type of entity.
      Throws:
      IllegalStateException - when trying to change the model after finished model-reading
    • addField

      void addField(FieldModel fieldModel) throws IllegalArgumentException
      Adds a nice-field to this entity model.

      WARNING: All key fields need to be added first! If you try to add a regular field first then you'll get a strange ClassCastException to Long.

      Note: a field "removed" (disabled) by removeField() cannot be re-added here.

      Parameters:
      fieldModel - The field model
      Throws:
      IllegalArgumentException
    • addRelation

      void addRelation(RelationModel relation)
      Parameters:
      relation - The relation.
      Throws:
      IllegalStateException - When trying to change the model after finished model-reading. Or when there is such a relation already.
      See Also:
    • setName

      void setName(String name)
      Parameters:
      name - the name, non-null
      Throws:
      IllegalStateException - when trying to change the model after finished model-reading
    • getDocumentation

      LinkedHashMap<String,String> getDocumentation()
      Returns the content of the documentation element of the EntityModel tag as a LinkedHashMap, divided by the AppModules extending the base EntityModel and contributing the documentation. The contents of the map are ordered according to the loading sequence of the AppModules.
      Returns:
      The LinkedHashMap contains the EntityModel's documentation tag.
    • addDocumentation

      void addDocumentation(String definingModule, String documentation)
      Adds documentation for the EntityModel, contributed by the defining AppModule.
      Parameters:
      definingModule - the string representation of the AppModule contributing the documentation
      documentation - the documentation for the EntityModel
    • getFieldByName

      @Nullable @Nullable FieldModel getFieldByName(String name, String locale)
      Get a possibly multilingual field by base name and locale.

      This is a shortcut for doing: EntityModel.getFieldByName( EntityModel.getLocalizedFieldMapper().getFieldName(name, locale) );

      Parameters:
      name - The field's base name, not empty.
      locale - Currently the 2-digit lowercase ISO-639 language code only, eg "fr" for French.
      Returns:
      The field, or null if this field doesn't exists (either at all or in that locale)
      See Also:
    • getFieldByName

      @Nullable @Nullable FieldModel getFieldByName(String name, Locale locale)
    • isLocalizedField

      boolean isLocalizedField(String baseName)
      Tells if there is a localized field with the given base name.
      Parameters:
      baseName - The field's base name as specified in the entity xml file, without language part.
      Returns:
      true If there is such a field and it is a localized one, false if there is no such field at all, or if it is not localized.
      See Also:
    • getLocalizedFields

      Map<Locale,FieldModel> getLocalizedFields(String baseName) throws IllegalArgumentException
      Returns all field models (one per system language) for the field that is of type 'localized'.
      Parameters:
      baseName - The field's base name as specified in the entity xml file, without language part.
      Returns:
      key = 2 letter iso language code in lower case. Not empty, no null values within.
      Throws:
      IllegalArgumentException - If the field is not localized, check first.
      See Also:
    • getLocalizedField

      @Nullable @Nullable FieldModel getLocalizedField(String baseName, Locale locale)
      Returns one field model for the field that is of type 'localized'.
      Parameters:
      baseName - The field's base name as specified in the entity xml file, without language part.
      locale - The desired language, must be one of the configured system languages (2 letter lower case iso code).
      Returns:
      null if there is no such field, or if it is not localized, or if there is no such language.
      See Also:
    • addAvailableLocale

      void addAvailableLocale(Locale locale)
    • getAvailableLocales

      Set<Locale> getAvailableLocales()
    • getLocalizedFieldMapper

      LocalizedFieldMapper getLocalizedFieldMapper()
    • hasRemovedField

      boolean hasRemovedField(String name)
      Does this Entity-Model contain a removed field?
      A possibility to ask the configuration if something got removed. This is imported to remove dependent stuff.



      For example the field 'username' is removed on an entity. The form-system needs to know that this field is removed that the field is also removed in the form.

      Parameters:
      name - the name
      Returns:
      true if this field got removed during the configuration-reading-process
    • getRemovedFields

      Collection<FieldModel> getRemovedFields()
      Returns all removed field models. Returns an empty collection if none exist.
    • hasRemovedRelation

      boolean hasRemovedRelation(String name)
      Does this Entity-Model contain a removed relation?
      A possibility to ask the configuration if something got removed. This is importet to remove dependend stuff.



      For example we remove the Field 'username' on an entity. Then the form-system need to know that this it's removed explictly and no spelling-error in the form-configuration. Then the form-system can remove the field aswell which would normally show this entity-field.

      Parameters:
      name - the name
      Returns:
      true if this field got removed during the configuration-reading-process
    • getRemovedRelations

      Collection<RelationModel> getRemovedRelations()
      Returns all removed field models. Returns an empty collection if none exist.
    • replaceRelation

      void replaceRelation(RelationModel relation)
      Throws:
      IllegalStateException - When trying to change the model after finished model-reading. Or when there is no such a relation yet.
      See Also:
    • getVisualisation

      EntityVisualisationModel getVisualisation()
      Get an object which describes the visualisation of this entity.
      Returns:
      The visualisation.
    • setVisualisation

      void setVisualisation(EntityVisualisationModel visualisation)
      Throws:
      IllegalStateException - When trying to change the model after finished model-reading.
    • getSearch

      EntitySearchModel getSearch()
      Get a description for how to search in this entity.
      Returns:
      The search behavior.
    • addSearch

      void addSearch(EntitySearchModel search)
      Adds another EntitySearchModel to this EntityModel.
      Parameters:
      search - The search model.
      Throws:
      IllegalStateException - when try to change the model after finished model-reading
    • removeField

      void removeField(FieldModel toRemove) throws IllegalStateException, IllegalArgumentException
      Parameters:
      toRemove - the field to remove
      Throws:
      IllegalStateException - when try to change the model after finished model-reading
      IllegalArgumentException - when the field is not removable (not there)
    • removeRelation

      void removeRelation(RelationModel toRemove)
      Parameters:
      toRemove - the field to remove
      Throws:
      IllegalStateException - When trying to change the model after finished model-reading.
    • setUseMassMutationActions

      void setUseMassMutationActions(Boolean useMassMutationActions)
    • getUseMassMutationActions

      @Nullable @Nullable Boolean getUseMassMutationActions()
    • setHasGenericActions

      void setHasGenericActions(Boolean hasGenericActions)
    • hasGenericActions

      @Nullable @Nullable Boolean hasGenericActions()
    • setUseHistoryAction

      void setUseHistoryAction(Boolean useMassMutationAction)
    • getUseHistoryAction

      @Nullable @Nullable Boolean getUseHistoryAction()
    • setUseEntityMergeAction

      void setUseEntityMergeAction(Boolean useEntityMergeAction)
    • getUseEntityMergeAction

      @Nullable @Nullable Boolean getUseEntityMergeAction()
    • setHasImportAction

      void setHasImportAction(Boolean hasImportAction)
    • hasImportAction

      @Nullable @Nullable Boolean hasImportAction()
    • setHasExportAction

      void setHasExportAction(Boolean hasExportAction)
    • hasExportAction

      @Nullable @Nullable Boolean hasExportAction()
    • setUseAdminCreate

      void setUseAdminCreate(Boolean useAdminCreate)
    • getUseAdminCreate

      Boolean getUseAdminCreate()
    • setUseAdminDelete

      void setUseAdminDelete(Boolean useAdminDelete)
    • getUseAdminDelete

      Boolean getUseAdminDelete()
    • setUseRemoteFieldNewButton

      void setUseRemoteFieldNewButton(Boolean useRemoteFieldNewButton)
    • getUseRemoteFieldNewButton

      Boolean getUseRemoteFieldNewButton()
    • setRelevantForExport

      void setRelevantForExport(Boolean relevantForExport)
    • getRelevantForExport

      Boolean getRelevantForExport()
    • isMarkable

      Boolean isMarkable()
    • setMarkable

      void setMarkable(Boolean markable)
    • getUseNiceFields

      Boolean getUseNiceFields()
    • setUseNiceFields

      void setUseNiceFields(Boolean useNiceFields)
    • getIndexPriority

      Integer getIndexPriority()
      Will be used as order for indexing entities. Also describes order when displaying results (higher value is higher in list). Possible values: * -1: not indexed * 0: indexed, but not visible in searching in "full-system-search". used for lookup entities for example. * 1..n: indexed
    • setIndexPriority

      void setIndexPriority(Integer indexPriority)
      See Also:
    • setBusinessUnitType

      void setBusinessUnitType(BusinessUnitType type)
    • getBusinessUnitType

      BusinessUnitType getBusinessUnitType()
    • getEntityDocumentsModel

      EntityDocumentsModel getEntityDocumentsModel()
    • setEntityDocumentsModel

      void setEntityDocumentsModel(EntityDocumentsModel entityDocumentsModel)
    • isOutputCenter

      boolean isOutputCenter()
    • setOutputCenter

      void setOutputCenter(boolean outputCenter)
    • getWidgetEntityType

      WidgetEntityType getWidgetEntityType()
      Get the entity widget entity type (CMS).
      Returns:
      the widget entity type.
    • setWidgetEntityType

      void setWidgetEntityType(WidgetEntityType widgetEntityType)
      Set widget entity type (CMS).
      Parameters:
      widgetEntityType - The widget entity type.
    • hasContentReference

      Boolean hasContentReference()
      Determine whether this entity can be a content reference source.
      Returns:
      true, if the entity can be a content reference source, else false.
    • setContentReference

      void setContentReference(Boolean contentReference)
      Specify whether this entity can be a content reference source.