@Test public void testDisabledHops() { TransMeta trans = new TransMeta(); StepMeta start = new StepMeta( "Start", stepMetaInterface ); trans.addStep( start ); StepMeta withEnabledHop = new StepMeta( "WithEnabledHop", stepMetaInterface ); trans.addStep( withEnabledHop ); StepMeta withDisabledHop = new StepMeta( "WithDisabledHop", stepMetaInterface ); trans.addStep( withDisabledHop ); StepMeta shouldStay = new StepMeta( "ShouldStay", stepMetaInterface ); trans.addStep( shouldStay ); StepMeta shouldNotStay = new StepMeta( "ShouldNotStay", stepMetaInterface ); trans.addStep( shouldNotStay ); StepMeta withEnabledAndDisabledHops = new StepMeta( "WithEnabledAndDisabledHops", stepMetaInterface ); trans.addStep( withEnabledAndDisabledHops ); StepMeta afterEnabledDisabled = new StepMeta( "AfterEnabledDisabled", stepMetaInterface ); trans.addStep( afterEnabledDisabled ); trans.addTransHop( new TransHopMeta( start, withEnabledHop ) ); trans.addTransHop( new TransHopMeta( start, withDisabledHop, false ) ); trans.addTransHop( new TransHopMeta( withEnabledHop, shouldStay ) ); trans.addTransHop( new TransHopMeta( withDisabledHop, shouldStay ) ); trans.addTransHop( new TransHopMeta( withDisabledHop, shouldNotStay ) ); trans.addTransHop( new TransHopMeta( start, withEnabledAndDisabledHops ) ); trans.addTransHop( new TransHopMeta( withEnabledHop, withEnabledAndDisabledHops, false ) ); trans.addTransHop( new TransHopMeta( withEnabledAndDisabledHops, afterEnabledDisabled ) ); Transformation transformation = TransMetaConverter.convert( trans ); List<String> steps = transformation.getOperations().stream().map( op -> op.getId() ).collect( Collectors.toList() ); assertThat( "Only 5 ops should exist", steps.size(), is( 5 ) ); assertThat( steps, hasItems( "Start", "WithEnabledHop", "ShouldStay", "WithEnabledAndDisabledHops", "AfterEnabledDisabled" ) ); List<String> hops = transformation.getHops().stream().map( hop -> hop.getId() ).collect( Collectors.toList() ); assertThat( "Only 4 hops should exist", hops.size(), is( 4 ) ); assertThat( hops, hasItems( "Start -> WithEnabledHop", "WithEnabledHop -> ShouldStay", "Start -> WithEnabledAndDisabledHops", "WithEnabledAndDisabledHops -> AfterEnabledDisabled" ) ); }
public static Transformation convert( TransMeta transMeta ) { final org.pentaho.di.engine.model.Transformation transformation = new org.pentaho.di.engine.model.Transformation( createTransformationId( transMeta ) ); try { TransMeta copyTransMeta = (TransMeta) transMeta.realClone( false ); cleanupDisabledHops( copyTransMeta ); disableLazyConversion( copyTransMeta ); searchAndReplaceHadoopClusterWithFileSystemURL( copyTransMeta ); copyTransMeta.getSteps().forEach( createOperation( transformation ) ); findHops( copyTransMeta, hop -> true ).forEach( createHop( transformation ) ); transformation.setConfig( TRANS_META_CONF_KEY, copyTransMeta.getXML() ); transformation.setConfig( TRANS_META_NAME_CONF_KEY, Optional.ofNullable( transMeta.getName() ).orElse( TRANS_DEFAULT_NAME ) ); Map<String, Transformation> subTransformations = copyTransMeta.getResourceDependencies().stream() .flatMap( resourceReference -> resourceReference.getEntries().stream() ) .filter( entry -> ResourceEntry.ResourceType.ACTIONFILE.equals( entry.getResourcetype() ) ) .collect( toMap( ResourceEntry::getResource, entry -> { try { return convert( new TransMeta( entry.getResource(), copyTransMeta.getParentVariableSpace() ) ); } catch ( KettleXMLException | KettleMissingPluginsException e ) { throw new RuntimeException( e ); } } ) ); transformation.setConfig( SUB_TRANSFORMATIONS_KEY, (Serializable) subTransformations ); } catch ( KettleException e ) { Throwables.propagate( e ); } return transformation; }
TransMetaConverter { public static Transformation convert( TransMeta transMeta ) { final org.pentaho.di.engine.model.Transformation transformation = new org.pentaho.di.engine.model.Transformation( createTransformationId( transMeta ) ); try { TransMeta copyTransMeta = (TransMeta) transMeta.realClone( false ); cleanupDisabledHops( copyTransMeta ); disableLazyConversion( copyTransMeta ); searchAndReplaceHadoopClusterWithFileSystemURL( copyTransMeta ); copyTransMeta.getSteps().forEach( createOperation( transformation ) ); findHops( copyTransMeta, hop -> true ).forEach( createHop( transformation ) ); transformation.setConfig( TRANS_META_CONF_KEY, copyTransMeta.getXML() ); transformation.setConfig( TRANS_META_NAME_CONF_KEY, Optional.ofNullable( transMeta.getName() ).orElse( TRANS_DEFAULT_NAME ) ); Map<String, Transformation> subTransformations = copyTransMeta.getResourceDependencies().stream() .flatMap( resourceReference -> resourceReference.getEntries().stream() ) .filter( entry -> ResourceEntry.ResourceType.ACTIONFILE.equals( entry.getResourcetype() ) ) .collect( toMap( ResourceEntry::getResource, entry -> { try { return convert( new TransMeta( entry.getResource(), copyTransMeta.getParentVariableSpace() ) ); } catch ( KettleXMLException | KettleMissingPluginsException e ) { throw new RuntimeException( e ); } } ) ); transformation.setConfig( SUB_TRANSFORMATIONS_KEY, (Serializable) subTransformations ); } catch ( KettleException e ) { Throwables.propagate( e ); } return transformation; } }
TransMetaConverter { public static Transformation convert( TransMeta transMeta ) { final org.pentaho.di.engine.model.Transformation transformation = new org.pentaho.di.engine.model.Transformation( createTransformationId( transMeta ) ); try { TransMeta copyTransMeta = (TransMeta) transMeta.realClone( false ); cleanupDisabledHops( copyTransMeta ); disableLazyConversion( copyTransMeta ); searchAndReplaceHadoopClusterWithFileSystemURL( copyTransMeta ); copyTransMeta.getSteps().forEach( createOperation( transformation ) ); findHops( copyTransMeta, hop -> true ).forEach( createHop( transformation ) ); transformation.setConfig( TRANS_META_CONF_KEY, copyTransMeta.getXML() ); transformation.setConfig( TRANS_META_NAME_CONF_KEY, Optional.ofNullable( transMeta.getName() ).orElse( TRANS_DEFAULT_NAME ) ); Map<String, Transformation> subTransformations = copyTransMeta.getResourceDependencies().stream() .flatMap( resourceReference -> resourceReference.getEntries().stream() ) .filter( entry -> ResourceEntry.ResourceType.ACTIONFILE.equals( entry.getResourcetype() ) ) .collect( toMap( ResourceEntry::getResource, entry -> { try { return convert( new TransMeta( entry.getResource(), copyTransMeta.getParentVariableSpace() ) ); } catch ( KettleXMLException | KettleMissingPluginsException e ) { throw new RuntimeException( e ); } } ) ); transformation.setConfig( SUB_TRANSFORMATIONS_KEY, (Serializable) subTransformations ); } catch ( KettleException e ) { Throwables.propagate( e ); } return transformation; }  }
TransMetaConverter { public static Transformation convert( TransMeta transMeta ) { final org.pentaho.di.engine.model.Transformation transformation = new org.pentaho.di.engine.model.Transformation( createTransformationId( transMeta ) ); try { TransMeta copyTransMeta = (TransMeta) transMeta.realClone( false ); cleanupDisabledHops( copyTransMeta ); disableLazyConversion( copyTransMeta ); searchAndReplaceHadoopClusterWithFileSystemURL( copyTransMeta ); copyTransMeta.getSteps().forEach( createOperation( transformation ) ); findHops( copyTransMeta, hop -> true ).forEach( createHop( transformation ) ); transformation.setConfig( TRANS_META_CONF_KEY, copyTransMeta.getXML() ); transformation.setConfig( TRANS_META_NAME_CONF_KEY, Optional.ofNullable( transMeta.getName() ).orElse( TRANS_DEFAULT_NAME ) ); Map<String, Transformation> subTransformations = copyTransMeta.getResourceDependencies().stream() .flatMap( resourceReference -> resourceReference.getEntries().stream() ) .filter( entry -> ResourceEntry.ResourceType.ACTIONFILE.equals( entry.getResourcetype() ) ) .collect( toMap( ResourceEntry::getResource, entry -> { try { return convert( new TransMeta( entry.getResource(), copyTransMeta.getParentVariableSpace() ) ); } catch ( KettleXMLException | KettleMissingPluginsException e ) { throw new RuntimeException( e ); } } ) ); transformation.setConfig( SUB_TRANSFORMATIONS_KEY, (Serializable) subTransformations ); } catch ( KettleException e ) { Throwables.propagate( e ); } return transformation; }  static Transformation convert( TransMeta transMeta ); }
TransMetaConverter { public static Transformation convert( TransMeta transMeta ) { final org.pentaho.di.engine.model.Transformation transformation = new org.pentaho.di.engine.model.Transformation( createTransformationId( transMeta ) ); try { TransMeta copyTransMeta = (TransMeta) transMeta.realClone( false ); cleanupDisabledHops( copyTransMeta ); disableLazyConversion( copyTransMeta ); searchAndReplaceHadoopClusterWithFileSystemURL( copyTransMeta ); copyTransMeta.getSteps().forEach( createOperation( transformation ) ); findHops( copyTransMeta, hop -> true ).forEach( createHop( transformation ) ); transformation.setConfig( TRANS_META_CONF_KEY, copyTransMeta.getXML() ); transformation.setConfig( TRANS_META_NAME_CONF_KEY, Optional.ofNullable( transMeta.getName() ).orElse( TRANS_DEFAULT_NAME ) ); Map<String, Transformation> subTransformations = copyTransMeta.getResourceDependencies().stream() .flatMap( resourceReference -> resourceReference.getEntries().stream() ) .filter( entry -> ResourceEntry.ResourceType.ACTIONFILE.equals( entry.getResourcetype() ) ) .collect( toMap( ResourceEntry::getResource, entry -> { try { return convert( new TransMeta( entry.getResource(), copyTransMeta.getParentVariableSpace() ) ); } catch ( KettleXMLException | KettleMissingPluginsException e ) { throw new RuntimeException( e ); } } ) ); transformation.setConfig( SUB_TRANSFORMATIONS_KEY, (Serializable) subTransformations ); } catch ( KettleException e ) { Throwables.propagate( e ); } return transformation; }  static Transformation convert( TransMeta transMeta ); static final String TRANS_META_CONF_KEY; static final String TRANS_META_NAME_CONF_KEY; static final String SUB_TRANSFORMATIONS_KEY; static final String STEP_META_CONF_KEY; static final String TRANS_DEFAULT_NAME; }