Search in sources :

Example 11 with IActionDefinition

use of org.pentaho.actionsequence.dom.IActionDefinition 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 12 with IActionDefinition

use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.

the class SolutionEngineInteractivityService method doGet.

@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
    PentahoSystem.systemEntryPoint();
    try {
        IPentahoSession userSession = getPentahoSession(request);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        // $NON-NLS-1$
        String solutionName = request.getParameter("solution");
        // $NON-NLS-1$
        String actionPath = request.getParameter("path");
        // $NON-NLS-1$
        String actionName = request.getParameter("action");
        IActionSequence actionSequence = new ActionSequenceJCRHelper().getActionSequence(ActionInfo.buildSolutionPath(solutionName, actionPath, actionName), PentahoSystem.loggingLevel, RepositoryFilePermission.READ);
        String fileName = null;
        if (actionSequence != null) {
            String title = actionSequence.getTitle();
            if ((title != null) && (title.length() > 0)) {
                fileName = title;
            } else {
                String sequenceName = actionSequence.getSequenceName();
                if ((sequenceName != null) && (sequenceName.length() > 0)) {
                    fileName = sequenceName;
                } else {
                    List actionDefinitionsList = actionSequence.getActionDefinitionsAndSequences();
                    int i = 0;
                    boolean done = false;
                    while ((actionDefinitionsList.size() > i) && !done) {
                        IActionDefinition actionDefinition = (IActionDefinition) actionDefinitionsList.get(i);
                        String componentName = actionDefinition.getComponentName();
                        if ((componentName != null) && (componentName.length() > 0)) {
                            fileName = componentName;
                            done = true;
                        } else {
                            i++;
                        }
                    }
                }
            }
        }
        IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
        HttpOutputHandler outputHandler = createOutputHandler(response, outputStream);
        outputHandler.setSession(userSession);
        IMimeTypeListener listener = new HttpMimeTypeListener(request, response);
        listener.setName(fileName);
        outputHandler.setMimeTypeListener(listener);
        SimpleUrlFactory urlFactory = new SimpleUrlFactory(requestContext.getContextPath() + // $NON-NLS-1$
        "SolutionEngineInteractivityService?");
        IParameterProvider requestParameters = new HttpRequestParameterProvider(request);
        setupOutputHandler(outputHandler, requestParameters);
        HttpServletRequestHandler requestHandler = getRequestHandler(request, response, userSession, requestParameters, outputStream, outputHandler, urlFactory);
        handleActionRequest(request, response, outputHandler, requestHandler, requestParameters, outputStream, null);
    } finally {
        PentahoSystem.systemExitPoint();
    }
}
Also used : IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) IActionSequence(org.pentaho.platform.api.engine.IActionSequence) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) HttpOutputHandler(org.pentaho.platform.web.http.HttpOutputHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HttpRequestParameterProvider(org.pentaho.platform.web.http.request.HttpRequestParameterProvider) List(java.util.List) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory)

Example 13 with IActionDefinition

use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.

the class XactionUtil method createOutputFileName.

@SuppressWarnings("rawtypes")
public static void createOutputFileName(RepositoryFile file, IOutputHandler outputHandler) {
    IPentahoSession userSession = PentahoSessionHolder.getSession();
    ActionSequenceJCRHelper actionHelper = new ActionSequenceJCRHelper(userSession);
    IActionSequence actionSequence = actionHelper.getActionSequence(file.getPath(), PentahoSystem.loggingLevel, RepositoryFilePermission.READ);
    // $NON-NLS-1$
    String fileName = "content";
    if (actionSequence != null) {
        String title = actionSequence.getTitle();
        if ((title != null) && (title.length() > 0)) {
            fileName = title;
        } else {
            String sequenceName = actionSequence.getSequenceName();
            if ((sequenceName != null) && (sequenceName.length() > 0)) {
                fileName = sequenceName;
            } else {
                List actionDefinitionsList = actionSequence.getActionDefinitionsAndSequences();
                int i = 0;
                boolean done = false;
                while ((actionDefinitionsList.size() > i) && (!done)) {
                    IActionDefinition actionDefinition = (IActionDefinition) actionDefinitionsList.get(i);
                    String componentName = actionDefinition.getComponentName();
                    if ((componentName != null) && (componentName.length() > 0)) {
                        fileName = componentName;
                        done = true;
                    } else {
                        ++i;
                    }
                }
            }
        }
    }
    IMimeTypeListener mimeTypeListener = outputHandler.getMimeTypeListener();
    if (mimeTypeListener != null) {
        mimeTypeListener.setName(fileName);
    }
}
Also used : IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) IActionSequence(org.pentaho.platform.api.engine.IActionSequence) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) List(java.util.List) ArrayList(java.util.ArrayList) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper)

Example 14 with IActionDefinition

use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.

the class ViewAction method doGet.

@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
    PentahoSystem.systemEntryPoint();
    try {
        IPentahoSession userSession = getPentahoSession(request);
        if (!doBackgroundExecution(request, response, userSession)) {
            OutputStream outputStream = getOutputStream(response, doMessages(request));
            ActionSequenceJCRHelper actionHelper = new ActionSequenceJCRHelper(userSession);
            // $NON-NLS-1$
            String actionPath = request.getParameter("path");
            IActionSequence actionSequence = actionHelper.getActionSequence(actionPath, PentahoSystem.loggingLevel, RepositoryFilePermission.READ);
            String fileName = null;
            if (actionSequence != null) {
                String title = actionSequence.getTitle();
                if ((title != null) && (title.length() > 0)) {
                    fileName = title;
                } else {
                    String sequenceName = actionSequence.getSequenceName();
                    if ((sequenceName != null) && (sequenceName.length() > 0)) {
                        fileName = sequenceName;
                    } else {
                        List actionDefinitionsList = actionSequence.getActionDefinitionsAndSequences();
                        int i = 0;
                        boolean done = false;
                        while ((actionDefinitionsList.size() > i) && !done) {
                            IActionDefinition actionDefinition = (IActionDefinition) actionDefinitionsList.get(i);
                            String componentName = actionDefinition.getComponentName();
                            if ((componentName != null) && (componentName.length() > 0)) {
                                fileName = componentName;
                                done = true;
                            } else {
                                i++;
                            }
                        }
                    }
                }
            }
            IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
            HttpOutputHandler outputHandler = createOutputHandler(response, outputStream);
            outputHandler.setSession(userSession);
            IMimeTypeListener listener = new HttpMimeTypeListener(request, response, fileName);
            outputHandler.setMimeTypeListener(listener);
            // $NON-NLS-1$
            SimpleUrlFactory urlFactory = new SimpleUrlFactory(requestContext.getContextPath() + "ViewAction?");
            IParameterProvider requestParameters = new HttpRequestParameterProvider(request);
            HttpServletRequestHandler requestHandler = getRequestHandler(request, response, userSession, requestParameters, outputStream, outputHandler, urlFactory);
            handleActionRequest(request, response, outputHandler, requestHandler, outputStream, null);
        }
    } finally {
        PentahoSystem.systemExitPoint();
    }
}
Also used : IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) IActionSequence(org.pentaho.platform.api.engine.IActionSequence) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) HttpOutputHandler(org.pentaho.platform.web.http.HttpOutputHandler) IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HttpRequestParameterProvider(org.pentaho.platform.web.http.request.HttpRequestParameterProvider) List(java.util.List) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory)

Example 15 with IActionDefinition

use of org.pentaho.actionsequence.dom.IActionDefinition in project pentaho-platform by pentaho.

the class ActionSequenceException method _printStack.

/*
   * We are not i18n-ing these stack trace messages. This can be thought of as Throwable.printStackTrace()
   */
@SuppressWarnings("nls")
protected void _printStack(IActionSequenceExecutableStatement statement, PrintWriter s, String prefix) {
    if (statement instanceof IActionIfStatement) {
        s.println(prefix + "IF STATEMENT: " + ((IActionIfStatement) statement).getCondition());
    } else if (statement instanceof IActionLoop) {
        s.println(prefix + "LOOP ON: " + ((IActionLoop) statement).getLoopOn());
    } else if (statement instanceof IActionDefinition) {
        String actionDesc = StringUtils.defaultString(((IActionDefinition) statement).getDescription(), "");
        s.println(prefix + "EXECUTING ACTION: " + actionDesc + " (" + ((IActionDefinition) statement).getComponentName() + ")");
    } else if (statement instanceof IActionControlStatement) {
        s.println(prefix + "UNKNOWN CONTROL STATEMENT");
    } else {
        s.println(prefix + "UNKNOWN EXECUTABLE STATEMENT");
    }
    IActionSequenceExecutableStatement parent = statement.getParent();
    if (parent != null) {
        _printStack(statement.getParent(), s, "\tin ");
    }
}
Also used : IActionLoop(org.pentaho.actionsequence.dom.IActionLoop) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) IActionControlStatement(org.pentaho.actionsequence.dom.IActionControlStatement) IActionSequenceExecutableStatement(org.pentaho.actionsequence.dom.IActionSequenceExecutableStatement) IActionIfStatement(org.pentaho.actionsequence.dom.IActionIfStatement)

Aggregations

IActionDefinition (org.pentaho.actionsequence.dom.IActionDefinition)19 Test (org.junit.Test)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 List (java.util.List)3 IActionInput (org.pentaho.actionsequence.dom.IActionInput)3 AbstractRelationalDbAction (org.pentaho.actionsequence.dom.actions.AbstractRelationalDbAction)3 IActionSequence (org.pentaho.platform.api.engine.IActionSequence)3 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)3 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)3 ActionSequenceJCRHelper (org.pentaho.platform.engine.services.ActionSequenceJCRHelper)3 ArrayList (java.util.ArrayList)2 IActionIfStatement (org.pentaho.actionsequence.dom.IActionIfStatement)2 IActionLoop (org.pentaho.actionsequence.dom.IActionLoop)2 CopyParamAction (org.pentaho.actionsequence.dom.actions.CopyParamAction)2 FormatMsgAction (org.pentaho.actionsequence.dom.actions.FormatMsgAction)2 PrintMapValsAction (org.pentaho.actionsequence.dom.actions.PrintMapValsAction)2 PrintParamAction (org.pentaho.actionsequence.dom.actions.PrintParamAction)2 SqlConnectionAction (org.pentaho.actionsequence.dom.actions.SqlConnectionAction)2 XQueryAction (org.pentaho.actionsequence.dom.actions.XQueryAction)2 XQueryConnectionAction (org.pentaho.actionsequence.dom.actions.XQueryConnectionAction)2