Skip to content

Commit

Permalink
MONDRIAN: Fixes for bug 2138161 Workbench Dimension Selection Issue
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 11689]
  • Loading branch information
e-cuellar committed Oct 7, 2008
1 parent d3c8d48 commit c461584
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/main/mondrian/gui/SchemaExplorer.java
Expand Up @@ -21,6 +21,7 @@
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.EventObject;
import java.util.Set;

import javax.swing.*;
import javax.swing.border.EtchedBorder;
Expand Down Expand Up @@ -3364,6 +3365,45 @@ public boolean isEditModeXML() {
public I18n getResourceConverter() {
return workbench.getResourceConverter();
}
public static void getTableNamesForJoin(MondrianGuiDef.RelationOrJoin aRelOrJoin, Set aTableNames) {
//EC: Loops join tree and collects table names.
if (aRelOrJoin instanceof MondrianGuiDef.Join) {
MondrianGuiDef.RelationOrJoin theRelOrJoin_L = ((MondrianGuiDef.Join) aRelOrJoin).left;
MondrianGuiDef.RelationOrJoin theRelOrJoin_R = ((MondrianGuiDef.Join) aRelOrJoin).right;
for (int i = 0 ; i < 2; i ++) { // Searches first using the Left Join and then the Right.
MondrianGuiDef.RelationOrJoin theCurrentRelOrJoin = (i == 0) ? theRelOrJoin_L : theRelOrJoin_R;
if (theCurrentRelOrJoin instanceof MondrianGuiDef.Table) {
MondrianGuiDef.Table theTable = ((MondrianGuiDef.Table) theCurrentRelOrJoin);
String theTableName = (theTable.alias != null && theTable.alias.trim().length() > 0) ? theTable.alias : theTable.name;
aTableNames.add(theTableName);
} else {
//calls recursively collecting all table names down the join tree.
getTableNamesForJoin(theCurrentRelOrJoin, aTableNames);
}
}
}
}
public static String getTableNameForAlias(MondrianGuiDef.RelationOrJoin aRelOrJoin, String anAlias) {
String theTableName = anAlias;
//EC: Loops join tree and finds the table name for an alias.
if (aRelOrJoin instanceof MondrianGuiDef.Join) {
MondrianGuiDef.RelationOrJoin theRelOrJoin_L = ((MondrianGuiDef.Join) aRelOrJoin).left;
MondrianGuiDef.RelationOrJoin theRelOrJoin_R = ((MondrianGuiDef.Join) aRelOrJoin).right;
for (int i = 0 ; i < 2; i ++) { // Searches first using the Left Join and then the Right.
MondrianGuiDef.RelationOrJoin theCurrentRelOrJoin = (i == 0) ? theRelOrJoin_L : theRelOrJoin_R;
if (theCurrentRelOrJoin instanceof MondrianGuiDef.Table) {
MondrianGuiDef.Table theTable = ((MondrianGuiDef.Table) theCurrentRelOrJoin);
if (theTable.alias != null && theTable.alias.equals(anAlias)) {
theTableName = theTable.name; // If the alias was found get its table name and return it.
}
} else {
//otherwise continue down the join tree.
theTableName = getTableNameForAlias(theCurrentRelOrJoin, anAlias);
}
}
}
return theTableName;
}
}

// End SchemaExplorer.java

0 comments on commit c461584

Please sign in to comment.