void prepareExecutionResultsFileFields( RowMetaInterface row, StepMeta nextStep ) throws KettleStepException { if ( nextStep != null && resultFilesTargetStepMeta != null && nextStep.equals( resultFilesTargetStepMeta ) ) { addFieldToRow( row, resultFilesFileNameField, ValueMetaInterface.TYPE_STRING ); } }
public List<TransHopMeta> findAllTransHopFrom( StepMeta fromstep ) { return hops.stream() .filter( hop -> hop.getFromStep() != null && hop.getFromStep().equals( fromstep ) ) .collect( Collectors.toList() ); } /**
public StreamInterface findTargetStream( StepMeta targetStep ) { for ( StreamInterface stream : getTargetStreams() ) { if ( targetStep.equals( stream.getStepMeta() ) ) { return stream; } } return null; }
public StreamInterface findInfoStream( StepMeta infoStep ) { for ( StreamInterface stream : getInfoStreams() ) { if ( infoStep.equals( stream.getStepMeta() ) ) { return stream; } } return null; } }
private static boolean isUnusedInput( TransMeta trans, StepMeta step ) { int nrEnabledOutHops = findHops( trans, hop -> hop.getFromStep().equals( step ) && hop.isEnabled() ).size(); int nrDisabledOutHops = findHops( trans, hop -> hop.getFromStep().equals( step ) && !hop.isEnabled() ).size(); int nrInputHops = findHops( trans, hop -> hop.getToStep().equals( step ) ).size(); return ( nrEnabledOutHops == 0 && nrDisabledOutHops > 0 && nrInputHops == 0 ); }
public boolean isSendingErrorRowsToStep( StepMeta targetStep ) { return ( isDoingErrorHandling() && stepErrorMeta.getTargetStep().equals( targetStep ) ); }
@Override public void getFields( RowMetaInterface inputRowMeta, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( nextStep != null ) { if ( nextStep.equals( executionResultTargetStepMeta ) ) { inputRowMeta.clear(); prepareExecutionResultsFields( inputRowMeta, nextStep ); } else if ( nextStep.equals( resultFilesTargetStepMeta ) ) { inputRowMeta.clear(); prepareExecutionResultsFileFields( inputRowMeta, nextStep ); } else if ( nextStep.equals( outputRowsSourceStepMeta ) ) { inputRowMeta.clear(); prepareResultsRowsFields( inputRowMeta ); } // else don't call clear on inputRowMeta, it's the main output and should mimic the input } }
/** * Retrieve an array of succeeding steps for a certain originating step. * * @param stepMeta * The originating step * @return an array of succeeding steps. * @deprecated use findNextSteps instead */ @Deprecated public StepMeta[] getNextSteps( StepMeta stepMeta ) { List<StepMeta> nextSteps = new ArrayList<>(); for ( int i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() && hi.getFromStep().equals( stepMeta ) ) { nextSteps.add( hi.getToStep() ); } } return nextSteps.toArray( new StepMeta[nextSteps.size()] ); }
@Override public boolean cleanAfterHopToRemove( StepMeta fromStep ) { boolean hasChanged = false; // If the hop we're removing comes from a Step that is being used as the main step for the Join, we have to clear // that reference if ( null != fromStep && fromStep.equals( getMainStep() ) ) { setMainStep( null ); setMainStepname( null ); hasChanged = true; } return hasChanged; } }
/** * Retrieve an array of preceding steps for a certain destination step. This includes the info steps. * * @param stepMeta * The destination step * @return An array containing the preceding steps. */ public StepMeta[] getPrevSteps( StepMeta stepMeta ) { List<StepMeta> prevSteps = previousStepCache.get( getStepMetaCacheKey( stepMeta, true ) ); if ( prevSteps == null ) { prevSteps = new ArrayList<>(); for ( int i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hopMeta = getTransHop( i ); if ( hopMeta.isEnabled() && hopMeta.getToStep().equals( stepMeta ) ) { prevSteps.add( hopMeta.getFromStep() ); } } } return prevSteps.toArray( new StepMeta[prevSteps.size()] ); }
/** * Retrieve a list of succeeding steps for a certain originating step. * * @param stepMeta * The originating step * @return an array of succeeding steps. */ public List<StepMeta> findNextSteps( StepMeta stepMeta ) { List<StepMeta> nextSteps = new ArrayList<>(); for ( int i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() && hi.getFromStep().equals( stepMeta ) ) { nextSteps.add( hi.getToStep() ); } } return nextSteps; }
/** * Find the number of succeeding steps for a certain originating step. * * @param stepMeta * The originating step * @return The number of succeeding steps. * @deprecated use {@link #getNextSteps(StepMeta)} */ @Deprecated public int findNrNextSteps( StepMeta stepMeta ) { int count = 0; int i; for ( i = 0; i < nrTransHops(); i++ ) { // Look at all the hops; TransHopMeta hi = getTransHop( i ); if ( hi.isEnabled() && hi.getFromStep().equals( stepMeta ) ) { count++; } } return count; }
/** * Search all hops for a hop where a certain step is at the start. * * @param fromstep * The step at the start of the hop. * @return The hop or null if no hop was found. */ public TransHopMeta findTransHopFrom( StepMeta fromstep ) { int i; for ( i = 0; i < nrTransHops(); i++ ) { TransHopMeta hi = getTransHop( i ); if ( hi.getFromStep() != null && hi.getFromStep().equals( fromstep ) ) { // return the first return hi; } } return null; }
/** * Search all hops for a hop where a certain step is at the end. * * @param tostep * The step at the end of the hop. * @return The hop or null if no hop was found. */ public TransHopMeta findTransHopTo( StepMeta tostep ) { int i; for ( i = 0; i < nrTransHops(); i++ ) { TransHopMeta hi = getTransHop( i ); if ( hi.getToStep() != null && hi.getToStep().equals( tostep ) ) { // Return the first! return hi; } } return null; }
private Set<StepMeta> enableDisableNextHops( StepMeta from, boolean enabled, Set<StepMeta> checkedEntries ) { checkedEntries.add( from ); transMeta.getTransHops().stream() .filter( hop -> from.equals( hop.getFromStep() ) ) .forEach( hop -> { if ( hop.isEnabled() != enabled ) { TransHopMeta before = (TransHopMeta) hop.clone(); setHopEnabled( hop, enabled ); TransHopMeta after = (TransHopMeta) hop.clone(); spoon.addUndoChange( transMeta, new TransHopMeta[] { before }, new TransHopMeta[] { after }, new int[] { transMeta .indexOfTransHop( hop ) } ); } if ( !checkedEntries.contains( hop.getToStep() ) ) { enableDisableNextHops( hop.getToStep(), enabled, checkedEntries ); } } ); return checkedEntries; }
@Override public void onStepChange( TransMeta transMeta, StepMeta oldMeta, StepMeta newMeta ) { for ( int i = 0; i < transMeta.nrTransHops(); i++ ) { TransHopMeta hopMeta = transMeta.getTransHop( i ); if ( hopMeta.getFromStep().equals( oldMeta ) ) { StepMeta toStepMeta = hopMeta.getToStep(); if ( ( toStepMeta.getStepMetaInterface() instanceof MetaInjectMeta ) && ( toStepMeta.equals( this .getParentStepMeta() ) ) ) { MetaInjectMeta toMeta = (MetaInjectMeta) toStepMeta.getStepMetaInterface(); Map<TargetStepAttribute, SourceStepField> sourceMapping = toMeta.getTargetSourceMapping(); for ( Entry<TargetStepAttribute, SourceStepField> entry : sourceMapping.entrySet() ) { SourceStepField value = entry.getValue(); if ( value.getStepname() != null && value.getStepname().equals( oldMeta.getName() ) ) { value.setStepname( newMeta.getName() ); } } } } } } }
@Override public void getFields( RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException { if ( space instanceof TransMeta ) { TransMeta transMeta = (TransMeta) space; StepMeta[] steps = transMeta.getPrevSteps( transMeta.findStep( origin ) ); StepMeta mainStep = transMeta.findStep( getMainStepname() ); rowMeta.clear(); if ( mainStep != null ) { rowMeta.addRowMeta( transMeta.getStepFields( mainStep ) ); } for ( StepMeta step : steps ) { if ( mainStep == null || !step.equals( mainStep ) ) { rowMeta.addRowMeta( transMeta.getStepFields( step ) ); } } } }
/** * Sorts the hops in a natural way: from beginning to end. */ public void sortHopsNatural() { // Loop over the hops... for ( int j = 0; j < nrTransHops(); j++ ) { // Buble sort: we need to do this several times... for ( int i = 0; i < nrTransHops() - 1; i++ ) { TransHopMeta one = getTransHop( i ); TransHopMeta two = getTransHop( i + 1 ); StepMeta a = two.getFromStep(); StepMeta b = one.getToStep(); if ( !findPrevious( a, b ) && !a.equals( b ) ) { setTransHop( i + 1, one ); setTransHop( i, two ); } } } }
@Test public void testEqualsHashCodeConsistency() throws Exception { StepMeta step = new StepMeta(); step.setName( "step" ); TestUtils.checkEqualsHashCodeConsistency( step, step ); StepMeta stepSame = new StepMeta(); stepSame.setName( "step" ); assertTrue( step.equals( stepSame ) ); TestUtils.checkEqualsHashCodeConsistency( step, stepSame ); StepMeta stepCaps = new StepMeta(); stepCaps.setName( "STEP" ); TestUtils.checkEqualsHashCodeConsistency( step, stepCaps ); StepMeta stepOther = new StepMeta(); stepOther.setName( "something else" ); TestUtils.checkEqualsHashCodeConsistency( step, stepOther ); }