Class AbstractEntityTableModel<E extends EntityEditModel>

java.lang.Object
is.codion.framework.model.AbstractEntityTableModel<E>
Type Parameters:
E - the EntityEditModel type
All Implemented Interfaces:
is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity>, EntityTableModel<E>

public abstract class AbstractEntityTableModel<E extends EntityEditModel> extends Object implements EntityTableModel<E>
An abstract EntityTableModel implementation
  • Nested Class Summary

    Nested classes/interfaces inherited from interface is.codion.framework.model.EntityTableModel

    EntityTableModel.OnInsert

    Nested classes/interfaces inherited from interface is.codion.common.model.FilterModel

    is.codion.common.model.FilterModel.AbstractRefresher<T extends Object>, is.codion.common.model.FilterModel.FilteredItems<T extends Object>, is.codion.common.model.FilterModel.Items<T extends Object>, is.codion.common.model.FilterModel.Refresher<T extends Object>, is.codion.common.model.FilterModel.VisibleItems<T extends Object>
  • Field Summary

    Fields inherited from interface is.codion.framework.model.EntityTableModel

    HANDLE_EDIT_EVENTS, ON_INSERT

    Fields inherited from interface is.codion.common.model.FilterModel

    ASYNC_REFRESH
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractEntityTableModel(E editModel, is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity> filterModel)
     
    protected
    AbstractEntityTableModel(E editModel, is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity> filterModel, EntityQueryModel queryModel)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final is.codion.framework.db.EntityConnection
    Do not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.
    final is.codion.framework.db.EntityConnectionProvider
     
    final Collection<is.codion.framework.domain.entity.Entity>
    Deletes the selected entities
    final is.codion.common.state.State
     
    final <C extends E>
    C
     
    final is.codion.framework.domain.entity.Entities
     
    final is.codion.framework.domain.entity.EntityDefinition
     
    final is.codion.framework.domain.entity.EntityType
     
    protected is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity>
     
    final is.codion.common.state.State
     
    final is.codion.common.model.FilterModel.Items<is.codion.framework.domain.entity.Entity>
     
    final is.codion.common.value.Value<EntityTableModel.OnInsert>
     
    protected abstract void
    onRowsUpdated(int fromIndex, int toIndex)
    Notifies all listeners that the given rows have changed
     
    final void
     
    final void
    refresh(Collection<is.codion.framework.domain.entity.Entity.Key> keys)
    Refreshes the entities with the given keys by re-selecting them from the underlying database.
    final void
    refresh(Consumer<Collection<is.codion.framework.domain.entity.Entity>> onRefresh)
     
    final is.codion.common.model.FilterModel.Refresher<is.codion.framework.domain.entity.Entity>
     
    final is.codion.common.state.State
     
    final void
    replace(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> foreignKeyValues)
    For every entity in this table model, replaces the foreign key instance bearing the primary key with the corresponding entity from foreignKeyValues, useful when attribute values have been changed in the referenced entity that must be reflected in the table model.
    final void
    replace(Collection<is.codion.framework.domain.entity.Entity> entities)
    Replaces the given entities in this table model
    final void
    select(Collection<is.codion.framework.domain.entity.Entity.Key> keys)
    Selects entities according to the primary keys in primaryKeys
    final String
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface is.codion.framework.model.EntityTableModel

    selection
  • Constructor Details

    • AbstractEntityTableModel

      protected AbstractEntityTableModel(E editModel, is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity> filterModel)
      Parameters:
      editModel - the edit model
      filterModel - the filter model
    • AbstractEntityTableModel

      protected AbstractEntityTableModel(E editModel, is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity> filterModel, EntityQueryModel queryModel)
      Parameters:
      editModel - the edit model
      filterModel - the filter model
      queryModel - the table query model
      Throws:
      IllegalArgumentException - in case the edit and query model entity types do not match
  • Method Details

    • entities

      public final is.codion.framework.domain.entity.Entities entities()
      Specified by:
      entities in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the underlying domain entities
    • entityDefinition

      public final is.codion.framework.domain.entity.EntityDefinition entityDefinition()
      Specified by:
      entityDefinition in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the definition of the underlying entity
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • onInsert

      public final is.codion.common.value.Value<EntityTableModel.OnInsert> onInsert()
      Specified by:
      onInsert in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the Value controlling the action to perform when entities are inserted via the associated edit model
      See Also:
    • removeDeleted

      public final is.codion.common.state.State removeDeleted()
      Specified by:
      removeDeleted in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the State controlling whether entities that are deleted via the associated edit model should be automatically removed from this table model
    • handleEditEvents

      public final is.codion.common.state.State handleEditEvents()
      Specified by:
      handleEditEvents in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the State controlling whether this table model handles entity edit events, by replacing updated entities
      See Also:
    • entityType

      public final is.codion.framework.domain.entity.EntityType entityType()
      Specified by:
      entityType in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the type of the entity this table model is based on
    • editModel

      public final <C extends E> C editModel()
      Specified by:
      editModel in interface EntityTableModel<E extends EntityEditModel>
      Type Parameters:
      C - the edit model type Returns the EntityEditModel associated with this table model
      Returns:
      the edit model associated with this table model
    • connectionProvider

      public final is.codion.framework.db.EntityConnectionProvider connectionProvider()
      Specified by:
      connectionProvider in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the connection provider used by this table model
    • connection

      public final is.codion.framework.db.EntityConnection connection()
      Description copied from interface: EntityTableModel
      Do not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.
      Specified by:
      connection in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the connection used by this table model
    • queryModel

      public final EntityQueryModel queryModel()
      Specified by:
      queryModel in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the underlying query model
    • editable

      public final is.codion.common.state.State editable()
      Specified by:
      editable in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the State controlling whether this table model is editable
    • replace

      public final void replace(Collection<is.codion.framework.domain.entity.Entity> entities)
      Description copied from interface: EntityTableModel
      Replaces the given entities in this table model
      Specified by:
      replace in interface EntityTableModel<E extends EntityEditModel>
      Parameters:
      entities - the entities to replace
    • refresh

      public final void refresh(Collection<is.codion.framework.domain.entity.Entity.Key> keys)
      Description copied from interface: EntityTableModel
      Refreshes the entities with the given keys by re-selecting them from the underlying database.
      Specified by:
      refresh in interface EntityTableModel<E extends EntityEditModel>
      Parameters:
      keys - the keys of the entities to refresh
    • select

      public final void select(Collection<is.codion.framework.domain.entity.Entity.Key> keys)
      Description copied from interface: EntityTableModel
      Selects entities according to the primary keys in primaryKeys
      Specified by:
      select in interface EntityTableModel<E extends EntityEditModel>
      Parameters:
      keys - the primary keys of the entities to select
    • deleteSelected

      public final Collection<is.codion.framework.domain.entity.Entity> deleteSelected()
      Description copied from interface: EntityTableModel
      Deletes the selected entities
      Specified by:
      deleteSelected in interface EntityTableModel<E extends EntityEditModel>
      Returns:
      the deleted entities
    • items

      public final is.codion.common.model.FilterModel.Items<is.codion.framework.domain.entity.Entity> items()
      Specified by:
      items in interface is.codion.common.model.FilterModel<E extends EntityEditModel>
    • refresher

      public final is.codion.common.model.FilterModel.Refresher<is.codion.framework.domain.entity.Entity> refresher()
      Specified by:
      refresher in interface is.codion.common.model.FilterModel<E extends EntityEditModel>
    • refresh

      public final void refresh()
      Specified by:
      refresh in interface is.codion.common.model.FilterModel<E extends EntityEditModel>
    • refresh

      public final void refresh(Consumer<Collection<is.codion.framework.domain.entity.Entity>> onRefresh)
      Specified by:
      refresh in interface is.codion.common.model.FilterModel<E extends EntityEditModel>
    • replace

      public final void replace(is.codion.framework.domain.entity.attribute.ForeignKey foreignKey, Collection<is.codion.framework.domain.entity.Entity> foreignKeyValues)
      Description copied from interface: EntityTableModel
      For every entity in this table model, replaces the foreign key instance bearing the primary key with the corresponding entity from foreignKeyValues, useful when attribute values have been changed in the referenced entity that must be reflected in the table model.
      Specified by:
      replace in interface EntityTableModel<E extends EntityEditModel>
      Parameters:
      foreignKey - the foreign key
      foreignKeyValues - the foreign key entities
    • filterModel

      protected is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity> filterModel()
      Returns:
      the underlying filter model
    • onRowsUpdated

      protected abstract void onRowsUpdated(int fromIndex, int toIndex)
      Notifies all listeners that the given rows have changed
      Parameters:
      fromIndex - the from index
      toIndex - the to index