Module is.codion.framework.model
Package is.codion.framework.model
Interface EntityTableModel<E extends EntityEditModel>
- Type Parameters:
E- the type ofEntityEditModelused by thisEntityTableModel
- All Superinterfaces:
is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity>
- All Known Implementing Classes:
AbstractEntityTableModel
public interface EntityTableModel<E extends EntityEditModel>
extends is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity>
Specifies a table model containing
Entity instances.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumDefines the actions a table model can perform when entities are inserted via the associated edit modelNested 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
FieldsModifier and TypeFieldDescriptionstatic final is.codion.common.property.PropertyValue<Boolean>Specifies whether table models handle entity edit events, by replacing updated entities Value type: Boolean Default value: truestatic final is.codion.common.property.PropertyValue<EntityTableModel.OnInsert>Specifies the default action a table model takes when entities are inserted via its edit model.Fields inherited from interface is.codion.common.model.FilterModel
ASYNC_REFRESH -
Method Summary
Modifier and TypeMethodDescriptionis.codion.framework.db.EntityConnectionDo not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.is.codion.framework.db.EntityConnectionProviderCollection<is.codion.framework.domain.entity.Entity>Deletes the selected entitiesis.codion.common.state.Stateeditable()<C extends E>
Cis.codion.framework.domain.entity.Entitiesentities()is.codion.framework.domain.entity.EntityDefinitionis.codion.framework.domain.entity.EntityTypeis.codion.common.state.Stateis.codion.common.value.Value<EntityTableModel.OnInsert>onInsert()voidrefresh(Collection<is.codion.framework.domain.entity.Entity.Key> keys) Refreshes the entities with the given keys by re-selecting them from the underlying database.is.codion.common.state.Statevoidreplace(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 fromforeignKeyValues, useful when attribute values have been changed in the referenced entity that must be reflected in the table model.voidreplace(Collection<is.codion.framework.domain.entity.Entity> entities) Replaces the given entities in this table modelvoidselect(Collection<is.codion.framework.domain.entity.Entity.Key> keys) Selects entities according to the primary keys inprimaryKeysis.codion.common.model.selection.MultiItemSelection<is.codion.framework.domain.entity.Entity>Methods inherited from interface is.codion.common.model.FilterModel
items, refresh, refresh, refresher
-
Field Details
-
ON_INSERT
Specifies the default action a table model takes when entities are inserted via its edit model.- Value type:
EntityTableModel.OnInsert - Default value:
EntityTableModel.OnInsert.ADD_TOP
- Value type:
-
HANDLE_EDIT_EVENTS
Specifies whether table models handle entity edit events, by replacing updated entities- Value type: Boolean
- Default value: true
-
-
Method Details
-
entityType
is.codion.framework.domain.entity.EntityType entityType()- Returns:
- the type of the entity this table model is based on
-
connectionProvider
is.codion.framework.db.EntityConnectionProvider connectionProvider()- Returns:
- the connection provider used by this table model
-
connection
is.codion.framework.db.EntityConnection connection()Do not cache or keep the connection returned by this method in a long living field, since it may become invalid and thereby unusable.- Returns:
- the connection used by this table model
-
entities
is.codion.framework.domain.entity.Entities entities()- Returns:
- the underlying domain entities
-
entityDefinition
is.codion.framework.domain.entity.EntityDefinition entityDefinition()- Returns:
- the definition of the underlying entity
-
editModel
- Type Parameters:
C- the edit model type Returns theEntityEditModelassociated with this table model- Returns:
- the edit model associated with this table model
-
replace
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 fromforeignKeyValues, useful when attribute values have been changed in the referenced entity that must be reflected in the table model.- Parameters:
foreignKey- the foreign keyforeignKeyValues- the foreign key entities
-
replace
Replaces the given entities in this table model- Parameters:
entities- the entities to replace
-
refresh
Refreshes the entities with the given keys by re-selecting them from the underlying database.- Parameters:
keys- the keys of the entities to refresh
-
editable
is.codion.common.state.State editable()- Returns:
- the
Statecontrolling whether this table model is editable
-
deleteSelected
Collection<is.codion.framework.domain.entity.Entity> deleteSelected()Deletes the selected entities- Returns:
- the deleted entities
- Throws:
is.codion.common.db.exception.DatabaseException- in case of a database exceptionis.codion.common.model.CancelException- in case the user cancels the operationIllegalStateException- in case this table model has no edit model or if the edit model does not allow deleting
-
handleEditEvents
is.codion.common.state.State handleEditEvents()- Returns:
- the
Statecontrolling whether this table model handles entity edit events, by replacing updated entities - See Also:
-
onInsert
is.codion.common.value.Value<EntityTableModel.OnInsert> onInsert()- Returns:
- the
Valuecontrolling the action to perform when entities are inserted via the associated edit model - See Also:
-
removeDeleted
is.codion.common.state.State removeDeleted()- Returns:
- the
Statecontrolling whether entities that are deleted via the associated edit model should be automatically removed from this table model
-
select
Selects entities according to the primary keys inprimaryKeys- Parameters:
keys- the primary keys of the entities to select
-
selection
is.codion.common.model.selection.MultiItemSelection<is.codion.framework.domain.entity.Entity> selection()- Specified by:
selectionin interfaceis.codion.common.model.FilterModel<E extends EntityEditModel>- Returns:
- the
MultiItemSelectioninstance
-
queryModel
EntityQueryModel queryModel()- Returns:
- the underlying query model
-