use of org.pentaho.actionsequence.dom.actions.XQueryConnectionAction in project pentaho-platform by pentaho.
the class XQueryBaseComponent method executeAction.
@Override
protected boolean executeAction() {
boolean result = false;
IActionDefinition actionDefinition = getActionDefinition();
// int queryTimeout = -1;
if (actionDefinition instanceof XQueryAction) {
XQueryAction xQueryAction = (XQueryAction) actionDefinition;
// Not implemented yet
// IActionInput queryTimeoutInput = xQueryAction.getQueryTimeout();
IActionInput maxRowsInput = xQueryAction.getMaxRows();
if (maxRowsInput != ActionInputConstant.NULL_INPUT) {
this.setMaxRows(maxRowsInput.getIntValue());
}
IPreparedComponent sharedConnection = (IPreparedComponent) xQueryAction.getSharedConnection().getValue();
if (sharedConnection != null) {
connectionOwner = false;
connection = sharedConnection.shareConnection();
} else {
connection = getConnection();
}
if (connection == null) {
error(Messages.getInstance().getErrorString("IPreparedComponent.ERROR_0002_CONNECTION_NOT_AVAILABLE", // $NON-NLS-1$
getActionName()));
} else if (connection.getDatasourceType() != IPentahoConnection.XML_DATASOURCE) {
error(Messages.getInstance().getErrorString("IPreparedComponent.ERROR_0001_INVALID_CONNECTION_TYPE", // $NON-NLS-1$
getActionName()));
} else {
result = runQuery(connection, xQueryAction.getQuery().getStringValue());
}
} else if (actionDefinition instanceof XQueryConnectionAction) {
XQueryConnectionAction xQueryConnectionAction = (XQueryConnectionAction) getActionDefinition();
connection = getConnection();
if (connection == null) {
error(Messages.getInstance().getErrorString("IPreparedComponent.ERROR_0002_CONNECTION_NOT_AVAILABLE", // $NON-NLS-1$
getActionName()));
} else if (connection.getDatasourceType() != IPentahoConnection.XML_DATASOURCE) {
error(Messages.getInstance().getErrorString("IPreparedComponent.ERROR_0001_INVALID_CONNECTION_TYPE", // $NON-NLS-1$
getActionName()));
} else {
xQueryConnectionAction.getOutputConnection().setValue(this);
result = true;
}
}
return result;
}
use of org.pentaho.actionsequence.dom.actions.XQueryConnectionAction in project pentaho-platform by pentaho.
the class XQueryBaseComponent method validateAction.
@Override
protected boolean validateAction() {
boolean result = false;
IActionDefinition actionDefinition = getActionDefinition();
if (actionDefinition instanceof XQueryAction) {
XQueryAction xQueryAction = (XQueryAction) actionDefinition;
if ((xQueryAction.getSourceXml() == ActionInputConstant.NULL_INPUT) && (xQueryAction.getXmlDocument() == null)) {
error(Messages.getInstance().getString("XQueryBaseComponent.ERROR_0008_SOURCE_NOT_DEFINED", // $NON-NLS-1$
getActionName()));
} else if (xQueryAction.getQuery() == ActionInputConstant.NULL_INPUT) {
error(Messages.getInstance().getErrorString("XQueryBaseComponent.ERROR_0001_QUERY_NOT_SPECIFIED", // $NON-NLS-1$
getActionName()));
} else if ((xQueryAction.getOutputPreparedStatement() == null) && (xQueryAction.getOutputResultSet() == null)) {
error(Messages.getInstance().getErrorString("XQueryBaseComponent.ERROR_0003_OUTPUT_NOT_SPECIFIED", // $NON-NLS-1$
getActionName()));
} else {
result = true;
}
} else if (actionDefinition instanceof XQueryConnectionAction) {
XQueryConnectionAction xQueryConnectionAction = (XQueryConnectionAction) actionDefinition;
if (xQueryConnectionAction.getOutputConnection() == null) {
error(Messages.getInstance().getErrorString("XQueryBaseComponent.ERROR_0003_OUTPUT_NOT_SPECIFIED", // $NON-NLS-1$
getActionName()));
} else {
result = true;
}
} else {
error(Messages.getInstance().getErrorString("ComponentBase.ERROR_0001_UNKNOWN_ACTION_TYPE", // $NON-NLS-1$
actionDefinition.getElement().asXML()));
}
return result;
}
Aggregations