use of org.pentaho.actionsequence.dom.actions.HQLConnectionAction in project pentaho-platform by pentaho.
the class HQLBaseComponent method validateAction.
@Override
protected boolean validateAction() {
HQLConnectionAction connAction = null;
HQLQueryAction queryAction = null;
boolean actionValidated = true;
try {
if (getActionDefinition() instanceof HQLQueryAction) {
queryAction = (HQLQueryAction) getActionDefinition();
actionValidated = isConnectionInfoSpecified(queryAction);
// Check if the query is defined.
if (actionValidated && (queryAction.getQuery() == ActionInputConstant.NULL_INPUT)) {
actionValidated = false;
error(Messages.getInstance().getErrorString("HQLBaseComponent.ERROR_0004_QUERY_NOT_SPECIFIED", // $NON-NLS-1$
getActionName()));
}
// Check if output for the query is correctly defined.
if (actionValidated && (queryAction.getOutputResultSetName() == null) && (queryAction.getOutputPreparedStatementName() == null)) {
actionValidated = false;
error(Messages.getInstance().getErrorString("HQLBaseComponent.ERROR_0005_OUTPUT_NOT_SPECIFIED", // $NON-NLS-1$
getActionName()));
}
} else if (getActionDefinition() instanceof HQLConnectionAction) {
connAction = (HQLConnectionAction) getActionDefinition();
actionValidated = isConnectionInfoSpecified(connAction);
} else {
actionValidated = false;
error(Messages.getInstance().getErrorString("ComponentBase.ERROR_0001_UNKNOWN_ACTION_TYPE", // $NON-NLS-1$
getActionDefinition().getElement().asXML()));
}
} catch (Exception e) {
actionValidated = false;
error(Messages.getInstance().getErrorString("HQLBaseComponent.ERROR_0006_VALIDATION_FAILED", getActionName()), // $NON-NLS-1$
e);
}
return actionValidated;
}
use of org.pentaho.actionsequence.dom.actions.HQLConnectionAction in project pentaho-platform by pentaho.
the class HQLBaseComponent method executeAction.
@Override
protected boolean executeAction() {
boolean returnValue = true;
try {
if (getActionDefinition() instanceof HQLQueryAction) {
HQLQueryAction queryAction = (HQLQueryAction) getActionDefinition();
String[] classNames = null;
String query = queryAction.getQuery().getStringValue();
if (queryAction.getInputSharedConnection() != ActionInputConstant.NULL_INPUT) {
connectionOwner = false;
IPreparedComponent component = (IPreparedComponent) queryAction.getInputSharedConnection().getValue();
IPentahoConnection conn = component.shareConnection();
if (IPentahoConnection.HQL_DATASOURCE.equals(conn.getDatasourceType())) {
connection = conn;
} else {
connection = null;
returnValue = false;
error(Messages.getInstance().getErrorString("IPreparedComponent.ERROR_0001_INVALID_CONNECTION_TYPE", // $NON-NLS-1$
getActionName()));
}
} else {
createBasicConnection(queryAction, classNames);
}
if (connection != null) {
IActionOutput actionOutput = queryAction.getOutputPreparedStatementParam();
if (actionOutput != null) {
// prepare the query for execution, but don't execute quite yet.
prepareQuery(query);
// set the output as self, which will be used later by another component.
actionOutput.setValue(this);
} else {
return runQuery(connection, classNames, query);
}
}
} else if (getActionDefinition() instanceof HQLConnectionAction) {
HQLConnectionAction connAction = (HQLConnectionAction) getActionDefinition();
String[] classNames = null;
createBasicConnection(connAction, classNames);
if (connection != null) {
IActionOutput outputConnection = connAction.getOutputConnectionParam();
if (outputConnection != null) {
outputConnection.setValue(this);
}
}
} else {
returnValue = false;
error(Messages.getInstance().getErrorString("HQLBaseComponent.ERROR_00011_INVALID_HQL_COMPONENT", // $NON-NLS-1$
getActionName()));
}
} catch (Exception e) {
returnValue = false;
// $NON-NLS-1$
error(Messages.getInstance().getErrorString("HQLBaseComponent.ERROR_00012_EXECUTE_FAILED", getActionName()), e);
}
return returnValue;
}
use of org.pentaho.actionsequence.dom.actions.HQLConnectionAction in project pentaho-platform by pentaho.
the class HQLBaseComponent method getCatalog.
/*
* Utility function to get the catalog info from hibernate config.
*/
private String getCatalog() {
IActionResource hibernateConfigRes = ((HQLConnectionAction) getActionDefinition()).getHibernateConfigResource();
String catalog = null;
String resAddress = null;
if (hibernateConfigRes != null) {
String resName = this.applyInputsToFormat(hibernateConfigRes.getName());
IActionSequenceResource resource = getResource(resName);
resAddress = resource.getAddress();
if (resAddress != null) {
catalog = this.applyInputsToFormat(resAddress);
}
}
return catalog;
}
Aggregations