use of org.pentaho.platform.engine.services.runtime.MapParameterResolver in project pentaho-platform by pentaho.
the class HQLBaseComponent method executePrepared.
/**
* executes a prepared method that returns a result set executePrepared looks up any "PREPARELATER" params in the
* preparedParams map.
*
* @param preparedParams
* a map of possible parameters.
* @return result set
*/
public IPentahoResultSet executePrepared(final Map preparedParams) {
try {
if (connection == null) {
error(Messages.getInstance().getErrorString("HQLBaseComponent.ERROR_0009_COULD_NOT_ESTABLISH_CONNECTION"));
// $NON-NLS-1$
return null;
}
if (!connection.initialized()) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("HQLBaseComponent.ERROR_0009_COULD_NOT_ESTABLISH_CONNECTION"));
return null;
}
if (preparedQuery == null) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("HQLBaseComponent.ERROR_00016_QUERY_NOT_SPECIFIED"));
return null;
}
// parse preparedQuery, replacing any {PREPARELATER:NAME} with appropriate values
String query = TemplateUtil.applyTemplate(preparedQuery, getRuntimeContext(), new MapParameterResolver(preparedParams, IPreparedComponent.PREPARE_LATER_PREFIX, getRuntimeContext()));
if (ComponentBase.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("HQLBaseComponent.DEBUG_RUNNING_QUERY", query));
}
// evaluate
IPentahoResultSet resultSet = connection.executeQuery(query);
rSet = resultSet;
return resultSet;
} catch (Exception e) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("HQLBaseComponent.ERROR_00012_EXECUTE_FAILED", getActionName()), e);
}
return null;
}
use of org.pentaho.platform.engine.services.runtime.MapParameterResolver in project pentaho-platform by pentaho.
the class MDXBaseComponent method executePrepared.
/**
* executes a prepared method that returns a result set executePrepared looks up any "PREPARELATER" params in the
* preparedParams map.
*
* @param preparedParams
* a map of possible parameters.
* @return result set
*/
public IPentahoResultSet executePrepared(final Map preparedParams) {
try {
if (connection == null) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("MDXBaseComponent.ERROR_0008_NO_CONNECTION"));
return null;
}
if (!connection.initialized()) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("MDXBaseComponent.ERROR_0008_NO_CONNECTION"));
return null;
}
if (preparedQuery == null) {
error(Messages.getInstance().getErrorString("MDXBaseComponent.ERROR_0001_QUERY_NOT_SPECIFIED", // $NON-NLS-1$
getActionName()));
return null;
}
// parse preparedQuery, replacing any {PREPARELATER:NAME} with appropriate values
String query = TemplateUtil.applyTemplate(preparedQuery, getRuntimeContext(), new MapParameterResolver(preparedParams, IPreparedComponent.PREPARE_LATER_PREFIX, getRuntimeContext()));
if (ComponentBase.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("MDXBaseComponent.DEBUG_RUNNING_QUERY", query));
}
// evaluate
IPentahoResultSet resultSet = connection.executeQuery(query);
rSet = resultSet;
return resultSet;
} catch (Exception e) {
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("MDXBaseComponent.ERROR_0006_EXECUTE_FAILED", getActionName()), e);
}
return null;
}
Aggregations