Search in sources :

Example 31 with MemoryResultSet

use of org.pentaho.commons.connection.memory.MemoryResultSet in project pdi-platform-plugin by pentaho.

the class PdiAction method registerAsStepListener.

/**
 * Registers this component as a step listener of a transformation. This allows this component to receive rows of data
 * from the transformation when it executes. These rows are made available to other components in the action sequence
 * as a result set.
 *
 * @param stepName
 * @param trans
 * @return
 * @throws KettleStepException
 */
protected void registerAsStepListener(String stepName, Trans trans) throws KettleStepException {
    if (trans != null) {
        List<StepMetaDataCombi> stepList = trans.getSteps();
        // find the specified step
        for (StepMetaDataCombi step : stepList) {
            if (step.stepname.equals(stepName)) {
                if (log.isDebugEnabled()) {
                    // $NON-NLS-1$
                    log.debug(Messages.getInstance().getString("Kettle.DEBUG_FOUND_STEP_IMPORTER"));
                }
                // this is the step we are looking for
                if (log.isDebugEnabled()) {
                    // $NON-NLS-1$
                    log.debug(Messages.getInstance().getString("Kettle.DEBUG_GETTING_STEP_METADATA"));
                }
                RowMetaInterface row = trans.getTransMeta().getStepFields(stepName);
                // create the metadata that the Pentaho result sets need
                String[] fieldNames = row.getFieldNames();
                String[][] columns = new String[1][fieldNames.length];
                for (int column = 0; column < fieldNames.length; column++) {
                    columns[0][column] = fieldNames[column];
                }
                if (log.isDebugEnabled()) {
                    // $NON-NLS-1$
                    log.debug(Messages.getInstance().getString("Kettle.DEBUG_CREATING_RESULTSET_METADATA"));
                }
                MemoryMetaData metaData = new MemoryMetaData(columns, null);
                transformationOutputRows = new MemoryResultSet(metaData);
                transformationOutputErrorRows = new MemoryResultSet(metaData);
                // add ourself as a row listener
                step.step.addRowListener(this);
                break;
            }
        }
    }
}
Also used : StepMetaDataCombi(org.pentaho.di.trans.step.StepMetaDataCombi) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) MemoryMetaData(org.pentaho.commons.connection.memory.MemoryMetaData) MemoryResultSet(org.pentaho.commons.connection.memory.MemoryResultSet)

Aggregations

MemoryResultSet (org.pentaho.commons.connection.memory.MemoryResultSet)31 MemoryMetaData (org.pentaho.commons.connection.memory.MemoryMetaData)24 IPentahoMetaData (org.pentaho.commons.connection.IPentahoMetaData)7 JavaScriptResultSet (org.pentaho.platform.plugin.services.connections.javascript.JavaScriptResultSet)7 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 StepMetaDataCombi (org.pentaho.di.trans.step.StepMetaDataCombi)2 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 MimeHeaders (javax.xml.soap.MimeHeaders)1 Name (javax.xml.soap.Name)1 Node (javax.xml.soap.Node)1 SOAPBody (javax.xml.soap.SOAPBody)1 SOAPConnection (javax.xml.soap.SOAPConnection)1 SOAPElement (javax.xml.soap.SOAPElement)1