Skip to content

Commit

Permalink
MONDRIAN: PSW-99 The CellRenderer was performing validation in order …
Browse files Browse the repository at this point in the history
…to display a little red X but was assuming that the fact table was always based off a Table element. Validations cannot be performed on a View.

[git-p4: depot-paths = "//open/mondrian-release/3.2.2/": change = 14059]
  • Loading branch information
lucboudreau committed Feb 2, 2011
1 parent e5cf49b commit bf8b177
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 @@ -406,48 +406,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 bf8b177

Please sign in to comment.