@Test public void testRemovingDisabledInputSteps() { TransMeta trans = new TransMeta(); StepMeta inputToBeRemoved = new StepMeta( "InputToBeRemoved", stepMetaInterface ); trans.addStep( inputToBeRemoved ); StepMeta inputToStay = new StepMeta( "InputToStay", stepMetaInterface ); trans.addStep( inputToStay ); StepMeta inputReceiver1 = new StepMeta( "InputReceiver1", stepMetaInterface ); trans.addStep( inputReceiver1 ); StepMeta inputReceiver2 = new StepMeta( "InputReceiver2", stepMetaInterface ); trans.addStep( inputReceiver2 ); TransHopMeta hop1 = new TransHopMeta( inputToBeRemoved, inputReceiver1, false ); TransHopMeta hop2 = new TransHopMeta( inputToStay, inputReceiver1 ); TransHopMeta hop3 = new TransHopMeta( inputToBeRemoved, inputReceiver2, false ); trans.addTransHop( hop1 ); trans.addTransHop( hop2 ); trans.addTransHop( hop3 ); Transformation transformation = TransMetaConverter.convert( trans ); List<String> steps = transformation.getOperations().stream().map( op -> op.getId() ).collect( Collectors.toList() ); assertThat( "Only 2 ops should exist", steps.size(), is( 2 ) ); assertThat( steps, hasItems( "InputToStay", "InputReceiver1" ) ); List<String> hops = transformation.getHops().stream().map( hop -> hop.getId() ).collect( Collectors.toList() ); assertThat( "Only 1 hop should exist", hops.size(), is( 1 ) ); assertThat( hops, hasItems( "InputToStay -> InputReceiver1" ) ); }
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; }