Interface EntityModel<M extends EntityModel<M,​E,​T>,​E extends EntityEditModel,​T extends EntityTableModel<E>>

    • Field Detail

      • SEARCH_ON_MASTER_INSERT

        static final PropertyValue<Boolean> SEARCH_ON_MASTER_INSERT
        Specifies whether a table model should automatically search by the inserted entity when an insert is performed in a master model. Value type: Boolean
        Default value: false
      • USE_CLIENT_PREFERENCES

        static final PropertyValue<Boolean> USE_CLIENT_PREFERENCES
        Specifies whether the client should save and apply user preferences
        Value type: Boolean
        Default value: true
    • Method Detail

      • entityType

        EntityType entityType()
        Returns:
        the type of the entity this entity model is based on
      • connectionProvider

        EntityConnectionProvider connectionProvider()
        Returns:
        the connection provider used by this entity model
      • entities

        Entities entities()
        Returns:
        the underlying domain entities
      • tableModel

        T tableModel()
        Returns:
        the EntityTableModel, null if none is specified
      • linkedDetailModels

        Collection<M> linkedDetailModels()
        Returns:
        an unmodifiable collection containing the detail models that are currently linked to this model
      • addLinkedDetailModel

        void addLinkedDetailModel​(M detailModel)
        Adds the given model to the currently linked detail models. Linked models are updated and filtered according to the entity/entities selected in this (the master) model. Calling this method with a null argument or a model which is already linked is safe.
        Parameters:
        detailModel - links the given detail model to this model
      • removeLinkedDetailModel

        void removeLinkedDetailModel​(M detailModel)
        Removes the given model from the currently linked detail models. Linked models are updated and filtered according to the entity/entities selected in this (the master) model. Calling this method with a null argument or a model which is not linked is safe.
        Parameters:
        detailModel - unlinks the given detail model from this model
      • initialize

        void initialize​(EntityType foreignKeyEntityType,
                        List<Entity> foreignKeyValues)
        Initializes this EntityModel according to the given foreign key entities. It sets the value for the first available foreign key property representing the given entityType in the EntityEditModel and sets the search values in the EntityTableModel.
        Parameters:
        foreignKeyEntityType - the id of the master entity
        foreignKeyValues - the master entities, empty list for none
      • initialize

        void initialize​(ForeignKey foreignKey,
                        List<Entity> foreignKeyValues)
        Initializes this EntityModel according to the given foreign key entities, sets the appropriate attribute value in the EntityEditModel and filters the EntityTableModel
        Parameters:
        foreignKey - the foreign key
        foreignKeyValues - the foreign key values, empty list for none
      • setMasterModel

        void setMasterModel​(M entityModel)
        Sets the model serving as master model
        Parameters:
        entityModel - the master entity model
        Throws:
        IllegalStateException - if the master model has already been set
      • getMasterModel

        M getMasterModel()
        Returns:
        the master model, if any
      • addDetailModels

        void addDetailModels​(M... detailModels)
        Adds the given detail model to this model, sets this model as the master model of the given detail models via setMasterModel(EntityModel), a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, via EntityTableModel.queryConditionRequiredState()
        Parameters:
        detailModels - the detail models to add
      • addDetailModel

        M addDetailModel​(M detailModel)
        Adds the given detail model to this model, sets this model as the master model of the given detail model via setMasterModel(EntityModel), a side effect if the detail model contains a table model is that it is configured so that a query condition is required for it to show any data, via EntityTableModel.queryConditionRequiredState()
        Parameters:
        detailModel - the detail model
        Returns:
        the detail model just added
      • containsDetailModel

        boolean containsDetailModel​(Class<? extends M> modelClass)
        Parameters:
        modelClass - the detail model class
        Returns:
        true if this model contains a detail model of the given class
      • containsDetailModel

        boolean containsDetailModel​(EntityType entityType)
        Parameters:
        entityType - the entityType
        Returns:
        true if this model contains a detail model for the given entityType
      • containsDetailModel

        boolean containsDetailModel​(M detailModel)
        Parameters:
        detailModel - the detail model
        Returns:
        true if this model contains the given detail model
      • detailModel

        <T extends M> T detailModel​(Class<? extends M> modelClass)
        Returns the first detail model of the given type
        Type Parameters:
        T - the model type
        Parameters:
        modelClass - the type of the required EntityModel
        Returns:
        the detail model of type entityModelClass
        Throws:
        IllegalArgumentException - in case a model is not found
      • detailModel

        M detailModel​(EntityType entityType)
        Returns a detail model of the given type
        Parameters:
        entityType - the entityType of the required EntityModel
        Returns:
        the detail model of type entityModelClass
        Throws:
        IllegalArgumentException - in case no detail model for the given entityType is found
      • detailModels

        Collection<M> detailModels()
        Returns:
        an unmodifiable collection containing the detail models this model contains
      • setDetailModelForeignKey

        void setDetailModelForeignKey​(M detailModel,
                                      ForeignKey foreignKey)
        Indicates that the given detail model is based on the foreign key attribute, this becomes practical when a detail model is based on an entity which contains multiple foreign keys to the same master entity. When initializing this detail model only the value for that foreignKey is set. If foreignKey is null the association is removed.
        Parameters:
        detailModel - the detail model
        foreignKey - the foreign key
        Throws:
        IllegalArgumentException - in case this EntityModel does not contain the given detail model
        See Also:
        initialize(ForeignKey, List)
      • detailModelForeignKey

        ForeignKey detailModelForeignKey​(M detailModel)
        Parameters:
        detailModel - the detail model
        Returns:
        the foreign key the given detail model is based on, null if none has been defined
      • clear

        void clear()
        Clears all data models used by this model.
      • clearDetailModels

        void clearDetailModels()
        Clears the detail models.
      • isSearchOnMasterInsert

        boolean isSearchOnMasterInsert()
        Returns:
        true if this models table model should automatically search by the inserted entity when an insert is performed in a master model
        See Also:
        SEARCH_ON_MASTER_INSERT
      • setSearchOnMasterInsert

        void setSearchOnMasterInsert​(boolean searchOnMasterInsert)
        Parameters:
        searchOnMasterInsert - if true then this models table model will automatically search by the inserted entity when an insert is performed in a master model
        See Also:
        SEARCH_ON_MASTER_INSERT
      • addLinkedDetailModelAddedListener

        void addLinkedDetailModelAddedListener​(EventDataListener<M> listener)
        Parameters:
        listener - a listener to be notified each time a linked detail model is added
      • removeLinkedDetailModelAddedListener

        void removeLinkedDetailModelAddedListener​(EventDataListener<M> listener)
        Parameters:
        listener - a listener to be removed
      • addLinkedDetailModelRemovedListener

        void addLinkedDetailModelRemovedListener​(EventDataListener<M> listener)
        Parameters:
        listener - a listener to be notified each time a linked detail model is removed
      • removeLinkedDetailModelRemovedListener

        void removeLinkedDetailModelRemovedListener​(EventDataListener<M> listener)
        Parameters:
        listener - a listener to be removed
      • savePreferences

        void savePreferences()
        Saves any user preferences