|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jminor.common.model.valuemap.AbstractValueChangeMapEditModel<String,Object>
org.jminor.framework.client.model.DefaultEntityEditModel
public class DefaultEntityEditModel
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 |
---|
protected static final org.slf4j.Logger LOG
Constructor Detail |
---|
public DefaultEntityEditModel(String entityID, EntityConnectionProvider connectionProvider)
entityID
.
entityID
- the ID of the entity to base this EntityEditModel onconnectionProvider
- the EntityConnectionProvider instancepublic DefaultEntityEditModel(String entityID, EntityConnectionProvider connectionProvider, Entity.Validator validator)
entityID
.
entityID
- the ID of the entity to base this EntityEditModel onconnectionProvider
- the EntityConnectionProvider instancevalidator
- the validator to useMethod Detail |
---|
public final String toString()
toString
in class Object
public Object getDefaultValue(Property property)
persistValueOnClear
should be overridden so that it returns true
for that property.
getDefaultValue
in interface EntityEditModel
property
- the property
Property.setDefaultValue(Object)
,
EntityEditModel.persistValueOnClear(org.jminor.framework.domain.Property)
public boolean persistValueOnClear(Property property)
Configuration.PERSIST_FOREIGN_KEY_VALUES
.
persistValueOnClear
in interface EntityEditModel
property
- the property
Configuration.PERSIST_FOREIGN_KEY_VALUES
public final boolean isReadOnly()
isReadOnly
in interface EntityEditModel
public final EntityEditModel setReadOnly(boolean readOnly)
setReadOnly
in interface EntityEditModel
readOnly
- the read only status
public final EntityEditModel setPersistValueOnClear(String propertyID, boolean persistValueOnClear)
setPersistValueOnClear
in interface EntityEditModel
propertyID
- the property IDpersistValueOnClear
- true if this model should persist the value of the given property on clear
Configuration.PERSIST_FOREIGN_KEY_VALUES
public final boolean isInsertAllowed()
isInsertAllowed
in interface EntityEditModel
public final EntityEditModel setInsertAllowed(boolean value)
setInsertAllowed
in interface EntityEditModel
value
- true if this model should allow inserts
public final StateObserver getAllowInsertState()
getAllowInsertState
in interface EntityEditModel
EntityEditModel.isInsertAllowed()
,
EntityEditModel.setInsertAllowed(boolean)
public final boolean isUpdateAllowed()
isUpdateAllowed
in interface EntityEditModel
public final EntityEditModel setUpdateAllowed(boolean value)
setUpdateAllowed
in interface EntityEditModel
value
- true if this model should allow records to be updated
public final StateObserver getAllowUpdateState()
getAllowUpdateState
in interface EntityEditModel
EntityEditModel.isUpdateAllowed()
,
EntityEditModel.setUpdateAllowed(boolean)
public final boolean isDeleteAllowed()
isDeleteAllowed
in interface EntityEditModel
public final EntityEditModel setDeleteAllowed(boolean value)
setDeleteAllowed
in interface EntityEditModel
value
- true if this model should allow records to be deleted
public final StateObserver getAllowDeleteState()
getAllowDeleteState
in interface EntityEditModel
EntityEditModel.isDeleteAllowed()
,
EntityEditModel.setDeleteAllowed(boolean)
public final StateObserver getEntityNullState()
getEntityNullState
in interface EntityEditModel
public final void setEntity(Entity entity)
setEntity
in interface EntityEditModel
entity
- the entitypublic final String getEntityID()
getEntityID
in interface EntityDataProvider
public final EntityConnectionProvider getConnectionProvider()
getConnectionProvider
in interface EntityDataProvider
public final Entity getForeignKeyValue(String foreignKeyPropertyID)
getForeignKeyValue
in interface EntityEditModel
foreignKeyPropertyID
- the ID of the property
public final void replaceForeignKeyValues(String foreignKeyEntityID, Collection<Entity> newForeignKeyValues)
foreignKeyValues
, useful when property
values have been changed in the referenced entity that must be reflected in the edit model.
replaceForeignKeyValues
in interface EntityEditModel
foreignKeyEntityID
- the entity ID of the foreign key valuesnewForeignKeyValues
- the new foreign key entitiespublic final Entity getEntityCopy()
getEntityCopy
in interface EntityEditModel
ValueChangeMap.getCopy()
public final Entity getEntityCopy(boolean includePrimaryKeyValues)
getEntityCopy
in interface EntityEditModel
includePrimaryKeyValues
- if false then the primary key values are excluded
ValueChangeMap.getCopy()
public final boolean isEntityNew()
isEntityNew
in interface EntityEditModel
Entity.isPrimaryKeyNull()
public final List<Entity.Key> insert() throws CancelException, DatabaseException, ValidationException
insert
in interface EntityEditModel
CancelException
- in case the user cancels the operation
DatabaseException
- in case of a database exception
ValidationException
- in case validation failsEntity.Validator.validate(java.util.Collection, int)
public final List<Entity.Key> insert(List<Entity> entities) throws CancelException, DatabaseException, ValidationException
insert
in interface EntityEditModel
entities
- the entities to insert
CancelException
- in case the user cancels the operation
DatabaseException
- in case of a database exception
ValidationException
- in case validation failsEntityEditModel.addBeforeInsertListener(java.awt.event.ActionListener)
,
EntityEditModel.addAfterInsertListener(java.awt.event.ActionListener)
,
Entity.Validator.validate(java.util.Collection, int)
public final List<Entity> update() throws CancelException, DatabaseException, ValidationException
update
in interface EntityEditModel
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 failsEntity.Validator.validate(java.util.Collection, int)
public final List<Entity> update(List<Entity> entities) throws DatabaseException, CancelException, ValidationException
update
in interface EntityEditModel
entities
- the Entities to update
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 failsEntityEditModel.addBeforeUpdateListener(java.awt.event.ActionListener)
,
EntityEditModel.addAfterUpdateListener(java.awt.event.ActionListener)
,
Entity.Validator.validate(java.util.Collection, int)
public final List<Entity> delete() throws DatabaseException, CancelException
delete
in interface EntityEditModel
DatabaseException
- in case of a database exception
CancelException
- in case the user cancels the operationEntityEditModel.addBeforeDeleteListener(java.awt.event.ActionListener)
,
EntityEditModel.addAfterDeleteListener(java.awt.event.ActionListener)
public final List<Entity> delete(List<Entity> entities) throws DatabaseException, CancelException
delete
in interface EntityEditModel
entities
- the entities to delete
DatabaseException
- in case of a database exception
CancelException
- in case the user cancels the operationEntityEditModel.addBeforeDeleteListener(java.awt.event.ActionListener)
,
EntityEditModel.addAfterDeleteListener(java.awt.event.ActionListener)
public final void refresh()
refresh
in interface Refreshable
refresh
in class AbstractValueChangeMapEditModel<String,Object>
public final void clear()
clear
in interface Refreshable
clear
in class AbstractValueChangeMapEditModel<String,Object>
public final void refreshComboBoxModels()
refreshComboBoxModels
in interface EntityEditModel
Refreshable
public final void clearComboBoxModels()
clearComboBoxModels
in interface EntityEditModel
public FilteredComboBoxModel createPropertyComboBoxModel(Property.ColumnProperty property, EventObserver refreshEvent, String nullValueString)
createPropertyComboBoxModel
in interface EntityEditModel
property
- the propertyrefreshEvent
- the combo box model is refreshed each time this event is firednullValueString
- the string to use as a null value caption
public EntityComboBoxModel createEntityComboBoxModel(Property.ForeignKeyProperty foreignKeyProperty)
createEntityComboBoxModel
in interface EntityEditModel
foreignKeyProperty
- the foreign key property for which to create a EntityComboBoxModel
Configuration.DEFAULT_COMBO_BOX_NULL_VALUE_ITEM
,
Property.isNullable()
public EntityLookupModel createEntityLookupModel(String entityID, List<Property.ColumnProperty> lookupProperties, Criteria additionalSearchCriteria)
createEntityLookupModel
in interface EntityEditModel
entityID
- the ID of the entitylookupProperties
- the properties involved in the lookupadditionalSearchCriteria
- an additional search criteria applied when performing the lookup
public final FilteredComboBoxModel getPropertyComboBoxModel(Property.ColumnProperty property)
getPropertyComboBoxModel
in interface EntityEditModel
property
- the property for which to get the ComboBoxModel
property
public final FilteredComboBoxModel initializePropertyComboBoxModel(Property.ColumnProperty property, EventObserver refreshEvent, String nullValueString)
initializePropertyComboBoxModel
in interface EntityEditModel
property
- the property for which to get the ComboBoxModelrefreshEvent
- 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
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 calledpublic final EntityComboBoxModel getEntityComboBoxModel(String propertyID)
getEntityComboBoxModel
in interface EntityEditModel
propertyID
- the ID of the property for which to retrieve the EntityComboBoxModel
propertyID
,
if no combo box model is associated with the property a new one is initialized, and associated
with the given propertypublic final EntityComboBoxModel getEntityComboBoxModel(Property.ForeignKeyProperty foreignKeyProperty)
getEntityComboBoxModel
in interface EntityEditModel
foreignKeyProperty
- the foreign key property for which to retrieve the EntityComboBoxModel
property
public final EntityComboBoxModel initializeEntityComboBoxModel(String propertyID)
initializeEntityComboBoxModel
in interface EntityEditModel
propertyID
- the ID of the foreign key property for which to retrieve the EntityComboBoxModel
property
,
if no combo box model is associated with the property a new one is initialized, and associated
with the given propertypublic final EntityComboBoxModel initializeEntityComboBoxModel(Property.ForeignKeyProperty foreignKeyProperty)
initializeEntityComboBoxModel
in interface EntityEditModel
foreignKeyProperty
- the foreign key property for which to retrieve the EntityComboBoxModel
property
,
if no combo box model is associated with the property a new one is initialized, and associated
with the given propertypublic final boolean containsComboBoxModel(String propertyID)
containsComboBoxModel
in interface EntityEditModel
propertyID
- the ID of the property
public final Entity getDefaultValueMap()
getDefaultValueMap
in interface ValueChangeMapEditModel<String,Object>
public final ValueCollectionProvider<Object> getValueProvider(Property property)
getValueProvider
in interface EntityEditModel
property
- the property
public final void removeBeforeInsertListener(ActionListener listener)
removeBeforeInsertListener
in interface EntityEditModel
listener
- a listener to be notified each timepublic final void addBeforeInsertListener(ActionListener listener)
addBeforeInsertListener
in interface EntityEditModel
listener
- a listener to be notified before an insert is performedpublic final void removeAfterInsertListener(ActionListener listener)
removeAfterInsertListener
in interface EntityEditModel
listener
- a listener to be notified each timepublic final void addAfterInsertListener(ActionListener listener)
addAfterInsertListener
in interface EntityEditModel
listener
- a listener to be notified each time a insert has been performedpublic final void removeBeforeUpdateListener(ActionListener listener)
removeBeforeUpdateListener
in interface EntityEditModel
listener
- a listener to be notified each timepublic final void addBeforeUpdateListener(ActionListener listener)
addBeforeUpdateListener
in interface EntityEditModel
listener
- a listener to be notified before an update is performedpublic final void removeAfterUpdateListener(ActionListener listener)
removeAfterUpdateListener
in interface EntityEditModel
listener
- a listener to be notified each timepublic final void addAfterUpdateListener(ActionListener listener)
addAfterUpdateListener
in interface EntityEditModel
listener
- a listener to be notified each time an update has been performedpublic final void addBeforeDeleteListener(ActionListener listener)
addBeforeDeleteListener
in interface EntityEditModel
listener
- a listener to be notified before a delete is performedpublic final void removeBeforeDeleteListener(ActionListener listener)
removeBeforeDeleteListener
in interface EntityEditModel
listener
- a listener to be notified each timepublic final void removeAfterDeleteListener(ActionListener listener)
removeAfterDeleteListener
in interface EntityEditModel
listener
- a listener to be notified each timepublic final void addAfterDeleteListener(ActionListener listener)
addAfterDeleteListener
in interface EntityEditModel
listener
- a listener to be notified each time a delete has been performedpublic final void removeEntitiesChangedListener(ActionListener listener)
removeEntitiesChangedListener
in interface EntityEditModel
listener
- a listener to be notified each timepublic final void addEntitiesChangedListener(ActionListener listener)
addEntitiesChangedListener
in interface EntityEditModel
listener
- a listener to be notified each time a entity is modified via this model,
updated, inserted or deletedpublic final void addBeforeRefreshListener(ActionListener listener)
addBeforeRefreshListener
in interface EntityEditModel
listener
- a listener to be notified before a refresh is performedpublic final void removeBeforeRefreshListener(ActionListener listener)
removeBeforeRefreshListener
in interface EntityEditModel
listener
- a listener to be notified each timepublic final void addAfterRefreshListener(ActionListener listener)
addAfterRefreshListener
in interface EntityEditModel
listener
- a listener to be notified each time a refresh has been performedpublic final void removeAfterRefreshListener(ActionListener listener)
removeAfterRefreshListener
in interface EntityEditModel
listener
- a listener to be notified each timeprotected List<Entity.Key> doInsert(List<Entity> entities) throws DatabaseException, CancelException
entities
- the entities to insert
DatabaseException
- in case of a database exception
CancelException
- in case the operation is canceledprotected List<Entity> doUpdate(List<Entity> entities) throws DatabaseException, CancelException
entities
- the entities to update
DatabaseException
- in case of a database exception
CancelException
- in case the operation is cancelledprotected void doDelete(List<Entity> entities) throws DatabaseException, CancelException
entities
- the entities to delete
DatabaseException
- in case of a database exception
CancelException
- in case the operation is canceledprotected final Entity getEntity()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |