Search in sources :

Example 1 with Mapping

use of org.pentaho.di.trans.steps.mapping.Mapping in project pentaho-kettle by pentaho.

the class BaseStep method findInputRowSet.

/**
 * Find input row set.
 *
 * @param from     the from
 * @param fromcopy the fromcopy
 * @param to       the to
 * @param tocopy   the tocopy
 * @return the row set
 */
public RowSet findInputRowSet(String from, int fromcopy, String to, int tocopy) {
    synchronized (inputRowSetsLock) {
        for (RowSet rs : inputRowSets) {
            if (rs.getOriginStepName().equalsIgnoreCase(from) && rs.getDestinationStepName().equalsIgnoreCase(to) && rs.getOriginStepCopy() == fromcopy && rs.getDestinationStepCopy() == tocopy) {
                return rs;
            }
        }
    }
    // See if the rowset is part of the output of a mapping source step...
    // 
    // Lookup step "From"
    // 
    StepMeta mappingStep = transMeta.findStep(from);
    // 
    if (mappingStep != null && mappingStep.isMapping()) {
        // In this case we can cast the step thread to a Mapping...
        // 
        List<StepInterface> baseSteps = trans.findBaseSteps(from);
        if (baseSteps.size() == 1) {
            Mapping mapping = (Mapping) baseSteps.get(0);
            // Find the appropriate rowset in the mapping...
            // The rowset in question has been passed over to a Mapping Input step inside the Mapping transformation.
            // 
            MappingOutput[] outputs = mapping.getMappingTrans().findMappingOutput();
            for (MappingOutput output : outputs) {
                for (RowSet rs : output.getOutputRowSets()) {
                    // 
                    if (rs.getDestinationStepName().equalsIgnoreCase(to)) {
                        return rs;
                    }
                }
            }
        }
    }
    return null;
}
Also used : RowSet(org.pentaho.di.core.RowSet) BlockingRowSet(org.pentaho.di.core.BlockingRowSet) Mapping(org.pentaho.di.trans.steps.mapping.Mapping) MappingOutput(org.pentaho.di.trans.steps.mappingoutput.MappingOutput)

Example 2 with Mapping

use of org.pentaho.di.trans.steps.mapping.Mapping in project pentaho-kettle by pentaho.

the class BaseStep method findOutputRowSet.

/**
 * Find an output rowset in a running transformation. It will also look at the "to" step to see if this is a mapping.
 * If it is, it will find the appropriate rowset in that transformation.
 *
 * @param from
 * @param fromcopy
 * @param to
 * @param tocopy
 * @return The rowset or null if none is found.
 */
public RowSet findOutputRowSet(String from, int fromcopy, String to, int tocopy) {
    synchronized (outputRowSetsLock) {
        for (RowSet rs : outputRowSets) {
            if (rs.getOriginStepName().equalsIgnoreCase(from) && rs.getDestinationStepName().equalsIgnoreCase(to) && rs.getOriginStepCopy() == fromcopy && rs.getDestinationStepCopy() == tocopy) {
                return rs;
            }
        }
    }
    // See if the rowset is part of the input of a mapping target step...
    // 
    // Lookup step "To"
    // 
    StepMeta mappingStep = transMeta.findStep(to);
    // 
    if (mappingStep != null && mappingStep.isMapping()) {
        // In this case we can cast the step thread to a Mapping...
        // 
        List<StepInterface> baseSteps = trans.findBaseSteps(to);
        if (baseSteps.size() == 1) {
            Mapping mapping = (Mapping) baseSteps.get(0);
            // Find the appropriate rowset in the mapping...
            // The rowset in question has been passed over to a Mapping Input step inside the Mapping transformation.
            // 
            MappingInput[] inputs = mapping.getMappingTrans().findMappingInput();
            for (MappingInput input : inputs) {
                for (RowSet rs : input.getInputRowSets()) {
                    // 
                    if (rs.getOriginStepName().equalsIgnoreCase(from)) {
                        return rs;
                    }
                }
            }
        }
    }
    // 
    return null;
}
Also used : MappingInput(org.pentaho.di.trans.steps.mappinginput.MappingInput) RowSet(org.pentaho.di.core.RowSet) BlockingRowSet(org.pentaho.di.core.BlockingRowSet) Mapping(org.pentaho.di.trans.steps.mapping.Mapping)

Aggregations

BlockingRowSet (org.pentaho.di.core.BlockingRowSet)2 RowSet (org.pentaho.di.core.RowSet)2 Mapping (org.pentaho.di.trans.steps.mapping.Mapping)2 MappingInput (org.pentaho.di.trans.steps.mappinginput.MappingInput)1 MappingOutput (org.pentaho.di.trans.steps.mappingoutput.MappingOutput)1