Java Code Examples for org.pentaho.di.trans.TransMeta#getSteps()
The following examples show how to use
org.pentaho.di.trans.TransMeta#getSteps() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowUnitTestMenuExtensionPoint.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
private void editLocation( TransUnitTestSetLocation location, Spoon spoon, TransMeta transMeta ) { try { FactoriesHierarchy hierarchy = new FactoriesHierarchy( spoon.getMetaStore(), spoon.getActiveDatabases() ); Map<String, RowMetaInterface> stepFieldsMap = new HashMap<>(); for ( StepMeta stepMeta : transMeta.getSteps() ) { stepFieldsMap.put( stepMeta.getName(), transMeta.getStepFields( stepMeta ) ); } TransUnitTestSetLocationDialog dialog = new TransUnitTestSetLocationDialog( spoon.getShell(), location, hierarchy.getSetFactory().getElements(), stepFieldsMap ); if ( dialog.open() ) { spoon.refreshGraph(); } } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Error editing dataset location", e ); } }
Example 2
Source File: RunBeamTransExecutionPoint.java From kettle-beam with Apache License 2.0 | 6 votes |
private TransMeta copyCleanTransMeta( TransMeta transMeta, Repository repository, IMetaStore metaStore, VariableSpace space ) throws KettleException { try { String transMetaXml = transMeta.getXML(); TransMeta copy = new TransMeta(); copy.setMetaStore( metaStore ); copy.loadXML( XMLHandler.loadXMLString( transMetaXml, TransMeta.XML_TAG ), null, metaStore, repository, true, space, null ); for ( StepMeta stepMeta : copy.getSteps() ) { stepMeta.setCopies( 1 ); DummyTransMeta dummyTransMeta = new DummyTransMeta(); // Replace all stepMeta with a Dummy with the same name // stepMeta.setStepID( "Dummy" ); stepMeta.setStepMetaInterface( dummyTransMeta ); } return copy; } catch ( Exception e ) { throw new KettleException( "Error copying/cleaning transformation metadata", e ); } }
Example 3
Source File: TransFileListenerTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void testProcessLinkedJobsWithFilename() { JobExecutorMeta jobExecutorMeta = spy( new JobExecutorMeta() ); jobExecutorMeta.setFileName( "/path/to/Job1.kjb" ); jobExecutorMeta.setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME ); StepMeta jobExecutorStep = mock( StepMeta.class ); when( jobExecutorStep.getStepID() ).thenReturn( "JobExecutor" ); when( jobExecutorStep.getStepMetaInterface() ).thenReturn( jobExecutorMeta ); TransMeta parent = mock( TransMeta.class ); when( parent.getSteps() ).thenReturn( Arrays.asList( jobExecutorStep ) ); TransMeta result = transFileListener.processLinkedJobs( parent ); boolean found = false; for ( StepMeta stepMeta : result.getSteps() ) { if ( stepMeta.getStepID().equalsIgnoreCase( "JobExecutor" ) ) { found = true; JobExecutorMeta resultExecMeta = (JobExecutorMeta) stepMeta.getStepMetaInterface(); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() ); assertEquals( resultExecMeta.getDirectoryPath(), "/path/to" ); assertEquals( resultExecMeta.getJobName(), "Job1" ); } } assertTrue( found ); }
Example 4
Source File: TransFileListenerTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void testProcessLinkedTransWithFilename() { TransExecutorMeta transExecutorMeta = spy( new TransExecutorMeta() ); transExecutorMeta.setFileName( "/path/to/Transformation2.ktr" ); transExecutorMeta.setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME ); StepMeta transExecutorStep = mock( StepMeta.class ); when( transExecutorStep.getStepID() ).thenReturn( "TransExecutor" ); when( transExecutorStep.getStepMetaInterface() ).thenReturn( transExecutorMeta ); TransMeta parent = mock( TransMeta.class ); when( parent.getSteps() ).thenReturn( Arrays.asList( transExecutorStep ) ); TransMeta result = transFileListener.processLinkedTrans( parent ); boolean found = false; for ( StepMeta stepMeta : result.getSteps() ) { if ( stepMeta.getStepID().equalsIgnoreCase( "TransExecutor" ) ) { found = true; TransExecutorMeta resultExecMeta = (TransExecutorMeta) stepMeta.getStepMetaInterface(); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() ); assertEquals( resultExecMeta.getDirectoryPath(), "/path/to" ); assertEquals( resultExecMeta.getTransName(), "Transformation2" ); } } assertTrue( found ); }
Example 5
Source File: TransFileListener.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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; }
Example 6
Source File: MappingDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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; }
Example 7
Source File: TransFileListener.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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; }
Example 8
Source File: SimpleMappingDialog.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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; }
Example 9
Source File: TransFileListenerTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void testProcessLinkedJobsWithNoFilename() { JobExecutorMeta jobExecutorMeta = spy( new JobExecutorMeta() ); jobExecutorMeta.setFileName( null ); jobExecutorMeta.setDirectoryPath( "/path/to" ); jobExecutorMeta.setJobName( "Job1" ); jobExecutorMeta.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); StepMeta transExecutorStep = mock( StepMeta.class ); when( transExecutorStep.getStepID() ).thenReturn( "JobExecutor" ); when( transExecutorStep.getStepMetaInterface() ).thenReturn( jobExecutorMeta ); TransMeta parent = mock( TransMeta.class ); when( parent.getSteps() ).thenReturn( Arrays.asList( transExecutorStep ) ); TransMeta result = transFileListener.processLinkedJobs( parent ); boolean found = false; for ( StepMeta stepMeta : result.getSteps() ) { if ( stepMeta.getStepID().equalsIgnoreCase( "JobExecutor" ) ) { found = true; JobExecutorMeta resultExecMeta = (JobExecutorMeta) stepMeta.getStepMetaInterface(); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() ); assertEquals( resultExecMeta.getDirectoryPath(), "/path/to" ); assertEquals( resultExecMeta.getJobName(), "Job1" ); } } assertTrue( found ); }
Example 10
Source File: TransFileListenerTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void testProcessLinkedTransWithNoFilename() { TransExecutorMeta transExecutorMeta = spy( new TransExecutorMeta() ); transExecutorMeta.setFileName( null ); transExecutorMeta.setDirectoryPath( "/path/to" ); transExecutorMeta.setTransName( "Transformation2" ); transExecutorMeta.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); StepMeta transExecutorStep = mock( StepMeta.class ); when( transExecutorStep.getStepID() ).thenReturn( "TransExecutor" ); when( transExecutorStep.getStepMetaInterface() ).thenReturn( transExecutorMeta ); TransMeta parent = mock( TransMeta.class ); when( parent.getSteps() ).thenReturn( Arrays.asList( transExecutorStep ) ); TransMeta result = transFileListener.processLinkedTrans( parent ); boolean found = false; for ( StepMeta stepMeta : result.getSteps() ) { if ( stepMeta.getStepID().equalsIgnoreCase( "TransExecutor" ) ) { found = true; TransExecutorMeta resultExecMeta = (TransExecutorMeta) stepMeta.getStepMetaInterface(); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() ); assertEquals( resultExecMeta.getDirectoryPath(), "/path/to" ); assertEquals( resultExecMeta.getTransName(), "Transformation2" ); } } assertTrue( found ); }
Example 11
Source File: SingleThreaderDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public static String getInjectorStep( TransMeta mappingTransMeta ) { for ( StepMeta stepMeta : mappingTransMeta.getSteps() ) { if ( stepMeta.getStepID().equals( "Injector" ) || stepMeta.getStepID().equals( "MappingInput" ) ) { return stepMeta.getName(); } } return ""; }
Example 12
Source File: TransMetaConverter.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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(); } } }
Example 13
Source File: RepositoryImporter.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * 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 ); } } }
Example 14
Source File: InlineEtlQueryExecutor.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 5 votes |
protected StepMeta getStepMeta( TransMeta meta, String name ) { for ( StepMeta step : meta.getSteps() ) { if ( name.equals( step.getName() ) ) { return step; } } return null; }
Example 15
Source File: AbstractKettleTransformationProducer.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private boolean isDynamicTransformation( final TransMeta transMeta ) { List<StepMeta> steps = transMeta.getSteps(); for ( final StepMeta step : steps ) { if ( step.isEtlMetaInject() ) { return true; } } return false; }
Example 16
Source File: SharedObjectSyncUtil.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public List<StepMeta> getObjectsForSyncFromTransformation( TransMeta transformation ) { return transformation.getSteps(); }
Example 17
Source File: RepositoryExporter.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void convertFromFileRepository( TransMeta transMeta ) { Object[] metaInjectObjectArray = new Object[4]; metaInjectObjectArray[0] = transMeta; metaInjectObjectArray[1] = PKG; if ( repository instanceof KettleFileRepository ) { KettleFileRepository fileRep = (KettleFileRepository) repository; metaInjectObjectArray[2] = fileRep; // The id of the transformation is the relative filename. // Setting the filename also sets internal variables needed to load the trans/job referenced. // String transMetaFilename = fileRep.calcFilename( transMeta.getObjectId() ); transMeta.setFilename( transMetaFilename ); for ( StepMeta stepMeta : transMeta.getSteps() ) { if ( stepMeta.isMapping() ) { MappingMeta mappingMeta = (MappingMeta) stepMeta.getStepMetaInterface(); // convert to a named based reference. // if ( mappingMeta.getSpecificationMethod() == ObjectLocationSpecificationMethod.FILENAME ) { try { TransMeta meta = MappingMeta.loadMappingMeta( mappingMeta, fileRep, fileRep.metaStore, transMeta ); FileObject fileObject = KettleVFS.getFileObject( meta.getFilename() ); mappingMeta.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); mappingMeta.setFileName( null ); mappingMeta.setTransName( meta.getName() ); mappingMeta.setDirectoryPath( Const.NVL( calcRepositoryDirectory( fileRep, fileObject ), "/" ) ); } catch ( Exception e ) { log.logError( BaseMessages.getString( PKG, "Repository.Exporter.Log.UnableToLoadTransInMap", mappingMeta .getName() ), e ); } } } metaInjectObjectArray[3] = stepMeta; try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.RepositoryExporterPatchTransStep.id, metaInjectObjectArray ); } catch ( KettleException ke ) { log.logError( ke.getMessage(), ke ); } } } }