Skip to content

Commit

Permalink
MONDRIAN: Integrate change 14063 - PSW-99 - The validator was casting…
Browse files Browse the repository at this point in the history
… the fact table as a Table object which caused problems with fact tables based on a view.

[git-p4: depot-paths = "//open/mondrian/": change = 14064]
  • Loading branch information
lucboudreau committed Feb 2, 2011
1 parent d51380e commit 19987ab
Showing 1 changed file with 43 additions and 41 deletions.
84 changes: 43 additions & 41 deletions src/main/mondrian/gui/validate/ValidationUtils.java
Expand Up @@ -407,48 +407,50 @@ && isEmpty(((MondrianGuiDef.View) cubeVal.fact).alias)))
} else if (cube != null && cube.fact != null) {
// Database validity check, if database connection is
// successful
final MondrianGuiDef.Table factTable =
(MondrianGuiDef.Table) cube.fact;
if (jdbcValidator.isInitialized()) {
String column = measure.column;
if (jdbcValidator.isColExists(
factTable.schema,
factTable.name,
column))
{
// Check for aggregator type only if column exists
// in table.

// Check if aggregator selected is valid on the data
// type of the column selected.
int colType =
jdbcValidator.getColumnDataType(
factTable.schema,
factTable.name,
measure.column);
// Coltype of 2, 4,5, 7, 8, -5 is numeric types
// whereas 1, 12 are char varchar string
// and 91 is date type.
// Types are enumerated in java.sql.Types.
int agIndex = -1;
if ("sum".equals(
measure.aggregator)
|| "avg".equals(
measure.aggregator))
{
// aggregator = sum or avg, column should be
// numeric
agIndex = 0;
}
if (!(agIndex == -1
|| (colType >= 2 && colType <= 8)
|| colType == -5))
if (cube.fact instanceof MondrianGuiDef.Table) {
final MondrianGuiDef.Table factTable =
(MondrianGuiDef.Table) cube.fact;
if (jdbcValidator.isInitialized()) {
String column = measure.column;
if (jdbcValidator.isColExists(
factTable.schema,
factTable.name,
column))
{
return messages.getFormattedString(
"schemaTreeCellRenderer.aggregatorNotValidForColumn.alert",
"Aggregator {0} is not valid for the data type of the column {1}",
measure.aggregator,
measure.column);
// Check for aggregator type only if column
// exists in table.

// Check if aggregator selected is valid on
// the data type of the column selected.
int colType =
jdbcValidator.getColumnDataType(
factTable.schema,
factTable.name,
measure.column);
// Coltype of 2, 4,5, 7, 8, -5 is numeric types
// whereas 1, 12 are char varchar string
// and 91 is date type.
// Types are enumerated in java.sql.Types.
int agIndex = -1;
if ("sum".equals(
measure.aggregator)
|| "avg".equals(
measure.aggregator))
{
// aggregator = sum or avg, column should
// be numeric
agIndex = 0;
}
if (!(agIndex == -1
|| (colType >= 2 && colType <= 8)
|| colType == -5))
{
return messages.getFormattedString(
"schemaTreeCellRenderer.aggregatorNotValidForColumn.alert",
"Aggregator {0} is not valid for the data type of the column {1}",
measure.aggregator,
measure.column);
}
}
}
}
Expand Down

0 comments on commit 19987ab

Please sign in to comment.