Package org.pentaho.platform.api.engine

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


  }

  public IContentItem getOutputContentItem( final String outputName, final String mimeType ) {

    IContentItem contentItem = null;
    IActionParameter parameter = (IActionParameter) actionSequence.getOutputDefinitions().get( outputName );
    if ( parameter == null ) {
      warn( Messages.getInstance().getErrorString(
          "RuntimeContext.ERROR_0021_INVALID_OUTPUT_REQUEST", outputName, actionSequence.getSequenceName() ) ); //$NON-NLS-1$
    } else {
      List destinationsList = parameter.getVariables();
      Iterator destinationsIterator = destinationsList.iterator();
      if ( destinationsList.size() > 1 ) {
        contentItem = new MultiContentItem();
      }
      while ( destinationsIterator.hasNext() ) {
View Full Code Here


  public IPentahoStreamSource getDataSource( final String parameterName ) {
    IPentahoStreamSource dataSource = null;

    // TODO Temp workaround for content repos bug
    IActionParameter actionParameter = paramManager.getCurrentInput( parameterName );
    if ( actionParameter == null ) {
      throw new InvalidParameterException( Messages.getInstance().getErrorString(
          "RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", parameterName, actionSequence.getSequenceName() ) ); //$NON-NLS-1$
    }

    Object locObj = actionParameter.getValue();
    if ( locObj != null ) {
      if ( locObj instanceof IContentItem ) { // At this point we have an IContentItem so why do anything else?
        dataSource = ( (IContentItem) locObj ).getDataSource();
      }
    }
View Full Code Here

      final IExecutionListener execListener, final boolean async ) throws ActionSequenceException {
    String loopParamName = sequence.getLoopParameter();

    boolean peekOnly = sequence.getLoopUsingPeek();
    Object loopList;
    IActionParameter loopParm = null;

    if ( loopParamName == null ) {
      loopList = new ArrayList<Integer>();
      ( (ArrayList) loopList ).add( new Integer( 0 ) );
    } else {
      loopParm = getLoopParameter( loopParamName );
      loopList = loopParm.getValue();

      // If the loop list is an array, convert it to an array list for processing
      if ( loopList instanceof Object[] ) {
        loopList = Arrays.asList( (Object[]) loopList );
      }

    }

    if ( loopList instanceof List ) {
      executeLoop( loopParm, (List) loopList, sequence, doneListener, execListener, async );
      if ( loopParm != null ) {
        addInputParameter( loopParm.getName(), loopParm ); // replace the loop param in case the last loop muggled
                                                           // it
      }
    } else if ( loopList instanceof IPentahoResultSet ) {
      executeLoop( loopParm, (IPentahoResultSet) loopList, sequence, doneListener, execListener, async, peekOnly );
    }
View Full Code Here

      if ( execListener != null ) {
        execListener.loop( this, loopCount );
      }
      if ( loopParm != null ) {
        IActionParameter ap;
        for ( int columnNo = 0; columnNo < headers.length; columnNo++ ) {
          String name = headers[columnNo].toString();
          Object value = row[columnNo];
          String type = null;
          if ( value instanceof String ) {
            type = IActionParameter.TYPE_STRING;
          } else if ( value instanceof Date ) {
            type = IActionParameter.TYPE_DATE;
          } else if ( ( value instanceof Long ) || ( value instanceof Integer ) ) {
            type = IActionParameter.TYPE_INTEGER;
          } else if ( ( value instanceof BigDecimal ) || ( value instanceof Double ) || ( value instanceof Float ) ) {
            type = IActionParameter.TYPE_DECIMAL;
          } else if ( value instanceof String[] ) {
            type = IActionParameter.TYPE_STRING;
          } else if ( value == null ) {
            warn( Messages.getInstance().getString( "RuntimeContext.WARN_VARIABLE_IN_LOOP_IS_NULL", name ) ); //$NON-NLS-1$
          } else {
            type = IActionParameter.TYPE_OBJECT;
            warn( Messages.getInstance().getString(
                "RuntimeContext.WARN_VARIABLE_IN_LOOP_NOT_RECOGNIZED", name, value.getClass().toString() ) ); //$NON-NLS-1$
          }
          // TODO make sure any previous loop values are removed
          ap = paramManager.getInput( name );
          if ( ap == null ) {
            ap = new ActionParameter( name, type, value, null, null );
            addInputParameter( name, ap );
          } else {
            ap.dispose();
            ap.setValue( value );
          }
        }
      }
      try {
        performActions( sequence, doneListener, execListener, async );
View Full Code Here

      if ( execListener != null ) {
        execListener.loop( this, loopCount );
      }
      Object loopVar = it.next();
      if ( loopParm != null ) {
        IActionParameter ap;
        if ( loopVar instanceof Map ) {
          ap = new ActionParameter( loopParm.getName(), "property-map", loopVar, null, null ); //$NON-NLS-1$
        } else {
          ap = new ActionParameter( loopParm.getName(), "string", loopVar, null, null ); //$NON-NLS-1$
        }
View Full Code Here

  private void resolveParameters() throws UnresolvedParameterException {

    Set inputNames = getInputNames();
    Iterator inputNamesIterator = inputNames.iterator();
    IActionParameter actionParameter;
    List variables;
    Iterator variablesIterator;
    ActionParameterSource variable;
    String sourceName;
    String sourceValue;
    Object variableValue = null;
    IParameterProvider parameterProvider;
    while ( inputNamesIterator.hasNext() ) {
      variableValue = null;

      String inputName = (String) inputNamesIterator.next();
      actionParameter = paramManager.getCurrentInput( inputName );
      if ( actionParameter == null ) {
        throw new UnresolvedParameterException( Messages.getInstance().getErrorString(
            "RuntimeContext.ERROR_0031_INPUT_NOT_FOUND", inputName ), //$NON-NLS-1$
            session.getName(), instanceId, getActionSequence().getSequenceName(), null );
      }

      variables = actionParameter.getVariables();
      variablesIterator = variables.iterator();
      while ( variablesIterator.hasNext() ) {
        variable = (ActionParameterSource) variablesIterator.next();
        sourceName = variable.getSourceName();
        sourceValue = variable.getValue();
        variableValue = null;
        // TODO support accessing the ancestors of the current instance,
        // e.g. runtme.parent
        if ( "runtime".equals( sourceName ) ) { //$NON-NLS-1$
          // first check the standard variables
          variableValue = getStringParameter( sourceValue, null );
          if ( variableValue == null ) {
            // now check the runtime data
            variableValue = runtimeData.getStringProperty( sourceValue, null );
          }
          if ( variableValue != null ) {
            break;
          }
        } else {
          parameterProvider = (IParameterProvider) parameterProviders.get( sourceName );
          if ( parameterProvider == null ) {
            warn( Messages.getInstance().getString(
                "RuntimeContext.WARN_REQUESTED_PARAMETER_SOURCE_NOT_AVAILABLE", sourceName, inputName ) ); //$NON-NLS-1$
          } else {
            variableValue = parameterProvider.getParameter( sourceValue );
            if ( variableValue != null ) {
              break;
            }
          }
        }
      } // while

      if ( variableValue == null ) {

        if ( actionParameter.getValue() != null ) {
          if ( actionParameter.hasDefaultValue() ) {
            if ( PentahoSystem.trace ) {
              trace( Messages.getInstance().getString( "RuntimeContext.TRACE_USING_DEFAULT_PARAMETER_VALUE", inputName ) ); //$NON-NLS-1$
            }
          } else {
            if ( PentahoSystem.trace ) {
              trace( Messages.getInstance().getString(
                  "RuntimeContext.TRACE_INFO_USING_CURRENT_PARAMETER_VALUE" + inputName ) ); //$NON-NLS-1$
            }
          }
        } else if ( "content".equals( actionParameter.getType() ) ) { //$NON-NLS-1$
          variableValue = ""; //$NON-NLS-1$
        }
      } else {
        actionParameter.setValue( variableValue );
      }
    } // while
  }
View Full Code Here

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

          solutionEngine
              .execute(
                  xactionStr,
                  "test1a.xaction", "empty action sequence test", false, true, null, false, providers, null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
      IActionParameter param = runtimeContext.getOutputParameter( "output1" );
      assertNotNull( "param is null", param );
      assertEquals( "setting is wrong", "value1", TestPojo1.setting1 );
      assertEquals( "setting is wrong", "value2", TestPojo1.setting2 );
      assertEquals( "setting is wrong", null, TestPojo1.setting3 );
      assertEquals( "param is wrong", "abcdeabcde", param.getValue() );
      assertEquals( "setInt2 failed", new Integer( 22 ), TestPojo1.int2 );
      assertEquals( "setBoolean2 failed", new Boolean( true ), TestPojo1.bool2 );
      assertEquals( "setLong2 failed", new Long( 99 ), TestPojo1.long2 );
      assertEquals( "setBigDecimal failed", new BigDecimal( "77.7" ), TestPojo1.bigDecimal );
      assertEquals( "setFloat2 failed", "44.4", TestPojo1.float2.toString() );
View Full Code Here

          solutionEngine
              .execute(
                  xactionStr,
                  "test1a.xaction", "empty action sequence test", false, true, null, false, providers, null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      assertNotNull( "RuntimeContext is null", runtimeContext );
      IActionParameter param = runtimeContext.getOutputParameter( "output1" );
      assertNotNull( "param is null", param );
      assertEquals( "setting is wrong", "value1", TestPojo1.setting1 );
      assertEquals( "setting is wrong", "value2", TestPojo1.setting2 );
      assertEquals( "setting is wrong", null, TestPojo1.setting3 );
      assertEquals( "param is wrong", "abcdeabcde", param.getValue() );
      assertEquals( "setInt2 failed", new Integer( 22 ), TestPojo1.int2 );
      assertEquals( "setBoolean2 failed", new Boolean( true ), TestPojo1.bool2 );
      assertEquals( "setLong2 failed", new Long( 99 ), TestPojo1.long2 );
      assertEquals( "setBigDecimal failed", new BigDecimal( "77.7" ), TestPojo1.bigDecimal );
      assertEquals( "setFloat2 failed", "44.4", TestPojo1.float2.toString() );
View Full Code Here

      IRuntimeContext runtimeContext =
          solutionEngine
              .execute(
                  xactionStr,
                  "pojo1b.xaction", "empty action sequence test", false, true, null, false, new HashMap(), null, null, new SimpleUrlFactory( "" ), new ArrayList() ); //$NON-NLS-1$ //$NON-NLS-2$
      IActionParameter param = runtimeContext.getOutputParameter( "output1" );
      assertNotNull( "RuntimeContext is null", runtimeContext );
      assertTrue( "done() was not called", PojoComponentTest.doneCalled );
      assertEquals( "setInt1 failed", 11, TestPojo1.int1 );
      assertEquals( "setInt2 failed", new Integer( 22 ), TestPojo1.int2 );
      assertEquals( "setBoolean1 failed", true, TestPojo1.bool1 );
View Full Code Here

TOP

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

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.