org.jminor.framework.client.model
Class DefaultEntityEditModel

java.lang.Object
  extended by org.jminor.common.model.valuemap.AbstractValueChangeMapEditModel<String,Object>
      extended by org.jminor.framework.client.model.DefaultEntityEditModel
All Implemented Interfaces:
Refreshable, ValueChangeMapEditModel<String,Object>, EntityDataProvider, EntityEditModel

public class DefaultEntityEditModel
extends AbstractValueChangeMapEditModel<String,Object>
implements EntityEditModel

A default EntityEditModel implementation

 String entityID = "some.entity";
 String clientTypeID = "JavadocDemo";
 User user = new User("scott", "tiger");

 EntityConnectionProvider connectionProvider = EntityConnectionProviders.createConnectionProvider(user, clientTypeID);

 EntityEditModel editModel = new DefaultEntityEditModel(entityID, connectionProvider);

 EntityEditPanel panel = new EntityEditPanel(editModel);
 


Field Summary
protected static org.slf4j.Logger LOG
           
 
Constructor Summary
DefaultEntityEditModel(String entityID, EntityConnectionProvider connectionProvider)
          Instantiates a new EntityEditModel based on the entity identified by entityID.
DefaultEntityEditModel(String entityID, EntityConnectionProvider connectionProvider, Entity.Validator validator)
          Instantiates a new EntityEditModel based on the entity identified by entityID.
 
Method Summary
 void addAfterDeleteListener(ActionListener listener)
          
 void addAfterInsertListener(ActionListener listener)
          
 void addAfterRefreshListener(ActionListener listener)
          
 void addAfterUpdateListener(ActionListener listener)
          
 void addBeforeDeleteListener(ActionListener listener)
          
 void addBeforeInsertListener(ActionListener listener)
          
 void addBeforeRefreshListener(ActionListener listener)
          
 void addBeforeUpdateListener(ActionListener listener)
          
 void addEntitiesChangedListener(ActionListener listener)
          
 void clear()
          Clears all data from this refreshable instance
 void clearComboBoxModels()
          Clears the data from all combo box models
 boolean containsComboBoxModel(String propertyID)
          Returns true if this edit model contains a ComboBoxModel for the given property
 EntityComboBoxModel createEntityComboBoxModel(Property.ForeignKeyProperty foreignKeyProperty)
          Creates a default EntityComboBoxModel for the given property, override to provide specific EntityComboBoxModels (filtered for example) for properties.
 EntityLookupModel createEntityLookupModel(String entityID, List<Property.ColumnProperty> lookupProperties, Criteria additionalSearchCriteria)
          Creates a EntityLookupModel for the given entityID
 FilteredComboBoxModel createPropertyComboBoxModel(Property.ColumnProperty property, EventObserver refreshEvent, String nullValueString)
          Creates a combo box model containing the current values of the given property
 List<Entity> delete()
          Deletes the active entity
 List<Entity> delete(List<Entity> entities)
          Deletes the given entities, returns silently on recieving an empty list
protected  void doDelete(List<Entity> entities)
          Deletes the given entities from the database
protected  List<Entity.Key> doInsert(List<Entity> entities)
          Inserts the given entities from the database
protected  List<Entity> doUpdate(List<Entity> entities)
          Updates the given entities in the database
 StateObserver getAllowDeleteState()
          
 StateObserver getAllowInsertState()
          
 StateObserver getAllowUpdateState()
          
 EntityConnectionProvider getConnectionProvider()
          
 Object getDefaultValue(Property property)
          Returns the default value for the given property, used when initializing a new default entity for this edit model.
 Entity getDefaultValueMap()
          
protected  Entity getEntity()
           
 EntityComboBoxModel getEntityComboBoxModel(Property.ForeignKeyProperty foreignKeyProperty)
          
 EntityComboBoxModel getEntityComboBoxModel(String propertyID)
          
 Entity getEntityCopy()
          
 Entity getEntityCopy(boolean includePrimaryKeyValues)
          
 String getEntityID()
          
 StateObserver getEntityNullState()
          
 Entity getForeignKeyValue(String foreignKeyPropertyID)
          Returns the value associated with the given propertyID assuming it is an Entity instance
 FilteredComboBoxModel getPropertyComboBoxModel(Property.ColumnProperty property)
          
 ValueCollectionProvider<Object> getValueProvider(Property property)
          Initializes a value provider for the given property, used for adding lookup functionality to input fields for example.
 EntityComboBoxModel initializeEntityComboBoxModel(Property.ForeignKeyProperty foreignKeyProperty)
          
 EntityComboBoxModel initializeEntityComboBoxModel(String propertyID)
          
 FilteredComboBoxModel initializePropertyComboBoxModel(Property.ColumnProperty property, EventObserver refreshEvent, String nullValueString)
          
 List<Entity.Key> insert()
          Performs a insert on the active entity
 List<Entity.Key> insert(List<Entity> entities)
          Performs an insert on the given entities, returns silently on recieving an empty list
 boolean isDeleteAllowed()
          
 boolean isEntityNew()
          
 boolean isInsertAllowed()
          
 boolean isReadOnly()
          
 boolean isUpdateAllowed()
          
 boolean persistValueOnClear(Property property)
          Returns true if the last available value for this property should be used when initializing a default entity.
 void refresh()
          Performs a refresh
 void refreshComboBoxModels()
          Refreshes the Refreshable ComboBoxModels associated with this EntityEditModel
 void removeAfterDeleteListener(ActionListener listener)
          
 void removeAfterInsertListener(ActionListener listener)
          
 void removeAfterRefreshListener(ActionListener listener)
          
 void removeAfterUpdateListener(ActionListener listener)
          
 void removeBeforeDeleteListener(ActionListener listener)
          
 void removeBeforeInsertListener(ActionListener listener)
          
 void removeBeforeRefreshListener(ActionListener listener)
          
 void removeBeforeUpdateListener(ActionListener listener)
          
 void removeEntitiesChangedListener(ActionListener listener)
          
 void replaceForeignKeyValues(String foreignKeyEntityID, Collection<Entity> newForeignKeyValues)
          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)
          Sets the Entity instance to edit
 EntityEditModel setInsertAllowed(boolean value)
          
 EntityEditModel setPersistValueOnClear(String propertyID, boolean persistValueOnClear)
          
 EntityEditModel setReadOnly(boolean readOnly)
          
 EntityEditModel setUpdateAllowed(boolean value)
          
 String toString()
           
 List<Entity> update()
          Performs a update on the active entity
 List<Entity> update(List<Entity> entities)
          Updates the given Entities.
 
Methods inherited from class org.jminor.common.model.valuemap.AbstractValueChangeMapEditModel
addValueListener, addValueMapSetListener, addValueSetListener, getModifiedState, getValidator, getValidState, getValue, getValueChangeObserver, getValueMap, isModified, isNullable, isValid, isValid, isValueNull, prepareNewValue, removeValueListener, removeValueMapSetListener, removeValueSetListener, setValue, setValueMap, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jminor.common.model.valuemap.ValueChangeMapEditModel
addValueListener, addValueMapSetListener, addValueSetListener, getModifiedState, getValidator, getValidState, getValue, getValueChangeObserver, isModified, isNullable, isValid, isValid, isValueNull, removeValueListener, removeValueMapSetListener, removeValueSetListener, setValue, setValueMap, validate
 

Field Detail

LOG

protected static final org.slf4j.Logger LOG
Constructor Detail

DefaultEntityEditModel

public DefaultEntityEditModel(String entityID,
                              EntityConnectionProvider connectionProvider)
Instantiates a new EntityEditModel based on the entity identified by entityID.

Parameters:
entityID - the ID of the entity to base this EntityEditModel on
connectionProvider - the EntityConnectionProvider instance

DefaultEntityEditModel

public DefaultEntityEditModel(String entityID,
                              EntityConnectionProvider connectionProvider,
                              Entity.Validator validator)
Instantiates a new EntityEditModel based on the entity identified by entityID.

Parameters:
entityID - the ID of the entity to base this EntityEditModel on
connectionProvider - the EntityConnectionProvider instance
validator - the validator to use
Method Detail

toString

public final String toString()
Overrides:
toString in class Object

getDefaultValue

public Object getDefaultValue(Property property)
Returns the default value for the given property, used when initializing a new default entity for this edit model. This does not apply to denormalized properties (Property.DenormalizedProperty) nor properties that are wrapped in foreign key properties (Property.ForeignKeyProperty) If the default value of a property should be the last value used persistValueOnClear should be overridden so that it returns true for that property.

Specified by:
getDefaultValue in interface EntityEditModel
Parameters:
property - the property
Returns:
the default value for the property
See Also:
Property.setDefaultValue(Object), EntityEditModel.persistValueOnClear(org.jminor.framework.domain.Property)

persistValueOnClear

public boolean persistValueOnClear(Property property)
Returns true if the last available value for this property should be used when initializing a default entity. Override for selective reset of field values when the model is cleared. For Property.ForeignKeyProperty values this method by default returns the value of the property Configuration.PERSIST_FOREIGN_KEY_VALUES.

Specified by:
persistValueOnClear in interface EntityEditModel
Parameters:
property - the property
Returns:
true if the given field value should be reset when the model is cleared
See Also:
Configuration.PERSIST_FOREIGN_KEY_VALUES

isReadOnly

public final boolean isReadOnly()

Specified by:
isReadOnly in interface EntityEditModel
Returns:
true if this model is read only, by default this returns the isReadOnly value of the underlying entity

setReadOnly

public final EntityEditModel setReadOnly(boolean readOnly)

Specified by:
setReadOnly in interface EntityEditModel
Parameters:
readOnly - the read only status
Returns:
this edit model instance

setPersistValueOnClear

public final EntityEditModel setPersistValueOnClear(String propertyID,
                                                    boolean persistValueOnClear)

Specified by:
setPersistValueOnClear in interface EntityEditModel
Parameters:
propertyID - the property ID
persistValueOnClear - true if this model should persist the value of the given property on clear
Returns:
this edit model instance
See Also:
Configuration.PERSIST_FOREIGN_KEY_VALUES

isInsertAllowed

public final boolean isInsertAllowed()

Specified by:
isInsertAllowed in interface EntityEditModel
Returns:
true if this model should allow records to be inserted

setInsertAllowed

public final EntityEditModel setInsertAllowed(boolean value)

Specified by:
setInsertAllowed in interface EntityEditModel
Parameters:
value - true if this model should allow inserts
Returns:
this edit model instance

getAllowInsertState

public final StateObserver getAllowInsertState()

Specified by:
getAllowInsertState in interface EntityEditModel
Returns:
the state used to determine if inserting should be enabled
See Also:
EntityEditModel.isInsertAllowed(), EntityEditModel.setInsertAllowed(boolean)

isUpdateAllowed

public final boolean isUpdateAllowed()

Specified by:
isUpdateAllowed in interface EntityEditModel
Returns:
true if this model should allow records to be updated

setUpdateAllowed

public final EntityEditModel setUpdateAllowed(boolean value)

Specified by:
setUpdateAllowed in interface EntityEditModel
Parameters:
value - true if this model should allow records to be updated
Returns:
this edit model instance

getAllowUpdateState

public final StateObserver getAllowUpdateState()

Specified by:
getAllowUpdateState in interface EntityEditModel
Returns:
the state used to determine if updating should be enabled
See Also:
EntityEditModel.isUpdateAllowed(), EntityEditModel.setUpdateAllowed(boolean)

isDeleteAllowed

public final boolean isDeleteAllowed()

Specified by:
isDeleteAllowed in interface EntityEditModel
Returns:
true if this model should allow records to be deleted

setDeleteAllowed

public final EntityEditModel setDeleteAllowed(boolean value)

Specified by:
setDeleteAllowed in interface EntityEditModel
Parameters:
value - true if this model should allow records to be deleted
Returns:
this edit model instance

getAllowDeleteState

public final StateObserver getAllowDeleteState()

Specified by:
getAllowDeleteState in interface EntityEditModel
Returns:
the state used to determine if deleting should be enabled
See Also:
EntityEditModel.isDeleteAllowed(), EntityEditModel.setDeleteAllowed(boolean)

getEntityNullState

public final StateObserver getEntityNullState()

Specified by:
getEntityNullState in interface EntityEditModel
Returns:
a State indicating whether or not the active entity is null

setEntity

public final void setEntity(Entity entity)
Sets the Entity instance to edit

Specified by:
setEntity in interface EntityEditModel
Parameters:
entity - the entity

getEntityID

public final String getEntityID()

Specified by:
getEntityID in interface EntityDataProvider
Returns:
the ID of the entity this data provider is based on

getConnectionProvider

public final EntityConnectionProvider getConnectionProvider()

Specified by:
getConnectionProvider in interface EntityDataProvider
Returns:
the db provider this data provider uses

getForeignKeyValue

public final Entity getForeignKeyValue(String foreignKeyPropertyID)
Returns the value associated with the given propertyID assuming it is an Entity instance

Specified by:
getForeignKeyValue in interface EntityEditModel
Parameters:
foreignKeyPropertyID - the ID of the property
Returns:
the value assuming it is an Entity

replaceForeignKeyValues

public final void replaceForeignKeyValues(String foreignKeyEntityID,
                                          Collection<Entity> newForeignKeyValues)
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.

Specified by:
replaceForeignKeyValues in interface EntityEditModel
Parameters:
foreignKeyEntityID - the entity ID of the foreign key values
newForeignKeyValues - the new foreign key entities

getEntityCopy

public final Entity getEntityCopy()

Specified by:
getEntityCopy in interface EntityEditModel
Returns:
a deep copy of the active entity
See Also:
ValueChangeMap.getCopy()

getEntityCopy

public final Entity getEntityCopy(boolean includePrimaryKeyValues)

Specified by:
getEntityCopy in interface EntityEditModel
Parameters:
includePrimaryKeyValues - if false then the primary key values are excluded
Returns:
a deep copy of the active entity
See Also:
ValueChangeMap.getCopy()

isEntityNew

public final boolean isEntityNew()

Specified by:
isEntityNew in interface EntityEditModel
Returns:
true if the active entity is new, that is, has a primary key with null value or a original null value
See Also:
Entity.isPrimaryKeyNull()

insert

public final List<Entity.Key> insert()
                              throws CancelException,
                                     DatabaseException,
                                     ValidationException
Performs a insert on the active entity

Specified by:
insert in interface EntityEditModel
Returns:
the primary keys of the inserted entities
Throws:
CancelException - in case the user cancels the operation
DatabaseException - in case of a database exception
ValidationException - in case validation fails
See Also:
Entity.Validator.validate(java.util.Collection, int)

insert

public final List<Entity.Key> insert(List<Entity> entities)
                              throws CancelException,
                                     DatabaseException,
                                     ValidationException
Performs an insert on the given entities, returns silently on recieving an empty list

Specified by:
insert in interface EntityEditModel
Parameters:
entities - the entities to insert
Returns:
the primary keys of the inserted entities
Throws:
CancelException - in case the user cancels the operation
DatabaseException - in case of a database exception
ValidationException - in case validation fails
See Also:
EntityEditModel.addBeforeInsertListener(java.awt.event.ActionListener), EntityEditModel.addAfterInsertListener(java.awt.event.ActionListener), Entity.Validator.validate(java.util.Collection, int)

update

public final List<Entity> update()
                          throws CancelException,
                                 DatabaseException,
                                 ValidationException
Performs a update on the active entity

Specified by:
update in interface EntityEditModel
Returns:
the updated entities
Throws:
CancelException - in case the user cancels the operation
DatabaseException - in case of a database exception
RecordModifiedException - in case an entity was modified by another user
ValidationException - in case validation fails
See Also:
Entity.Validator.validate(java.util.Collection, int)

update

public final List<Entity> update(List<Entity> entities)
                          throws DatabaseException,
                                 CancelException,
                                 ValidationException
Updates the given Entities. If the entities are unmodified or the list is empty this method returns silently.

Specified by:
update in interface EntityEditModel
Parameters:
entities - the Entities to update
Returns:
the updated entities
Throws:
DatabaseException - in case of a database exception
RecordModifiedException - in case an entity was modified by another user
CancelException - in case the user cancels the operation
ValidationException - in case validation fails
See Also:
EntityEditModel.addBeforeUpdateListener(java.awt.event.ActionListener), EntityEditModel.addAfterUpdateListener(java.awt.event.ActionListener), Entity.Validator.validate(java.util.Collection, int)

delete

public final List<Entity> delete()
                          throws DatabaseException,
                                 CancelException
Deletes the active entity

Specified by:
delete in interface EntityEditModel
Returns:
the deleted entities
Throws:
DatabaseException - in case of a database exception
CancelException - in case the user cancels the operation
See Also:
EntityEditModel.addBeforeDeleteListener(java.awt.event.ActionListener), EntityEditModel.addAfterDeleteListener(java.awt.event.ActionListener)

delete

public final List<Entity> delete(List<Entity> entities)
                          throws DatabaseException,
                                 CancelException
Deletes the given entities, returns silently on recieving an empty list

Specified by:
delete in interface EntityEditModel
Parameters:
entities - the entities to delete
Returns:
the deleted entities
Throws:
DatabaseException - in case of a database exception
CancelException - in case the user cancels the operation
See Also:
EntityEditModel.addBeforeDeleteListener(java.awt.event.ActionListener), EntityEditModel.addAfterDeleteListener(java.awt.event.ActionListener)

refresh

public final void refresh()
Performs a refresh

Specified by:
refresh in interface Refreshable
Overrides:
refresh in class AbstractValueChangeMapEditModel<String,Object>

clear

public final void clear()
Clears all data from this refreshable instance

Specified by:
clear in interface Refreshable
Overrides:
clear in class AbstractValueChangeMapEditModel<String,Object>

refreshComboBoxModels

public final void refreshComboBoxModels()
Refreshes the Refreshable ComboBoxModels associated with this EntityEditModel

Specified by:
refreshComboBoxModels in interface EntityEditModel
See Also:
Refreshable

clearComboBoxModels

public final void clearComboBoxModels()
Clears the data from all combo box models

Specified by:
clearComboBoxModels in interface EntityEditModel

createPropertyComboBoxModel

public FilteredComboBoxModel createPropertyComboBoxModel(Property.ColumnProperty property,
                                                         EventObserver refreshEvent,
                                                         String nullValueString)
Creates a combo box model containing the current values of the given property

Specified by:
createPropertyComboBoxModel in interface EntityEditModel
Parameters:
property - the property
refreshEvent - the combo box model is refreshed each time this event is fired
nullValueString - the string to use as a null value caption
Returns:
a combo box model based on the given property

createEntityComboBoxModel

public EntityComboBoxModel createEntityComboBoxModel(Property.ForeignKeyProperty foreignKeyProperty)
Creates a default EntityComboBoxModel for the given property, override to provide specific EntityComboBoxModels (filtered for example) for properties. This method is called when creating a EntityComboBoxModel for entity properties, both for the edit fields used when editing a single record and the edit field used when updating multiple records. This default implementation returns a sorted EntityComboBoxModel with the default nullValueItem if the underlying property is nullable

Specified by:
createEntityComboBoxModel in interface EntityEditModel
Parameters:
foreignKeyProperty - the foreign key property for which to create a EntityComboBoxModel
Returns:
a EntityComboBoxModel for the given property
See Also:
Configuration.DEFAULT_COMBO_BOX_NULL_VALUE_ITEM, Property.isNullable()

createEntityLookupModel

public EntityLookupModel createEntityLookupModel(String entityID,
                                                 List<Property.ColumnProperty> lookupProperties,
                                                 Criteria additionalSearchCriteria)
Creates a EntityLookupModel for the given entityID

Specified by:
createEntityLookupModel in interface EntityEditModel
Parameters:
entityID - the ID of the entity
lookupProperties - the properties involved in the lookup
additionalSearchCriteria - an additional search criteria applied when performing the lookup
Returns:
a EntityLookupModel

getPropertyComboBoxModel

public final FilteredComboBoxModel getPropertyComboBoxModel(Property.ColumnProperty property)

Specified by:
getPropertyComboBoxModel in interface EntityEditModel
Parameters:
property - the property for which to get the ComboBoxModel
Returns:
a PropertyComboBoxModel representing property

initializePropertyComboBoxModel

public final FilteredComboBoxModel initializePropertyComboBoxModel(Property.ColumnProperty property,
                                                                   EventObserver refreshEvent,
                                                                   String nullValueString)

Specified by:
initializePropertyComboBoxModel in interface EntityEditModel
Parameters:
property - the property for which to get the ComboBoxModel
refreshEvent - the combo box model is refreshed when this event fires, if none is specified addEntitiesChangedListener() is used.
nullValueString - the value to use for representing the null item at the top of the list, if this value is null then no such item is included
Returns:
a PropertyComboBoxModel representing property, if no combo box model has been initialized for the given property, a new one is created and associated with the property, to be returned the next time this method is called

getEntityComboBoxModel

public final EntityComboBoxModel getEntityComboBoxModel(String propertyID)

Specified by:
getEntityComboBoxModel in interface EntityEditModel
Parameters:
propertyID - the ID of the property for which to retrieve the EntityComboBoxModel
Returns:
the EntityComboBoxModel for the property identified by propertyID, if no combo box model is associated with the property a new one is initialized, and associated with the given property

getEntityComboBoxModel

public final EntityComboBoxModel getEntityComboBoxModel(Property.ForeignKeyProperty foreignKeyProperty)

Specified by:
getEntityComboBoxModel in interface EntityEditModel
Parameters:
foreignKeyProperty - the foreign key property for which to retrieve the EntityComboBoxModel
Returns:
the EntityComboBoxModel associated with the property

initializeEntityComboBoxModel

public final EntityComboBoxModel initializeEntityComboBoxModel(String propertyID)

Specified by:
initializeEntityComboBoxModel in interface EntityEditModel
Parameters:
propertyID - the ID of the foreign key property for which to retrieve the EntityComboBoxModel
Returns:
the EntityComboBoxModel for the property, if no combo box model is associated with the property a new one is initialized, and associated with the given property

initializeEntityComboBoxModel

public final EntityComboBoxModel initializeEntityComboBoxModel(Property.ForeignKeyProperty foreignKeyProperty)

Specified by:
initializeEntityComboBoxModel in interface EntityEditModel
Parameters:
foreignKeyProperty - the foreign key property for which to retrieve the EntityComboBoxModel
Returns:
the EntityComboBoxModel for the property, if no combo box model is associated with the property a new one is initialized, and associated with the given property

containsComboBoxModel

public final boolean containsComboBoxModel(String propertyID)
Returns true if this edit model contains a ComboBoxModel for the given property

Specified by:
containsComboBoxModel in interface EntityEditModel
Parameters:
propertyID - the ID of the property
Returns:
true if a ComboBoxModel has been initialized for the given property

getDefaultValueMap

public final Entity getDefaultValueMap()

Specified by:
getDefaultValueMap in interface ValueChangeMapEditModel<String,Object>
Returns:
a value map containing the default values

getValueProvider

public final ValueCollectionProvider<Object> getValueProvider(Property property)
Initializes a value provider for the given property, used for adding lookup functionality to input fields for example.

Specified by:
getValueProvider in interface EntityEditModel
Parameters:
property - the property
Returns:
a value provider for the given property

removeBeforeInsertListener

public final void removeBeforeInsertListener(ActionListener listener)

Specified by:
removeBeforeInsertListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time

addBeforeInsertListener

public final void addBeforeInsertListener(ActionListener listener)

Specified by:
addBeforeInsertListener in interface EntityEditModel
Parameters:
listener - a listener to be notified before an insert is performed

removeAfterInsertListener

public final void removeAfterInsertListener(ActionListener listener)

Specified by:
removeAfterInsertListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time

addAfterInsertListener

public final void addAfterInsertListener(ActionListener listener)

Specified by:
addAfterInsertListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time a insert has been performed

removeBeforeUpdateListener

public final void removeBeforeUpdateListener(ActionListener listener)

Specified by:
removeBeforeUpdateListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time

addBeforeUpdateListener

public final void addBeforeUpdateListener(ActionListener listener)

Specified by:
addBeforeUpdateListener in interface EntityEditModel
Parameters:
listener - a listener to be notified before an update is performed

removeAfterUpdateListener

public final void removeAfterUpdateListener(ActionListener listener)

Specified by:
removeAfterUpdateListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time

addAfterUpdateListener

public final void addAfterUpdateListener(ActionListener listener)

Specified by:
addAfterUpdateListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time an update has been performed

addBeforeDeleteListener

public final void addBeforeDeleteListener(ActionListener listener)

Specified by:
addBeforeDeleteListener in interface EntityEditModel
Parameters:
listener - a listener to be notified before a delete is performed

removeBeforeDeleteListener

public final void removeBeforeDeleteListener(ActionListener listener)

Specified by:
removeBeforeDeleteListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time

removeAfterDeleteListener

public final void removeAfterDeleteListener(ActionListener listener)

Specified by:
removeAfterDeleteListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time

addAfterDeleteListener

public final void addAfterDeleteListener(ActionListener listener)

Specified by:
addAfterDeleteListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time a delete has been performed

removeEntitiesChangedListener

public final void removeEntitiesChangedListener(ActionListener listener)

Specified by:
removeEntitiesChangedListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time

addEntitiesChangedListener

public final void addEntitiesChangedListener(ActionListener listener)

Specified by:
addEntitiesChangedListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time a entity is modified via this model, updated, inserted or deleted

addBeforeRefreshListener

public final void addBeforeRefreshListener(ActionListener listener)

Specified by:
addBeforeRefreshListener in interface EntityEditModel
Parameters:
listener - a listener to be notified before a refresh is performed

removeBeforeRefreshListener

public final void removeBeforeRefreshListener(ActionListener listener)

Specified by:
removeBeforeRefreshListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time

addAfterRefreshListener

public final void addAfterRefreshListener(ActionListener listener)

Specified by:
addAfterRefreshListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time a refresh has been performed

removeAfterRefreshListener

public final void removeAfterRefreshListener(ActionListener listener)

Specified by:
removeAfterRefreshListener in interface EntityEditModel
Parameters:
listener - a listener to be notified each time

doInsert

protected List<Entity.Key> doInsert(List<Entity> entities)
                             throws DatabaseException,
                                    CancelException
Inserts the given entities from the database

Parameters:
entities - the entities to insert
Returns:
a list containing the primary keys of the inserted entities
Throws:
DatabaseException - in case of a database exception
CancelException - in case the operation is canceled

doUpdate

protected List<Entity> doUpdate(List<Entity> entities)
                         throws DatabaseException,
                                CancelException
Updates the given entities in the database

Parameters:
entities - the entities to update
Returns:
a list containing the updated entities
Throws:
DatabaseException - in case of a database exception
CancelException - in case the operation is cancelled

doDelete

protected void doDelete(List<Entity> entities)
                 throws DatabaseException,
                        CancelException
Deletes the given entities from the database

Parameters:
entities - the entities to delete
Throws:
DatabaseException - in case of a database exception
CancelException - in case the operation is canceled

getEntity

protected final Entity getEntity()
Returns:
the Entity instance being edited