org.jminor.framework.client.model
Class DefaultEntityTableSearchModel

java.lang.Object
  extended by org.jminor.framework.client.model.DefaultEntityTableSearchModel
All Implemented Interfaces:
FilterCriteria<Entity>, Refreshable, EntityDataProvider, EntityTableSearchModel

public class DefaultEntityTableSearchModel
extends Object
implements EntityTableSearchModel, EntityDataProvider

A default EntityTableSearchModel implementation


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jminor.common.model.FilterCriteria
FilterCriteria.AcceptAllCriteria<T>, FilterCriteria.RejectAllCriteria<T>
 
Constructor Summary
DefaultEntityTableSearchModel(String entityID, EntityConnectionProvider connectionProvider, boolean simpleSearch)
          Instantiates a new DefaultEntityTableSearchModel
DefaultEntityTableSearchModel(String entityID, EntityConnectionProvider connectionProvider, boolean simpleSearch, PropertyFilterModelProvider filterModelProvider, PropertySearchModelProvider searchModelProvider)
          Instantiates a new DefaultEntityTableSearchModel
 
Method Summary
 void addFilterStateListener(ActionListener listener)
          
 void clear()
          Clears all data from this refreshable instance
 void clearPropertySearchModels()
          Clears the state of all PropertySearchModels
 boolean containsPropertySearchModel(String propertyID)
          
 Criteria<Property.ColumnProperty> getAdditionalSearchCriteria()
          
 EntityConnectionProvider getConnectionProvider()
          
 String getEntityID()
          
 ColumnSearchModel<Property> getPropertyFilterModel(String propertyID)
          The PropertyFilterModel associated with the property identified by propertyID
 Collection<ColumnSearchModel<Property>> getPropertyFilterModels()
          
 List<ColumnSearchModel<Property>> getPropertyFilterModelsOrdered()
          
 PropertySearchModel<? extends Property.SearchableProperty> getPropertySearchModel(String propertyID)
          
 Collection<PropertySearchModel<? extends Property.SearchableProperty>> getPropertySearchModels()
          
 List<Property.SearchableProperty> getSearchableProperties()
          
 Conjunction getSearchConjunction()
          
 Criteria<Property.ColumnProperty> getSearchCriteria()
          
 StateObserver getSearchStateChangedState()
          
 boolean include(Entity item)
          
 boolean isFilterEnabled(String propertyID)
          
 boolean isSearchEnabled(String propertyID)
          
 boolean isSimpleSearch()
          
 void refresh()
          Performs a refresh
 void removeFilterStateListener(ActionListener listener)
          
 EntityTableSearchModel setAdditionalSearchCriteria(Criteria<Property.ColumnProperty> criteria)
          Sets the additional search criteria, one not based on any individual property criteria
 void setFilterValue(String propertyID, Comparable value)
          Sets the criteria value of the PropertyFilterModel associated with the property identified by propertyID.
 void setSearchConjunction(Conjunction conjunction)
          
 void setSearchEnabled(String propertyID, boolean enabled)
          Enables/disables the search for the given property
 void setSearchModelState()
          Sets the current search model state
 boolean setSearchValues(String propertyID, Collection<?> values)
          Sets the search criteria values of the search model associated with the property identified by propertyID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEntityTableSearchModel

public DefaultEntityTableSearchModel(String entityID,
                                     EntityConnectionProvider connectionProvider,
                                     boolean simpleSearch)
Instantiates a new DefaultEntityTableSearchModel

Parameters:
entityID - the ID of the underlying entity
connectionProvider - a EntityConnectionProvider instance, required if searchableProperties include foreign key properties assumed to belong to the entity identified by entityID
simpleSearch - if true then search panels based on this search model should implement a simplified search

DefaultEntityTableSearchModel

public DefaultEntityTableSearchModel(String entityID,
                                     EntityConnectionProvider connectionProvider,
                                     boolean simpleSearch,
                                     PropertyFilterModelProvider filterModelProvider,
                                     PropertySearchModelProvider searchModelProvider)
Instantiates a new DefaultEntityTableSearchModel

Parameters:
entityID - the ID of the underlying entity
connectionProvider - a EntityConnectionProvider instance, required if searchableProperties include foreign key properties assumed to belong to the entity identified by entityID
simpleSearch - if true then search panels based on this search model should implement a simplified search
filterModelProvider - provides the column filter models for this table search model
searchModelProvider - provides the column search models for this table search model
Method Detail

getEntityID

public final String getEntityID()

Specified by:
getEntityID in interface EntityDataProvider
Specified by:
getEntityID in interface EntityTableSearchModel
Returns:
the ID of the entity this table searcher is based on

getConnectionProvider

public final EntityConnectionProvider getConnectionProvider()

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

isSimpleSearch

public final boolean isSimpleSearch()

Specified by:
isSimpleSearch in interface EntityTableSearchModel
Returns:
true if simple search should be activated

getSearchableProperties

public final List<Property.SearchableProperty> getSearchableProperties()

Specified by:
getSearchableProperties in interface EntityTableSearchModel
Returns:
the properties that are searchable via this searcher

setSearchModelState

public final void setSearchModelState()
Sets the current search model state

Specified by:
setSearchModelState in interface EntityTableSearchModel
See Also:
EntityTableSearchModel.getSearchStateChangedState()

getPropertyFilterModel

public final ColumnSearchModel<Property> getPropertyFilterModel(String propertyID)
The PropertyFilterModel associated with the property identified by propertyID

Specified by:
getPropertyFilterModel in interface EntityTableSearchModel
Parameters:
propertyID - the id of the property for which to retrieve the PropertyFilterModel
Returns:
the PropertyFilterModel for the property with id propertyID

getPropertyFilterModels

public final Collection<ColumnSearchModel<Property>> getPropertyFilterModels()

Specified by:
getPropertyFilterModels in interface EntityTableSearchModel
Returns:
the property filters configured in this table search model

getPropertyFilterModelsOrdered

public final List<ColumnSearchModel<Property>> getPropertyFilterModelsOrdered()

Specified by:
getPropertyFilterModelsOrdered in interface EntityTableSearchModel
Returns:
the PropertyFilterModels in the same order as the columns they represent

include

public final boolean include(Entity item)

Specified by:
include in interface FilterCriteria<Entity>
Parameters:
item - the item
Returns:
true if item should be included, false if it should be filtered

refresh

public final void refresh()
Performs a refresh

Specified by:
refresh in interface Refreshable

clear

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

Specified by:
clear in interface Refreshable

clearPropertySearchModels

public final void clearPropertySearchModels()
Clears the state of all PropertySearchModels

Specified by:
clearPropertySearchModels in interface EntityTableSearchModel

getPropertySearchModels

public final Collection<PropertySearchModel<? extends Property.SearchableProperty>> getPropertySearchModels()

Specified by:
getPropertySearchModels in interface EntityTableSearchModel
Returns:
a list containing the PropertySearchModels configured in this table search model

containsPropertySearchModel

public final boolean containsPropertySearchModel(String propertyID)

Specified by:
containsPropertySearchModel in interface EntityTableSearchModel
Parameters:
propertyID - the id of the property for which to check for the PropertySearchModel
Returns:
true if this EntityTableSearchModel contains a PropertySearchModel associated with the property identified by propertyID

getPropertySearchModel

public final PropertySearchModel<? extends Property.SearchableProperty> getPropertySearchModel(String propertyID)

Specified by:
getPropertySearchModel in interface EntityTableSearchModel
Parameters:
propertyID - the id of the property for which to retrieve the PropertySearchModel
Returns:
the PropertySearchModel associated with the property identified by propertyID

isSearchEnabled

public final boolean isSearchEnabled(String propertyID)

Specified by:
isSearchEnabled in interface EntityTableSearchModel
Parameters:
propertyID - the column propertyID
Returns:
true if the PropertySearchModel behind column with index columnIndex is enabled

isFilterEnabled

public final boolean isFilterEnabled(String propertyID)

Specified by:
isFilterEnabled in interface EntityTableSearchModel
Parameters:
propertyID - column propertyID
Returns:
true if the PropertyFilterModel behind column with index columnIndex is enabled

setSearchValues

public final boolean setSearchValues(String propertyID,
                                     Collection<?> values)
Sets the search criteria values of the search model associated with the property identified by propertyID

Specified by:
setSearchValues in interface EntityTableSearchModel
Parameters:
propertyID - the ID of the property
values - the search criteria values
Returns:
true if the search state changed as a result of this method call, false otherwise

setFilterValue

public final void setFilterValue(String propertyID,
                                 Comparable value)
Sets the criteria value of the PropertyFilterModel associated with the property identified by propertyID.

Specified by:
setFilterValue in interface EntityTableSearchModel
Parameters:
propertyID - the id of the property
value - the criteria value

getSearchCriteria

public final Criteria<Property.ColumnProperty> getSearchCriteria()

Specified by:
getSearchCriteria in interface EntityTableSearchModel
Returns:
the current criteria based on the state of the search models

getAdditionalSearchCriteria

public final Criteria<Property.ColumnProperty> getAdditionalSearchCriteria()

Specified by:
getAdditionalSearchCriteria in interface EntityTableSearchModel
Returns:
any additional search criteria, not based on any individual property criteria

setAdditionalSearchCriteria

public final EntityTableSearchModel setAdditionalSearchCriteria(Criteria<Property.ColumnProperty> criteria)
Sets the additional search criteria, one not based on any individual property criteria

Specified by:
setAdditionalSearchCriteria in interface EntityTableSearchModel
Parameters:
criteria - the criteria
Returns:
this EntityTableSearchModel instance

getSearchConjunction

public final Conjunction getSearchConjunction()

Specified by:
getSearchConjunction in interface EntityTableSearchModel
Returns:
the conjunction to be used when more than one column search criteria is active, the default is Conjunction.AND
See Also:
Conjunction

setSearchConjunction

public final void setSearchConjunction(Conjunction conjunction)

Specified by:
setSearchConjunction in interface EntityTableSearchModel
Parameters:
conjunction - the conjunction to be used when more than one column search criteria is active
See Also:
Conjunction

setSearchEnabled

public final void setSearchEnabled(String propertyID,
                                   boolean enabled)
Enables/disables the search for the given property

Specified by:
setSearchEnabled in interface EntityTableSearchModel
Parameters:
propertyID - the ID of the property for which to enable/disable the search
enabled - if true the search is enabled, otherwise it is disabled

getSearchStateChangedState

public final StateObserver getSearchStateChangedState()

Specified by:
getSearchStateChangedState in interface EntityTableSearchModel
Returns:
a State activated each time the search state differs from the state at last reset
See Also:
EntityTableSearchModel.setSearchModelState()

addFilterStateListener

public final void addFilterStateListener(ActionListener listener)

Specified by:
addFilterStateListener in interface EntityTableSearchModel
Parameters:
listener - a listener notified each time the filter state changes

removeFilterStateListener

public final void removeFilterStateListener(ActionListener listener)

Specified by:
removeFilterStateListener in interface EntityTableSearchModel
Parameters:
listener - the listener to remove