Package org.pentaho.platform.api.engine

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


    SimpleOutputHandler outputHandler = new SimpleOutputHandler( out, false );
    outputHandler.setOutputPreference( IOutputHandler.OUTPUT_TYPE_DEFAULT );

    startTest();
    IPentahoSession session = new StandaloneSession( "system" );
    ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
    if ( outputHandler != null ) {
      outputHandler.setSession( session );
    }
    try {
      String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "test/pojo/pojo2.xaction" );
      PojoComponentTest.setActionSequenceResourceCalled = false;
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "test1.xaction", "empty action sequence test", false, true, null, false, new HashMap(), outputHandler, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      IActionParameter param = runtimeContext.getOutputParameter( "outputstream" );
      assertNotNull( "RuntimeContext is null", runtimeContext );
View Full Code Here


                                                    IPentahoSession userSession, boolean forcePrompt,
                                                    List messages ) throws Exception {
    String processId = XactionUtil.class.getName();
    String instanceId = httpServletRequest.getParameter( "instance-id" ); //$NON-NLS-1$
    SimpleUrlFactory urlFactory = new SimpleUrlFactory( "" ); //$NON-NLS-1$
    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, userSession );
    ISystemSettings systemSettings = PentahoSystem.getSystemSettings();

    if ( solutionEngine == null ) {
      throw new ObjectFactoryException( "No Solution Engine" );
    }

    boolean instanceEnds = "true".equalsIgnoreCase(
      requestParams.getStringParameter( "instanceends", "true" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    String parameterXsl = systemSettings
      .getSystemSetting( "default-parameter-xsl", "DefaultParameterForm.xsl" ); //$NON-NLS-1$ //$NON-NLS-2$

    solutionEngine.setLoggingLevel( 2 );
    solutionEngine.init( userSession );
    solutionEngine.setForcePrompt( forcePrompt );
    if ( parameterXsl != null ) {
      solutionEngine.setParameterXsl( parameterXsl );
    }
    return solutionEngine.execute( file.getPath(), processId, false, instanceEnds, instanceId, false,
      parameterProviders, outputHandler, null, urlFactory, messages );
  }
View Full Code Here

  protected void runActionSequence( final IPentahoSession pentahoSession,
      final Map<String, IParameterProvider> parameterProviders, final IOutputHandler outputHandler,
      final ActionSequenceDocument doc ) throws RuntimeException {

    // Get the solution engine
    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, pentahoSession );
    if ( solutionEngine == null ) {
      throw new RuntimeException( "solutionEngine is null" ); //$NON-NLS-1$
    }
    solutionEngine.setLoggingLevel( ILogger.DEBUG );
    solutionEngine.init( pentahoSession );

    IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
    String contextPath = requestContext.getContextPath();

    IPentahoUrlFactory urlFactory = new SimpleUrlFactory( contextPath ); //$NON-NLS-1$

    IRuntimeContext runtime;
    IParameterProvider requestParmProvider = parameterProviders.get( "request" );
    if ( requestParmProvider.hasParameter( "obj_id" ) ) {

      final String obj_id = (String) requestParmProvider.getParameter( "obj_id" );
      final String msg_name = (String) requestParmProvider.getParameter( "message_name" );
      final String job_id = (String) requestParmProvider.getParameter( "job_id" );

      runtime = solutionEngine.execute( doc.toString(), obj_id, job_id, false, true, //$NON-NLS-1$ //$NON-NLS-2$
          msg_name, true, parameterProviders, outputHandler, null, urlFactory, new ArrayList() ); //$NON-NLS-1$
    } else {
      runtime = solutionEngine.execute( doc.toString(), "chartbeans_mql", "myprocessid", false, true, //$NON-NLS-1$ //$NON-NLS-2$
          "myinstanceid", true, parameterProviders, outputHandler, null, urlFactory, new ArrayList() ); //$NON-NLS-1$
    }

    if ( ( runtime != null ) && ( runtime.getStatus() != IRuntimeContext.RUNTIME_STATUS_SUCCESS ) ) {
      StringBuilder buf = new StringBuilder();
View Full Code Here

  protected IPentahoResultSet getActionData() {
    // create an instance of the solution engine to execute the specified
    // action

    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, getSession() );
    solutionEngine.setLoggingLevel( ILogger.DEBUG );
    solutionEngine.init( getSession() );

    HashMap parameterProviders = getParameterProviders();

    OutputStream outputStream = null;
    SimpleOutputHandler outputHandler = null;
    outputHandler = new SimpleOutputHandler( outputStream, false );

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

    String actionSeqPath = ActionInfo.buildSolutionPath( solution, actionPath, actionName );

    context =
        solutionEngine.execute( actionSeqPath, processId, false, true, instanceId, false, parameterProviders,
            outputHandler, null, urlFactory, messages );

    if ( actionOutput != null ) {
      if ( context.getOutputNames().contains( actionOutput ) ) {
        IActionParameter output = context.getOutputParameter( actionOutput );
View Full Code Here

  @Override
  public String publish( final IPentahoSession localSession ) {
    try {
      HashMap<String, String> parameters = new HashMap<String, String>();
      ISolutionEngine engine = SolutionHelper.execute( "publisher", localSession, "admin/clean_repository.xaction", //$NON-NLS-1$//$NON-NLS-2$
          parameters, null );
      IRuntimeContext context = engine.getExecutionContext();
      int status = context.getStatus();
      if ( status != IRuntimeContext.RUNTIME_STATUS_SUCCESS ) {
        return Messages.getInstance().getString( "CleanRepoPublisher.ERROR_0001_CLEAN_REPO_FAILED" ); //$NON-NLS-1$
      }
    } catch ( Throwable t ) {
View Full Code Here

  public IRuntimeContext run( String actionPath, String instanceId, boolean persisted,
      IParameterProvider parameterProvider, IOutputHandler outputHandler, IPentahoSession session ) {
    assertTrue( initOk );

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

    return run( solutionEngine, actionPath, instanceId, persisted, parameterProvider, outputHandler );
  }
View Full Code Here

        .put( StandardSettings.ACTION_URL_COMPONENT, getInputStringValue( StandardSettings.ACTION_URL_COMPONENT ) );

    // get the ouptut stream
    // TODO verify this with MB and JD
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); // getDefaultOutputStream();
    ISolutionEngine solutionEngine = null;
    try {
      solutionEngine =
          SolutionHelper.execute( getProcessId(), session, actionPath, parameters, outputStream, null, true, false );
      if ( outputStream.size() > 0 ) {
        getDefaultOutputStream( null ).write( outputStream.toByteArray() );
      }

      int status = solutionEngine.getStatus();
      if ( status == IRuntimeContext.RUNTIME_STATUS_SUCCESS ) {
        // now pass any outputs back
        Iterator<?> it = this.getOutputNames().iterator();
        while ( it.hasNext() ) {
          String outputName = (String) it.next();
          IActionParameter param = solutionEngine.getExecutionContext().getOutputParameter( outputName );
          if ( param != null ) {
            setOutputValue( outputName, param.getValue() );
            ignoreParameters.add( param.getValue() );
          }
        }
        return true;
      } else {
        return false;
      }
    } finally {
      if ( solutionEngine != null ) {
        solutionEngine.getExecutionContext().dispose( ignoreParameters );
      }
    }
  }
View Full Code Here

    } else {
      outputHandler = new SimpleOutputHandler( xactionResultsOutputStream, false );
    }
    IRuntimeContext rt = null;
    try {
      ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, null );
      solutionEngine.setCreateFeedbackParameterCallback( null );
      solutionEngine.setLoggingLevel( ILogger.DEBUG );
      solutionEngine.setForcePrompt( false );

      ArrayList messages = new ArrayList();

      HashMap<String, Object> parameterProviders = new HashMap<String, Object>();
      parameterProviders.put( IParameterProvider.SCOPE_REQUEST, new SimpleParameterProvider( xActionInputParams ) );
      parameterProviders.put( IParameterProvider.SCOPE_SESSION, new PentahoSessionParameterProvider(
          PentahoSessionHolder.getSession() ) );
      String xactionPath = null;
      if ( xactionDefInputStream instanceof RepositoryFileInputStream ) {
        xactionPath = ( (RepositoryFileInputStream) xactionDefInputStream ).getFile().getPath();
      }
      rt =
          solutionEngine.execute( xactionPath, this.getClass().getName(), false, true, null, true, parameterProviders,
            outputHandler, null, null, messages );

      if ( !outputHandler.contentDone() ) {
        if ( ( rt != null ) && ( rt.getStatus() == IRuntimeContext.RUNTIME_STATUS_SUCCESS ) ) {
          boolean isFlushed = false;
View Full Code Here

    SimpleOutputHandler outputHandler = new SimpleOutputHandler( outputStream, true );
    outputHandler.setOutputPreference( IOutputHandler.OUTPUT_TYPE_PARAMETERS );
    StandaloneSession session =
        new StandaloneSession( Messages.getInstance().getString( "BaseTest.DEBUG_JUNIT_SESSION" ) ); //$NON-NLS-1$

    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session );
    solutionEngine.setLoggingLevel( getLoggingLevel() );
    solutionEngine.init( session );
    solutionEngine.setForcePrompt( true );
    IRuntimeContext context =
        run( solutionEngine,
            "/test/reporting/jfreereport-reports-test-param.xaction", null, false, parameterProvider, outputHandler ); //$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$
View Full Code Here

  public IRuntimeContext run( String actionSequencePath, String actionSequence, IParameterProvider parameterProvider,
      IOutputHandler outputHandler ) {
    List messages = new ArrayList();
    String instanceId = null;
    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session );
    solutionEngine.setLoggingLevel( ILogger.ERROR );
    solutionEngine.init( session );
    HashMap parameterProviderMap = new HashMap();
    IPentahoUrlFactory urlFactory = new SimpleUrlFactory( "" );
    IRuntimeContext runtimeContext = null;
    Reader reader = null;
    try {
      File file = new File( actionSequencePath + actionSequence );
      StringBuilder str = new StringBuilder();
      reader = new FileReader( file );
      char[] buffer = new char[4096];
      int n = reader.read( buffer );
      while ( n != -1 ) {
        str.append( buffer, 0, n );
        n = reader.read( buffer );
      }
      String xactionStr = str.toString();

      solutionEngine.setSession( session );
      runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  actionSequence,
                  "action sequence test", false, true, instanceId, false, parameterProviderMap, null, null, urlFactory, messages ); //$NON-NLS-1$
    } catch ( Exception e ) {
View Full Code Here

TOP

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

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.