Search in sources :

Example 16 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class RuntimeContext method executeSequence.

@SuppressWarnings({ "unchecked" })
public void executeSequence(final IActionSequence sequence, final IActionCompleteListener doneListener, 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) {
            // replace the loop param in case the last loop muggled it
            addInputParameter(loopParm.getName(), loopParm);
        }
    } else if (loopList instanceof IPentahoResultSet) {
        executeLoop(loopParm, (IPentahoResultSet) loopList, sequence, doneListener, execListener, async, peekOnly);
    }
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 17 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class RuntimeContext method getInputStream.

public InputStream getInputStream(final String parameterName) {
    InputStream inputStream = null;
    IActionParameter inputParameter = getInputParameter(parameterName);
    if (inputParameter == null) {
        throw new InvalidParameterException(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", parameterName, // $NON-NLS-1$
        actionSequence.getSequenceName()));
    }
    Object value = inputParameter.getValue();
    if (value instanceof IContentItem) {
        IContentItem contentItem = (IContentItem) value;
        inputStream = contentItem.getInputStream();
    }
    return inputStream;
}
Also used : InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IContentItem(org.pentaho.platform.api.repository.IContentItem) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 18 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class RuntimeContext method getInputParameterValue.

// IRuntimeContext input and output methods
public Object getInputParameterValue(final String name) {
    Object value = null;
    IActionParameter actionParameter = paramManager.getCurrentInput(name);
    if (actionParameter == null) {
        // TODO need to know from the action definition if this is ok or not
        warn(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0019_INVALID_INPUT_REQUEST", name, // $NON-NLS-1$
        actionSequence.getSequenceName()));
    } else {
        value = actionParameter.getValue();
    }
    return value;
}
Also used : IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 19 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class RuntimeContext method getDataSource.

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, // $NON-NLS-1$
        actionSequence.getSequenceName()));
    }
    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();
        }
    }
    // This will return null if the locObj is null
    return dataSource;
}
Also used : InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) IContentItem(org.pentaho.platform.api.repository.IContentItem) IPentahoStreamSource(org.pentaho.commons.connection.IPentahoStreamSource) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 20 with IActionParameter

use of org.pentaho.platform.api.engine.IActionParameter in project pentaho-platform by pentaho.

the class ComponentBase method addTempParameterObject.

protected void addTempParameterObject(final String name, final Object paramObject) {
    // $NON-NLS-1$
    String pType = "object";
    IActionParameter actionParameter = new ActionParameter(name, pType, paramObject, null, null);
    addTempParameter(name, actionParameter);
}
Also used : ActionParameter(org.pentaho.platform.engine.services.actionsequence.ActionParameter) IActionParameter(org.pentaho.platform.api.engine.IActionParameter) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Aggregations

IActionParameter (org.pentaho.platform.api.engine.IActionParameter)68 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)24 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)22 Iterator (java.util.Iterator)19 Map (java.util.Map)14 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)14 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)13 List (java.util.List)9 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)9 Set (java.util.Set)8 IContentItem (org.pentaho.platform.api.repository.IContentItem)8 IOException (java.io.IOException)7 OutputStream (java.io.OutputStream)6 Test (org.junit.Test)6 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)6 ActionParameter (org.pentaho.platform.engine.services.actionsequence.ActionParameter)6 Document (org.dom4j.Document)5 IPreparedComponent (org.pentaho.platform.api.data.IPreparedComponent)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4