Transfer version 1.1

transfer.com.sql
Class TransferSelecter

WEB-INF.cftags.component
        extended by transfer.com.sql.AbstractBaseTransfer
            extended by transfer.com.sql.TransferSelecter
Direct Known Subclasses:
TransferSelecter , TransferSelecter , TransferSelecter , TransferSelecter

public class TransferSelecter
extends AbstractBaseTransfer

Selects the data for a Transfer Object


Constructor Summary
init(Datasource datasource, ObjectManager objectManager, TQLConverter tQLConverter, QueryExecutionPool queryExecutionPool, QueryCache queryCache, Transaction transaction)
          Constructor
 
Method Summary
private string appendCollectionColumn(struct columnStruct, Object object, Collection collection)
          appends a collection column if it has a key or an order. returns the property name, if one is added, otherwise return ''
private void appendCompositeKeyForeignKeys(Object object, struct columnStruct)
          appending composite foreign keys to the object, particularly for lazy loading
private void appendCompositeKeyValue(any buffer, string table, string column)
          appends the composite key value to the buffer
private void appendProxiedColumns(struct columnStruct, Object object)
          add the columns we need for proxied collections for ordering and struct values, and composite keys
private struct buildColumnStruct(Object object, [boolean lazyLoaded='false'], [struct columnStruct='[runtime expression]'], [array visitedClasses='[runtime expression]'], [string compositionName=''], [boolean proxied='false'])
          Builds an struct with a key on table, with an array inside of each column, with type and column
private string buildCompositeKeyValue(string tableName, Object object)
          builds the sql for a composite parent key
private string buildConditionSQL(Object object, Condition condition, numeric orderIndex)
          Builds the where statement for a condition
private string buildInitialFromSQL(Object object)
          Builds the initial from SQL
private string buildManyToManyFromSQL(Object object, Object composite, ManyToMany manyToMany, string fromSQL, numeric orderIndex)
          Builds the from SQL from a many to many composition
private string buildManyToOneFromSQL(Object object, Object composite, ManyToOne manyToOne, string fromSQL, numeric orderIndex)
          Builds the from SQL for many to one composition
private string buildOneToManyFromSQL(Object object, Object composite, OneToMany oneToMany, string fromSQL, numeric orderIndex)
          Builds the from SQL for a One to Many SQL
private string buildOrder(any orderBuffer, Collection collection, Object object)
          Builds the ORDER BY part of the sql
private Query buildSQL(Object object, Query query, struct columnStruct, string fromSQL, [string whereSQL=''], [Object originalObject='[runtime expression]'], [string parentCompositeName=''], [Object parentObject='[runtime expression]'], [string parentParentClass=''], [array visitedClasses='[runtime expression]'], [numeric orderIndex='1'], [string compositeName=''], [boolean isArray='false'], [any orderBuffer='[runtime expression]'], [boolean hasCompositeID='[runtime expression]'], [boolean isProxied='false'])
          Builds the SQL via a stringBuffer
private void buildSelect(Query query, Object object, Object parentObject, struct columnStruct, numeric orderIndex, boolean hasCompositeID)
          Builds the column list part of the SELECT for a given object
private Query buildSelectSQL(Object object, [string lazyLoadName])
          Creates the SQL for the Object BO
private boolean concatSeperator(any buffer, boolean isFirst)
          seperates values with commas
private boolean containsCompositeID(Object object, [array visitedClasses='[runtime expression]'])
          do I have a composite id inside the object
private struct createColumnMeta(Property property, [string column='[runtime expression]'])
          Builds the Column meta data. Struct returned with column name (column), and type (type)
private string createTableName(any object, numeric orderIndex)
          Creates a table name from the table and hte orderindex
private array flattenColumnStruct(struct columnStruct)
          returns a flat array of column names, without duplicates
private TQLConverter getTQLConverter()
 query select(Object object, any key, [string lazyLoadName])
          read the object data from the DB, and return it
private void setRequiredProperty(struct args, boolean isProxied, Collection collection)
          sets the required property argument
private void setTQLConverter(TQLConverter TQLConverter)
private boolean tableContainsColumnName(array table, string column)
          if the table contains this column
private any throw(string type, string message, [string detail=''])
          Throws an Exception
private string writeConcat()
          writes concat seperator
private string writeEndConcat()
          writes the end concat seperator
private string writeNULL(string column, string type)
          Overwrite to implement database specific NULL string text.
private string writeStartConcat()
          writes the start concat seperator
 
Methods inherited from class transfer.com.sql.AbstractBaseTransfer
andSeperator, commaSeperator, equalsString, getDatasource, getMethodInvoker, getObjectManager, getQueryCache, getQueryExecutionPool, getTransaction, invokeGetPrimaryKey, isString, mapCompositeKey, mapPrimaryKey, mapSingularKey, nullString, setCompositeKey, setDatasource, setMethodInvoker, setObjectManager, setPrimaryKey, setQueryCache, setQueryExecutionPool, setSingularKey, setTransaction
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init(Datasource datasource, ObjectManager objectManager, TQLConverter tQLConverter, QueryExecutionPool queryExecutionPool, QueryCache queryCache, Transaction transaction)
Constructor

Parameters:
datasource - The datasource BO
objectManager - Need to object manager for making queries
tQLConverter - Converter for {property} statements
queryExecutionPool - the query execution pool
queryCache - the query object cache
transaction
Method Detail

appendCollectionColumn

private string appendCollectionColumn(struct columnStruct, Object object, Collection collection)
appends a collection column if it has a key or an order. returns the property name, if one is added, otherwise return ''

Parameters:
columnStruct - Struct of Arrays defining tables and their columns
object - The BO of the object to build the list to
collection - the collection meta data

appendCompositeKeyForeignKeys

private void appendCompositeKeyForeignKeys(Object object, struct columnStruct)
appending composite foreign keys to the object, particularly for lazy loading

Parameters:
object - The BO of the object to build the list to
columnStruct - Struct of Arrays defining tables and their columns

appendCompositeKeyValue

private void appendCompositeKeyValue(any buffer, string table, string column)
appends the composite key value to the buffer

Parameters:
buffer - the string buffer
table - the name of the table
column - the column to add

appendProxiedColumns

private void appendProxiedColumns(struct columnStruct, Object object)
add the columns we need for proxied collections for ordering and struct values, and composite keys

Parameters:
columnStruct - Struct of Arrays defining tables and their columns
object - The BO of the object to build the list to

buildColumnStruct

private struct buildColumnStruct(Object object, [boolean lazyLoaded='false'], [struct columnStruct='[runtime expression]'], [array visitedClasses='[runtime expression]'], [string compositionName=''], [boolean proxied='false'])
Builds an struct with a key on table, with an array inside of each column, with type and column

Parameters:
object - The BO of the object to build the list to
lazyLoaded - if the SQL is for a lazy populate
columnStruct - Struct of Arrays defining tables and their columns
visitedClasses - Array of class names that have been visited
compositionName - The name of the composition
proxied - whether or not the data is being proxied

buildCompositeKeyValue

private string buildCompositeKeyValue(string tableName, Object object)
builds the sql for a composite parent key

Parameters:
tableName - the name of the table to build against
object - the parent object

buildConditionSQL

private string buildConditionSQL(Object object, Condition condition, numeric orderIndex)
Builds the where statement for a condition

Parameters:
object - The Object that is being created in the collection
condition - The condition
orderIndex - The order index

buildInitialFromSQL

private string buildInitialFromSQL(Object object)
Builds the initial from SQL

Parameters:
object - The BO of the object to build FROM from

buildManyToManyFromSQL

private string buildManyToManyFromSQL(Object object, Object composite, ManyToMany manyToMany, string fromSQL, numeric orderIndex)
Builds the from SQL from a many to many composition

Parameters:
object - The original object
composite - The composite object
manyToMany - The many to many connector
fromSQL - The from SQL already written
orderIndex - The order index of this select

buildManyToOneFromSQL

private string buildManyToOneFromSQL(Object object, Object composite, ManyToOne manyToOne, string fromSQL, numeric orderIndex)
Builds the from SQL for many to one composition

Parameters:
object - The original object
composite - The composite object
manyToOne - The many to many connector
fromSQL - The from SQL already written
orderIndex - The order index of this select

buildOneToManyFromSQL

private string buildOneToManyFromSQL(Object object, Object composite, OneToMany oneToMany, string fromSQL, numeric orderIndex)
Builds the from SQL for a One to Many SQL

Parameters:
object - The original object
composite - The composite object
oneToMany - The one to many connector
fromSQL - The from SQL already written
orderIndex - The order index of this select

buildOrder

private string buildOrder(any orderBuffer, Collection collection, Object object)
Builds the ORDER BY part of the sql

Parameters:
orderBuffer - The java.util.StringBuffer for order bys
collection - The collection that is being created
object - The Object that is being created in the collection

buildSQL

private Query buildSQL(Object object, Query query, struct columnStruct, string fromSQL, [string whereSQL=''], [Object originalObject='[runtime expression]'], [string parentCompositeName=''], [Object parentObject='[runtime expression]'], [string parentParentClass=''], [array visitedClasses='[runtime expression]'], [numeric orderIndex='1'], [string compositeName=''], [boolean isArray='false'], [any orderBuffer='[runtime expression]'], [boolean hasCompositeID='[runtime expression]'], [boolean isProxied='false'])
Builds the SQL via a stringBuffer

Parameters:
object - The BO of the object to build the list to
query - the query object
columnStruct - Struct of Arrays that defines tables and columns
fromSQL - String that contains the from statement
whereSQL - The WHERE clause of the SQL
originalObject - the original object being searched for
parentCompositeName - The paren't composite name
parentObject - The parent object to set the item to
parentParentClass - parent class 2 levels up
visitedClasses - Array of class names that have been visited
orderIndex - The order index of this select
compositeName - The name of the composite structure
isArray - is this memento part of an array?
orderBuffer - java.land.StringBuffer that tracks order by statement
hasCompositeID - whether there is a composite id in the tree
isProxied - whether or not it is proxied

buildSelect

private void buildSelect(Query query, Object object, Object parentObject, struct columnStruct, numeric orderIndex, boolean hasCompositeID)
Builds the column list part of the SELECT for a given object

Parameters:
query - The sql query object
object - The BO of the object to build the list to
parentObject - The parent object to set the item to
columnStruct - Struct of Arrays defining the columns
orderIndex - The order index of this select
hasCompositeID - if it has a composite id in the tree

buildSelectSQL

private Query buildSelectSQL(Object object, [string lazyLoadName])
Creates the SQL for the Object BO

Parameters:
object - The Object BO
lazyLoadName - the name of the lazy load, if there is one, for locking and caching

concatSeperator

private boolean concatSeperator(any buffer, boolean isFirst)
seperates values with commas

Parameters:
buffer - the stringbuffer object object
isFirst - if this is the first request to for the comma

containsCompositeID

private boolean containsCompositeID(Object object, [array visitedClasses='[runtime expression]'])
do I have a composite id inside the object

Parameters:
object - The BO of the object to build the list to
visitedClasses - Array of class names that have been visited

createColumnMeta

private struct createColumnMeta(Property property, [string column='[runtime expression]'])
Builds the Column meta data. Struct returned with column name (column), and type (type)

Parameters:
property - The property to get the type from
column - The column to set

createTableName

private string createTableName(any object, numeric orderIndex)
Creates a table name from the table and hte orderindex

Parameters:
object - The object whose table we need
orderIndex - The order Index

flattenColumnStruct

private array flattenColumnStruct(struct columnStruct)
returns a flat array of column names, without duplicates

Parameters:
columnStruct - Struct of Arrays defining the columns

getTQLConverter

private TQLConverter getTQLConverter()


select

public query select(Object object, any key, [string lazyLoadName])
read the object data from the DB, and return it

Parameters:
object - The Object BO
key - The id key for the data
lazyLoadName - the name of the lazy load, if there is one, for locking and caching

setRequiredProperty

private void setRequiredProperty(struct args, boolean isProxied, Collection collection)
sets the required property argument

Parameters:
args - the argument collection
isProxied - whether or not the composition is proxied
collection - the collection to look at

setTQLConverter

private void setTQLConverter(TQLConverter TQLConverter)

Parameters:
TQLConverter

tableContainsColumnName

private boolean tableContainsColumnName(array table, string column)
if the table contains this column

Parameters:
table - the table meta data
column - the name of the column

throw

private any throw(string type, string message, [string detail=''])
Throws an Exception

Overrides:
throw in class AbstractBaseTransfer
Parameters:
type - The type of exception
message - The message to accompany the exception
detail - The detail message for the exception

writeConcat

private string writeConcat()
writes concat seperator


writeEndConcat

private string writeEndConcat()
writes the end concat seperator


writeNULL

private string writeNULL(string column, string type)
Overwrite to implement database specific NULL string text.

Parameters:
column - The column to write the 'NULL' for
type - The type to write the 'NULL' for

writeStartConcat

private string writeStartConcat()
writes the start concat seperator


Transfer version 1.1