Module is.codion.framework.model
Package is.codion.framework.model
Class AbstractEntityTableModel<E extends EntityEditModel>
java.lang.Object
is.codion.framework.model.AbstractEntityTableModel<E>
- Type Parameters:
E
- theEntityEditModel
type
- All Implemented Interfaces:
FilterModel<Entity>
,EntityTableModel<E>
- Direct Known Subclasses:
SwingEntityTableModel
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
FilterModel.AbstractRefresher<T>, FilterModel.FilteredItems<T>, FilterModel.Items<T>, FilterModel.Refresher<T>, FilterModel.Sorter<T>, FilterModel.VisibleItems<T>
-
Field Summary
Fields inherited from interface is.codion.framework.model.EntityTableModel
HANDLE_EDIT_EVENTS, ON_INSERT, ORDER_QUERY_BY_SORT_ORDER
Fields inherited from interface is.codion.common.model.FilterModel
ASYNC_REFRESH
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractEntityTableModel
(E editModel, FilterModel<Entity> filterModel) protected
AbstractEntityTableModel
(E editModel, FilterModel<Entity> filterModel, EntityQueryModel queryModel) -
Method Summary
Modifier and TypeMethodDescriptionfinal 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 EntityConnectionProvider
final Collection
<Entity> Deletes the selected entitiesfinal State
editable()
final E
Returns theEntityEditModel
associated with this table modelfinal Entities
entities()
final EntityDefinition
final EntityType
protected FilterModel
<Entity> final Value
<EntityTableModel.OnInsert> onInsert()
protected abstract void
onRowsUpdated
(int fromIndex, int toIndex) Notifies all listeners that the given rows have changedfinal State
Specifies whether the currentFilterModel.sorter()
order is used as a basis for theEntityQueryModel
order by clause.final EntityQueryModel
final void
refresh
(Collection<Entity.Key> keys) Refreshes the entities with the given keys by re-selecting them from the underlying database.final State
final void
replace
(Collection<Entity> entities) Replaces the given entities in this table modelfinal void
select
(Collection<Entity.Key> keys) Selects entities according to the primary keys inprimaryKeys
final String
toString()
protected void
updated
(ForeignKey foreignKey, Map<Entity.Key, Entity> entities) Called when entities of the type referenced by the given foreign key are updatedMethods 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
Methods inherited from interface is.codion.common.model.FilterModel
items, sorter
-
Constructor Details
-
AbstractEntityTableModel
- Parameters:
editModel
- the edit modelfilterModel
- the filter model
-
AbstractEntityTableModel
protected AbstractEntityTableModel(E editModel, FilterModel<Entity> filterModel, EntityQueryModel queryModel) - Parameters:
editModel
- the edit modelfilterModel
- the filter modelqueryModel
- the table query model- Throws:
IllegalArgumentException
- in case the edit and query model entity types do not match
-
-
Method Details
-
entities
- Specified by:
entities
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the underlying domain entities
-
entityDefinition
- Specified by:
entityDefinition
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the definition of the underlying entity
-
toString
-
onInsert
- Specified by:
onInsert
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the
Value
controlling the action to perform when entities are inserted via the associated edit model - See Also:
-
removeDeleted
- Specified by:
removeDeleted
in interfaceEntityTableModel<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
-
entityType
- Specified by:
entityType
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the type of the entity this table model is based on
-
editModel
Description copied from interface:EntityTableModel
Returns theEntityEditModel
associated with this table model- Specified by:
editModel
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the edit model associated with this table model
-
connectionProvider
- Specified by:
connectionProvider
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the connection provider used by this table model
-
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 interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the connection used by this table model
-
orderQueryBySortOrder
Description copied from interface:EntityTableModel
Specifies whether the currentFilterModel.sorter()
order is used as a basis for theEntityQueryModel
order by clause. Note that this only applies to column attributes.- Specified by:
orderQueryBySortOrder
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the
State
controlling whether the current sort order should be used as a basis for the query order by clause
-
queryModel
- Specified by:
queryModel
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the underlying query model
-
editable
- Specified by:
editable
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the
State
controlling whether this table model is editable
-
replace
Description copied from interface:EntityTableModel
Replaces the given entities in this table model- Specified by:
replace
in interfaceEntityTableModel<E extends EntityEditModel>
- Parameters:
entities
- the entities to replace
-
refresh
Description copied from interface:EntityTableModel
Refreshes the entities with the given keys by re-selecting them from the underlying database.- Specified by:
refresh
in interfaceEntityTableModel<E extends EntityEditModel>
- Parameters:
keys
- the keys of the entities to refresh
-
select
Description copied from interface:EntityTableModel
Selects entities according to the primary keys inprimaryKeys
- Specified by:
select
in interfaceEntityTableModel<E extends EntityEditModel>
- Parameters:
keys
- the primary keys of the entities to select
-
deleteSelected
Description copied from interface:EntityTableModel
Deletes the selected entities- Specified by:
deleteSelected
in interfaceEntityTableModel<E extends EntityEditModel>
- Returns:
- the deleted entities
-
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 indextoIndex
- the to index
-
orderByFromSortModel
- Returns:
- a
OrderBy
instance based on the sort order according to theFilterModel.sorter()
model, an emptyOptional
if unsorted
-
updated
Called when entities of the type referenced by the given foreign key are updated- Parameters:
foreignKey
- the foreign keyentities
- the updated entities, mapped to their original primary key
-