|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.datatools.modelbase.sql.query.helper.JoinHelper
public class JoinHelper
This is a helper class that provides methods that assist in creating and manipulating SQL joins.
Field Summary | |
---|---|
static java.lang.String |
BOTH
|
static java.lang.String |
copyright
|
static java.lang.String |
GENERIC_BINARY
|
static java.lang.String |
GENERIC_BLOB
|
static java.lang.String |
GENERIC_CHARACTER
|
static java.lang.String |
GENERIC_DATE
|
static java.lang.String |
GENERIC_DECIMAL
|
static java.lang.String |
GENERIC_INTEGER
|
static java.lang.String |
GENERIC_OTHER
|
static java.lang.String |
GENERIC_TIME
|
static java.lang.String |
GENERIC_TIMESTAMP
|
static int |
JOIN_COL_TYPE_MISMATCH
|
static int |
JOIN_COL_USED
|
static int |
JOIN_SAME_TABLE
|
static int |
JOIN_VALID
|
static java.lang.String |
LEFT
|
static java.lang.String |
NONE
|
static java.lang.String |
RIGHT
|
Constructor Summary | |
---|---|
JoinHelper()
|
Method Summary | |
---|---|
static TableJoined |
addJoin(java.util.List fromClause,
TableExpression sourceTable,
TableExpression targetTable,
ValueExpressionColumn sourceColumn,
ValueExpressionColumn targetColumn,
int joinType)
Creates a new joined table or join condition containing the given join source and target objects, and updates the given FROM clause list. |
static TableJoined |
addJoinedTable(java.util.List fromClause,
TableReference joinSource,
TableReference joinTarget,
int joinType)
Creates a new joined table containing the given join source and target objects, and adds it to the given FROM clause list. |
static PredicateBasic |
buildPredicateBasic(QueryValueExpression leftExpr,
QueryValueExpression rightExpr,
java.lang.String oper)
Creates a PredicateBasic object using the given expressions and operator. |
static QuerySearchCondition |
buildSearchCondition(QuerySearchCondition currentSearchCon,
QueryValueExpression leftExpr,
QueryValueExpression rightExpr,
java.lang.String oper)
Creates a new predicate and adds it to the given search condition. |
static int |
checkJoin(java.util.List fromClause,
TableExpression sourceTable,
TableExpression targetTable,
ValueExpressionColumn sourceColumn,
ValueExpressionColumn targetColumn,
boolean isMove)
Checks whether or not a join between the given join source and target objects is valid. |
static boolean |
checkJoinType(ValueExpressionColumn sourceColumn,
ValueExpressionColumn targetColumn)
Determines if source and target columns are of compatible type for joining. |
static boolean |
conditionContainsTable(QuerySearchCondition condition,
TableExpression table)
Checks to see if the given SQLSearchCondition (ON clause) contains the given table. |
static TableJoined |
findClosestContainingJoin(TableExpression joinSource,
TableExpression joinTarget)
Finds and returns the closest enclosing join containing both the given source and target tables, working from the leafs of the join tree to the root. |
static java.util.List |
findConditionsContainingTable(QuerySearchCondition cond,
TableExpression table)
Finds and returns the individual conditions (predicates) in the given QuerySearchCondition (ON clause) that contain references to the given table. |
static java.util.List |
findJoinsWithTableInCondition(TableExpression table,
TableJoined join)
Searches upwards in the join tree to see if the given table exists in any of the conditions in the joins. |
static TableReference |
findOutermostContainingJoin(java.util.List fromClause,
TableExpression targetTable)
Finds and returns the outermost table reference in the From clause that contains the given table. |
static java.lang.String |
getGenericType(java.lang.Object datatype)
Returns a string indicating the "generic" type for the given datatype object. |
static java.util.List |
getLeftJoinsForTable(TableExpression tableExpr)
Returns a list of TableJoined objects of which the given TableExpression is the left side. |
static TableReference |
getNestedTable(TableReference tableRef)
Returns the table "nested" in the given table, if any. |
static java.util.List |
getRightJoinsForTable(TableExpression tableExpr)
Returns a list of TableJoined objects of which the given TableExpression is the right side. |
static java.util.List |
getTablesInJoin(TableJoined join)
Gets a list of TableExpression objects embedded inside the given join object. |
static java.util.List |
getTablesInNestedTable(TableNested tableNested)
Returns a list of TableExpressions contained in the given TableNested object. |
static void |
removeJoin(java.util.List fromClause,
TableJoined joinedTable)
Removes the given joined table from the given FROM clause list. |
static void |
removeJoinCondition(java.util.List fromClause,
TableJoined joinedTable,
PredicateBasic joinCond)
Removes the given join condition (PredicateBasic) from the given joined table. |
static void |
removeJoinConditionsForTables(java.util.List fromClause,
java.util.List tableList,
java.util.List joinList)
Unravels the content (left or right) of a join by removing all ON clause conditions in the given join list that refer to the tables in the given table list. |
static void |
removeJoinsForTable(java.util.List fromClause,
TableExpression table)
Removes any joins from the FROM clause list that contain or reference the given table. |
static QuerySearchCondition |
removePredicateFromCondition(Predicate pred,
QuerySearchCondition searchCon)
Removes the given predicate from the given search condition. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String copyright
public static final java.lang.String GENERIC_CHARACTER
public static final java.lang.String GENERIC_INTEGER
public static final java.lang.String GENERIC_DECIMAL
public static final java.lang.String GENERIC_BINARY
public static final java.lang.String GENERIC_DATE
public static final java.lang.String GENERIC_TIME
public static final java.lang.String GENERIC_TIMESTAMP
public static final java.lang.String GENERIC_BLOB
public static final java.lang.String GENERIC_OTHER
public static final int JOIN_COL_TYPE_MISMATCH
public static final int JOIN_COL_USED
public static final int JOIN_SAME_TABLE
public static final int JOIN_VALID
public static final java.lang.String LEFT
public static final java.lang.String RIGHT
public static final java.lang.String BOTH
public static final java.lang.String NONE
Constructor Detail |
---|
public JoinHelper()
Method Detail |
---|
public static TableJoined addJoin(java.util.List fromClause, TableExpression sourceTable, TableExpression targetTable, ValueExpressionColumn sourceColumn, ValueExpressionColumn targetColumn, int joinType)
fromClause
- the list of objects (tables and joins) in the FROM clausesourceTable
- the source (left side) table of the jointargetTable
- the target (right side) table of the joinsourceColumn
- the source column expression of the jointargetColumn
- the target column expression of the joinjoinType
- the type of join (inner, left outer, etc.)
public static TableJoined addJoinedTable(java.util.List fromClause, TableReference joinSource, TableReference joinTarget, int joinType)
fromClause
- the list of objects (tables and joins) in the FROM clausejoinSource
- the source (left side) of the joinjoinTarget
- the target (right side) of the joinjoinType
- the type of join (inner, left outer, etc.)
public static PredicateBasic buildPredicateBasic(QueryValueExpression leftExpr, QueryValueExpression rightExpr, java.lang.String oper)
leftExpr
- the left side expressionrightExpr
- the right side expressionoper
- the operator
public static QuerySearchCondition buildSearchCondition(QuerySearchCondition currentSearchCon, QueryValueExpression leftExpr, QueryValueExpression rightExpr, java.lang.String oper)
currentSearchCon
- the existing search condition or nullleftExpr
- the left side expression of the new predicaterightExpr
- the right side expression of the new predicateoper
- the operator string (eg: "=" )
public static int checkJoin(java.util.List fromClause, TableExpression sourceTable, TableExpression targetTable, ValueExpressionColumn sourceColumn, ValueExpressionColumn targetColumn, boolean isMove)
fromClause
- the list of objects (tables and joins) in the FROM clausesourceTable
- the source (left side) table of the jointargetTable
- the target (right side) table of the joinsourceColumn
- the source column of the jointargetColumn
- the target column of the joinisMove
- true when a join is being moved, false when a join
is being created
public static boolean checkJoinType(ValueExpressionColumn sourceColumn, ValueExpressionColumn targetColumn)
sourceColumn
- the source column to checktargetColumn
- the target column to check
public static boolean conditionContainsTable(QuerySearchCondition condition, TableExpression table)
condition
- the condition to searchtable
- the table to search for
public static TableJoined findClosestContainingJoin(TableExpression joinSource, TableExpression joinTarget)
joinSource
- the source (left side) of a joinjoinTarget
- the target (right side) of a join
public static java.util.List findConditionsContainingTable(QuerySearchCondition cond, TableExpression table)
cond
- the QuerySearchCondition to searchtable
- the TableExpression to use to search for predicates
public static java.util.List findJoinsWithTableInCondition(TableExpression table, TableJoined join)
table
- the table to be searched forjoin
- the join at which the search starts
public static TableReference findOutermostContainingJoin(java.util.List fromClause, TableExpression targetTable)
fromClause
- the list of objects (tables and joins) in the FROM clausetargetTable
- the table reference to be looked for
public static java.util.List getLeftJoinsForTable(TableExpression tableExpr)
tableExpr
- the TableExpression for which to find the joinspublic static TableReference getNestedTable(TableReference tableRef)
tableRef
- the table reference from which the nested table is wanted
public static java.util.List getRightJoinsForTable(TableExpression tableExpr)
tableExpr
- the TableExpression for which to find the joinspublic static java.lang.String getGenericType(java.lang.Object datatype)
datatype
- the datatype for which a generic type is neededpublic static java.util.List getTablesInJoin(TableJoined join)
join
- the join from which the tables are to be obtained
public static java.util.List getTablesInNestedTable(TableNested tableNested)
tableNested
- the TableNested object from which the TableExpressions are to be obtained
public static void removeJoin(java.util.List fromClause, TableJoined joinedTable)
fromClause
- the list of objects (tables and joins) in the FROM clausethe
- join to be removedpublic static void removeJoinCondition(java.util.List fromClause, TableJoined joinedTable, PredicateBasic joinCond)
fromClause
- the list of objects (tables and joins) in the FROM clausejoinedTable
- the join from which the join condition is to be removedjoinCond
- the join condition to be removedpublic static void removeJoinConditionsForTables(java.util.List fromClause, java.util.List tableList, java.util.List joinList)
fromClause
- the list of objects (tables and joins) in the FROM clausetableList
- a list of tables for which joins are to be removedjoinList
- a list of joins to be searched for conditions involving
the tables and updated or removedpublic static void removeJoinsForTable(java.util.List fromClause, TableExpression table)
fromClause
- the list of objects (tables and joins) in the FROM clausetable
- the table for which joins should be removedpublic static QuerySearchCondition removePredicateFromCondition(Predicate pred, QuerySearchCondition searchCon)
pred
- the Predicate which needs to be removed from the conditionsearchCon
- the SearchCondition from which predicate needs to be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |