Package org.pentaho.platform.util.beans

Examples of org.pentaho.platform.util.beans.ActionHarness$DefaultActionCallback


  private IActionOutput[] actionDefintionOutputs;

  public ActionDelegate( Object actionBean ) {
    this.actionBean = actionBean;
    actionHarness = new ActionHarness( (IAction) actionBean );
  }
View Full Code Here


    IParameterProvider pathParams = parameterProviders.get( "path" ); //$NON-NLS-1$
    IParameterProvider requestParams = parameterProviders.get( IParameterProvider.SCOPE_REQUEST );

    RepositoryFile file = (RepositoryFile) pathParams.getParameter( "file" ); //$NON-NLS-1$

    ActionHarness harness = new ActionHarness( this );

    Iterator<?> iter = requestParams.getParameterNames();

    while ( iter.hasNext() ) {
      String paramName = (String) iter.next();
      harness.setValue( paramName, requestParams.getParameter( paramName ) );
    }

    this.setOutputStream( out );
    this.setRepositoryFile( file );
    this.execute();
View Full Code Here

    Callable<Boolean> actionBeanRunner = new Callable<Boolean>() {

      public Boolean call() throws Exception {
        LocaleHelper.setLocaleOverride( (Locale) params.get( LocaleHelper.USER_LOCALE_PARAM ) );
        // sync job params to the action bean
        ActionHarness actionHarness = new ActionHarness( actionBean );
        boolean updateJob = false;

        final Map<String, Object> actionParams = new HashMap<String, Object>();
        actionParams.putAll( params );
        if ( streamProvider != null ) {
          actionParams.put( "inputStream", streamProvider.getInputStream() );
        }
        actionHarness.setValues( actionParams, new ActionSequenceCompatibilityFormatter() );

        if ( actionBean instanceof IVarArgsAction ) {
          actionParams.remove( "inputStream" );
          actionParams.remove( "outputStream" );
          ( (IVarArgsAction) actionBean ).setVarArgs( actionParams );
        }

        boolean waitForFileCreated = false;
        OutputStream stream = null;
       
        if ( streamProvider != null ) {
          actionParams.remove( "inputStream" );
          if ( actionBean instanceof IStreamingAction ) {
            streamProvider.setStreamingAction( (IStreamingAction) actionBean );
          }

          // BISERVER-9414 - validate that output path still exist
          SchedulerOutputPathResolver resolver =
              new SchedulerOutputPathResolver( streamProvider.getOutputPath(), actionUser );
          String outputPath = resolver.resolveOutputFilePath();
          actionParams.put( "useJcr", Boolean.TRUE );
          actionParams.put( "jcrOutputPath", outputPath.substring( 0, outputPath.lastIndexOf( "/" ) ) );

          if ( !outputPath.equals( streamProvider.getOutputPath() ) ) {
            streamProvider.setOutputFilePath( outputPath ); // set fallback path
            updateJob = true; // job needs to be deleted and recreated with the new output path
          }

          stream = streamProvider.getOutputStream();
          if ( stream instanceof ISourcesStreamEvents ) {
            ( (ISourcesStreamEvents) stream ).addListener( new IStreamListener() {
              public void fileCreated( final String filePath ) {
                synchronized ( lock ) {
                  outputFilePath = filePath;
                  lock.notifyAll();
                }
              }
            } );
            waitForFileCreated = true;
          }
          actionParams.put( "outputStream", stream );
          // The lineage_id is only useful for the metadata and not needed at this level see PDI-10171
          actionParams.remove( QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID );
          actionHarness.setValues( actionParams );
        }

        actionBean.execute();

        if (stream != null) {
View Full Code Here

  }

  @Test
  public void testSetValue() throws Exception {
    IAction action = new TestVarArgsAction();
    ActionHarness harness = new ActionHarness( action );
    harness.setValue( "message", "test message" );

    Assert.assertEquals( "test message", harness.getValue( "message" ) );
  }
View Full Code Here

  }

  @Test
  public void testSetValue2() throws Exception {
    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness( action1 );
    harness1.setValue( "message", "test message action1" );

    TestAction action2 = new TestAction();
    ActionHarness harness2 = new ActionHarness( action2 );
    harness2.setValue( "message", "test message action2" );

    Assert.assertEquals( "test message action1", harness1.getValue( "message" ) );
    Assert.assertEquals( "test message action2", harness2.getValue( "message" ) );
  }
View Full Code Here

  @Test
  public void testVarArgsActionSetValue() throws Exception {

    TestVarArgsAction action = new TestVarArgsAction();
    ActionHarness harness = new ActionHarness( action );
    harness.setValue( "message", "test message" );
    harness.setValue( "undeclaredParam1", "undeclaredParam1 value" );
    harness.setValue( "undeclaredParam2", "undeclaredParam2 value" );

    Assert.assertEquals( "test message", harness.getValue( "message" ) );
    Assert.assertTrue( action.getVarArgs().containsKey( "undeclaredParam1" ) );
    Assert.assertTrue( action.getVarArgs().containsKey( "undeclaredParam2" ) );
    Assert.assertEquals( "undeclaredParam1 value", action.getVarArgs().get( "undeclaredParam1" ) );
    Assert.assertEquals( "undeclaredParam2 value", action.getVarArgs().get( "undeclaredParam2" ) );
  }
View Full Code Here

  @Test( expected = IllegalAccessException.class )
  public void testSetValueNonExistentProperty() throws Exception {

    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness( action1 );
    harness1.setValue( "THISPROPERTYDOESNOTEXIST", "", new EagerFailingCallback() );

    Assert.assertEquals( "test message action1", harness1.getValue( "message" ) );
  }
View Full Code Here

  @Test
  public void testSetNullIsSkippedWithNotError() throws Exception {

    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness( action1 );
    // commons bBeanutils will throw exception if you try to type convert a null value. Pentaho BeanUtil
    // will skip the set operation altogether if you try to set a null value on a bean. This test ensures
    // that no exception is thrown in this case. The correct behavior is a message will be logged indicating
    // that the null value could not be set. I don't consider this a "real" type conversion problem like
    // a text string failing conversion to a Long type.. this type of conversion will still fail.
    harness1.setValue( "count", null, new EagerFailingCallback() );
    // If no exception thrown, then the test is essentially passed. We'll double check that
    // count was not set as well.
    Assert.assertNull( "count property should remain null since null set value ops should be skipped", action1
        .getCount() );
  }
View Full Code Here

  @Test( expected = Exception.class )
  public void testSetValueFailedConvertWitNonNullValue() throws Exception {

    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness( action1 );
    harness1.setValue( "count", new CustomParamType(), new EagerFailingCallback() );
  }
View Full Code Here

  @Test
  public void testSetValueWithFormatter() throws Exception {

    TestAction action1 = new TestAction();
    ActionHarness harness1 = new ActionHarness( action1 );

    PropertyNameFormatter f = new PropertyNameFormatter() {

      public String format( String name ) {
        return "message";
      }
    };

    harness1.setValue( "THISWILLGETCLOBBERED", "test message action1", new EagerFailingCallback(), f );

    Assert.assertEquals( "test message action1", harness1.getValue( "message" ) );
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.util.beans.ActionHarness$DefaultActionCallback

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.