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 or not the client should save and apply user preferences
        Value type: Boolean
        Default value: true if required JSON library is found on classpath, false otherwise
    • Method Detail

      • getEntityId

        String getEntityId()
        Returns:
        the ID of the entity this entity model is based on
      • getConnectionProvider

        EntityConnectionProvider getConnectionProvider()
        Returns:
        the connection provider used by this entity model
      • getTableModel

        T getTableModel()
        Returns:
        the EntityTableModel, null if none is specified
      • getLinkedDetailModels

        Collection<M> getLinkedDetailModels()
        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​(String foreignKeyEntityId,
                        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 entityId in the EntityEditModel and sets the search values in the EntityTableModel.
        Parameters:
        foreignKeyEntityId - the ID of the master entity
        foreignKeyValues - the master entities
      • initialize

        void initialize​(ForeignKeyProperty foreignKeyProperty,
                        List<Entity> foreignKeyValues)
        Initializes this EntityModel according to the given foreign key entities, sets the appropriate property value in the EntityEditModel and filters the EntityTableModel
        Parameters:
        foreignKeyProperty - the ID of the foreign key
        foreignKeyValues - the foreign key values
      • 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.getQueryConditionRequiredState()
        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.getQueryConditionRequiredState()
        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​(String entityId)
        Parameters:
        entityId - the entity ID
        Returns:
        true if this model contains a detail model for the given entity ID
      • containsDetailModel

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

        M getDetailModel​(Class<? extends M> modelClass)
        Returns the first detail model of the given 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
      • getDetailModel

        M getDetailModel​(String entityId)
        Returns a detail model of the given type
        Parameters:
        entityId - the entity ID of the required EntityModel
        Returns:
        the detail model of type entityModelClass
        Throws:
        IllegalArgumentException - in case no detail model for the given entityId is found
      • getDetailModels

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

        void setDetailModelForeignKey​(M detailModel,
                                      String foreignKeyPropertyId)
        Indicates that the given detail model is based on the foreign key with the given ID, 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 foreignKeyProperty is set. If foreignKeyPropertyId is null the association is removed.
        Parameters:
        detailModel - the detail model
        foreignKeyPropertyId - the foreign key property ID
        Throws:
        IllegalArgumentException - in case this EntityModel does not contain the given detail model
        See Also:
        initialize(ForeignKeyProperty, java.util.List)
      • getDetailModelForeignKey

        ForeignKeyProperty getDetailModelForeignKey​(M detailModel)
        Parameters:
        detailModel - the detail model
        Returns:
        the ForeignKeyProperty the given detail model is based on, null if none has been defined
      • refreshDetailModels

        void refreshDetailModels()
        Refreshes the detail models.
      • 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
      • addBeforeRefreshListener

        void addBeforeRefreshListener​(EventListener listener)
        Parameters:
        listener - a listener to be notified before a refresh is performed
      • removeBeforeRefreshListener

        void removeBeforeRefreshListener​(EventListener listener)
        Parameters:
        listener - the listener to remove
      • addAfterRefreshListener

        void addAfterRefreshListener​(EventListener listener)
        Parameters:
        listener - a listener to be notified each time a refresh has been performed
      • removeAfterRefreshListener

        void removeAfterRefreshListener​(EventListener listener)
        Parameters:
        listener - the listener to remove
      • 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