use of org.pentaho.platform.plugin.services.connections.mondrian.MDXResultSet in project pentaho-platform by pentaho.
the class MDXBaseComponent method runQuery.
protected boolean runQuery(final IPentahoConnection localConnection, final String rawQuery) {
try {
if (localConnection == null) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("MDXBaseComponent.ERROR_0008_NO_CONNECTION"));
return false;
}
if (!localConnection.initialized()) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("MDXBaseComponent.ERROR_0008_NO_CONNECTION"));
return false;
}
if (rawQuery == null) {
error(Messages.getInstance().getErrorString("MDXBaseComponent.ERROR_0001_QUERY_NOT_SPECIFIED", // $NON-NLS-1$
getActionName()));
return false;
}
if (ComponentBase.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("MDXBaseComponent.DEBUG_RUNNING_QUERY", rawQuery));
}
// execute the query, read the results and cache them
IPentahoResultSet resultSet = localConnection.executeQuery(rawQuery);
if (resultSet != null && resultSet instanceof MDXResultSet) {
// BISERVER-3543 - set the result set to return formatted cell values
boolean formattedCellValues = false;
if (isDefinedInput(FORMATTED_CELL_VALUES)) {
formattedCellValues = getInputBooleanValue(FORMATTED_CELL_VALUES, false);
}
((MDXResultSet) resultSet).setFormattedCellValues(formattedCellValues);
}
rSet = resultSet;
if (resultSet != null) {
MdxQueryAction mdxQueryAction = (MdxQueryAction) getActionDefinition();
IActionOutput actionOutput = mdxQueryAction.getOutputResultSet();
if (actionOutput != null) {
actionOutput.setValue(resultSet);
}
return true;
} else {
// close the connection
error(Messages.getInstance().getErrorString("MDXBaseComponent.ERROR_0006_EXECUTE_FAILED", // $NON-NLS-1$
getActionName()));
localConnection.close();
return false;
}
} catch (Exception e) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("MDXBaseComponent.ERROR_0006_EXECUTE_FAILED", getActionName()), e);
}
return false;
}
Aggregations