Package org.pentaho.platform.api.engine

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


  }

  public IRuntimeContext handleActionRequest( final int timeout, final int timeoutType ) {

    // Get the solution engine
    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session );
    if ( solutionEngine == null ) {
      Logger.error( this, Messages.getInstance().getErrorString( "BaseRequestHandler.ERROR_0001_NO_SOLUTION_ENGINE" ) ); //$NON-NLS-1$
      return null;
    }
    solutionEngine.setCreateFeedbackParameterCallback( createFeedbackParameterCallback );
    solutionEngine.setLoggingLevel( ILogger.DEBUG );
    solutionEngine.init( session );
    solutionEngine.setForcePrompt( forcePrompt );
    if ( parameterXsl != null ) {
      solutionEngine.setParameterXsl( parameterXsl );
    }

    dispose();
    runtime =
        solutionEngine.execute( actionPath, processId, false, instanceEnds, instanceId, true, parameterProviders,
            outputHandler, this, urlFactory, messages );

    // need to wait until this is complete
    // TODO
View Full Code Here


    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    SimpleOutputHandler outputHandler = new SimpleOutputHandler( outputStream, true );
    outputHandler.setOutputPreference( outputPreference );

    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 ) {
View Full Code Here

    String solution = XmlDom4JHelper.getNodeText( "data-solution", node ); //$NON-NLS-1$
    String actionPath = XmlDom4JHelper.getNodeText( "data-path", node ); //$NON-NLS-1$
    String actionName = XmlDom4JHelper.getNodeText( "data-action", node ); //$NON-NLS-1$
    String listSource = XmlDom4JHelper.getNodeText( "data-output", node ); //$NON-NLS-1$

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

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

    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 );
View Full Code Here

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

    IPentahoSession session = new StandaloneSession( "system" );
    ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
    outputHandler.setSession( session );

    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 ) {
View Full Code Here

      final IExecutionListener execListener, final boolean collateMessages, final boolean manageHibernate ) {

    if ( manageHibernate ) {
      PentahoSystem.systemEntryPoint();
    }
    ISolutionEngine solutionEngine = null;
    try {

      solutionEngine = PentahoSystem.get( ISolutionEngine.class, session );
      solutionEngine.init( session );
      solutionEngine.setlistener( execListener );

      SimpleParameterProvider parameterProvider = new SimpleParameterProvider( parameters );
      IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
      String url = requestContext.getContextPath();
      // Modifications by Ezequiel Cuellar
      // Old code.
      // String baseUrl = PentahoSystem.getApplicationContext().getBaseUrl();
      // New code. Since the SubActionComponent is being instantiated below to return feedback
      // it is necesary to configure the baseUrl to include the ViewAction.
      Object actionUrlComponent = parameters.get( StandardSettings.ACTION_URL_COMPONENT );
      if ( ( actionUrlComponent != null ) && ( actionUrlComponent.toString().length() > 0 ) ) {
        url += actionUrlComponent.toString();
      } else {
        url += "ViewAction?"; //$NON-NLS-1$
      }

      HashMap<String, IParameterProvider> parameterProviderMap = new HashMap<String, IParameterProvider>();
      parameterProviderMap.put( IParameterProvider.SCOPE_REQUEST, parameterProvider );

      IPentahoUrlFactory urlFactory = new SimpleUrlFactory( url );

      String processName = description;
      boolean persisted = false;
      // for now, the messages list needs to be untyped since we may put exceptions as well as strings in it
      List<?> messages = null;

      if ( collateMessages ) {
        messages = new ArrayList();
      }

      if ( outputStream == null ) {
        outputStream = new ByteArrayOutputStream( 0 );
      }
      SimpleOutputHandler outputHandler = null;
      if ( outputStream != null ) {

        // Modifications by Ezequiel Cuellar
        // Old code.
        // outputHandler = new SimpleOutputHandler(outputStream, false);
        // New code. Without setting the allowFeedback parameter to true it is assumed that SubActionComponent
        // instances
        // are never capable of returning feedback which may not always be the case.
        outputHandler = new SimpleOutputHandler( outputStream, true );
        outputHandler.setOutputPreference( IOutputHandler.OUTPUT_TYPE_DEFAULT );
      }
      solutionEngine.execute( actionSequence, processName, false, true, null, persisted, parameterProviderMap,
          outputHandler, null, urlFactory, messages );

    } finally {
      if ( manageHibernate ) {
        PentahoSystem.systemExitPoint();
View Full Code Here

    List messages = new ArrayList();
    String instanceId = null;
    IPentahoSession session = new StandaloneSession( "system" );
    PentahoSessionHolder.setSession( session );
    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class );
    solutionEngine.setLoggingLevel( ILogger.ERROR );
    solutionEngine.init( session );
    String baseUrl = PentahoSystem.getApplicationContext().getBaseUrl();
    HashMap parameterProviderMap = new HashMap();
    IPentahoUrlFactory urlFactory = new SimpleUrlFactory( baseUrl );

    try {
      File file = new File( getSolutionPath() + "/samples/platform/SetGlobalOutputTest.xaction" );
      StringBuilder str = new StringBuilder();
      Reader 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 );
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                xactionStr,
                "SetGlobalOutputTest.xaction", "empty action sequence test", false, true, instanceId, false,
                parameterProviderMap, null, null, urlFactory, messages ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
View Full Code Here

  }

  public void testMultiOutput() {

    startTest();
    ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
    String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "services/MultiOutputTest.xaction" );
    IRuntimeContext runtimeContext =
        solutionEngine
            .execute(
                xactionStr,
                "test1a.xaction", "empty action sequence test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
    finishTest();
View Full Code Here

  @Test
  public void testEmptyActionSequence() throws IOException {
    List<Object> messages = new ArrayList<Object>();
    String instanceId = null;
    IPentahoSession session = new StandaloneSession( "system" );
    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session );
    solutionEngine.setLoggingLevel( ILogger.ERROR );
    solutionEngine.init( session );
    Map<Object, Object> parameterProviderMap = new HashMap<Object, Object>();
    IPentahoUrlFactory urlFactory = new SimpleUrlFactory( "" );
    Reader reader = null;
    try {
      File file = new File( SOLUTION_PATH + "/services_layer/test1.xaction" );
      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 );
      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "test1.xaction", "empty action sequence test", false, true, instanceId, false, parameterProviderMap, null, null, urlFactory, messages ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertEquals( "Action sequence execution failed", runtimeContext.getStatus(),
View Full Code Here

   * @throws XmlParseException
   */
  public void testIsOutputParameter() throws XmlParseException {
    startTest();

    ISolutionEngine solutionEngine = ServiceTestHelper.getSolutionEngine();
    String xactionStr = ServiceTestHelper.getXAction( SOLUTION_PATH, "services/" + xactionName );

    Document actionSequenceDocument = XmlDom4JHelper.getDocFromString( xactionStr, null );
    IActionSequence actionSequence =
        SequenceDefinition.ActionSequenceFactory( actionSequenceDocument,
            "", this, PentahoSystem.getApplicationContext(), DEBUG ); //$NON-NLS-1$
    Map allParameters = actionSequence.getOutputDefinitions();
    Set<String> outParameters = new HashSet<String>();
    Set<String> nonOutParameters = new HashSet<String>();
    for ( Object key : allParameters.keySet() ) {
      IActionParameter param = (IActionParameter) allParameters.get( key );
      if ( param.isOutputParameter() ) {
        outParameters.add( param.getName() );
      } else {
        nonOutParameters.add( param.getName() );
      }
    }
    Assert.assertEquals( "expected 2 outputable parameters in xaction", 2, outParameters.size() );
    Assert.assertEquals( "expected 1 paramater with is-output-parameter=false", 1, nonOutParameters.size() );

    IRuntimeContext runtimeContext =
        solutionEngine
            .execute(
                xactionStr,
                xactionName,
                "simple output test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
    IParameterManager paramManager = runtimeContext.getParameterManager();
View Full Code Here

    return getSolutionEngine( session );

  }

  public static ISolutionEngine getSolutionEngine( IPentahoSession session ) {
    ISolutionEngine solutionEngine = PentahoSystem.get( ISolutionEngine.class, session );
    solutionEngine.setLoggingLevel( ILogger.ERROR );
    solutionEngine.init( session );
    return solutionEngine;
  }
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.