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

    • Field Detail

      • 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
      • activeDetailModels

        Collection<M> activeDetailModels()
        Returns:
        an unmodifiable collection containing the active detail models, that is, those that should respond to master model events
      • addDetailModels

        void addDetailModels​(M... detailModels)
        Adds the given detail model to this model, 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(). Note that each detail model is associated with the first foreign key found referencing this models entity.
        Parameters:
        detailModels - the detail models to add
        Throws:
        IllegalArgumentException - in case no foreign key exists between the entities involved
      • addDetailModel

        ForeignKeyDetailModelLink<M,​E,​T> addDetailModel​(M detailModel)
        Adds the given detail model to this model, 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(). Note that the detail model is associated with the first foreign key found referencing this models entity.
        Parameters:
        detailModel - the detail model
        Returns:
        the resulting ForeignKeyDetailModelLink
        Throws:
        IllegalArgumentException - in case no foreign key exists between the entities involved
      • addDetailModel

        ForeignKeyDetailModelLink<M,​E,​T> addDetailModel​(M detailModel,
                                                                    ForeignKey foreignKey)
        Adds the given detail model to this model, 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() Specify the foreign key in case the detail model is based on an entity which contains multiple foreign keys to the same master entity.
        Parameters:
        detailModel - the detail model
        foreignKey - the foreign key to base the detail model on
        Returns:
        the resulting ForeignKeyDetailModelLink
      • 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 this model does not contain a detail model of the given type
      • 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 this model does not contain a detail model for the entityType
      • detailModels

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

        <L extends DetailModelLink<M,​E,​T>> L detailModelLink​(M detailModel)
        Type Parameters:
        L - the DetailModelLink type
        Parameters:
        detailModel - the detail model
        Returns:
        the link for the given detail model
        Throws:
        IllegalArgumentException - in case this model does not contain the given detail model
      • savePreferences

        void savePreferences()
        Saves any user preferences for this model, its table model and each detail model. Note that if USE_CLIENT_PREFERENCES is set to 'false', calling this method has no effect. Remember to call super.savePreferences() when overriding.
      • addActiveDetailModelsListener

        void addActiveDetailModelsListener​(EventDataListener<Collection<M>> listener)
        Parameters:
        listener - notified each time the active detail models change
      • removeActiveDetailModelsListener

        void removeActiveDetailModelsListener​(EventDataListener<Collection<M>> listener)
        Parameters:
        listener - the listener to remove