com.instantbank.component.job.util
Class AuxGenerateSQLtext

java.lang.Object
  |
  +--com.instantbank.component.job.util.AuxGenerateSQLtext
All Implemented Interfaces:
java.io.Serializable

public class AuxGenerateSQLtext
extends java.lang.Object
implements java.io.Serializable

Auxiliary Class that supports SQL sentence generation

Author:
InstantBank (Consuelo Franky)
See Also:
Serialized Form

Field Summary
private  Debug debug
           
private  java.lang.String rootType
          fixed rootType for systemAlias and systemFields attributes
private  java.util.Hashtable systemAlias
          memory representation of system alias key: tableAlias (String), value: Alias element
private  java.util.Hashtable systemFields
          memory representation of system fields for current company key: fieldIdLong (Long), value: Field element
 
Constructor Summary
AuxGenerateSQLtext(java.util.Hashtable systemFields, java.util.Hashtable systemAlias, java.lang.String rootType)
          Constructor for the AuxGenerateSQLtext object
 
Method Summary
 java.lang.String alias(long fieldId)
          Finds tableAlias corresponding to a fieldId
 java.lang.String beginSELECT()
          Builds beginning of SELECT part according to rootType
 JoinElement buildJoinElement(java.lang.String alias)
          Builds a JoinElement corresponding to an alias
 java.lang.String builtTable(java.lang.String alias)
          Finds builtTable corresponding to an alias
 java.lang.String category(java.lang.String alias)
          Finds fieldCategory corresponding to an alias
 java.lang.String direction(java.lang.String direction)
          Tranforms a direction of DatabaseNames.LETT_JOB_ORDER in a SQL direction
 java.lang.String endWHERE(java.lang.String companyId)
          Builds ending condition of WHERE part according to rootType
 java.lang.String fieldColumn(long fieldId)
          Finds fieldColumn corresponding to a fieldId
 int findAlias(java.util.ArrayList participantTables, java.lang.String alias)
          Finds index of alias in the list of participant tables of the job SQL sentence
 int findParent(java.util.ArrayList joinList, java.lang.String alias)
          Finds index of parent of an alias in the join list of the job SQL sentence
 java.lang.String parentTableAlias(java.lang.String alias)
          Finds ParentTableAlias corresponding to an alias
 java.lang.String realTable(java.lang.String alias)
          Finds realTable corresponding to an alias
 java.lang.String rename(long fieldId)
          Builds output name of a field in the SELECT
 java.lang.String rootParticipant()
          Finds tableAlias of root table according to rootType
 java.lang.String value(java.lang.String value, java.lang.String ruleOperator, long fieldId)
          Tranforms a value of DatabaseNames.LETT_JOB_WHERE in a SQL value
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

rootType

private java.lang.String rootType
fixed rootType for systemAlias and systemFields attributes

systemAlias

private java.util.Hashtable systemAlias
memory representation of system alias key: tableAlias (String), value: Alias element

systemFields

private java.util.Hashtable systemFields
memory representation of system fields for current company key: fieldIdLong (Long), value: Field element

debug

private Debug debug
Constructor Detail

AuxGenerateSQLtext

public AuxGenerateSQLtext(java.util.Hashtable systemFields,
                          java.util.Hashtable systemAlias,
                          java.lang.String rootType)
Constructor for the AuxGenerateSQLtext object
Parameters:
systemFields - values of system fields for current company
systemAlias - values of system alias
rootType - fixed rootType for systemAlias and systemFields
Method Detail

beginSELECT

public java.lang.String beginSELECT()
Builds beginning of SELECT part according to rootType
Returns:
beginning string of SELECT

alias

public java.lang.String alias(long fieldId)
Finds tableAlias corresponding to a fieldId
Parameters:
fieldId - unique code of field
Returns:
name of table alias

fieldColumn

public java.lang.String fieldColumn(long fieldId)
Finds fieldColumn corresponding to a fieldId
Parameters:
fieldId - unique code of field
Returns:
column name corresponding to field

rename

public java.lang.String rename(long fieldId)
Builds output name of a field in the SELECT
Parameters:
fieldId - unique code of field
Returns:
output name of the field

rootParticipant

public java.lang.String rootParticipant()
Finds tableAlias of root table according to rootType
Returns:
name of table alias corresponding to root table

findAlias

public int findAlias(java.util.ArrayList participantTables,
                     java.lang.String alias)
Finds index of alias in the list of participant tables of the job SQL sentence
Parameters:
participantTables - list of participant tables in the job SQL sentence; elements of type ParticipantTable
alias - table alias to search
Returns:
< 0 if not found index >=0 if found

buildJoinElement

public JoinElement buildJoinElement(java.lang.String alias)
Builds a JoinElement corresponding to an alias
Parameters:
alias - name of table alias
Returns:
instance of type JoinElement

findParent

public int findParent(java.util.ArrayList joinList,
                      java.lang.String alias)
Finds index of parent of an alias in the join list of the job SQL sentence
Parameters:
joinList - join list of the job SQL sentence; elements of type JoinElement
alias - name of table alias
Returns:
< 0 if not found index >=0 if found

parentTableAlias

public java.lang.String parentTableAlias(java.lang.String alias)
Finds ParentTableAlias corresponding to an alias
Parameters:
alias - name of table alias
Returns:
alias of parent table for join

value

public java.lang.String value(java.lang.String value,
                              java.lang.String ruleOperator,
                              long fieldId)
Tranforms a value of DatabaseNames.LETT_JOB_WHERE in a SQL value
Parameters:
value - value of a job where condition
ruleOperator - ruleOperator of the job where condition
fieldId - fieldId corresponding to value
Returns:
the corresponding SQL value

endWHERE

public java.lang.String endWHERE(java.lang.String companyId)
Builds ending condition of WHERE part according to rootType
Parameters:
companyId - current company
Returns:
ending condition of WHERE (without "AND" )

category

public java.lang.String category(java.lang.String alias)
Finds fieldCategory corresponding to an alias
Parameters:
alias - name of table alias
Returns:
category of fields corresponding to the alias

realTable

public java.lang.String realTable(java.lang.String alias)
Finds realTable corresponding to an alias
Parameters:
alias - name of table alias
Returns:
name of real table corrsponding to the alias

builtTable

public java.lang.String builtTable(java.lang.String alias)
Finds builtTable corresponding to an alias
Parameters:
alias - name of table alias of fieldCategory == LetterTemplateGlobals.TEMPORAL_FIELDS
Returns:
SQL string for building the associated temporal table

direction

public java.lang.String direction(java.lang.String direction)
Tranforms a direction of DatabaseNames.LETT_JOB_ORDER in a SQL direction
Parameters:
direction - direction of a job order element: "ascending" or "descending"
Returns:
the corresponding SQL direction: "" or "DESC"