public interface EntityEditModel extends ValueMapEditModel<Property,java.lang.Object>, Refreshable, EntityDataProvider
Entity
instances.Modifier and Type | Interface and Description |
---|---|
static interface |
EntityEditModel.DeleteEvent
An event describing a delete action.
|
static interface |
EntityEditModel.InsertEvent
An event describing a insert action.
|
static interface |
EntityEditModel.UpdateEvent
An event describing a update action.
|
Modifier and Type | Field and Description |
---|---|
static PropertyValue<java.lang.String> |
COMBO_BOX_NULL_VALUE_ITEM
Specifies the value used by default to represent a null value in combo box models.
|
static PropertyValue<java.lang.Boolean> |
PERSIST_FOREIGN_KEY_VALUES
Specifies whether foreign key values should persist when the UI is cleared or be reset to null
Value type: Boolean Default value: true |
static PropertyValue<java.lang.Boolean> |
WARN_ABOUT_UNSAVED_DATA
Indicates whether the application should ask for confirmation when exiting if some data is unsaved
and whether it should warn when unsaved data is about to be lost due to selection changes f.ex. |
Modifier and Type | Method and Description |
---|---|
void |
addAfterDeleteListener(EventDataListener<EntityEditModel.DeleteEvent> listener) |
void |
addAfterInsertListener(EventDataListener<EntityEditModel.InsertEvent> listener) |
void |
addAfterRefreshListener(EventListener listener) |
void |
addAfterUpdateListener(EventDataListener<EntityEditModel.UpdateEvent> listener) |
void |
addBeforeDeleteListener(EventDataListener<EntityEditModel.DeleteEvent> listener) |
void |
addBeforeInsertListener(EventDataListener<EntityEditModel.InsertEvent> listener) |
void |
addBeforeRefreshListener(EventListener listener) |
void |
addBeforeUpdateListener(EventDataListener<EntityEditModel.UpdateEvent> listener) |
void |
addConfirmSetEntityObserver(EventDataListener<State> listener) |
void |
addEntitiesChangedListener(EventListener listener) |
void |
addEntitySetListener(EventDataListener<Entity> listener) |
void |
addForeignKeyValues(java.util.List<Entity> values)
Adds the inserted entities to all foreign key models based on that entity type
|
void |
addValueListener(java.lang.String propertyId,
EventDataListener<ValueChange<Property,java.lang.Object>> listener)
Adds a listener notified each time the value associated with the given key changes
|
void |
addValueSetListener(java.lang.String propertyId,
EventDataListener<ValueChange<Property,java.lang.Object>> listener)
Adds a listener notified each time the value associated with the given property is set via
ValueMapEditModel.put(Object, Object) , note that this event is only fired when the the value changes |
boolean |
containsLookupModel(java.lang.String foreignKeyPropertyId)
Returns true if this edit model contains a
EntityLookupModel for the given foreign key property |
boolean |
containsUnsavedData()
Returns true if an entity is selected and a value has been modified or if the entity is new
and one or more non-default values have been entered
|
EntityLookupModel |
createForeignKeyLookupModel(ForeignKeyProperty foreignKeyProperty)
Creates a
EntityLookupModel for looking up entities referenced by the given foreign key property,
using the search properties defined for that entity type, or if none are defined all string based searchable
properties in that entity. |
java.util.List<Entity> |
delete()
Deletes the active entity
|
java.util.List<Entity> |
delete(java.util.List<Entity> entities)
Deletes the given entities, returns silently on receiving an empty list
|
java.lang.Object |
get(java.lang.String propertyId)
Returns the value associated with the given property
|
StateObserver |
getAllowDeleteObserver() |
StateObserver |
getAllowInsertObserver() |
StateObserver |
getAllowUpdateObserver() |
Entity |
getDefaultEntity() |
java.lang.Object |
getDefaultValue(Property property)
Returns the default value for the given property, used when initializing a new default entity for this edit model.
|
Domain |
getDomain() |
Entity |
getEntityCopy() |
Entity |
getEntityCopy(boolean includePrimaryKeyValues) |
Entity.Definition |
getEntityDefinition() |
StateObserver |
getEntityNewObserver() |
Entity |
getForeignKey(java.lang.String foreignKeyPropertyId)
Returns the value associated with the given propertyId assuming it
is an
Entity instance |
EntityLookupModel |
getForeignKeyLookupModel(ForeignKeyProperty foreignKeyProperty) |
EntityLookupModel |
getForeignKeyLookupModel(java.lang.String foreignKeyPropertyId) |
StateObserver |
getModifiedObserver()
Returns a StateObserver responsible for indicating when and if any values in the underlying Entity are modified.
|
StateObserver |
getPrimaryKeyNullObserver() |
EventObserver<ValueChange<Property,java.lang.Object>> |
getValueObserver(java.lang.String propertyId) |
ValueCollectionProvider |
getValueProvider(Property property)
Initializes a value provider for the given property, useful for adding lookup
functionality to input fields for example.
|
java.util.List<Entity> |
insert()
Performs a insert on the active entity, sets the primary key values of the active entity
according to the primary key of the inserted entity
|
java.util.List<Entity> |
insert(java.util.List<Entity> entities)
Performs an insert on the given entities, returns silently on receiving an empty list
|
boolean |
isDeleteAllowed() |
boolean |
isEntityNew()
Returns true if the active entity is new or false if it represents a row already persisted.
|
boolean |
isInsertAllowed() |
boolean |
isLookupAllowed(Property property)
Returns true if values based on this property should be available for lookup via this EditModel.
|
boolean |
isModified() |
boolean |
isNotNull(java.lang.String propertyId) |
boolean |
isNull(java.lang.String propertyId) |
boolean |
isReadOnly() |
boolean |
isUpdateAllowed() |
boolean |
isValuePersistent(Property property)
Returns true if the last available value for this property should be used when initializing
a default entity.
|
boolean |
isWarnAboutUnsavedData() |
void |
put(java.lang.String propertyId,
java.lang.Object value)
Sets the given value in the underlying value map
|
void |
refreshEntity()
Refreshes the active Entity from the database, discarding all changes.
|
java.lang.Object |
remove(java.lang.String propertyId)
Removes the given value from the underlying value map
|
void |
removeAfterDeleteListener(EventDataListener listener) |
void |
removeAfterInsertListener(EventDataListener listener) |
void |
removeAfterRefreshListener(EventListener listener) |
void |
removeAfterUpdateListener(EventDataListener listener) |
void |
removeBeforeDeleteListener(EventDataListener listener) |
void |
removeBeforeInsertListener(EventDataListener listener) |
void |
removeBeforeRefreshListener(EventListener listener) |
void |
removeBeforeUpdateListener(EventDataListener listener) |
void |
removeConfirmSetEntityObserver(EventDataListener listener) |
void |
removeEntitiesChangedListener(EventListener listener) |
void |
removeEntitySetListener(EventDataListener listener) |
void |
removeForeignKeyValues(java.util.List<Entity> values)
Removes the deleted entities from all foreign key models based on that entity type
todo set foreign key values referencing the deleted entity to null
|
void |
removeValueListener(java.lang.String propertyId,
EventDataListener listener) |
void |
removeValueSetListener(java.lang.String propertyId,
EventDataListener listener) |
void |
replaceForeignKeyValues(java.lang.String foreignKeyEntityId,
java.util.Collection<Entity> foreignKeyValues)
For every field referencing the given foreign key values, replaces that foreign key instance with
the corresponding entity from
foreignKeyValues , useful when property
values have been changed in the referenced entity that must be reflected in the edit model. |
EntityEditModel |
setDeleteAllowed(boolean value) |
void |
setEntity(Entity entity)
|
void |
setForeignKeyValues(java.util.List<Entity> values)
Sets the values in the given list as the values for the respective foreign keys, uses the first
value found for each entity type in case of multiple entities of that type
|
EntityEditModel |
setInsertAllowed(boolean value) |
EntityEditModel |
setReadOnly(boolean readOnly)
Makes this model read-only by disallowing insert, update and delete
|
EntityEditModel |
setUpdateAllowed(boolean value) |
EntityEditModel |
setValuePersistent(java.lang.String propertyId,
boolean persistValueOnClear) |
EntityEditModel |
setWarnAboutUnsavedData(boolean warnAboutUnsavedData) |
java.util.List<Entity> |
update()
Performs a update on the active entity
|
java.util.List<Entity> |
update(java.util.List<Entity> entities)
Updates the given entities.
|
<V> Value<V> |
value(java.lang.String propertyId)
Instantiates a new Value based on the value identified by
propertyId in this edit model |
addValueListener, addValueSetListener, get, getValidator, getValidObserver, getValueObserver, getValueObserver, isNotNull, isNull, isNullable, isValid, isValid, put, remove, removeValueListener, removeValueSetListener, validate, validate, validate, validate
clear, refresh
getConnectionProvider, getEntityId
static final PropertyValue<java.lang.Boolean> PERSIST_FOREIGN_KEY_VALUES
static final PropertyValue<java.lang.Boolean> WARN_ABOUT_UNSAVED_DATA
static final PropertyValue<java.lang.String> COMBO_BOX_NULL_VALUE_ITEM
Entity getDefaultEntity()
getDefaultValue(Property)
void setEntity(Entity entity)
Entity
into the underlying
Entity
being edited by this edit model. If entity
is null then the entity being edited is populated with default valuesentity
- the entityvoid refreshEntity()
Entity getEntityCopy()
ValueMap.getCopy()
Entity getEntityCopy(boolean includePrimaryKeyValues)
includePrimaryKeyValues
- if false then the primary key values are excludedValueMap.getCopy()
boolean isEntityNew()
getPrimaryKeyNullObserver()
,
Entity.isKeyNull()
boolean containsUnsavedData()
WARN_ABOUT_UNSAVED_DATA
boolean isNull(java.lang.String propertyId)
propertyId
- the ID of the propertyboolean isNotNull(java.lang.String propertyId)
propertyId
- the ID of the propertyvoid put(java.lang.String propertyId, java.lang.Object value)
propertyId
- the ID of the property to associate the given value withvalue
- the value to associate with the given propertyjava.lang.Object remove(java.lang.String propertyId)
propertyId
- the ID of the propertyjava.lang.Object get(java.lang.String propertyId)
propertyId
- the ID of the propertyEntity getForeignKey(java.lang.String foreignKeyPropertyId)
Entity
instancevoid replaceForeignKeyValues(java.lang.String foreignKeyEntityId, java.util.Collection<Entity> foreignKeyValues)
foreignKeyValues
, useful when property
values have been changed in the referenced entity that must be reflected in the edit model.foreignKeyEntityId
- the entity ID of the foreign key valuesforeignKeyValues
- the new foreign key entitiesValueCollectionProvider getValueProvider(Property property)
property
- the property<V> Value<V> value(java.lang.String propertyId)
propertyId
in this edit modelV
- the value typepropertyId
- the property idDomain getDomain()
Entity.Definition getEntityDefinition()
boolean isReadOnly()
isInsertAllowed()
,
isUpdateAllowed()
,
isDeleteAllowed()
EntityEditModel setReadOnly(boolean readOnly)
readOnly
- the read only statussetInsertAllowed(boolean)
,
setUpdateAllowed(boolean)
,
setDeleteAllowed(boolean)
boolean isWarnAboutUnsavedData()
WARN_ABOUT_UNSAVED_DATA
EntityEditModel setWarnAboutUnsavedData(boolean warnAboutUnsavedData)
warnAboutUnsavedData
- if true then this model warns about unsaved dataWARN_ABOUT_UNSAVED_DATA
boolean isInsertAllowed()
EntityEditModel setInsertAllowed(boolean value)
value
- true if this model should allow insertsboolean isUpdateAllowed()
EntityEditModel setUpdateAllowed(boolean value)
value
- true if this model should allow records to be updatedboolean isDeleteAllowed()
EntityEditModel setDeleteAllowed(boolean value)
value
- true if this model should allow records to be deletedEntityLookupModel createForeignKeyLookupModel(ForeignKeyProperty foreignKeyProperty)
EntityLookupModel
for looking up entities referenced by the given foreign key property,
using the search properties defined for that entity type, or if none are defined all string based searchable
properties in that entity.foreignKeyProperty
- the foreign key property for which to create a EntityLookupModel
EntityLookupModel
for looking up entities of the type referenced by the given foreign key property,java.lang.IllegalStateException
- in case no searchable properties can be found for the entity type referenced by the
given foreign key propertyboolean containsLookupModel(java.lang.String foreignKeyPropertyId)
EntityLookupModel
for the given foreign key propertyforeignKeyPropertyId
- the ID of the propertyEntityLookupModel
has been initialized for the given foreign key propertyEntityLookupModel getForeignKeyLookupModel(java.lang.String foreignKeyPropertyId)
foreignKeyPropertyId
- the ID of the property for which to retrieve the EntityLookupModel
EntityLookupModel
associated with the property
, if no lookup model
has been initialized for the given property, a new one is created, associated with the property and returned.EntityLookupModel getForeignKeyLookupModel(ForeignKeyProperty foreignKeyProperty)
foreignKeyProperty
- the foreign key property for which to retrieve the EntityLookupModel
EntityLookupModel
associated with the property
, if no lookup model
has been initialized for the given property, a new one is created, associated with the property and returned.java.lang.Object getDefaultValue(Property property)
setValuePersistent(String, boolean)
with true
for the given property or override isValuePersistent(org.jminor.framework.domain.property.Property)
so that it
returns true
for that property in case the value should persist.property
- the propertyProperty.Builder#setDefaultValue(Object)
,
setValuePersistent(String, boolean)
,
isValuePersistent(Property)
boolean isValuePersistent(Property property)
PERSIST_FOREIGN_KEY_VALUES
.property
- the propertyPERSIST_FOREIGN_KEY_VALUES
boolean isLookupAllowed(Property property)
property
- the propertyEntityEditModel setValuePersistent(java.lang.String propertyId, boolean persistValueOnClear)
propertyId
- the property IDpersistValueOnClear
- true if this model should persist the value of the given property on clearPERSIST_FOREIGN_KEY_VALUES
java.util.List<Entity> insert() throws DatabaseException, ValidationException
DatabaseException
- in case of a database exceptionValidationException
- in case validation failsEntity.Validator.validate(java.util.Collection)
java.util.List<Entity> insert(java.util.List<Entity> entities) throws DatabaseException, ValidationException
entities
- the entities to insertDatabaseException
- in case of a database exceptionValidationException
- in case validation failsaddBeforeInsertListener(EventDataListener)
,
addAfterInsertListener(EventDataListener)
,
Entity.Validator.validate(java.util.Collection)
java.util.List<Entity> update() throws DatabaseException, ValidationException
DatabaseException
- in case of a database exceptionRecordModifiedException
- in case an entity was modified by another userValidationException
- in case validation failsEntity.Validator.validate(java.util.Collection)
java.util.List<Entity> update(java.util.List<Entity> entities) throws DatabaseException, ValidationException
entities
- the entities to updateDatabaseException
- in case of a database exceptionRecordModifiedException
- in case an entity was modified by another userValidationException
- in case validation failsaddBeforeUpdateListener(EventDataListener)
,
addAfterUpdateListener(EventDataListener)
,
Entity.Validator.validate(java.util.Collection)
java.util.List<Entity> delete() throws DatabaseException
DatabaseException
- in case of a database exceptionaddBeforeDeleteListener(EventDataListener)
,
addAfterDeleteListener(EventDataListener)
java.util.List<Entity> delete(java.util.List<Entity> entities) throws DatabaseException
entities
- the entities to deleteDatabaseException
- in case of a database exceptionaddBeforeDeleteListener(EventDataListener)
,
addAfterDeleteListener(EventDataListener)
boolean isModified()
getModifiedObserver()
void addForeignKeyValues(java.util.List<Entity> values)
values
- the valuesvoid removeForeignKeyValues(java.util.List<Entity> values)
values
- the valuesvoid setForeignKeyValues(java.util.List<Entity> values)
values
- the entitiesStateObserver getModifiedObserver()
isModified()
,
ValueMap.getModifiedObserver()
StateObserver getEntityNewObserver()
isEntityNew()
StateObserver getAllowDeleteObserver()
isDeleteAllowed()
,
setDeleteAllowed(boolean)
StateObserver getPrimaryKeyNullObserver()
StateObserver
indicating whether or not the primary key of the active entity is nullStateObserver getAllowUpdateObserver()
StateObserver
used to determine if updating should be enabledisUpdateAllowed()
,
setUpdateAllowed(boolean)
StateObserver getAllowInsertObserver()
StateObserver
used to determine if inserting should be enabledisInsertAllowed()
,
setInsertAllowed(boolean)
EventObserver<ValueChange<Property,java.lang.Object>> getValueObserver(java.lang.String propertyId)
propertyId
- the ID of the property for which to retrieve the eventvoid addValueSetListener(java.lang.String propertyId, EventDataListener<ValueChange<Property,java.lang.Object>> listener)
ValueMapEditModel.put(Object, Object)
, note that this event is only fired when the the value changespropertyId
- the ID of the property for which to monitor value changeslistener
- a listener notified each time the value of the given property is set via this modelvoid removeValueSetListener(java.lang.String propertyId, EventDataListener listener)
propertyId
- the propertyIdlistener
- the listener to removevoid addValueListener(java.lang.String propertyId, EventDataListener<ValueChange<Property,java.lang.Object>> listener)
propertyId
- the ID of the property for which to monitor value changeslistener
- a listener notified each time the value of the property identified by propertyId
changesvoid removeValueListener(java.lang.String propertyId, EventDataListener listener)
propertyId
- the ID of the property for which to remove the listenerlistener
- the listener to removevoid addEntitySetListener(EventDataListener<Entity> listener)
listener
- a listener notified each time the entity is setvoid removeEntitySetListener(EventDataListener listener)
listener
- the listener to removevoid addBeforeInsertListener(EventDataListener<EntityEditModel.InsertEvent> listener)
listener
- a listener to be notified before an insert is performedvoid removeBeforeInsertListener(EventDataListener listener)
listener
- a listener to removevoid addAfterInsertListener(EventDataListener<EntityEditModel.InsertEvent> listener)
listener
- a listener to be notified each time a insert has been performedvoid removeAfterInsertListener(EventDataListener listener)
listener
- a listener to removevoid addBeforeUpdateListener(EventDataListener<EntityEditModel.UpdateEvent> listener)
listener
- a listener to be notified before an update is performedvoid removeBeforeUpdateListener(EventDataListener listener)
listener
- a listener to removevoid addAfterUpdateListener(EventDataListener<EntityEditModel.UpdateEvent> listener)
listener
- a listener to be notified each time an update has been performedvoid removeAfterUpdateListener(EventDataListener listener)
listener
- a listener to removevoid addBeforeDeleteListener(EventDataListener<EntityEditModel.DeleteEvent> listener)
listener
- a listener to be notified before a delete is performedvoid removeBeforeDeleteListener(EventDataListener listener)
listener
- a listener to removevoid addAfterDeleteListener(EventDataListener<EntityEditModel.DeleteEvent> listener)
listener
- a listener to be notified each time a delete has been performedvoid removeAfterDeleteListener(EventDataListener listener)
listener
- a listener to removevoid addBeforeRefreshListener(EventListener listener)
listener
- a listener to be notified before a refresh is performedvoid removeBeforeRefreshListener(EventListener listener)
listener
- a listener to removevoid addAfterRefreshListener(EventListener listener)
listener
- a listener to be notified each time a refresh has been performedvoid removeAfterRefreshListener(EventListener listener)
listener
- a listener to removevoid addEntitiesChangedListener(EventListener listener)
listener
- a listener to be notified each time a entity is modified via this model,
updated, inserted or deletedvoid removeEntitiesChangedListener(EventListener listener)
listener
- a listener to removevoid addConfirmSetEntityObserver(EventDataListener<State> listener)
listener
- a listener notified each time the active entity is about to be setvoid removeConfirmSetEntityObserver(EventDataListener listener)
listener
- a listener to remove