Module is.codion.framework.model
Package is.codion.framework.model
Interface EntityApplicationModel<M extends EntityModel<M,E,T,R>,E extends EntityEditModel<R>,T extends EntityTableModel<E,R>,R extends EntityEditor<R>>
- Type Parameters:
M- theEntityModeltypeE- theEntityEditModeltypeT- theEntityTableModeltypeR- theEntityEditortype
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractEntityApplicationModel,SwingEntityApplicationModel
public interface EntityApplicationModel<M extends EntityModel<M,E,T,R>,E extends EntityEditModel<R>,T extends EntityTableModel<E,R>,R extends EntityEditor<R>>
extends AutoCloseable
A central application model, coordinating the
EntityModel instances of an application.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceEntityApplicationModel.EntityModels<M extends EntityModel<M,E, T, R>, E extends EntityEditModel<R>, T extends EntityTableModel<E, R>, R extends EntityEditor<R>> Manages theEntityModels for aEntityApplicationModel -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyValue<String> Specifies the key to use when creating file based application preferences.static final PropertyValue<Boolean> Specifies whether the client should apply and save user preferences Value type: Boolean Default value: true -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this model along with itsconnection(), after which neither can be used.Returns theEntityConnectionused by this application model, a single self-managing instance shared by all its entity models: it validates the underlying connection before each operation and re-establishes it when it has gone bad, so it is safe to hold on to and use for the lifetime of the application, seeEntityConnection.builder().entities()models()voidrestore(Preferences preferences) Restores the model-owned persistent state of this application's model tree from the given preferences node.voidstore(Preferences preferences) Stores the model-owned persistent state of this application's model tree to the given preferences node.user()Note that this user may differ from the connection user, which is reachable viaconnection().user()
-
Field Details
-
USER_PREFERENCES
Specifies whether the client should apply and save user preferences- Value type: Boolean
- Default value: true
-
PREFERENCES_KEY
Specifies the key to use when creating file based application preferences. Note that this string may only contain valid filename characters and symbols.- Value type: String
- Default value: null
-
-
Method Details
-
user
User user()Note that this user may differ from the connection user, which is reachable viaconnection().user()- Returns:
- the application user
-
connection
EntityConnection connection()Returns the
EntityConnectionused by this application model, a single self-managing instance shared by all its entity models: it validates the underlying connection before each operation and re-establishes it when it has gone bad, so it is safe to hold on to and use for the lifetime of the application, seeEntityConnection.builder().- Returns:
- the connection used by this application model
-
entities
Entities entities()- Returns:
- the underlying domain entities
-
models
EntityApplicationModel.EntityModels<M,E, models()T, R> - Returns:
- the
EntityApplicationModel.EntityModels
-
store
Stores the model-owned persistent state of this application's model tree to the given preferences node. Each root model stores its state under a child node named by itsEntityModel.preferencesKey(). May be overridden to persist custom state, in which casesuper.store(preferences)should be called in order to retain the default state.Custom state belongs in a child node of its own, named so as not to clash with a model's preferences key.
- Parameters:
preferences- the preferences node representing the entity models- See Also:
-
restore
Restores the model-owned persistent state of this application's model tree from the given preferences node. Each root model restores its state from a child node named by itsEntityModel.preferencesKey().- Parameters:
preferences- the preferences node representing the entity models- See Also:
-
close
void close()Closes this model along with itsconnection(), after which neither can be used. Closing it again has no effect.A UI calls this as the application exits, once the exit can no longer be cancelled and the preferences have been stored. It may block, closing a remote connection for example logging out.
Override to release what a model holds, before calling super, as it may depend on the connection.
- Specified by:
closein interfaceAutoCloseable
-