Search in sources :

Example 1 with XQueryConnectionAction

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;
}
Also used : IActionInput(org.pentaho.actionsequence.dom.IActionInput) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) XQueryConnectionAction(org.pentaho.actionsequence.dom.actions.XQueryConnectionAction) XQueryAction(org.pentaho.actionsequence.dom.actions.XQueryAction) IPreparedComponent(org.pentaho.platform.api.data.IPreparedComponent)

Example 2 with XQueryConnectionAction

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;
}
Also used : IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) XQueryConnectionAction(org.pentaho.actionsequence.dom.actions.XQueryConnectionAction) XQueryAction(org.pentaho.actionsequence.dom.actions.XQueryAction)

Aggregations

IActionDefinition (org.pentaho.actionsequence.dom.IActionDefinition)2 XQueryAction (org.pentaho.actionsequence.dom.actions.XQueryAction)2 XQueryConnectionAction (org.pentaho.actionsequence.dom.actions.XQueryConnectionAction)2 IActionInput (org.pentaho.actionsequence.dom.IActionInput)1 IPreparedComponent (org.pentaho.platform.api.data.IPreparedComponent)1