@Override public List<StepMeta> getObjectsForSyncFromTransformation( TransMeta transformation ) { return transformation.getSteps(); }
/** * Gets the list of used steps, which are the steps that are connected by hops. * * @return a list with all the used steps */ public List<StepMeta> getUsedSteps() { List<StepMeta> list = new ArrayList<>(); for ( StepMeta stepMeta : steps ) { if ( isStepUsedInTransHops( stepMeta ) ) { list.add( stepMeta ); } } if ( list.isEmpty() && getSteps().size() == 1 ) { list = getSteps(); } return list; }
private static void disableLazyConversion( TransMeta transMeta ) { transMeta.getSteps().stream().filter( step -> "CsvInput".equals( step.getStepID() ) ) .forEach( step -> ( (CsvInputMeta) step.getStepMetaInterface() ).setLazyConversionActive( false ) ); transMeta.getSteps().stream().filter( step -> "TableInput".equals( step.getStepID() ) ) .forEach( step -> ( (TableInputMeta) step.getStepMetaInterface() ).setLazyConversionActive( false ) ); }
public static String[] getMappingSteps( TransMeta mappingTransMeta, boolean mappingInput ) { List<StepMeta> steps = new ArrayList<StepMeta>(); for ( StepMeta stepMeta : mappingTransMeta.getSteps() ) { if ( mappingInput && stepMeta.getStepID().equals( "MappingInput" ) ) { steps.add( stepMeta ); } if ( !mappingInput && stepMeta.getStepID().equals( "MappingOutput" ) ) { steps.add( stepMeta ); } } String[] stepnames = new String[ steps.size() ]; for ( int i = 0; i < stepnames.length; i++ ) { stepnames[ i ] = steps.get( i ).getName(); } return stepnames; }
public static String[] getMappingSteps( TransMeta mappingTransMeta, boolean mappingInput ) { List<StepMeta> steps = new ArrayList<StepMeta>(); for ( StepMeta stepMeta : mappingTransMeta.getSteps() ) { if ( mappingInput && stepMeta.getStepID().equals( "MappingInput" ) ) { steps.add( stepMeta ); } if ( !mappingInput && stepMeta.getStepID().equals( "MappingOutput" ) ) { steps.add( stepMeta ); } } String[] stepnames = new String[ steps.size() ]; for ( int i = 0; i < stepnames.length; i++ ) { stepnames[ i ] = steps.get( i ).getName(); } return stepnames; }
public static String getInjectorStep( TransMeta mappingTransMeta ) { for ( StepMeta stepMeta : mappingTransMeta.getSteps() ) { if ( stepMeta.getStepID().equals( "Injector" ) || stepMeta.getStepID().equals( "MappingInput" ) ) { return stepMeta.getName(); } } return ""; }
private static void resolveStepMetaResources( TransMeta transMeta ) { for ( StepMeta stepMeta : transMeta.getSteps() ) { StepMetaInterface smi = stepMeta.getStepMetaInterface(); if ( smi instanceof ResolvableResource ) { ResolvableResource resolvableMeta = (ResolvableResource) smi; resolvableMeta.resolve(); } } }
/** * Removes input steps having only disabled output hops so they will not be executed. * @param transMeta transMeta to process */ private static void removeDisabledInputs( TransMeta transMeta ) { List<StepMeta> unusedInputs = findHops( transMeta, hop -> !hop.isEnabled() ).stream() .map( hop -> hop.getFromStep() ) .filter( step -> isUnusedInput( transMeta, step ) ) .collect( Collectors.toList() ); for ( StepMeta unusedInput : unusedInputs ) { List<TransHopMeta> outHops = transMeta.findAllTransHopFrom( unusedInput ); List<StepMeta> subsequentSteps = outHops.stream().map( hop -> hop.getToStep() ).collect( Collectors.toList() ); outHops.forEach( transMeta::removeTransHop ); transMeta.getSteps().remove( unusedInput ); removeInactivePaths( transMeta, subsequentSteps ); } }
/** * package-local visibility for testing purposes */ void patchTransSteps( TransMeta transMeta ) { for ( StepMeta stepMeta : transMeta.getSteps() ) { StepMetaInterface stepMetaInterface = stepMeta.getStepMetaInterface(); if ( stepMetaInterface instanceof HasRepositoryDirectories ) { patchRepositoryDirectories( stepMetaInterface.isReferencedObjectEnabled(), (HasRepositoryDirectories) stepMetaInterface ); } } }
protected void populateSubSteps( Event event ) { try { String current = wSubStep.getText(); wSubStep.removeAll(); ofNullable( getMappingMeta() ) .ifPresent( transMeta -> transMeta .getSteps() .stream() .map( StepMeta::getName ) .sorted() .forEach( wSubStep::add ) ); //I don't know why but just calling setText does not work when the text is not one of the items in the list. //Instead the first item in the list is selected. asyncExec solves it. If you have a better solution, by all //means go ahead and implement Display.getDefault().asyncExec( () -> wSubStep.setText( current ) ); } catch ( KettleException e ) { logDebug( e.getMessage(), e ); } }
protected TransMeta processLinkedJobs( TransMeta transMeta ) { for ( StepMeta stepMeta : transMeta.getSteps() ) { if ( stepMeta.getStepID().equalsIgnoreCase( "JobExecutor" ) ) { JobExecutorMeta jem = (JobExecutorMeta) stepMeta.getStepMetaInterface(); ObjectLocationSpecificationMethod specMethod = jem.getSpecificationMethod(); // If the reference is by filename, change it to Repository By Name. Otherwise it's fine so leave it alone if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) { jem.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); String filename = jem.getFileName(); String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) ); String directory = filename.substring( 0, filename.lastIndexOf( "/" ) ); jem.setJobName( jobname ); jem.setDirectoryPath( directory ); } } } return transMeta; }
protected TransMeta processLinkedTrans( TransMeta transMeta ) { for ( StepMeta stepMeta : transMeta.getSteps() ) { if ( stepMeta.getStepID().equalsIgnoreCase( "TransExecutor" ) ) { TransExecutorMeta tem = (TransExecutorMeta) stepMeta.getStepMetaInterface(); ObjectLocationSpecificationMethod specMethod = tem.getSpecificationMethod(); // If the reference is by filename, change it to Repository By Name. Otherwise it's fine so leave it alone if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) { tem.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); String filename = tem.getFileName(); String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) ); String directory = filename.substring( 0, filename.lastIndexOf( "/" ) ); tem.setTransName( jobname ); tem.setDirectoryPath( directory ); } } } return transMeta; }
@Override TransMeta createTransMetaForNode( Node transnode ) throws KettleMissingPluginsException, KettleXMLException { TransMeta meta = mock( TransMeta.class ); StepMeta stepMeta = mock( StepMeta.class ); when( stepMeta.isMapping() ).thenReturn( true ); when( stepMeta.getStepMetaInterface() ).thenReturn( stepMetaInterface ); when( meta.getSteps() ).thenReturn( Collections.singletonList( stepMeta ) ); return meta; }
if ( !StringUtil.isEmpty( getSubStep() ) ) { String realSubStepName = space.environmentSubstitute( getSubStep() ); if ( transMeta.getSteps().stream().anyMatch( stepMeta -> stepMeta.getName().equals( realSubStepName ) ) ) { rowMeta.addRowMeta( transMeta.getPrevStepFields( realSubStepName ) ); transMeta.getSteps().stream().filter( stepMeta -> stepMeta.getName().equals( realSubStepName ) ) .findFirst() .ifPresent( stepMeta ->
findHops( trans, hop -> hop.getToStep().equals( step ) || hop.getFromStep().equals( step ) ) .forEach( trans::removeTransHop ); trans.getSteps().remove( step );
copyTransMeta.getSteps().forEach( createOperation( transformation ) ); findHops( copyTransMeta, hop -> true ).forEach( createHop( transformation ) );
@Before public void setUp() throws Exception { meta = new StuffStreamMeta(); KettleLogStore.setLogChannelInterfaceFactory( logChannelFactory ); when( logChannelFactory.create( any(), any() ) ).thenReturn( logChannel ); when( logChannelFactory.create( any() ) ).thenReturn( logChannel ); when( mappingMetaRetriever.get( any(), any(), any(), any() ) ).thenReturn( subTransMeta ); when( subTransMeta.getPrevStepFields( anyString() ) ).thenReturn( prevRowMeta ); when( subTransMeta.getSteps() ).thenReturn( singletonList( subTransStepMeta ) ); when( subTransStepMeta.getStepMetaInterface() ).thenReturn( stepMetaInterface ); when( subTransStepMeta.getName() ).thenReturn( "SubStepName" ); meta.mappingMetaRetriever = mappingMetaRetriever; }
@Test public void testIsAnySelectedStepUsedInTransHopsNothingSelectedCase() { List<StepMeta> selectedSteps = asList( new StepMeta(), new StepMeta(), new StepMeta() ); transMeta.getSteps().addAll( selectedSteps ); assertFalse( transMeta.isAnySelectedStepUsedInTransHops() ); }
@Override public void run() { try { trans.prepareExecution( args ); // Do we capture data? // if ( transPreviewDelegate.isActive() ) { transPreviewDelegate.capturePreviewData( trans, transMeta.getSteps() ); } initialized = true; } catch ( KettleException e ) { log.logError( trans.getName() + ": preparing transformation execution failed", e ); checkErrorVisuals(); } halted = trans.hasHaltedSteps(); if ( trans.isReadyToStart() ) { checkStartThreads(); // After init, launch the threads. } else { initialized = false; running = false; checkErrorVisuals(); } } };
@Test public void testIsAnySelectedStepUsedInTransHopsAnySelectedCase() { StepMeta stepMeta = new StepMeta(); stepMeta.setName( STEP_NAME ); TransHopMeta transHopMeta = new TransHopMeta(); stepMeta.setSelected( true ); List<StepMeta> selectedSteps = asList( new StepMeta(), stepMeta, new StepMeta() ); transHopMeta.setToStep( stepMeta ); transHopMeta.setFromStep( stepMeta ); transMeta.getSteps().addAll( selectedSteps ); transMeta.addTransHop( transHopMeta ); assertTrue( transMeta.isAnySelectedStepUsedInTransHops() ); }