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- theEntityEditModeltype
- 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.OnInsertNested 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_INSERTFields inherited from interface is.codion.common.model.FilterModel
ASYNC_REFRESH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractEntityTableModel(E editModel, is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity> filterModel) protectedAbstractEntityTableModel(E editModel, is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity> filterModel, EntityQueryModel queryModel) -
Method Summary
Modifier and TypeMethodDescriptionfinal is.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.final is.codion.framework.db.EntityConnectionProviderfinal Collection<is.codion.framework.domain.entity.Entity>Deletes the selected entitiesfinal is.codion.common.state.Stateeditable()final <C extends E>
Cfinal is.codion.framework.domain.entity.Entitiesentities()final is.codion.framework.domain.entity.EntityDefinitionfinal is.codion.framework.domain.entity.EntityTypeprotected is.codion.common.model.FilterModel<is.codion.framework.domain.entity.Entity>final is.codion.common.state.Statefinal is.codion.common.model.FilterModel.Items<is.codion.framework.domain.entity.Entity>items()final is.codion.common.value.Value<EntityTableModel.OnInsert>onInsert()protected abstract voidonRowsUpdated(int fromIndex, int toIndex) Notifies all listeners that the given rows have changedfinal EntityQueryModelfinal voidrefresh()final 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.final voidrefresh(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.Statefinal voidreplace(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.final voidreplace(Collection<is.codion.framework.domain.entity.Entity> entities) Replaces the given entities in this table modelfinal voidselect(Collection<is.codion.framework.domain.entity.Entity.Key> keys) Selects entities according to the primary keys inprimaryKeysfinal StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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 modelfilterModel- 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 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
public final is.codion.framework.domain.entity.Entities entities()- Specified by:
entitiesin interfaceEntityTableModel<E extends EntityEditModel>- Returns:
- the underlying domain entities
-
entityDefinition
public final is.codion.framework.domain.entity.EntityDefinition entityDefinition()- Specified by:
entityDefinitionin interfaceEntityTableModel<E extends EntityEditModel>- Returns:
- the definition of the underlying entity
-
toString
-
onInsert
- Specified by:
onInsertin interfaceEntityTableModel<E extends EntityEditModel>- Returns:
- the
Valuecontrolling 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:
removeDeletedin interfaceEntityTableModel<E extends EntityEditModel>- Returns:
- the
Statecontrolling 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:
handleEditEventsin interfaceEntityTableModel<E extends EntityEditModel>- Returns:
- the
Statecontrolling 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:
entityTypein interfaceEntityTableModel<E extends EntityEditModel>- Returns:
- the type of the entity this table model is based on
-
editModel
- Specified by:
editModelin interfaceEntityTableModel<E extends EntityEditModel>- Type Parameters:
C- the edit model type Returns theEntityEditModelassociated with this table model- Returns:
- the edit model associated with this table model
-
connectionProvider
public final is.codion.framework.db.EntityConnectionProvider connectionProvider()- Specified by:
connectionProviderin interfaceEntityTableModel<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:EntityTableModelDo 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:
connectionin interfaceEntityTableModel<E extends EntityEditModel>- Returns:
- the connection used by this table model
-
queryModel
- Specified by:
queryModelin interfaceEntityTableModel<E extends EntityEditModel>- Returns:
- the underlying query model
-
editable
public final is.codion.common.state.State editable()- Specified by:
editablein interfaceEntityTableModel<E extends EntityEditModel>- Returns:
- the
Statecontrolling whether this table model is editable
-
replace
Description copied from interface:EntityTableModelReplaces the given entities in this table model- Specified by:
replacein interfaceEntityTableModel<E extends EntityEditModel>- Parameters:
entities- the entities to replace
-
refresh
Description copied from interface:EntityTableModelRefreshes the entities with the given keys by re-selecting them from the underlying database.- Specified by:
refreshin interfaceEntityTableModel<E extends EntityEditModel>- Parameters:
keys- the keys of the entities to refresh
-
select
Description copied from interface:EntityTableModelSelects entities according to the primary keys inprimaryKeys- Specified by:
selectin interfaceEntityTableModel<E extends EntityEditModel>- Parameters:
keys- the primary keys of the entities to select
-
deleteSelected
Description copied from interface:EntityTableModelDeletes the selected entities- Specified by:
deleteSelectedin interfaceEntityTableModel<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:
itemsin interfaceis.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:
refresherin interfaceis.codion.common.model.FilterModel<E extends EntityEditModel>
-
refresh
public final void refresh()- Specified by:
refreshin interfaceis.codion.common.model.FilterModel<E extends EntityEditModel>
-
refresh
- Specified by:
refreshin interfaceis.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:EntityTableModelFor 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.- Specified by:
replacein interfaceEntityTableModel<E extends EntityEditModel>- Parameters:
foreignKey- the foreign keyforeignKeyValues- 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 indextoIndex- the to index
-