private void createThetaJoin(StringBuffer buf) {
Set joinedAliases = new HashSet();
// add all the additional path tables
if (!ctermJoinPaths.isEmpty()) {
for (Iterator iter = ctermJoinPaths.iterator(); iter.hasNext(); ) {
ASTPath path = (ASTPath) iter.next();
for (int i = 0; i < path.size(); i++) {
createThetaJoin(path, i, joinedAliases, buf);
}
}
}
// add all the collection member path tables
if (!ctermCollectionMemberJoinPaths.isEmpty()) {
for (Iterator iter = ctermCollectionMemberJoinPaths.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
String childAlias = (String) entry.getKey();
ASTPath path = (ASTPath) entry.getValue();
// join the member path
createThetaJoin(path, path.size() - 1, joinedAliases, childAlias, buf);
// join the member path parents
for (int i = 0; i < path.size() - 1; i++) {
createThetaJoin(path, i, joinedAliases, buf);
}
}
}
// get all the left joined paths
if (!ctermLeftJoinPaths.isEmpty()) {
Set allLeftJoins = new HashSet();
for (Iterator iter = ctermLeftJoinPaths.values().iterator(); iter.hasNext(); ) {
allLeftJoins.addAll((Set) iter.next());
}
// add all parent paths for left joins
for (Iterator iter = allLeftJoins.iterator(); iter.hasNext(); ) {
ASTPath path = (ASTPath) iter.next();
// don't declare the last one as the first path was left joined
for (int i = 0; i < path.size() - 1; i++) {
createThetaJoin(path, i, joinedAliases, buf);
}
}
}
}