use of org.teiid.query.sql.lang.FromClause in project teiid by teiid.
the class TestJoinPredicate method example.
// ################################## TEST HELPERS ################################
/**
* Constructs an example <code>JoinPredicate</code> object that can be used
* as join predicate in a query.
*
* @param joinType the type of join to be constructed
* @param joinOnElement the element name to be used in the left and right
* side criteria of the ON expression of the join
* @return a join predicate object
*/
public static JoinPredicate example(JoinType joinType, String joinOnElement) {
JoinPredicate jp = new JoinPredicate();
// $NON-NLS-1$
GroupSymbol g1 = new GroupSymbol("m.g1");
// $NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("m.g2");
FromClause lc = new UnaryFromClause(g1);
FromClause rc = new UnaryFromClause(g2);
// $NON-NLS-1$
Expression le = new ElementSymbol("m.g1." + joinOnElement);
// $NON-NLS-1$
Expression re = new ElementSymbol("m.g2." + joinOnElement);
Criteria c1 = new CompareCriteria(le, CompareCriteria.EQ, re);
jp.setLeftClause(lc);
jp.setRightClause(rc);
jp.setJoinType(joinType != null ? joinType : JoinType.JOIN_LEFT_OUTER);
jp.setJoinCriteria(Arrays.asList(new Object[] { c1 }));
return jp;
}
Aggregations