org.jminor.framework.client.model
Interface EntityTableModel

All Superinterfaces:
EntityDataProvider, FilteredModel<Entity>, FilteredTableModel<Entity,Property>, Refreshable, TableModel
All Known Implementing Classes:
DefaultEntityTableModel

public interface EntityTableModel
extends FilteredTableModel<Entity,Property>, EntityDataProvider

Specifies a table model containing Entity objects


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jminor.common.model.FilteredTableModel
FilteredTableModel.SortingState
 
Method Summary
 void addEntitiesByPrimaryKeys(List<Entity.Key> primaryKeys, boolean atFront)
          Retrieves the entities identified by the given primary keys and adds them to this table model
 void deleteSelected()
          Deletes the selected entities
 StateObserver getBatchUpdateAllowedState()
           
 EntityEditModel getEditModel()
          Returns the edit model associated with this table model, throws a RuntimeExcption in case no edit model has been associated with this table model
 List<Entity> getEntitiesByPrimaryKeys(List<Entity.Key> keys)
          Finds entities according to the values in keys
 Collection<Entity> getEntitiesByPropertyValues(Map<String,Object> values)
          Finds entities according to the values of propertyValues
 Entity getEntityByPrimaryKey(Entity.Key primaryKey)
           
 int getFetchCount()
          Returns the maximum number of records to fetch via the underlying query, by default this returns -1, meaning all records should be fetched
 List<Entity.Key> getPrimaryKeysOfSelectedEntities()
           
 Color getPropertyBackgroundColor(int row, Property columnProperty)
           
 PropertySummaryModel getPropertySummaryModel(Property property)
          Returns the PropertySummaryModel associated with the given property
 PropertySummaryModel getPropertySummaryModel(String propertyID)
          Returns the PropertySummaryModel associated with the property identified by propertyID
 ReportDataWrapper getReportDataSource()
          Returns an initialized ReportDataWrapper instance, the default implementation returns null.
 EntityTableSearchModel getSearchModel()
           
 Iterator<Entity> getSelectedEntitiesIterator()
          Returns an Iterator which iterates through the selected entities
 Map<String,Collection<Entity>> getSelectionDependencies()
           
 SortingDirective getSortingDirective(String propertyID)
           
 String getStatusMessage()
           
 List<Property> getTableColumnProperties()
           
 Collection<Object> getValues(Property property, boolean selectedOnly)
           
 boolean hasEditModel()
           
 int indexOf(Entity.Key primaryKey)
           
 boolean isBatchUpdateAllowed()
           
 boolean isDeleteAllowed()
           
 boolean isDetailModel()
           
 boolean isQueryConfigurationAllowed()
           
 boolean isQueryCriteriaRequired()
           
 boolean isReadOnly()
           
 boolean isUpdateAllowed()
           
 void replaceEntities(Collection<Entity> entities)
          Replaces the given entities in this table model
 void replaceForeignKeyValues(String foreignKeyEntityID, Collection<Entity> newForeignKeyValues)
          For every entity in this table model, replaces the foreign key instance bearing the primary key with the corresponding entity from foreignKeyValues, useful when property values have been changed in the referenced entity that must be reflected in the table model.
 EntityTableModel setBatchUpdateAllowed(boolean batchUpdateAllowed)
           
 EntityTableModel setDetailModel(boolean detailModel)
           
 void setEditModel(EntityEditModel editModel)
          Associates the given edit model with this table model, this enables delete/update functionality via this table model as well as enabling it to react to delete events in the edit model.
 EntityTableModel setFetchCount(int fetchCount)
          Sets the maximum number of records to fetch via the underlying query, a value of -1 means all records should be fetched
 void setForeignKeySearchValues(String referencedEntityID, List<Entity> referenceEntities)
          Refreshes this table model according the the given values by finding the first foreign key property referencing the entity identified by referencedEntityID and setting referenceEntities as the criteria values.
 EntityTableModel setQueryConfigurationAllowed(boolean value)
          Specifies whether or not the underlying query should be configurable
 EntityTableModel setQueryCriteriaRequired(boolean value)
           
 EntityTableModel setReportDataSource(ReportDataWrapper reportDataSource)
          Sets the report data source to use during report generation
 void setSelectedByPrimaryKeys(List<Entity.Key> keys)
          Sets the selected entities according to the primary keys in primaryKeys
 void setSortingDirective(String propertyID, SortingDirective directive, boolean addColumnToSort)
           
 void update(List<Entity> entities)
          Updates the given Entities.
 
Methods inherited from interface org.jminor.common.model.FilteredTableModel
addColumnHiddenListener, addColumnShownListener, addRefreshDoneListener, addRefreshStartedListener, addSelectedIndexListener, addSelectedItemIndex, addSelectedItemIndexes, addSelectionChangedListener, addSortingListener, addTableDataChangedListener, clearSelection, clearSortingState, findNextItemCoordinate, findNextItemCoordinate, getColumnIdentifer, getColumnModel, getFilterModel, getHiddenColumns, getItemAt, getMultipleSelectionState, getSelectedIndex, getSelectedIndexes, getSelectedItem, getSelectedItems, getSelectionCount, getSelectionEmptyState, getSelectionModel, getSortingDirective, getSortingPriority, getTableColumn, indexOf, isColumnVisible, isRegularExpressionSearch, isSelectionEmpty, moveSelectionDown, moveSelectionUp, removeColumnHiddenListener, removeColumnShownListener, removeItem, removeItems, removeRefreshDoneListener, removeRefreshStartedListener, removeSelectedIndexListener, removeSelectionChangedListener, removeSortingListener, removeTableDataChangedListener, selectAll, setColumnVisible, setRegularExpressionSearch, setSelectedItem, setSelectedItemIndex, setSelectedItemIndexes, setSelectedItems, setSortingDirective
 
Methods inherited from interface org.jminor.common.model.FilteredModel
addFilteringListener, contains, filterContents, getAllItems, getFilterCriteria, getFilteredItemCount, getFilteredItems, getVisibleItemCount, getVisibleItems, isFiltered, isVisible, removeFilteringListener, setFilterCriteria
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from interface org.jminor.common.model.Refreshable
clear, refresh
 
Methods inherited from interface org.jminor.framework.client.model.EntityDataProvider
getConnectionProvider, getEntityID
 

Method Detail

getEditModel

EntityEditModel getEditModel()
Returns the edit model associated with this table model, throws a RuntimeExcption in case no edit model has been associated with this table model

Returns:
the edit model associated with this table model
See Also:
setEditModel(EntityEditModel)

hasEditModel

boolean hasEditModel()
Returns:
true if this table model contains a edit model

setEditModel

void setEditModel(EntityEditModel editModel)
Associates the given edit model with this table model, this enables delete/update functionality via this table model as well as enabling it to react to delete events in the edit model. Throws a RuntimeException in case the edit model has been previously set

Parameters:
editModel - the edit model to associate with this table model
See Also:
deleteSelected(), update(java.util.List)

setDetailModel

EntityTableModel setDetailModel(boolean detailModel)
Parameters:
detailModel - if set to true then this table model will not run a query unless a query criteria has been specified
Returns:
this table model instance
See Also:
setQueryCriteriaRequired(boolean)

setForeignKeySearchValues

void setForeignKeySearchValues(String referencedEntityID,
                               List<Entity> referenceEntities)
Refreshes this table model according the the given values by finding the first foreign key property referencing the entity identified by referencedEntityID and setting referenceEntities as the criteria values. If no foreign key property is found this method has no effect.

Parameters:
referencedEntityID - the ID of the master entity
referenceEntities - the entities to use as criteria values
See Also:
isDetailModel()

replaceForeignKeyValues

void replaceForeignKeyValues(String foreignKeyEntityID,
                             Collection<Entity> newForeignKeyValues)
For every entity in this table model, replaces the foreign key instance bearing the primary key with the corresponding entity from foreignKeyValues, useful when property values have been changed in the referenced entity that must be reflected in the table model.

Parameters:
foreignKeyEntityID - the entity ID of the foreign key values
newForeignKeyValues - the foreign key entities

addEntitiesByPrimaryKeys

void addEntitiesByPrimaryKeys(List<Entity.Key> primaryKeys,
                              boolean atFront)
Retrieves the entities identified by the given primary keys and adds them to this table model

Parameters:
primaryKeys - the primary keys
atFront - if true the entities are added to the front

replaceEntities

void replaceEntities(Collection<Entity> entities)
Replaces the given entities in this table model

Parameters:
entities - the entities to replace

isQueryConfigurationAllowed

boolean isQueryConfigurationAllowed()
Returns:
true if the underlying query should be configurable

setQueryConfigurationAllowed

EntityTableModel setQueryConfigurationAllowed(boolean value)
Specifies whether or not the underlying query should be configurable

Parameters:
value - the value
Returns:
this table model instance

getSearchModel

EntityTableSearchModel getSearchModel()
Returns:
the EntityTableSearcher instance used by this table model

isDetailModel

boolean isDetailModel()
Returns:
true if this table model has a master model

isDeleteAllowed

boolean isDeleteAllowed()
Returns:
true if this model allows records to be deleted

isReadOnly

boolean isReadOnly()
Returns:
true if this model is read only or if no edit model has been specified.
See Also:
setEditModel(EntityEditModel)

isUpdateAllowed

boolean isUpdateAllowed()
Returns:
true if this model allows records to be deleted

isBatchUpdateAllowed

boolean isBatchUpdateAllowed()
Returns:
true if this model allows multiple entities to be updated at a time

setBatchUpdateAllowed

EntityTableModel setBatchUpdateAllowed(boolean batchUpdateAllowed)
Parameters:
batchUpdateAllowed - true if this model should allow multiple entities to be updated at a time
Returns:
this EntityTableModel instance

getPropertySummaryModel

PropertySummaryModel getPropertySummaryModel(String propertyID)
Returns the PropertySummaryModel associated with the property identified by propertyID

Parameters:
propertyID - the ID of the property
Returns:
the PropertySummaryModel for the given property ID

getPropertySummaryModel

PropertySummaryModel getPropertySummaryModel(Property property)
Returns the PropertySummaryModel associated with the given property

Parameters:
property - the property
Returns:
the PropertySummaryModel for the given property

getPropertyBackgroundColor

Color getPropertyBackgroundColor(int row,
                                 Property columnProperty)
Parameters:
row - the row for which to retrieve the background color
columnProperty - the column property for which to retrieve the background color
Returns:
the background color for this row and property, specified by the row entity
See Also:
Entity.Definition.setBackgroundColorProvider(org.jminor.framework.domain.Entity.BackgroundColorProvider), EntityTableCellRenderer

getTableColumnProperties

List<Property> getTableColumnProperties()
Returns:
the underlying table column properties

getStatusMessage

String getStatusMessage()
Returns:
a String describing the selected/filtered state of this table model

getFetchCount

int getFetchCount()
Returns the maximum number of records to fetch via the underlying query, by default this returns -1, meaning all records should be fetched

Returns:
the fetch count

setFetchCount

EntityTableModel setFetchCount(int fetchCount)
Sets the maximum number of records to fetch via the underlying query, a value of -1 means all records should be fetched

Parameters:
fetchCount - the fetch count
Returns:
this table model

getSelectionDependencies

Map<String,Collection<Entity>> getSelectionDependencies()
Returns:
a Map containing all entities which depend on the selected entities, where the keys are entityIDs and the value is an array of entities of that type

update

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

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

deleteSelected

void deleteSelected()
                    throws CancelException,
                           DatabaseException
Deletes the selected entities

Throws:
DatabaseException - in case of a database exception
CancelException - in case the user cancels the operation

isQueryCriteriaRequired

boolean isQueryCriteriaRequired()
Returns:
whether to show all underlying entities when no criteria is applied.

setQueryCriteriaRequired

EntityTableModel setQueryCriteriaRequired(boolean value)
Parameters:
value - if set to true then all underlying entities are shown when no criteria is applied, which can be problematic in the case of huge datasets.
Returns:
this table model instance

getEntitiesByPrimaryKeys

List<Entity> getEntitiesByPrimaryKeys(List<Entity.Key> keys)
Finds entities according to the values in keys

Parameters:
keys - the primary key values to use as condition
Returns:
the entities having the primary key values as in keys

setSelectedByPrimaryKeys

void setSelectedByPrimaryKeys(List<Entity.Key> keys)
Sets the selected entities according to the primary keys in primaryKeys

Parameters:
keys - the primary keys of the entities to select

getEntitiesByPropertyValues

Collection<Entity> getEntitiesByPropertyValues(Map<String,Object> values)
Finds entities according to the values of propertyValues

Parameters:
values - the property values to use as condition mapped to their respective propertyIDs
Returns:
the entities having the exact same property values as in properties

getSelectedEntitiesIterator

Iterator<Entity> getSelectedEntitiesIterator()
Returns an Iterator which iterates through the selected entities

Returns:
the iterator used when generating reports
See Also:
getReportDataSource()

getPrimaryKeysOfSelectedEntities

List<Entity.Key> getPrimaryKeysOfSelectedEntities()
Returns:
a list containing the primary keys of the selected entities, if none are selected an empty list is returned

getReportDataSource

ReportDataWrapper getReportDataSource()
Returns an initialized ReportDataWrapper instance, the default implementation returns null.

Returns:
an initialized ReportDataWrapper
See Also:
getSelectedEntitiesIterator()

setReportDataSource

EntityTableModel setReportDataSource(ReportDataWrapper reportDataSource)
Sets the report data source to use during report generation

Parameters:
reportDataSource - the data source
Returns:
this table model instance

getValues

Collection<Object> getValues(Property property,
                             boolean selectedOnly)
Parameters:
property - the property for which to retrieve the values
selectedOnly - if true only values from the selected entities are returned
Returns:
the values of property from the entities in the table model

getEntityByPrimaryKey

Entity getEntityByPrimaryKey(Entity.Key primaryKey)
Parameters:
primaryKey - the primary key to search by
Returns:
the entity with the given primary key from the table model, null if it's not found

indexOf

int indexOf(Entity.Key primaryKey)
Parameters:
primaryKey - the primary key
Returns:
the row index of the entity with the given primary key, -1 if not found

setSortingDirective

void setSortingDirective(String propertyID,
                         SortingDirective directive,
                         boolean addColumnToSort)
Parameters:
propertyID - the propertyID
directive - the sorting directive
addColumnToSort - if false then the sorting state is cleared, otherwise this column is added to the sorted column set according to getSortingPriority()

getSortingDirective

SortingDirective getSortingDirective(String propertyID)
Parameters:
propertyID - the propertyID
Returns:
the sorting directive assigned to the given property column

getBatchUpdateAllowedState

StateObserver getBatchUpdateAllowedState()
Returns:
the state used to determine if batch updating of entities should be enabled
See Also:
isBatchUpdateAllowed()