Package org.pentaho.platform.api.engine

Examples of org.pentaho.platform.api.engine.IRuntimeContext


    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, getSession() );
    solutionEngine.setLoggingLevel( getLoggingLevel() );
    solutionEngine.init( userSession );

    IRuntimeContext context = null;
    try {
      String actionSeqPath = ActionInfo.buildSolutionPath( solutionName, actionPath, actionName );

      context =
          solutionEngine
              .execute(
                  actionSeqPath,
                  Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_TEST" ), false, true, instanceId, false, getParameterProviders(), outputHandler, null, urlFactory, getMessages() ); //$NON-NLS-1$
    } finally {
      if ( context != null ) {
        context.dispose();
      }
    }
    return outputStream;
  }
View Full Code Here


    ArrayList messages = new ArrayList();
    String processId = this.getClass().getName();
    String instanceId = null;

    IRuntimeContext context = null;
    try {
      String actionSeqPath = ActionInfo.buildSolutionPath( solution, actionPath, actionName );
      context =
          solutionEngine.execute( actionSeqPath, processId, false, true, instanceId, false, parameterProviders,
              outputHandler, null, null, messages );

      if ( listSource != null ) {
        if ( context.getOutputNames().contains( listSource ) ) {
          IActionParameter output = context.getOutputParameter( listSource );
          IPentahoResultSet results = output.getValueAsResultSet();
          if ( results != null ) {
            results = results.memoryCopy();
          }
          return results;
        } else {
          // this is an error
          return null;
        }
      } else {
        // return the first list that we find...
        Iterator it = context.getOutputNames().iterator();
        while ( it.hasNext() ) {
          IActionParameter output = (IActionParameter) it.next();
          if ( output.getType().equalsIgnoreCase( IActionParameter.TYPE_RESULT_SET ) ) {
            IPentahoResultSet results = output.getValueAsResultSet();
            if ( results != null ) {
              results = results.memoryCopy();
            }
            return results;
          }
        }
      }
      return null;
    } finally {
      if ( context != null ) {
        context.dispose();
      }
    }
  }
View Full Code Here

        requestHandler.setActionPath( actionSeqPath );

        if ( ServletBase.debug ) {
          debug( Messages.getInstance().getString( "HttpWebService.DEBUG_WEB_SERVICE_START" ) ); //$NON-NLS-1$
        }
        IRuntimeContext runtime = null;
        try {
          runtime = requestHandler.handleActionRequest( 0, 0 );
          Document responseDoc =
              SoapHelper.createSoapResponseDocument( runtime, outputHandler, contentStream, requestHandler
                .getMessages() );
          XmlDom4JHelper.saveDom( responseDoc, outputStream, PentahoSystem.getSystemSetting( "web-service-encoding",
            "utf-8" ), true );
        } finally {
          if ( runtime != null ) {
            runtime.dispose();
          }
        }
      } else if ( "dial".equals( component ) ) { //$NON-NLS-1$
        doDial( solutionName, actionPath, actionName, parameterProvider, outputStream, userSession );
      } else if ( "chart".equals( component ) ) { //$NON-NLS-1$
View Full Code Here

  @SuppressWarnings( "unchecked" )
  protected void handleActionRequest( final HttpServletRequest request, final HttpServletResponse response,
      final IOutputHandler outputHandler, final HttpServletRequestHandler requestHandler, OutputStream outputStream,
      final IContentItem contentItem ) throws ServletException, IOException {
    IRuntimeContext runtime = null;
    try {
      runtime = requestHandler.handleActionRequest( 0, 0 );

      if ( runtime == null ) {
        StringBuffer buffer = new StringBuffer();
        for ( String message : (List<String>) requestHandler.getMessages() ) {
          buffer.append( message );
        }
        outputStream.write( buffer.toString().getBytes( LocaleHelper.getSystemEncoding() ) );
        return;
      }

      /*
       * the flag "hasResponse" should be set if the outputHandler is expected to serve a response back via either the
       * "response.content" output (a final content output), or an intermediate response such as a form to request
       * parameters such as from a SecureFilterComponent.
       */
      boolean hasResponse = outputHandler.isResponseExpected();
      IContentItem responseContentItem =
          outputHandler.getOutputContentItem( IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null );

      boolean success = ( runtime != null && runtime.getStatus() == IRuntimeContext.RUNTIME_STATUS_SUCCESS );
      boolean debugMessages = doMessages( request );
      boolean printSuccess = ( runtime != null ) && success && ( !hasResponse || debugMessages );
      boolean printError = ( runtime != null ) && !success && !response.isCommitted();

      if ( printSuccess || printError ) {
        final String htmlMimeType = "text/html"; //$NON-NLS-1$
        responseContentItem.setMimeType( htmlMimeType );
        // this is going to be the response output stream unless you are in debug mode
        outputStream = responseContentItem.getOutputStream( null );

        response.setContentType( htmlMimeType );
        StringBuffer buffer = new StringBuffer();

        IMessageFormatter formatter = PentahoSystem.get( IMessageFormatter.class, PentahoSessionHolder.getSession() );

        if ( printSuccess ) {
          boolean doWrapper = !( "false".equals( request.getParameter( "wrapper" ) ) ); //$NON-NLS-1$ //$NON-NLS-2$
          formatter.formatSuccessMessage( htmlMimeType, runtime, buffer, debugMessages, doWrapper );
        } else {
          response.resetBuffer();
          formatter.formatFailureMessage( htmlMimeType, runtime, buffer, requestHandler.getMessages() );
        }

        outputStream.write( buffer.toString().getBytes( LocaleHelper.getSystemEncoding() ) );
        responseContentItem.closeOutputStream();
      }
    } finally {
      if ( runtime != null ) {
        runtime.dispose();
      }
    }
  }
View Full Code Here

    String xactionStr = ServiceTestHelper.getXAction( "test-res/solution/test/ActionDelegateTest", actionSequenceFile );

    /*
     * execute the action sequence, providing the outputHandler created above
     */
    IRuntimeContext rc =
        solutionEngine.execute( xactionStr, actionSequenceFile, "action sequence to test the TestAction", false, true,
            null, false, new HashMap(), outputHandler, null, new SimpleUrlFactory( "" ), new ArrayList() );
    int status = rc.getStatus();
    if ( status == IRuntimeContext.PARAMETERS_FAIL || status == IRuntimeContext.RUNTIME_CONTEXT_RESOLVE_FAIL
        || status == IRuntimeContext.RUNTIME_STATUS_FAILURE || status == IRuntimeContext.RUNTIME_STATUS_INITIALIZE_FAIL
        || status == IRuntimeContext.RUNTIME_STATUS_SETUP_FAIL ) {
      throw new ActionSequenceException( "Action sequence failed!" );
    }
View Full Code Here

   */
  public static boolean doAction( String actionPath, final String processId,
      final IParameterProvider parameterProvider, final OutputStream outputStream, final IPentahoSession userSession,
      final ArrayList messages, final ILogger logger ) {
    int status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
    IRuntimeContext runtime = null;
    try {
      runtime =
          SolutionHelper.doActionInternal( actionPath, processId, parameterProvider, outputStream, userSession,
              messages, logger );
      if ( runtime != null ) {
        status = runtime.getStatus();
      }
    } finally {
      if ( runtime != null ) {
        runtime.dispose();
      }
    }
    return status == IRuntimeContext.RUNTIME_STATUS_SUCCESS;
  }
View Full Code Here

    mql += "</mql>"; //$NON-NLS-1$
    ArrayList messages = new ArrayList();
    SimpleParameterProvider lookupParameters = new SimpleParameterProvider();
    lookupParameters.setParameter( "mql", mql ); //$NON-NLS-1$

    IRuntimeContext runtime =
        SolutionHelper.doAction(
            "/system/metadata/PickList.xaction", "lookup-list", lookupParameters, getSession(), messages, this ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    IPentahoResultSet results = null;
    if ( runtime != null ) {
      if ( runtime.getStatus() == IRuntimeContext.RUNTIME_STATUS_SUCCESS ) {
        if ( runtime.getOutputNames().contains( "data" ) ) { //$NON-NLS-1$
          results = runtime.getOutputParameter( "data" ).getValueAsResultSet(); //$NON-NLS-1$
          Object[][] columnHeaders = results.getMetaData().getColumnHeaders();
          boolean hasColumnHeaders = columnHeaders != null;

          Element rowElement;
          Element dataElement = root.addElement( "data" ); //$NON-NLS-1$
View Full Code Here

    return SOLUTION_PATH;
  }

  public void testResultSet() {
    startTest();
    IRuntimeContext context = run( "/test/rules/ResultSetTest.xaction" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals(
        Messages.getInstance().getString( "BaseTest.USER_RUNNING_ACTION_SEQUENCE" ), IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus() ); //$NON-NLS-1$
    finishTest();
  }
View Full Code Here

    finishTest();
  }

  public void testJavaScriptResultSet() {
    startTest();
    IRuntimeContext context = run( "/test/rules/JavaScriptResultSetTest.xaction" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals(
        Messages.getInstance().getString( "BaseTest.USER_RUNNING_ACTION_SEQUENCE" ), IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus() ); //$NON-NLS-1$
    finishTest();
  }
View Full Code Here

    finishTest();
  }

  public void testResultSetWithoutColumnHeader() {
    startTest();
    IRuntimeContext context = run( "/test/rules/ResultSetTest_without_columnheader.xaction" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals(
        Messages.getInstance().getString( "BaseTest.USER_RUNNING_ACTION_SEQUENCE" ), IRuntimeContext.RUNTIME_STATUS_FAILURE, context.getStatus() ); //$NON-NLS-1$
    finishTest();
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.engine.IRuntimeContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.