|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.datatools.sqltools.sqlbuilder.model.SearchConditionHelper
public class SearchConditionHelper
This class provides "helper" functions for building and manipulating query search conditions. The Query Builder builds search conditions in a particular way. Conditions are structured as a tree of Predicate and SearchConditionCombined objects that "grows" from the bottom left as new conditions are added to the condition grid. That is, new Predicate and SearchConditionCombined objects are added to the right, creating a new "root" SearchConditionCombined as each predicate is added. Let's say you have a single condition in the Conditions grid in the UI. This condition is represented in the model as a single Predicate object, call it P1. When the user adds a new condition as the 2nd row of the Condition grid, another Predicate, P2, is created, and P1 and P2 are combined using a SearchConditionCombined (call it SCC1), like this: SCC1 / \ P1 P2 When another condition is added in the third row of the Conditions grid, the model is modified like this: SCC2 / \ SCC1 P3 / \ P1 P2 Adding a fourth condition results in the following tree: SCC3 / \ SCC2 P4 / \ SCC1 P3 / \ P1 P2 And so on. Navigating the search condition tree in the code can be confusing. The model provides calls to get the left or right parent SearchConditionCombined (if any) of a node, and to get the left or right child condition (if any) of a SearchConditionCombined. (The child can be a Predicate or a SearchConditionCombined.) Considering a node in the tree (the node can be either a Predicate or a SearchConditionCombined), the other nodes in relation to it are as follows: combinedRight combinedLeft \ / node / \ leftCondition rightCondition The methods in the model for navigating the tree are named accordingly: getCombinedRight - get the SearchConditionCombined for which this node is the right child getCombinedLeft - get the SearchConditionCombined for which this node is the left child getLeftCondition - get the condition (Predicate or SearchConditionCombined) that is the left child of this node (which must be a SearchConditionCombined) getRightCondition - get the condition (Predicate or SearchConditionCombined) that is the right child of this node (which must be a SearchConditionCombined) Notes: 1. For any node, getCombinedLeft and getCombinedRight cannot both return non-null. (Both may return null, which indicates the node is the root of the condition tree.) 2. In the trees built by the Query Builder, getRightCondition will always return a Predicate, never a SearchConditionCombined.
Field Summary | |
---|---|
static java.lang.String[] |
operators
|
Constructor Summary | |
---|---|
SearchConditionHelper(SQLDomainModel domainModel)
Constructs an instance of this class, with the given domain model object. |
Method Summary | |
---|---|
static Predicate |
buildEmptyPredicate()
Creates an empty predicate. |
Predicate |
buildNewPredicate(SQLQueryObject currStmt,
QueryValueExpression left,
java.lang.String right,
java.lang.String comparisonKind)
Builds the Predicate for the given comparison kind. |
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. |
QuerySearchCondition |
buildSearchCondition(SQLQueryObject currStmt,
QuerySearchCondition currentSearchCon,
QueryValueExpression left,
java.lang.String right,
java.lang.String comparisonKind)
Creates a new predicate with the given values and append it to the give search condition. |
static java.util.List |
getAllPredicates(QuerySearchCondition condition)
|
QueryValueExpression |
getDefaultLeft(java.lang.String predOpr)
Returns the default left side of a predicate for the given operator. |
java.lang.String |
getDefaultRight(java.lang.String predOpr)
Returns the default right side of a predicate for the given operator. |
QueryValueExpression |
getLeftFromPredicate(Predicate pred)
Returns the left value for the given predicate |
java.lang.String |
getPredicateOperator(Predicate pred)
Returns the operator for the given predicate |
java.lang.String |
getRightFromPredicate(Predicate pred)
Returns the right value for the given predicate |
boolean |
isHavingClause()
|
static QuerySearchCondition |
removePredicateFromCondition(Predicate pred,
QuerySearchCondition searchCon)
Removes the given predicate from the search condition. |
void |
removePredicateFromCondition(Predicate pred,
QuerySearchCondition searchCon,
SQLQueryObject currStmt)
Removes the given predicate from the search condition. |
static QuerySearchCondition |
replacePredicate(QuerySearchCondition searchCon,
Predicate oldPred,
Predicate newPred)
|
void |
replacePredicate(SQLQueryObject stmt,
QuerySearchCondition searchCon,
Predicate oldPred,
Predicate newPred)
Replaces the given predicate with the new predicate |
void |
replaceSearchCondition(SQLQueryObject statement,
QuerySearchCondition searchCon)
|
QuerySearchCondition |
setAndOrInSearchCondition(SQLQueryObject currStmt,
QuerySearchCondition searchCon,
Predicate pred,
java.lang.String andOrValue)
Sets the And/Or for the condition, creates the new predicate if needed and returns the searchCondition with new added predicate. |
void |
setHavingClause(boolean havingClause)
|
boolean |
setLeftInPredicate(Predicate pred,
QueryValueExpression value)
Sets the ValueExpression as Left value in the given predicate. |
boolean |
setOperatorInPredicate(SQLQueryObject currStmt,
QuerySearchCondition searchCon,
Predicate pred,
java.lang.String value)
Sets the given value as the operator in the given predicate. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String[] operators
Constructor Detail |
---|
public SearchConditionHelper(SQLDomainModel domainModel)
domainModel
- the query builder domain model to useMethod Detail |
---|
public Predicate buildNewPredicate(SQLQueryObject currStmt, QueryValueExpression left, java.lang.String right, java.lang.String comparisonKind)
currStmt
- the SQL statement for which new predicate will be part ofleft
- the QueryValueExpression represents left side of the predicateright
- the String value for right side of the predicatecomparisonKind
- String value that indicates what type of Predicate it is going to be
public static Predicate buildEmptyPredicate()
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 PredicateBasic buildPredicateBasic(QueryValueExpression leftExpr, QueryValueExpression rightExpr, java.lang.String oper)
leftExpr
- the left side expressionrightExpr
- the right side expressionoper
- the operator
public QuerySearchCondition buildSearchCondition(SQLQueryObject currStmt, QuerySearchCondition currentSearchCon, QueryValueExpression left, java.lang.String right, java.lang.String comparisonKind)
currentSearchCon
- the current QuerySearchCondition, null is passed if building search condition first time.left
- the QueryValueExpression represents left side of the predicateright
- the String value for right side of the predicatecomparisonKind
- String value that indicates what type of Predicate needs to build
public 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 removedpublic void removePredicateFromCondition(Predicate pred, QuerySearchCondition searchCon, SQLQueryObject currStmt)
pred
- the Predicate which needs to be removed from the conditionsearchCon
- the SearchCondition from which predicate needs to be removedcurrStmt
- the statement containing the search conditionpublic QueryValueExpression getLeftFromPredicate(Predicate pred)
pred
- the predicate for which left expression needs to be returned
public java.lang.String getRightFromPredicate(Predicate pred)
pred
- the predicate for which right expression needs to be returned
public java.lang.String getPredicateOperator(Predicate pred)
pred
- the predicate for which operator needs to be returned
public static java.util.List getAllPredicates(QuerySearchCondition condition)
condition
-
public boolean setLeftInPredicate(Predicate pred, QueryValueExpression value)
pred
- the Predicate for which left expression needs to be setvalue
- the QueryValueExpression needs to set for the predicate
public boolean setOperatorInPredicate(SQLQueryObject currStmt, QuerySearchCondition searchCon, Predicate pred, java.lang.String value)
pred
- the Predicate for which operator needs to be setvalue
- the String value needs to set as operator for the predicate
public java.lang.String getDefaultRight(java.lang.String predOpr)
predOpr
- the String predicate operator for which default value is needed
public QueryValueExpression getDefaultLeft(java.lang.String predOpr)
predOpr
- the String predicate operator for which default value is needed
public QuerySearchCondition setAndOrInSearchCondition(SQLQueryObject currStmt, QuerySearchCondition searchCon, Predicate pred, java.lang.String andOrValue)
currStmt
- the current QueryStatementsearchCon
- the QuerySearchCondition to which predicate is added if neededpred
- the current Predicate on which And/Or needs to be setandOrValue
- the String And/Or value
public static QuerySearchCondition replacePredicate(QuerySearchCondition searchCon, Predicate oldPred, Predicate newPred)
public void replacePredicate(SQLQueryObject stmt, QuerySearchCondition searchCon, Predicate oldPred, Predicate newPred)
stmt
- the current QueryStatementsearchCon
- the QuerySearchCondition which needs to be updated with new predicateoldPred
- the Predicate which needs to be replacednewPred
- the new Predicatepublic void replaceSearchCondition(SQLQueryObject statement, QuerySearchCondition searchCon)
statement
- searchCon
- public boolean isHavingClause()
public void setHavingClause(boolean havingClause)
havingClause
- The havingClause to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |