com.taggercat.model
Class DataSource

java.lang.Object
  extended by com.taggercat.model.DataSource
All Implemented Interfaces:
com.taggercat.el.ELPropertyResolver, DataSourceEventListener, java.io.Serializable

public class DataSource
extends java.lang.Object
implements DataSourceEventListener, com.taggercat.el.ELPropertyResolver, java.io.Serializable

Encapsulates a named HNB8 query and it's associated result set, or a child collection of a parent entity.

Obviously, the size this class has gotten out of hand, and it is now horribly too long. We plan to split into two classes, one for parent datasources, and a second one for child data sources. However, we've done a ton of totally free work... so if you don't like this; then offer to fund the time needed, or pitch in yourself, to refactor this into two classes.

See Also:
Serialized Form
 

Nested Class Summary
static class DataSource.PropertyComparator
          The comparator used when sorting child data sources
 
Constructor Summary
DataSource()
          Creates a new data source object.
DataSource(DataSourceInitParameter parameterObject)
           
 
Method Summary
 void addAutoFilterWhereClauseField(java.lang.String columName, java.lang.String[] values)
          Adds a columnName - values term to the autoFilter where clause
 void addDataSourceEventListener(DataSourceEventListener listener)
          Adds a DataSourceEventListener to this data source.
 void addQBFParameter(java.lang.String propertyName, java.lang.String propertyValue)
          Adds a parameter to the QBF criteria.
 void addSelectedRowID(java.lang.String rowID)
          Adds a rowID to the list of selected row IDs.
 void addSortOrderTerm(java.lang.String orderByTerm)
          Adds an additional term to the order by clause.
 java.lang.String applyProfanityFilter(java.lang.String strValue)
           
 void assignDerivations(TCEntity entity, com.taggercat.el.ELContext elContext)
           
 void buildDetachedCriteria(java.lang.String userWhereClause)
          Build a detached criteria, since we need to be able to re-use the same definition later in Auto-Filter type queries.later in Auto-Filter type queries.
 void checkEntityConstraints(TCEntity entity, java.util.Map<java.lang.String,java.lang.Boolean> additionalContextParms)
          Check that the entity is in a state that does not violate any entity level constraints.
 void checkPropertyConstraints(TCEntity entity, java.lang.String propertyName, com.taggercat.el.ELContext elContext, boolean validateOnly)
          Check that the new value does not violate any property level constraints.
 void clearAutoFilterWhereClause()
          Clears the Auto Filter Where clause and fields.
 void clearModfiedFlags()
          Clear all modified and inserted properties
 void clearQBFWhereClause()
          Clears the QBF WHERE clause and fields.
 void clearSelectedRowIDs()
          Clears the selectedRowIDs list.
 void close()
           
 void delete()
          Deletes the current entity from the resultset ( the previous entity becomes the current entity).
 void deleteSelected()
          Deletes selected entities from resultset ( the entity prior to the final deletion becomes current if current entity at time of method call cannot be restored).
 void executeQuery()
          Executes the query on the data source.
 java.util.List<TCEntity> findAll(IResultSetCollection resultset, java.lang.String expression)
          Returns a list of all entities in the current result-set that match the expression.
 java.util.List<TCEntity> findAll(java.lang.String expression)
          Returns a list of all entities in the current result-set that match the expression.
 TCEntity findFirst(java.lang.String expression)
          Finds the first entity in the resultset that returns true for the expression.
 TCEntity first()
          Positions the resultset to first tcEntity or block of rows.
 java.lang.String getAutoFilterField(java.lang.String propertyName)
          Gets the current auto filter where for the specified propertyName, returns null is there not not one set.
 AutoFilterWhereClause getAutoFilterWhere()
          Get the current auto filter where clause object; not the string representation of it.
 java.lang.String getAutoFilterWhereClause()
          Gets the current auto filter where clause, returns null is there not not one set.
 org.hibernate.metadata.ClassMetadata getBaseEntityMetadata()
           
 int getBufferedRowCount()
          Returns the number of rows in the current resultset.
 java.lang.String getCacheRegion()
           
 TCEntity getCurrentEntity()
          Gets the current entity from the resultset.
 org.hibernate.metadata.ClassMetadata getCurrentEntityMetadata()
          Return the Hibernate metadata for the current entity if there is a current entity, otherwise, the metadata for the base entity used by the datasource
 java.lang.String getCurrentEntityName()
          Returns the base entity name this data source represents.
 int getCurrentPageNo()
           
 int getCurrentRowIndex()
          Gets the current entity's index (0-based) in the resultset.
 java.util.List<TCEntity> getDeletedEntities()
           
 org.hibernate.criterion.DetachedCriteria getDetatchedCriteria()
           
 TCEntity getEntity(java.lang.String pkHexCode, boolean makeCurrent)
          Returns a TCEntity instance by PK HexCode, and optionally makes the returned entity current in the resultset.
 TCEntity getEntityById(java.lang.Object id)
          Returns the entity for the specified id.
 TCEntity getEntityByRowId(java.lang.String pkHexCode)
          Returns the entity for the specified tcEntity id.
 int getEntityIndex(TCEntity entity)
          Returns the index of the specified entity.
 org.hibernate.metadata.ClassMetadata getEntityMetadata(java.lang.Class<? extends TCEntity> entityType)
           
 org.hibernate.metadata.ClassMetadata getEntityMetadata(java.lang.String entityTypeClassName)
           
 java.lang.String getEntityName()
          Returns the base entity name this data source represents.
 java.lang.String getEntityShortName()
           
 java.lang.String getHbn8CascadeRules()
           
 java.lang.Object getId(TCEntity entity)
          Returns the Hibernate ID Object for the specified entity.
 java.lang.String getInitialOrderByClause()
           
 java.lang.String getInitialWhereClause()
           
 long getLastAccessed()
           
 int getMaxRows()
           
 DataSourceMode getMode()
          Gets the mode of the data source.
 Model getModel()
          Returns the model object associated with this page's session.
 java.util.List<DataSourceEventListener> getMyEventListeners()
           
 java.lang.String getName()
          Gets the name of the data source.
 java.lang.String getOrderByClause()
          Gets the initial orderByClause.
 java.lang.Integer getPageSize()
           
 java.lang.String getParentAdderMethodName()
           
 java.lang.String getParentCollectionName()
           
 DataSource getParentDataSource()
          Returns the parent data source, or null if there is no parent.
 java.lang.String getParentDataSourceName()
           
 java.lang.String getParentPropertyName()
           
 java.lang.String getParentRowPkHexCode()
           
 java.lang.String getPKHexCode(TCEntity entity)
          Returns a hex encoded value of the primary key.
 int getPreFetchedRowCount()
           
 java.lang.String getProjectionProperties()
           
 java.lang.String getPropertyType(java.lang.String propertyName)
           
 org.apache.commons.beanutils.PropertyUtilsBean getPropertyUtilsBean()
           
 java.lang.String getQBFFieldValue(java.lang.String propertyName)
          Gets current QBF field value mapped to a specified field name.
 DataSourceQBFData getQBFFieldValues()
           
 java.lang.String getQbfWhereClause()
           
 IResultSetCollection<TCEntity> getResultSet()
          Gets this data source's resultset.
<T> java.util.Collection<T>
getResultSet(java.lang.Class<T> dest)
          A somewhat uncool method for getting a typed collection
 int getRowCount()
          Returns the number of rows in the current resultset.
 java.util.Set<java.lang.String> getSelectedRowIDs()
          Returns the current list of selected row IDs.
 java.util.List<SortProperty> getSortedOnProperties()
           
 java.lang.String getSortOrderByClause()
          Gets the orderByClause used in the last sort action.
 long getTimeout()
           
 int getTopRowIndexForCurrentRow(int size)
          Gets the index in the resultset of the top tcEntity in a block of rows that contains the current entity.
 int getTotalPages()
           
 java.util.Set<java.lang.Object> getUniquePropertyValues(java.lang.String propertyName, java.lang.String expression)
          Returns a SortedSet of all unique property values for the specified field for the entities in the current resultset that match the expression.
 java.lang.String getWhereClause()
          Gets the initial Where clause of the data source.
 boolean getYesNoField(java.lang.String propertyName)
          Gets the boolean value of the specified field in the result set's current entity.
 void handleDataSourceEvent(DataSourceEvent event)
          A call-back method that is notified of a data source event.
 void init(Model model, java.lang.String dsn, java.lang.String entityName, java.lang.String initialWhereClause, java.lang.String initialOrderByClause, DataSourceMode mode, java.lang.String parentDataSourceName, java.lang.String scope)
          Initializes this data source.
 void init(Model model, java.lang.String dsn, java.lang.String entityName, java.lang.String initialWhereClause, java.lang.String initialOrderByClause, DataSourceMode mode, java.lang.String parentDataSourceName, java.lang.String scope, int maxRows, boolean prefetchRowCount, java.lang.Integer pageSize)
          Initializes this data source.
 void init(Model model, java.lang.String dsn, java.lang.String entityName, java.lang.String initialWhereClause, java.lang.String initialOrderByClause, DataSourceMode mode, java.lang.String parentDataSourceName, java.lang.String scope, int maxRows, java.lang.Integer pageSize)
          Initializes this data source.
 TCEntity insert()
           
 TCEntity insert(java.lang.Class<? extends TCEntity> newEntityType)
          Inserts new entity into resultset (new entity becomes current).
 java.lang.Object instantiateNewEntityInstance(java.lang.Class<? extends TCEntity> newEntityType)
          Create a new instance of the TCEntity managed by this data source
 boolean isApplicationScope()
           
 boolean isCacheable()
           
 boolean isCurrentRow()
          Returns true if the entity is current.
 boolean isDirty()
          Returns true if this data source is deemed to be in a dirty state of mind.
 boolean isEmpty()
          Returns true if the current resultset is empty.
 boolean isExpired()
           
 boolean isLargeResultSet()
          Did the last query on this data source return a large resultset?
 boolean isPaginated()
           
 boolean isReloadCollection()
           
 boolean isRequestScope()
          Returns true if the requestScope attribute is set.
 boolean isSelected()
          Returns true if the row ID of the current entity in the resultset is in the list of selected row IDs.
 boolean isUsePrefetchRowCount()
           
 TCEntity last()
          Positions the resultset to last entity or block of rows.
 TCEntity next(int size)
          Positions the resultset to next entity or block of rows.
 TCEntity previous(int size)
          Positions the resultset to previous entity or block of rows.
 void refreshParentEntity()
          Refreshes parent data source's current entity (if a parent data source instance exists).
 void reloadCurrentEntity()
          Reloads the current entity from the DS using the Hibernate LockMode.READ
 void removeAutoFilterWhereClauseField(java.lang.String columName)
          Removes a columnName from the autoFilter where clause
 boolean removeDataSourceEventListener(DataSourceEventListener listener)
          Removes a DataSourceEventListener from this data source.
 void removeQBFField(java.lang.String propertyName)
          Removes the current QBF property value mapped to a specified property name.
 void reset()
          Resets this data source to free up its resultset.
 java.lang.Object resolveProperty(java.lang.String name, com.taggercat.el.ELContext elContext)
          This is the call back method registered with the expression evaluator.
 void restoreRepeatingRegionTopRowIndex()
          Restores the top tcEntity index in the ds after the repeating region is completed.
 void save()
          Saves any changed entities back into a Hibernate session, and to the database.
 void saveWithoutNotification()
          Saves this datasource without AFTER_SAVE parent notifications being issued.
 void setAppendQbfWhereClause(boolean appendQBFtoWhereClause)
          Sets the state of the appendQBFtoWhereClause property.
 void setApplicationScope(boolean applicationScope)
           
 void setAutoFilterWhere(AutoFilterWhereClause autoFilterWhereClause)
          Sets a new auto filter where clause object; not the string representation.
 void setCacheable(boolean cacheable)
           
 void setCacheRegion(java.lang.String cacheRegion)
           
 TCEntity setCurrentEntity(int index)
          Sets the current entity in the resultset by index.
 void setCurrentEntity(java.lang.String rowID)
          Sets the current entity in the resultset based on the row ID.
 int setCurrentEntity(TCEntity entity)
          Sets the current entity in the resultset.
 void setCurrentPageNo(int currentPageNo)
           
 void setDirty(boolean dirty)
           
 void setEmptyValuePolicy(int emptyValuePolicy)
          Sets the policy of this data source for property values that have changed to an empty string from a non-empty value.
 void setHbn8CascadeRules(java.lang.String hbn8CascadeRules)
           
 void setLastAccessed(long lastAccessed)
           
 void setMaxRows(int maxRows)
           
 void setMode(DataSourceMode mode)
          Sets the mode of the data source.
 void setModel(Model model)
          Sets the Model that owns this data source.
 void setModified()
          Sets this data source as being modified ( AKA dirty); needs to be saved.
 void setPageSize(java.lang.Integer pageSize)
           
 void setParentAdderMethodName(java.lang.String parentForeignKey)
           
 void setParentCollectionName(java.lang.String parentCollectionName)
           
 void setParentDataSource(DataSource parentDataSource)
          Sets the parent data source
 void setParentModified()
          Recursively call up the parent Hierarchy and set the modified property on parent entities.
 void setParentPropertyName(java.lang.String parentPropertyName)
           
 void setParentRowPkHexCode(java.lang.String parentRowPkHexCode)
           
 void setProjectionProperties(java.lang.String projectionProperties)
           
 void setPropertyObject(TCEntity entity, java.lang.String propertyName, java.lang.Object propertyValue)
          Sets a named property's value for a specified entity.
 boolean setPropertyValue(java.lang.String propertyName, java.lang.String propertyValue, boolean applyDerivations)
          Sets a named property value for current entity.
 boolean setPropertyValue(java.lang.String rowID, java.lang.String propertyName, java.lang.String propertyValue, boolean applyDerivations)
          Sets a named property value for a entity specified with a row ID.
 boolean setPropertyValue(TCEntity entity, java.lang.String propertyName, java.lang.String propertyValue, boolean applyDerivations)
          Sets a named property value for a specified entity.
 boolean setPropertyValue(TCEntity entity, java.lang.String propertyName, java.lang.String propertyValue, boolean applyDerivations, boolean validateOnly, java.lang.String sourceOfValuesExpr)
          Sets a named property's value for a specified entity.
 void setQBFFields(java.util.Map<java.lang.String,java.lang.String> qbfFields, java.lang.String wildCardChar)
          Set the qbf fields map, and rebuilds the QBF where clause.
 void setQBFFieldValue(java.lang.String propertyName, java.lang.String value)
          Sets the current QBF field value mapped to a specified field name.
 void setReloadCollection(boolean reloadCollection)
           
 TCEntity setRepeatingRegionProcessing(int size)
          Sets the isRepeatedRegionProcessing indicator, and the size of the sets the current tcEntity index for restoration after the region has been processed.
 void setRetainSortOrder(boolean state)
          Sets a property to retain the order by clause last used to sort the data source.
 void setSortedOnProperties(java.util.List<SortProperty> sortedOnProperties)
           
 void setTimeout(long timeout)
          Sets the timeout for this datasource to reset its result set
 void setTotalPages(int totalPages)
           
 void setUsePrefetchRowCount(boolean usePrefetchRowCount)
           
 void setWhereClause(java.lang.String where)
          Sets the where clause.
 void sort(java.lang.String orderByTerm)
          Sort the data source with the specified orderByTerm.
 java.lang.String toString()
           
 void undo()
          Undoes all pending changes on the current entity on the data source.
 boolean usePrefetchRowCount()
          Returns true if the dataSource uses prefetchRowCounts.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataSource

public DataSource()
Creates a new data source object.


DataSource

public DataSource(DataSourceInitParameter parameterObject)
           throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

addDataSourceEventListener

public void addDataSourceEventListener(DataSourceEventListener listener)
Adds a DataSourceEventListener to this data source.

Parameters:
listener - DataSourceEventListener instance.

addQBFParameter

public void addQBFParameter(java.lang.String propertyName,
                            java.lang.String propertyValue)
                     throws java.lang.Exception
Adds a parameter to the QBF criteria.

Throws:
java.lang.Exception
Parameters:
propertyName - name of property being set
propertyValue - the new value of property

addSelectedRowID

public void addSelectedRowID(java.lang.String rowID)
Adds a rowID to the list of selected row IDs.

Parameters:
rowID - row ID of entity instance.

setRepeatingRegionProcessing

public TCEntity setRepeatingRegionProcessing(int size)
Sets the isRepeatedRegionProcessing indicator, and the size of the sets the current tcEntity index for restoration after the region has been processed.

Parameters:
size - Number of rows displayed.
Returns:
TCEntity instance for top entity in display.

clearAutoFilterWhereClause

public void clearAutoFilterWhereClause()
Clears the Auto Filter Where clause and fields.


clearQBFWhereClause

public void clearQBFWhereClause()
Clears the QBF WHERE clause and fields. Changes the mode of the datasource to QBF


clearSelectedRowIDs

public void clearSelectedRowIDs()
Clears the selectedRowIDs list.


delete

public void delete()
            throws java.lang.Exception
Deletes the current entity from the resultset ( the previous entity becomes the current entity).

Throws:
java.lang.Exception

deleteSelected

public void deleteSelected()
                    throws java.lang.Exception
Deletes selected entities from resultset ( the entity prior to the final deletion becomes current if current entity at time of method call cannot be restored).

Throws:
java.lang.Exception

restoreRepeatingRegionTopRowIndex

public void restoreRepeatingRegionTopRowIndex()
Restores the top tcEntity index in the ds after the repeating region is completed.


reset

public void reset()
Resets this data source to free up its resultset. Also resets page and row counters. The QBF, selectedRowIds and sort order definitions are not modified. The data source is not removed from the model.


executeQuery

public void executeQuery()
                  throws java.lang.Exception

Executes the query on the data source.

The query is executed using the Criteria API, and also applies to child data sources represented by collections.

Throws:
java.lang.Exception - thrown if query fails

buildDetachedCriteria

public void buildDetachedCriteria(java.lang.String userWhereClause)
                           throws PropertyValueException
Build a detached criteria, since we need to be able to re-use the same definition later in Auto-Filter type queries.later in Auto-Filter type queries.

Throws:
PropertyValueException
Parameters:
userWhereClause -

findAll

public java.util.List<TCEntity> findAll(java.lang.String expression)
                                 throws java.lang.Exception
Returns a list of all entities in the current result-set that match the expression. The location of the currently selected tcEntity is unchanged.

Throws:
java.lang.Exception
Parameters:
expression - the expression to evaluate
Returns:
the located entity; otherwise null

findAll

public java.util.List<TCEntity> findAll(IResultSetCollection resultset,
                                        java.lang.String expression)
                                 throws java.lang.Exception
Returns a list of all entities in the current result-set that match the expression. The location of the currently selected tcEntity is unchanged.

Throws:
java.lang.Exception
Parameters:
expression - the expression to evaluate
resultset - the result set to search
Returns:
the located entity; otherwise null

findFirst

public TCEntity findFirst(java.lang.String expression)
                   throws java.lang.Exception
Finds the first entity in the resultset that returns true for the expression. The located entity is also set as the currently selected tcEntity if found. Otherwise, the tcEntity selection is not changed.

Throws:
java.lang.Exception
Parameters:
expression - the expression to evaluate
Returns:
the located entity; otherwise null

first

public TCEntity first()
               throws java.lang.Exception
Positions the resultset to first tcEntity or block of rows.

Throws:
java.lang.Exception - ModelException
Returns:
TCEntity instance, or null.

getCurrentEntity

public TCEntity getCurrentEntity()
Gets the current entity from the resultset.

Returns:
TCEntity instance, else null if resultset or entity is null.

getCurrentRowIndex

public int getCurrentRowIndex()
Gets the current entity's index (0-based) in the resultset.

Returns:
The current entity's index, else -1 if resultset or entity are null.

getMode

public DataSourceMode getMode()
Gets the mode of the data source.

Returns:
the data source's mode

getName

public java.lang.String getName()
Gets the name of the data source.

Returns:
This data source's name.

getOrderByClause

public java.lang.String getOrderByClause()
Gets the initial orderByClause.

Returns:
The current orderByClause.

getSortOrderByClause

public java.lang.String getSortOrderByClause()
Gets the orderByClause used in the last sort action.

Returns:
The orderByClause used in the last sort action.

setParentDataSource

public void setParentDataSource(DataSource parentDataSource)
Sets the parent data source

Parameters:
parentDataSource - the parentDataSource to set

getParentDataSource

public DataSource getParentDataSource()
Returns the parent data source, or null if there is no parent.

Returns:
the parent DS

getBaseEntityMetadata

public org.hibernate.metadata.ClassMetadata getBaseEntityMetadata()

getCurrentEntityMetadata

public org.hibernate.metadata.ClassMetadata getCurrentEntityMetadata()
Return the Hibernate metadata for the current entity if there is a current entity, otherwise, the metadata for the base entity used by the datasource

Returns:
the Hibernate meta data for the current entity

getEntityMetadata

public org.hibernate.metadata.ClassMetadata getEntityMetadata(java.lang.Class<? extends TCEntity> entityType)

getEntityMetadata

public org.hibernate.metadata.ClassMetadata getEntityMetadata(java.lang.String entityTypeClassName)

getPKHexCode

public java.lang.String getPKHexCode(TCEntity entity)
Returns a hex encoded value of the primary key. If the entity is an inserted entity, then it should have a temporary ID of -1,-2,-3 etc.

Parameters:
entity - the entity to return the hex encoded PK
Returns:
the hex encoded PK

getQBFFieldValue

public java.lang.String getQBFFieldValue(java.lang.String propertyName)
Gets current QBF field value mapped to a specified field name.

Parameters:
propertyName - the name of QBF field
Returns:
value of specified QBF field, else null if no mapping found

setQBFFieldValue

public void setQBFFieldValue(java.lang.String propertyName,
                             java.lang.String value)
Sets the current QBF field value mapped to a specified field name.

Parameters:
propertyName - then name of QBF property.
value - the value to set

removeQBFField

public void removeQBFField(java.lang.String propertyName)
Removes the current QBF property value mapped to a specified property name.

Parameters:
propertyName - the name of QBF field to remove

getResultSet

public IResultSetCollection<TCEntity> getResultSet()
Gets this data source's resultset.

Returns:
This data source's resultset, else null if query or resultset null.

getEntity

public TCEntity getEntity(java.lang.String pkHexCode,
                          boolean makeCurrent)
                   throws java.lang.Exception
Returns a TCEntity instance by PK HexCode, and optionally makes the returned entity current in the resultset.

Throws:
java.lang.Exception - ModelException
Parameters:
pkHexCode - the row ID
makeCurrent - Set to true to make the returned entity current in the resultset.
Returns:
TCEntity instance specified by rowID, else null if resultset is null or a matching entity cannot be found.

getRowCount

public int getRowCount()
Returns the number of rows in the current resultset.

Returns:
the number of rows in the current resultset

getBufferedRowCount

public int getBufferedRowCount()
Returns the number of rows in the current resultset.

Returns:
the number of rows in the current resultset.

getEntityName

public java.lang.String getEntityName()
Returns the base entity name this data source represents.

Returns:
the entity name

getCurrentEntityName

public java.lang.String getCurrentEntityName()
Returns the base entity name this data source represents.

Returns:
the entity name

getEntityById

public TCEntity getEntityById(java.lang.Object id)
Returns the entity for the specified id. Where the id Hibernate ID and not not the PKHexCode.

Parameters:
id -
Returns:
the entity if located, otherwise null

getEntityIndex

public int getEntityIndex(TCEntity entity)
Returns the index of the specified entity.

Parameters:
entity -
Returns:
the index of the entity

getEntityByRowId

public TCEntity getEntityByRowId(java.lang.String pkHexCode)
Returns the entity for the specified tcEntity id. Where the id is the tcEntity PK in its hex encoded representation.

Parameters:
pkHexCode -
Returns:
the entity if located, otherwise null

getSelectedRowIDs

public java.util.Set<java.lang.String> getSelectedRowIDs()
Returns the current list of selected row IDs. Where the selected record IDs are typically set with a series of check boxes on a JSP page.

Returns:
the current List, and null if there are no selected IDs

getSortedOnProperties

public java.util.List<SortProperty> getSortedOnProperties()
Returns:
the sortedOnProperties

setSortedOnProperties

public void setSortedOnProperties(java.util.List<SortProperty> sortedOnProperties)
Parameters:
sortedOnProperties - the sortedOnProperties to set

getTopRowIndexForCurrentRow

public int getTopRowIndexForCurrentRow(int size)
Gets the index in the resultset of the top tcEntity in a block of rows that contains the current entity.

Parameters:
size - Number of rows displayed.
Returns:
Index of the top entity.

getWhereClause

public java.lang.String getWhereClause()
Gets the initial Where clause of the data source.

Returns:
This data source's Where clause.

getYesNoField

public boolean getYesNoField(java.lang.String propertyName)
Gets the boolean value of the specified field in the result set's current entity.
Specifically applicable to Boolean or Yes/No fields.

Parameters:
propertyName - the property name to get the value for
Returns:
the specified property's value as a boolean, null = false.

handleDataSourceEvent

public void handleDataSourceEvent(DataSourceEvent event)
                           throws java.lang.Exception
A call-back method that is notified of a data source event.

Specified by:
handleDataSourceEvent in interface DataSourceEventListener
Throws:
java.lang.Exception - ModelException
Parameters:
event - DataSourceEvent instance.

isDirty

public boolean isDirty()
Returns true if this data source is deemed to be in a dirty state of mind.

Returns:
true indicates that there are unsaved changes, else false.

init

public void init(Model model,
                 java.lang.String dsn,
                 java.lang.String entityName,
                 java.lang.String initialWhereClause,
                 java.lang.String initialOrderByClause,
                 DataSourceMode mode,
                 java.lang.String parentDataSourceName,
                 java.lang.String scope)
          throws java.lang.Exception
Initializes this data source.

Throws:
java.lang.Exception - thrown if query execution fails
Parameters:
model - The Model instance that owns this data source instance.
dsn - data source name.
entityName - the Hibernate (entity) name
initialWhereClause - "WHERE" clause for query.
initialOrderByClause - "ORDERBY" clause for query.
mode - If equal to "qbf", the query is not executed during this method call (used by QBF-style data sources to delay query execution).
parentDataSourceName - Name of the parent data source (can be null for no parent).

init

public void init(Model model,
                 java.lang.String dsn,
                 java.lang.String entityName,
                 java.lang.String initialWhereClause,
                 java.lang.String initialOrderByClause,
                 DataSourceMode mode,
                 java.lang.String parentDataSourceName,
                 java.lang.String scope,
                 int maxRows,
                 java.lang.Integer pageSize)
          throws java.lang.Exception
Initializes this data source.

Throws:
java.lang.Exception - thrown if query execution fails
Parameters:
model - The Model instance that owns this data source instance.
dsn - data source name.
entityName - the Hibernate (entity) name
initialWhereClause - "WHERE" clause for query
initialOrderByClause - "ORDERBY" clause for query
mode - If equal to "qbf", query is not executed during this method call (used by QBF-style data sources to delay query execution).
parentDataSourceName - the name of the parent data source (can be null for no parent)
maxRows - the maximum Rows to read on the initial fetch.

init

public void init(Model model,
                 java.lang.String dsn,
                 java.lang.String entityName,
                 java.lang.String initialWhereClause,
                 java.lang.String initialOrderByClause,
                 DataSourceMode mode,
                 java.lang.String parentDataSourceName,
                 java.lang.String scope,
                 int maxRows,
                 boolean prefetchRowCount,
                 java.lang.Integer pageSize)
          throws java.lang.Exception
Initializes this data source.

Throws:
java.lang.Exception - thrown if query execution fails
Parameters:
model - The Model instance that owns this data source instance.
dsn - data source name.
entityName - the Hibernate entity name
initialWhereClause - "WHERE" clause for query.
initialOrderByClause - "ORDERBY" clause for query.
mode - If equal to "qbf", the query is not executed during this method call (used by QBF-style data sources to delay query execution).
parentDataSourceName - Name of the parent data source (can be null for no parent).
maxRows - the maximum Rows to read on the initial fetch.
prefetchRowCount - set true to have the ds pre-fetch the entity count

insert

public TCEntity insert()
                throws java.lang.Exception
Throws:
java.lang.Exception

insert

public TCEntity insert(java.lang.Class<? extends TCEntity> newEntityType)
                throws java.lang.Exception
Inserts new entity into resultset (new entity becomes current).

Throws:
java.lang.Exception - ModelException
Returns:
the newly inserted entity

instantiateNewEntityInstance

public java.lang.Object instantiateNewEntityInstance(java.lang.Class<? extends TCEntity> newEntityType)
                                              throws java.lang.Exception
Create a new instance of the TCEntity managed by this data source

Throws:
java.lang.Exception
Returns:
the new entity instance

isCurrentRow

public boolean isCurrentRow()
Returns true if the entity is current.


isEmpty

public boolean isEmpty()
Returns true if the current resultset is empty.

Returns:
true if the current resultset is empty

isLargeResultSet

public boolean isLargeResultSet()
Did the last query on this data source return a large resultset? Where a large resultset is defined as one exceeding the max rows.

Returns:
the data source's mode

isRequestScope

public boolean isRequestScope()
Returns true if the requestScope attribute is set.

Returns:
true if reset

isSelected

public boolean isSelected()
Returns true if the row ID of the current entity in the resultset is in the list of selected row IDs.

Returns:
true if the row ID of the current resultset entity is in the list of selected row IDs, else false.

last

public TCEntity last()
              throws java.lang.Exception
Positions the resultset to last entity or block of rows.

Throws:
java.lang.Exception - ModelException
Returns:
TCEntity instance, or null.

next

public TCEntity next(int size)
              throws java.lang.Exception
Positions the resultset to next entity or block of rows.

Throws:
java.lang.Exception - ModelException
Parameters:
size - Number of rows displayed.
Returns:
TCEntity instance, or null.

previous

public TCEntity previous(int size)
                  throws java.lang.Exception
Positions the resultset to previous entity or block of rows.

Throws:
java.lang.Exception - ModelException
Parameters:
size - the number of rows displayed
Returns:
the TCEntity instance, or null

refreshParentEntity

public void refreshParentEntity()
                         throws java.lang.Exception
Refreshes parent data source's current entity (if a parent data source instance exists). This method is typically called after an insertion, update, or deletion in a child data source, since these changes can potentially alter the parent entity's derived fields (e.g. a count of child rows). This method is recursive; rows are refreshed upwards from the data source instance on which this method is called, since each refreshed entity can potentially alter a higher-level parent data source's current entity.

Throws:
java.lang.Exception

removeDataSourceEventListener

public boolean removeDataSourceEventListener(DataSourceEventListener listener)
Removes a DataSourceEventListener from this data source.

Parameters:
listener - DataSourceEventListener instance.
Returns:
true if listener was present, else false .

save

public void save()
          throws java.lang.Exception
Saves any changed entities back into a Hibernate session, and to the database. Due to the way Hibernate works, we need to potentially recursively call up the parent chain and add the parent objects to the session before we can add any child object. This is additionally complicated because the actual processing depends upon how the cascade rules are specified in the Hibernate mappings. In the case of parent-child related data sources (collections), the transaction is controlled by the originating data source that the save() method was called on.

Throws:
java.lang.Exception

saveWithoutNotification

public void saveWithoutNotification()
                             throws java.lang.Exception,
                                    ModelException
Saves this datasource without AFTER_SAVE parent notifications being issued.

Throws:
java.lang.Exception
ModelException

clearModfiedFlags

public void clearModfiedFlags()
                       throws java.lang.Exception
Clear all modified and inserted properties

Throws:
java.lang.Exception

close

public void close()

setAppendQbfWhereClause

public void setAppendQbfWhereClause(boolean appendQBFtoWhereClause)
Sets the state of the appendQBFtoWhereClause property.

Parameters:
appendQBFtoWhereClause - if true ( default ) QBF where clause is appended to the main where clause.

setCurrentEntity

public void setCurrentEntity(java.lang.String rowID)
                      throws java.lang.Exception
Sets the current entity in the resultset based on the row ID.

Throws:
java.lang.Exception - ModelException
Parameters:
rowID - row ID of entity to make current.

setCurrentEntity

public int setCurrentEntity(TCEntity entity)
                     throws java.lang.Exception
Sets the current entity in the resultset. DataSourceEvent Listeners are notified.

Throws:
java.lang.Exception - ModelException
Parameters:
entity - the entity to make current
Returns:
the new current index

setCurrentEntity

public TCEntity setCurrentEntity(int index)
                          throws java.lang.Exception
Sets the current entity in the resultset by index. DataSourceEvent Listeners are notified.

Throws:
java.lang.Exception
Parameters:
index - the index of the entity to make current
Returns:
the TCEntity at the specified index

setPropertyValue

public boolean setPropertyValue(java.lang.String propertyName,
                                java.lang.String propertyValue,
                                boolean applyDerivations)
                         throws java.lang.IllegalArgumentException,
                                PropertyValueException
Sets a named property value for current entity.

Throws:
java.lang.IllegalArgumentException - Description of the Exception
PropertyValueException
Parameters:
propertyName - name of property being set
propertyValue - the new value of property
applyDerivations - set true to immediately apply derivations
Returns:
true if the property was actually changed

setPropertyValue

public boolean setPropertyValue(java.lang.String rowID,
                                java.lang.String propertyName,
                                java.lang.String propertyValue,
                                boolean applyDerivations)
                         throws java.lang.Exception
Sets a named property value for a entity specified with a row ID.

Throws:
java.lang.IllegalArgumentException - Description of the Exception
java.lang.Exception
Parameters:
rowID - row ID.
propertyName - name of property being set
propertyValue - the new value of property
applyDerivations - set true to immediately apply derivations
Returns:
true if the property value was changed

setPropertyValue

public boolean setPropertyValue(TCEntity entity,
                                java.lang.String propertyName,
                                java.lang.String propertyValue,
                                boolean applyDerivations)
                         throws java.lang.IllegalArgumentException,
                                PropertyValueException
Sets a named property value for a specified entity.

Throws:
java.lang.IllegalArgumentException - Description of the Exception
PropertyValueException
Parameters:
entity - the TCEntity to update.
propertyName - name of property being set
propertyValue - the new value of property
applyDerivations - set to true to immediately apply derivations
Returns:
true if the property was modified

setPropertyValue

public boolean setPropertyValue(TCEntity entity,
                                java.lang.String propertyName,
                                java.lang.String propertyValue,
                                boolean applyDerivations,
                                boolean validateOnly,
                                java.lang.String sourceOfValuesExpr)
                         throws java.lang.IllegalArgumentException,
                                PropertyValueException
Sets a named property's value for a specified entity.

Throws:
java.lang.IllegalArgumentException - Description of the Exception
PropertyValueException
Parameters:
entity - the TCEntity to update.
propertyName - name of property being set
propertyValue - the new value of property
applyDerivations - set to true to immediately apply derivations
validateOnly - set to true to if this call is only used to apply validation constraints
sourceOfValuesExpr - the EL expression where the source values can be looked up from, applies to association and property references
Returns:
true if the property was modified

applyProfanityFilter

public java.lang.String applyProfanityFilter(java.lang.String strValue)

checkPropertyConstraints

public void checkPropertyConstraints(TCEntity entity,
                                     java.lang.String propertyName,
                                     com.taggercat.el.ELContext elContext,
                                     boolean validateOnly)
                              throws PropertyValueException
Check that the new value does not violate any property level constraints. If a constraint condition evaluates to false, then an exception is raised. The field's new value is read by the expression evaluator before it is actually assigned to the field.

Throws:
PropertyValueException
Parameters:
entity - the entity to check
propertyName - the property name being checked
elContext - additional values for the expression evaluator - including new value, old value, and target entity
validateOnly - is this call only to validate the value when in an Ajax validation cycle

assignDerivations

public void assignDerivations(TCEntity entity,
                              com.taggercat.el.ELContext elContext)
                       throws PropertyValueException
Throws:
PropertyValueException

checkEntityConstraints

public void checkEntityConstraints(TCEntity entity,
                                   java.util.Map<java.lang.String,java.lang.Boolean> additionalContextParms)
                            throws java.lang.Exception
Check that the entity is in a state that does not violate any entity level constraints. If a constraint condition evaluates to false, then an exception is raised.

Throws:
java.lang.Exception
Parameters:
entity - the entity to check
additionalContextParms - any additional context parameters

setPropertyObject

public void setPropertyObject(TCEntity entity,
                              java.lang.String propertyName,
                              java.lang.Object propertyValue)
                       throws java.lang.IllegalArgumentException,
                              PropertyValueException
Sets a named property's value for a specified entity. This method expects that the value object corresponds to type of the property. Use the version of this method that takes a String property value to convert string arguments to the correct type.

Throws:
java.lang.IllegalArgumentException - Description of the Exception
PropertyValueException
Parameters:
entity - the TCEntity to update.
propertyName - the property name being set
propertyValue - the property value being set

getPropertyType

public java.lang.String getPropertyType(java.lang.String propertyName)

getUniquePropertyValues

public java.util.Set<java.lang.Object> getUniquePropertyValues(java.lang.String propertyName,
                                                               java.lang.String expression)
                                                        throws java.lang.Exception
Returns a SortedSet of all unique property values for the specified field for the entities in the current resultset that match the expression. The location of the currently selected tcEntity is unchanged.

Throws:
java.lang.Exception
Parameters:
expression - the expression to evaluate
Returns:
the located entity; otherwise null

setMode

public void setMode(DataSourceMode mode)
Sets the mode of the data source.

Parameters:
mode - the mode for the ds

setModel

public void setModel(Model model)
Sets the Model that owns this data source.

Parameters:
model - the model

setWhereClause

public void setWhereClause(java.lang.String where)
Sets the where clause.

Parameters:
where - the new initial where clause

setRetainSortOrder

public void setRetainSortOrder(boolean state)
Sets a property to retain the order by clause last used to sort the data source. The default is false. If set true, then initial sort order value specified in the data source tag is used when the data source query is re-executed.

Parameters:
state - set true to have the sort order of the last sort action used for subsequent queries.

sort

public void sort(java.lang.String orderByTerm)
          throws java.lang.Exception
Sort the data source with the specified orderByTerm.
If there is a previous orderByTerm of the same property as the new term, then existing one has its direction toggled.

Throws:
java.lang.Exception
Parameters:
orderByTerm - the new orderByClause

addSortOrderTerm

public void addSortOrderTerm(java.lang.String orderByTerm)
                      throws java.lang.Exception
Adds an additional term to the order by clause.

Throws:
java.lang.Exception
Parameters:
orderByTerm -

reloadCurrentEntity

public void reloadCurrentEntity()
                         throws java.lang.Exception
Reloads the current entity from the DS using the Hibernate LockMode.READ

Throws:
java.lang.Exception

undo

public void undo()
          throws java.lang.Exception
Undoes all pending changes on the current entity on the data source.

Throws:
java.lang.Exception - ModelException

usePrefetchRowCount

public boolean usePrefetchRowCount()
Returns true if the dataSource uses prefetchRowCounts.

Returns:
true if usePrefetchRowCount is on

getModel

public Model getModel()
Returns the model object associated with this page's session.

Returns:
the model object

addAutoFilterWhereClauseField

public void addAutoFilterWhereClauseField(java.lang.String columName,
                                          java.lang.String[] values)
Adds a columnName - values term to the autoFilter where clause

Parameters:
columName - the column name to add
values - the values for this column

removeAutoFilterWhereClauseField

public void removeAutoFilterWhereClauseField(java.lang.String columName)
Removes a columnName from the autoFilter where clause

Parameters:
columName -

getAutoFilterWhereClause

public java.lang.String getAutoFilterWhereClause()
Gets the current auto filter where clause, returns null is there not not one set.


getAutoFilterField

public java.lang.String getAutoFilterField(java.lang.String propertyName)
Gets the current auto filter where for the specified propertyName, returns null is there not not one set.


resolveProperty

public java.lang.Object resolveProperty(java.lang.String name,
                                        com.taggercat.el.ELContext elContext)
                                 throws java.lang.IllegalArgumentException
This is the call back method registered with the expression evaluator. The EL calls this method for all terms of the expression that have a dot delimited name.
The dot delimited name is assumed to be of the form dsn.field or that of a scope prefixed variable:
Where the prefix name is one of:
Examples:

 customer.Name request.orderDate session.user page.isValid

 
The attribute on the scope variables may have been added with the TCSet, TCOut etc. tags or with any other means.

Specified by:
resolveProperty in interface com.taggercat.el.ELPropertyResolver
Throws:
java.lang.IllegalArgumentException
Parameters:
name - the dot delimited name of the term to resolve, eg, customer.Name
elContext - the context values
Returns:
the object representing the named value

setQBFFields

public void setQBFFields(java.util.Map<java.lang.String,java.lang.String> qbfFields,
                         java.lang.String wildCardChar)
                  throws java.lang.Exception
Set the qbf fields map, and rebuilds the QBF where clause.

Throws:
java.lang.Exception
Parameters:
qbfFields - the new qbfFields
wildCardChar - the wildCardChar if any

setAutoFilterWhere

public void setAutoFilterWhere(AutoFilterWhereClause autoFilterWhereClause)
Sets a new auto filter where clause object; not the string representation.

Parameters:
autoFilterWhereClause -

getAutoFilterWhere

public AutoFilterWhereClause getAutoFilterWhere()
Get the current auto filter where clause object; not the string representation of it.


getMaxRows

public int getMaxRows()
Returns:
Returns the maxRows.

setMaxRows

public void setMaxRows(int maxRows)
Parameters:
maxRows - The maxRows to set.

getMyEventListeners

public java.util.List<DataSourceEventListener> getMyEventListeners()
Returns:
Returns the myEventListeners.

getInitialOrderByClause

public java.lang.String getInitialOrderByClause()
Returns:
Returns the initialOrderByClause.

getId

public java.lang.Object getId(TCEntity entity)
Returns the Hibernate ID Object for the specified entity.

Parameters:
entity -
Returns:
the Hibernate ID Object for the specified entity

getInitialWhereClause

public java.lang.String getInitialWhereClause()
Returns:
Returns the initialWhereClause.

getPreFetchedRowCount

public int getPreFetchedRowCount()
Returns:
Returns the preFetchedRowCount.

getQBFFieldValues

public DataSourceQBFData getQBFFieldValues()
Returns:
Returns the DataSourceQBFData.

setEmptyValuePolicy

public void setEmptyValuePolicy(int emptyValuePolicy)
Sets the policy of this data source for property values that have changed to an empty string from a non-empty value. Values can be: EVP_SET_TO_NULL sets the field to null ( assuming that it is nullable ) EVP_SET_TO_ZERO sets the field value to 0 for numeric fields, and the current date for dates

Parameters:
emptyValuePolicy -

getQbfWhereClause

public java.lang.String getQbfWhereClause()
Returns:
Returns the String representation qbfWhereClause .

getParentCollectionName

public java.lang.String getParentCollectionName()
Returns:
Returns the parentCollectionName that this data source represents.

setParentCollectionName

public void setParentCollectionName(java.lang.String parentCollectionName)
Parameters:
parentCollectionName - The parentCollectionName to set.

setParentModified

public void setParentModified()
Recursively call up the parent Hierarchy and set the modified property on parent entities.


getParentAdderMethodName

public java.lang.String getParentAdderMethodName()

setParentAdderMethodName

public void setParentAdderMethodName(java.lang.String parentForeignKey)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getProjectionProperties

public java.lang.String getProjectionProperties()

setProjectionProperties

public void setProjectionProperties(java.lang.String projectionProperties)

getPropertyUtilsBean

public org.apache.commons.beanutils.PropertyUtilsBean getPropertyUtilsBean()
Returns:
the propertyUtilsBean

isPaginated

public boolean isPaginated()

setDirty

public void setDirty(boolean dirty)
Parameters:
dirty - the dirty state to set

setModified

public void setModified()
Sets this data source as being modified ( AKA dirty); needs to be saved.


getParentPropertyName

public java.lang.String getParentPropertyName()

setParentPropertyName

public void setParentPropertyName(java.lang.String parentPropertyName)

getHbn8CascadeRules

public java.lang.String getHbn8CascadeRules()

setHbn8CascadeRules

public void setHbn8CascadeRules(java.lang.String hbn8CascadeRules)

getParentRowPkHexCode

public java.lang.String getParentRowPkHexCode()

setParentRowPkHexCode

public void setParentRowPkHexCode(java.lang.String parentRowPkHexCode)

isApplicationScope

public boolean isApplicationScope()

setApplicationScope

public void setApplicationScope(boolean applicationScope)

getDetatchedCriteria

public org.hibernate.criterion.DetachedCriteria getDetatchedCriteria()

getParentDataSourceName

public java.lang.String getParentDataSourceName()

getDeletedEntities

public java.util.List<TCEntity> getDeletedEntities()

getEntityShortName

public java.lang.String getEntityShortName()

isCacheable

public boolean isCacheable()

setCacheable

public void setCacheable(boolean cacheable)

getCacheRegion

public java.lang.String getCacheRegion()

setCacheRegion

public void setCacheRegion(java.lang.String cacheRegion)

isUsePrefetchRowCount

public boolean isUsePrefetchRowCount()
Returns:
the usePrefetchRowCount

setUsePrefetchRowCount

public void setUsePrefetchRowCount(boolean usePrefetchRowCount)
Parameters:
usePrefetchRowCount - the usePrefetchRowCount to set

getTimeout

public long getTimeout()
Returns:
the timeout in seconds

setTimeout

public void setTimeout(long timeout)
Sets the timeout for this datasource to reset its result set

Parameters:
timeout - the timeout to set in Seconds; set to 0 to never expire

getLastAccessed

public long getLastAccessed()
Returns:
the lastAccessed

setLastAccessed

public void setLastAccessed(long lastAccessed)
Parameters:
lastAccessed - the lastAccessed to set

isExpired

public boolean isExpired()

getPageSize

public java.lang.Integer getPageSize()

setPageSize

public void setPageSize(java.lang.Integer pageSize)

getTotalPages

public int getTotalPages()

setTotalPages

public void setTotalPages(int totalPages)

getCurrentPageNo

public int getCurrentPageNo()

setCurrentPageNo

public void setCurrentPageNo(int currentPageNo)

isReloadCollection

public boolean isReloadCollection()

setReloadCollection

public void setReloadCollection(boolean reloadCollection)

getResultSet

public <T> java.util.Collection<T> getResultSet(java.lang.Class<T> dest)
A somewhat uncool method for getting a typed collection

Type Parameters:
T - the type to cast the collection into
Parameters:
dest - the type to convert the collection into
Returns:
the cast typed collection