use of mondrian.rolap.RolapStar.Column in project mondrian by pentaho.
the class SqlConstraintUtils method getColumnString.
/**
* Returns the column expression for the level, assuring
* appropriate tables are added to the from clause of
* sqlQuery if required.
* Determines the correct table and field based on the cube
* and whether an AggStar is present.
*/
private static String getColumnString(SqlQuery sqlQuery, AggStar aggStar, RolapLevel level, RolapCube baseCube) {
String columnString;
RolapStar.Column column = null;
if (level instanceof RolapCubeLevel) {
// this method can be called within the context of shared members,
// outside of the normal rolap star, therefore we need to
// check the level to see if it is a shared or cube level.
column = ((RolapCubeLevel) level).getBaseStarKeyColumn(baseCube);
}
// REVIEW: The following code mostly uses the name column (or name
// expression) of the level. Shouldn't it use the key column (or key
// expression)?
RolapHierarchy hierarchy = level.getHierarchy();
if (column != null) {
if (aggStar != null) {
// this assumes that the name column is identical to the
// id column
int bitPos = column.getBitPosition();
AggStar.Table.Column aggColumn = aggStar.lookupColumn(bitPos);
AggStar.Table table = aggColumn.getTable();
table.addToFrom(sqlQuery, false, true);
columnString = aggColumn.generateExprString(sqlQuery);
} else {
RolapStar.Table targetTable = column.getTable();
hierarchy.addToFrom(sqlQuery, targetTable);
columnString = column.generateExprString(sqlQuery);
}
} else {
assert (aggStar == null);
hierarchy.addToFrom(sqlQuery, level.getKeyExp());
MondrianDef.Expression nameExp = level.getNameExp();
if (nameExp == null) {
nameExp = level.getKeyExp();
}
columnString = nameExp.getExpression(sqlQuery);
}
return columnString;
}
Aggregations